Merge branch 'master' of github.com:kivitendo/kivitendo-erp
authorNiclas Zimmermann <niclas@kivitendo-premium.de>
Mon, 3 Jun 2013 11:50:52 +0000 (13:50 +0200)
committerNiclas Zimmermann <niclas@kivitendo-premium.de>
Mon, 3 Jun 2013 11:50:52 +0000 (13:50 +0200)
14 files changed:
SL/Controller/ClientConfig.pm
SL/DB/Helper/FlattenToForm.pm
SL/DB/MetaSetup/Default.pm
SL/DO.pm
SL/IS.pm
SL/OE.pm
bin/mozilla/io.pl
locale/de/all
sql/Pg-upgrade2/gewichte.sql [new file with mode: 0644]
templates/webpages/client_config/form.html
templates/webpages/do/form_footer.html
templates/webpages/ir/form_footer.html
templates/webpages/is/form_footer.html
templates/webpages/oe/form_footer.html

index 1bfa615..148054e 100644 (file)
@@ -55,6 +55,9 @@ sub action_edit {
     $self->{warehouse_id} ||= $self->{WAREHOUSES}->[$max -1]->{id};
     $self->{bin_id}       ||= $self->{WAREHOUSES}->[$max -1]->{BINS}->[0]->{id};
   }
+
+  $self->{show_weight} = SL::DB::Default->get->show_weight;
+
   $self->render('client_config/form', title => $::locale->text('Client Configuration'));
 }
 
