Keine Default Exporte mehr in den main:: space
[kivitendo-erp.git] / bin / mozilla / io.pl
index 1dc7a64..cdf43d3 100644 (file)
@@ -57,7 +57,7 @@ use SL::DB::Language;
 use SL::DB::Printer;
 use SL::DB::Vendor;
 use SL::Helper::CreatePDF;
-use SL::Helper::Flash;
+use SL::Helper::Flash qw(flash);
 
 require "bin/mozilla/common.pl";
 
@@ -319,7 +319,8 @@ sub display_row {
       $ship_qty          *= $all_units->{$form->{"partunit_$i"}}->{factor};
       $ship_qty          /= ( $all_units->{$form->{"unit_$i"}}->{factor} || 1 );
 
-      $column_data{ship}  = $form->format_amount(\%myconfig, $form->round_amount($ship_qty, 2) * 1) . ' ' . $form->{"unit_$i"};
+      $column_data{ship}  = $form->format_amount(\%myconfig, $form->round_amount($ship_qty, 2) * 1) . ' ' . $form->{"unit_$i"}
+      . $cgi->hidden(-name => "ship_$i", -value => $form->format_amount(\%myconfig, $form->{"ship_$i"}, $qty_dec));
 
       my $ship_missing_qty    = $form->{"qty_$i"} - $ship_qty;
       my $ship_missing_amount = $form->round_amount($ship_missing_qty * $form->{"sellprice_$i"} * (100 - $form->{"discount_$i"}) / 100 / $price_factor, 2);
@@ -1058,6 +1059,7 @@ sub edit_e_mail {
                                      a_filename    => $attachment_filename,
                                      subject       => $subject,
                                      print_options => print_options('inline' => 1),
+                                     action        => 'send_email',
                                      HIDDEN        => [ map +{ name => $_, value => $form->{$_} }, @hidden_keys ],
                                      SHOW_BCC      => $::auth->assert('email_bcc', 'may fail') });
 
@@ -1245,6 +1247,17 @@ sub print_form {
     $order                = 1;
   }
 
+  if (($form->{type} eq 'sales_order') && ($form->{formname} eq 'ic_supply') ) {
+    $inv                  = "inv";
+    $due                  = "due";
+    $form->{"${inv}date"} = $form->{transdate};
+    $form->{"invdate"}    = $form->{transdate};
+    $form->{invnumber}    = $form->{ordnumber};
+    $form->{label}        = $locale->text('Intra-Community supply');
+    $numberfld            = "sonumber";
+    $order                = 1;
+  }
+
   if ($form->{formname} eq 'request_quotation') {
     $inv                  = "quo";
     $due                  = "req";
@@ -1759,36 +1772,21 @@ sub _update_ship {
 
   my $all_units = AM->retrieve_all_units();
 
-  my %ship = DO->get_shipped_qty('type'  => ($form->{type} eq 'purchase_order') ? 'purchase' : 'sales',
-                                 'oe_id' => $form->{id},);
+  my %ship = DO->get_shipped_qty('oe_id' => $form->{id});
 
   foreach my $i (1..$form->{rowcount}) {
     next unless ($form->{"id_${i}"});
 
     $form->{"ship_$i"} = 0;
 
-    my $ship_entry = $ship{$form->{"id_$i"}};
-
-    next if (!$ship_entry || ($ship_entry->{qty} <= 0));
-
-    my $rowqty =
-      ($form->{simple_save} ? $form->{"qty_$i"} : $form->parse_amount(\%myconfig, $form->{"qty_$i"}))
-      * $all_units->{$form->{"unit_$i"}}->{factor}
-      / $all_units->{$form->{"partunit_$i"}}->{factor};
-
-    $form->{"ship_$i"}  = min($rowqty, $ship_entry->{qty});
-    $ship_entry->{qty} -= $form->{"ship_$i"};
-  }
-
-  foreach my $i (1..$form->{rowcount}) {
-    next unless ($form->{"id_${i}"});
-
-    my $ship_entry = $ship{$form->{"id_$i"}};
+    my $ship_entry = $ship{$i};
 
-    next if (!$ship_entry || ($ship_entry->{qty} <= 0.01));
+    next if (!$ship_entry || ($ship_entry->{qty_ordered} <= 0));
 
-    $form->{"ship_$i"} += $ship_entry->{qty};
-    $ship_entry->{qty}  = 0;
+    my $rowqty = $ship_entry->{qty_ordered} - $ship_entry->{qty_notdelivered};
+    $rowqty   *= $all_units->{$form->{"unit_$i"}}->{factor} /
+                 $all_units->{$form->{"partunit_$i"}}->{factor} if !$form->{simple_save};
+    $form->{"ship_$i"}  = $rowqty;
   }
 
   $main::lxdebug->leave_sub();