]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/do.pl
Project-Controller: Paginaten beim CSV-/PDF-Export ausschalten
[mfinanz.git] / bin / mozilla / do.pl
index e3c192a69afdbfcf94697d421cad0866e47531de..67819fbc90b2f214f6f58fe8a8ba119dca36efb1 100644 (file)
@@ -369,6 +369,8 @@ sub update_delivery_order {
 
   set_headings($form->{"id"} ? "edit" : "add");
 
+  $form->{insertdate} = SL::DB::DeliveryOrder->new(id => $form->{id})->load->itime_as_date if $form->{id};
+
   $form->{update} = 1;
 
   my $payment_id;
@@ -419,16 +421,37 @@ sub update_delivery_order {
 
       if ($rows > 1) {
 
-        select_item(mode => $mode);
+        select_item(mode => $mode, pre_entered_qty => $form->{"qty_$i"});
         ::end_of_request();
 
       } else {
 
+        my $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
+
         map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
 
         $form->{"marge_price_factor_$i"} = $form->{item_list}->[0]->{price_factor};
+
+        if ($sellprice) {
+          $form->{"sellprice_$i"} = $sellprice;
+        } else {
+          my $record        = _make_record();
+          my $price_source  = SL::PriceSource->new(record_item => $record->items->[$i-1], record => $record);
+          my $best_price    = $price_source->best_price;
+          my $best_discount = $price_source->best_discount;
+
+          if ($best_price) {
+            $::form->{"sellprice_$i"}           = $best_price->price;
+            $::form->{"active_price_source_$i"} = $best_price->source;
+          }
+          if ($best_discount) {
+            $::form->{"discount_$i"}               = $best_discount->discount;
+            $::form->{"active_discount_source_$i"} = $best_discount->source;
+          }
+        }
+
         $form->{"sellprice_$i"}          = $form->format_amount(\%myconfig, $form->{"sellprice_$i"});
-        $form->{"lastcost_$i"}          = $form->format_amount(\%myconfig, $form->{"lastcost_$i"});
+        $form->{"lastcost_$i"}           = $form->format_amount(\%myconfig, $form->{"lastcost_$i"});
         $form->{"qty_$i"}                = $form->format_amount(\%myconfig, $form->{"qty_$i"});
       }
 
@@ -511,6 +534,7 @@ sub orders {
     shipvia                 globalprojectnumber
     transaction_description department
     open                    delivered
+    insertdate
   );
 
   $form->{l_open}      = $form->{l_closed} = "Y" if ($form->{open}      && $form->{closed});
@@ -525,7 +549,8 @@ sub orders {
   my @hidden_variables = map { "l_${_}" } @columns;
   push @hidden_variables, $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered donumber ordnumber serialnumber cusordnumber
                                           transaction_description transdatefrom transdateto reqdatefrom reqdateto
-                                          type vc employee_id salesman_id project_id);
+                                          type vc employee_id salesman_id project_id
+                                          insertdatefrom insertdateto);
 
   my $href = build_std_url('action=orders', grep { $form->{$_} } @hidden_variables);
 
@@ -547,9 +572,10 @@ sub orders {
     'open'                    => { 'text' => $locale->text('Open'), },
     'delivered'               => { 'text' => $locale->text('Delivered'), },
     'department'              => { 'text' => $locale->text('Department'), },
+    'insertdate'              => { 'text' => $locale->text('Insert Date'), },
   );
 
-  foreach my $name (qw(id transdate reqdate donumber ordnumber name employee salesman shipvia transaction_description department)) {
+  foreach my $name (qw(id transdate reqdate donumber ordnumber name employee salesman shipvia transaction_description department insertdate)) {
     my $sortdir                 = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir};
     $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir";
   }
@@ -600,6 +626,11 @@ sub orders {
     push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{reqdatefrom}, 1)       if $form->{reqdatefrom};
     push @options, $locale->text('Bis')  . " " . $locale->date(\%myconfig, $form->{reqdateto},   1)       if $form->{reqdateto};
   };
+  if ( $form->{insertdatefrom} or $form->{insertdateto} ) {
+    push @options, $locale->text('Insert Date');
+    push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{insertdatefrom}, 1)    if $form->{insertdatefrom};
+    push @options, $locale->text('Bis')  . " " . $locale->date(\%myconfig, $form->{insertdateto},   1)    if $form->{insertdateto};
+  };
   if ($form->{open}) {
     push @options, $locale->text('Open');
   }
@@ -1599,8 +1630,7 @@ sub transfer_in_out_default {
                         'bin_id' => $part_info_map{$form->{"id_$i"}}{bin_id},
                         'qty' => $qty,
                         'parts_id' => $form->{"id_$i"},
-                        'comment' => 'Default transfer DO',
-                        'ok' => 1,
+                        'comment' => $locale->text("Default transfer delivery order"),
                         'unit' => $part_info_map{$form->{"id_$i"}}{unit},
                         'warehouse_id' => $part_info_map{$form->{"id_$i"}}{warehouse_id},
                         'oe_id' => $form->{id},