@@ -76,12 +79,16 @@ sub action_save {
 
   map { SL::DB::Default->get->update_attributes($_ => $::form->{$_}); } qw(sales_order_show_delete purchase_order_show_delete sales_delivery_order_show_delete purchase_delivery_order_show_delete);
 
+<<<<<<< HEAD
   # undef warehouse_id if the empty value is selected
   if ( ($::form->{warehouse_id} == 0) && ($::form->{bin_id} == 0) ) {
     undef $::form->{warehouse_id};
     undef $::form->{bin_id};
   }
   map { SL::DB::Default->get->update_attributes($_ => $::form->{$_}); } qw(warehouse_id bin_id);
+=======
+  SL::DB::Default->get->update_attributes('show_weight'     => $::form->{show_weight});
+>>>>>>> gewicht
 
   flash_later('info', $::locale->text('Client Configuration saved!'));
 
index c2d8a5f..9754d2b 100644 (file)
@@ -59,6 +59,7 @@ sub flatten_to_form {
 
     $form->{"id_${idx}"}         = $item->parts_id;
     $form->{"partnumber_${idx}"} = $item->part->partnumber;
+    $form->{"weight_${idx}"}     = $item->part->weight;
     _copy($item,          $form, '',        "_${idx}", 0,               qw(description project_id ship serialnumber pricegroup_id ordnumber cusordnumber unit
                                                                            subtotal longdescription price_factor_id marge_price_factor approved_sellprice reqdate transdate));
     _copy($item,          $form, '',        "_${idx}", $format_amounts, qw(qty sellprice marge_total marge_percent lastcost));
index d6b6b84..6c1e5ec 100644 (file)
@@ -70,6 +70,7 @@ __PACKAGE__->meta->setup(
     warehouse_id                        => { type => 'integer' },
     bin_id                              => { type => 'integer' },
     currency_id                         => { type => 'integer', not_null => 1 },
+    show_weight                         => { type => 'boolean', default => 'false', not_null => 1 },
   ],
 
   primary_key_columns => [ 'id' ],
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();
 
index 8f91a23..1dc1eff 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -154,7 +154,7 @@ sub invoice_details {
        partnotes serialnumber reqdate sellprice listprice netprice
        discount p_discount discount_sub nodiscount_sub
        linetotal  nodiscount_linetotal tax_rate projectnumber projectdescription
-       price_factor price_factor_name partsgroup);
+       price_factor price_factor_name partsgroup weight lineweight);
 
   push @arrays, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
 
@@ -164,6 +164,7 @@ sub invoice_details {
 
   map { $form->{TEMPLATE_ARRAYS}->{$_} = [] } (@arrays, @tax_arrays, @payment_arrays);
 
+  my $totalweight = 0;
   foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
     $i = $item->[0];
 
@@ -280,6 +281,13 @@ sub invoice_details {
       push(@{ $form->{TEMPLATE_ARRAYS}->{projectnumber} },              $projectnumbers{$form->{"project_id_$i"}});
       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;
+
       @taxaccounts = split(/ /, $form->{"taxaccounts_$i"});
       $taxrate     = 0;
       $taxdiff     = 0;
@@ -366,6 +374,11 @@ sub invoice_details {
     }
   }
 
+  $form->{totalweight}       = $form->format_amount($myconfig, $totalweight, 3);
+  $form->{totalweight_nofmt} = $totalweight;
+  my $defaults = AM->get_defaults();
+  $form->{weightunit}        = $defaults->{weightunit};
+
   foreach my $item (sort keys %taxaccounts) {
     $tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2);
 
@@ -1941,7 +1954,7 @@ sub retrieve_item {
          p.unit, p.assembly, p.onhand,
          p.notes AS partnotes, p.notes AS longdescription,
          p.not_discountable, p.formel, p.payment_id AS part_payment_id,
-         p.price_factor_id,
+         p.price_factor_id, p.weight,
 
          pfac.factor AS price_factor,
 
index f18cb06..0c0b767 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -1116,7 +1116,7 @@ sub order_details {
        partnotes serialnumber reqdate sellprice listprice netprice
        discount p_discount discount_sub nodiscount_sub
        linetotal  nodiscount_linetotal tax_rate projectnumber projectdescription
-       price_factor price_factor_name partsgroup);
+       price_factor price_factor_name partsgroup weight lineweight);
 
   push @arrays, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
 
@@ -1124,6 +1124,7 @@ sub order_details {
 
   map { $form->{TEMPLATE_ARRAYS}->{$_} = [] } (@arrays, @tax_arrays);
 
+  my $totalweight = 0;
   my $sameitem = "";
   foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
     $i = $item->[0];
@@ -1238,6 +1239,13 @@ sub order_details {
       push(@{ $form->{TEMPLATE_ARRAYS}->{projectnumber} },              $projectnumbers{$form->{"project_id_$i"}});
       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;
+
       my ($taxamount, $taxbase);
       my $taxrate = 0;
 
@@ -1304,6 +1312,11 @@ sub order_details {
     }
   }
 
+  $form->{totalweight}       = $form->format_amount($myconfig, $totalweight, 3);
+  $form->{totalweight_nofmt} = $totalweight;
+  my $defaults = AM->get_defaults();
+  $form->{weightunit}        = $defaults->{weightunit};
+
   my $tax = 0;
   foreach $item (sort keys %taxaccounts) {
     $tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2);
index 4db8256..99b61f3 100644 (file)
@@ -123,6 +123,10 @@ sub display_row {
 
   my ($stock_in_out, $stock_in_out_title);
 
+  my $defaults = AM->get_defaults();
+  $form->{show_weight} = $defaults->{show_weight};
+  $form->{weightunit} = $defaults->{weightunit};
+
   my $is_purchase        = (first { $_ eq $form->{type} } qw(request_quotation purchase_order purchase_delivery_order)) || ($form->{script} eq 'ir.pl');
   my $show_min_order_qty =  first { $_ eq $form->{type} } qw(request_quotation purchase_order);
   my $is_delivery_order  = $form->{type} =~ /_delivery_order$/;
@@ -141,7 +145,7 @@ sub display_row {
   }
 
   # column_index
-  my @header_sort = qw(runningnumber partnumber description ship qty unit sellprice_pg sellprice discount linetotal);
+  my @header_sort = qw(runningnumber partnumber description ship qty unit weight sellprice_pg sellprice discount linetotal);
   my @HEADER = (
     {  id => 'runningnumber', width => 5,     value => $locale->text('No.'),                  display => 1, },
     {  id => 'partnumber',    width => 8,     value => $locale->text('Number'),               display => 1, },
@@ -150,6 +154,7 @@ sub display_row {
     {  id => 'qty',           width => 5,     value => $locale->text('Qty'),                  display => 1, },
     {  id => 'price_factor',  width => 5,     value => $locale->text('Price Factor'),         display => !$is_delivery_order, },
     {  id => 'unit',          width => 5,     value => $locale->text('Unit'),                 display => 1, },
+    {  id => 'weight',        width => 5,     value => $locale->text('Weight'),               display => $defaults->{show_weight}, },
     {  id => 'serialnr',      width => 10,    value => $locale->text('Serial No.'),           display => 0, },
     {  id => 'projectnr',     width => 10,    value => $locale->text('Project'),              display => 0, },
     {  id => 'sellprice',     width => 15,    value => $locale->text('Price'),                display => !$is_delivery_order, },
@@ -187,12 +192,13 @@ sub display_row {
   my $deliverydate  = $locale->text('Required by');
 
   # special alignings
-  my %align  = map { $_ => 'right' } qw(qty ship right sellprice_pg discount linetotal stock_in_out);
+  my %align  = map { $_ => 'right' } qw(qty ship right sellprice_pg discount linetotal stock_in_out weight);
   my %nowrap = map { $_ => 1 }       qw(description unit);
 
   $form->{marge_total}           = 0;
   $form->{sellprice_total}       = 0;
   $form->{lastcost_total}        = 0;
+  $form->{totalweight}           = 0;
   my %projectnumber_labels = ();
   my @projectnumber_values = ("");
 
@@ -205,6 +211,8 @@ sub display_row {
   _update_ship() if ($is_s_p_order);
   _update_custom_variables();
 
+  my $totalweight = 0;
+
   # rows
 
   my @ROWS;
@@ -246,6 +254,7 @@ sub display_row {
     } else {
       $column_data{price_factor} = '&nbsp;';
     }
+    $form->{"weight_$i"} *= AM->convert_unit($form->{"selected_unit_$i"}, $form->{"partunit_$i"}, $all_units) || 1;
 
     $column_data{"unit"} = AM->unit_select_html($all_units, "unit_$i", $this_unit, $form->{"id_$i"} ? $form->{"unit_$i"} : undef);
 # / unit ending
@@ -325,6 +334,8 @@ sub display_row {
     $column_data{linetotal}   = $form->format_amount(\%myconfig, $linetotal, 2);
     $column_data{bin}         = $form->{"bin_$i"};
 
+    $column_data{weight}      = $form->format_amount(\%myconfig, $form->{"qty_$i"} * $form->{"weight_$i"}, 3) . ' ' . $defaults->{weightunit} if $defaults->{show_weight};
+
     if ($is_delivery_order) {
       $column_data{stock_in_out} =  calculate_stock_in_out($i);
     }
@@ -389,6 +400,9 @@ sub display_row {
       if $form->{"id_$i"} && ($form->{type} =~ /^sales_/ ||  $form->{type} =~ /invoice/) ;
 # / marge calculations ending
 
+# Calculate total weight
+    $totalweight += ($form->{"qty_$i"} * $form->{"weight_$i"});
+
 # calculate onhand
     if ($form->{"id_$i"}) {
       my $part         = IC->get_basic_part_info(id => $form->{"id_$i"});
@@ -416,7 +430,7 @@ sub display_row {
           map { ($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } map { $_."_$i" }
             (qw(orderitems_id bo pricegroup_old price_old id inventory_accno bin partsgroup partnotes
                 income_accno expense_accno listprice assembly taxaccounts ordnumber transdate cusordnumber
-                longdescription basefactor marge_absolut marge_percent marge_price_factor), @hidden_vars)
+                longdescription basefactor marge_absolut marge_percent marge_price_factor weight), @hidden_vars)
     );
 
     map { $form->{"${_}_base"} += $linetotal } (split(/ /, $form->{"taxaccounts_$i"}));
@@ -429,6 +443,8 @@ sub display_row {
     push @ROWS, { ROW1 => \@ROW1, ROW2 => \@ROW2, HIDDENS => \@HIDDENS, colspan => $colspan, error => $form->{"row_error_$i"}, };
   }
 
+  $form->{totalweight} = $totalweight;
+
   print $form->parse_html_template('oe/sales_order', { ROWS   => \@ROWS,
                                                        HEADER => \@HEADER,
                                                      });
@@ -1789,6 +1805,7 @@ sub _update_part_information {
 
     my $info                 = $form->{PART_INFORMATION}->{$form->{"id_${i}"}} || { };
     $form->{"partunit_${i}"} = $info->{unit};
+    $form->{"weight_$i"}     = $info->{weight};
   }
 
   $main::lxdebug->leave_sub();
index 2d3c55d..5a5009c 100755 (executable)
@@ -1821,6 +1821,8 @@ $self->{texts} = {
   'Show old dunnings'           => 'Alte Mahnungen anzeigen',
   'Show overdue sales quotations and requests for quotations...' => 'Überfällige Angebote und Preisanfragen anzeigen...',
   'Show settings'               => 'Einstellungen anzeigen',
+  'Show the weights of articles and the total weight in orders, invoices and delivery notes?' => 'Sollen Warengewichte und Gesamtgewicht in Aufträgen, Rechnungen und Lieferscheinen angezeigt werden?',
+  'Show weights'                => 'Gewichte anzeigen',
   'Show your TODO list after loggin in' => 'Aufgabenliste nach dem Anmelden anzeigen',
   'Signature'                   => 'Unterschrift',
   'Since bin is not enforced in the parts data, please specify a bin where goods without a specified bin will be put.' => 'Da Lagerpl&auml;tze kein Pflichtfeld sind, geben Sie bitte einen Lagerplatz an, in dem Waren ohne spezifizierten Lagerplatz eingelagert werden sollen.',
@@ -2201,6 +2203,7 @@ $self->{texts} = {
   'Total Fees'                  => 'Kumulierte Gebühren',
   'Total stock value'           => 'Gesamter Bestandswert',
   'Total sum'                   => 'Gesamtsumme',
+  'Total weight'                => 'Gesamtgewicht',
   'Totals'                      => 'Summen',
   'Trade Discount'              => 'Rabatt',
   'Trans Id'                    => 'Trans-ID',
diff --git a/sql/Pg-upgrade2/gewichte.sql b/sql/Pg-upgrade2/gewichte.sql
new file mode 100644 (file)
index 0000000..b8d03ef
--- /dev/null
@@ -0,0 +1,6 @@
+-- @tag: gewichte
+-- @description: Je nach Mandantenkonfiguration können Warengewichte in Angeboten/Aufträgen/Lieferscheinen/Rechnungen angezeigt werden oder nicht.
+-- @depends: release_3_0_0
+-- @charset: utf-8
+
+ALTER TABLE defaults ADD show_weight BOOLEAN NOT NULL DEFAULT FALSE;
index 737db1a..0d2d64e 100644 (file)
  </tr>
 
 
+ <tr class='listheading'>
+   <th colspan="3">[% 'Weight' | $T8 %]</th>
+ </tr>
+ <tr>
+   <td align="right">[% 'Show weights' | $T8 %]</td>
+   <td>
+     [% L.yes_no_tag('show_weight', SELF.show_weight) %]
+   </td>
+   <td>
+     [% 'Show the weights of articles and the total weight in orders, invoices and delivery notes?' | $T8 %]<br>
+   </td>
+ </tr>
 </table>
 
 <br>
index 78ad35a..d87b156 100644 (file)
 
      </td>
     </tr>
+[%- IF show_weight %]
+  <tr>
+    <td>
+      <table width="100%">
+        <tr valign="bottom">
+          <td align="right">
+            <table>
+            <tr>
+              <th  align="left">[% 'Total weight' | $T8 %]</th>
+              <td align="right">
+                [% LxERP.format_amount(totalweight, 3) %] [% HTML.escape(weightunit) %]
+              </td>
+            </tr>
+            </table>
+          </td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+[%- END %]
    </table>
   </p>
 
index 8538fd4..6675800 100644 (file)
 [%- END %]
        </table>
       </td>
+[%- IF show_weight %]
+      <td>
+       <table>
+        <tr>
+         <th  align=left>[% 'Total weight' | $T8 %]</th>
+         <td>
+          [% LxERP.format_amount(totalweight) %] [% HTML.escape(weightunit) %]
+         </td>
+        </tr>
+       </table>
+      </td>
+[%- END %]
       <td align="right">
   [%- IF taxaccounts %]
        <input name="taxincluded" class="checkbox" type="checkbox" [% IF taxincluded %]checked[% END %]>
index 52179c2..28fafaa 100644 (file)
 [%- END %]
        </table>
       </td>
+[%- IF show_weight %]
+      <td>
+       <table>
+        <tr>
+         <th  align=left>[% 'Total weight' | $T8 %]</th>
+         <td>
+          [% LxERP.format_amount(totalweight) %] [% HTML.escape(weightunit) %]
+         </td>
+        </tr>
+       </table>
+      </td>
+[%- END %]
       <td>
        <table>
         <tr>
index c9078ef..87c1993 100644 (file)
       [%- END %]
       </table>
           </td>
+      [%- IF show_weight %]
+          <td>
+            <table>
+            <tr>
+              <th  align="left">[% 'Total weight' | $T8 %]</th>
+              <td align="right">
+                [% LxERP.format_amount(totalweight, 3) %] [% HTML.escape(weightunit) %]
+              </td>
+            </tr>
+            </table>
+          </td>
+      [%- END %]
 [%- IF is_sales %]
           <td>
             <table>