Merge branch 'gewicht'
[kivitendo-erp.git] / SL / DO.pm
index 04d5e84..a4677bb 100644 (file)
--- a/SL/DO.pm
+++ b/SL/DO.pm
@@ -810,7 +810,7 @@ sub order_details {
     qw(runningnumber number description longdescription qty unit
        partnotes serialnumber reqdate projectnumber projectdescription
        si_runningnumber si_number si_description
-       si_warehouse si_bin si_chargenumber si_bestbefore si_qty si_unit);
+       si_warehouse si_bin si_chargenumber si_bestbefore si_qty si_unit weight lineweight);
 
   map { $form->{TEMPLATE_ARRAYS}->{$_} = [] } (@arrays);
 
@@ -819,6 +819,7 @@ sub order_details {
   $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
   my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} };
 
+  my $totalweight = 0;
   my $sameitem = "";
   foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
     $i = $item->[0];
@@ -854,6 +855,13 @@ sub order_details {
     push @{ $form->{TEMPLATE_ARRAYS}{projectdescription} },
       $projectdescriptions{$form->{"project_id_$i"}};
 
+    my $lineweight = $form->{"qty_$i"} * $form->{"weight_$i"};
+    $totalweight += $lineweight;
+    push @{ $form->{TEMPLATE_ARRAYS}->{weight} },            $form->format_amount($myconfig, $form->{"weight_$i"}, 3);
+    push @{ $form->{TEMPLATE_ARRAYS}->{weight_nofmt} },      $form->{"weight_$i"};
+    push @{ $form->{TEMPLATE_ARRAYS}->{lineweight} },        $form->format_amount($myconfig, $lineweight, 3);
+    push @{ $form->{TEMPLATE_ARRAYS}->{lineweight_nofmt} },  $lineweight;
+
     if ($form->{"assembly_$i"}) {
       $sameitem = "";
 
@@ -907,6 +915,11 @@ sub order_details {
         for @{ $ic_cvar_configs };
   }
 
+  $form->{totalweight}       = $form->format_amount($myconfig, $totalweight, 3);
+  $form->{totalweight_nofmt} = $totalweight;
+  my $defaults = AM->get_defaults();
+  $form->{weightunit}        = $defaults->{weightunit};
+
   $h_pg->finish();
   $h_bin_wh->finish();