X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDO.pm;h=fb8672c6a6fab970c250ad043715ee52b2dd9d06;hb=a67ad20f388cd35487a7a9d46a003e39e1f402aa;hp=a598f025d6642a87d8c3b25c7a6525912b701eac;hpb=82c4717d48bbdb8d30c9671e71ecb0d6d8eac963;p=kivitendo-erp.git diff --git a/SL/DO.pm b/SL/DO.pm index a598f025d..fb8672c6a 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -229,7 +229,7 @@ sub save { $query = qq|SELECT nextval('id')|; ($form->{id}) = selectrow_query($form, $dbh, $query); - $query = qq|INSERT INTO delivery_orders (id, donumber, employee_id) VALUES (?, '', ?)|; + $query = qq|INSERT INTO delivery_orders (id, donumber, employee_id, currency_id) VALUES (?, '', ?, (SELECT currency_id FROM defaults LIMIT 1))|; do_query($form, $dbh, $query, $form->{id}, conv_i($form->{employee_id})); } @@ -350,7 +350,7 @@ sub save { shippingpoint = ?, shipvia = ?, notes = ?, intnotes = ?, closed = ?, delivered = ?, department_id = ?, language_id = ?, shipto_id = ?, globalproject_id = ?, employee_id = ?, salesman_id = ?, cp_id = ?, transaction_description = ?, - is_sales = ?, taxzone_id = ?, taxincluded = ?, terms = ?, curr = ? + is_sales = ?, taxzone_id = ?, taxincluded = ?, terms = ?, currency_id = (SELECT id FROM currencies WHERE name = ?) WHERE id = ?|; @values = ($form->{donumber}, $form->{ordnumber}, @@ -364,7 +364,7 @@ sub save { conv_i($form->{salesman_id}), conv_i($form->{cp_id}), $form->{transaction_description}, $form->{type} =~ /^sales/ ? 't' : 'f', - conv_i($form->{taxzone_id}), $form->{taxincluded} ? 't' : 'f', conv_i($form->{terms}), substr($form->{currency}, 0, 3), + conv_i($form->{taxzone_id}), $form->{taxincluded} ? 't' : 'f', conv_i($form->{terms}), $form->{currency}, conv_i($form->{id})); do_query($form, $dbh, $query, @values); @@ -618,7 +618,7 @@ sub retrieve { d.description AS department, dord.language_id, dord.shipto_id, dord.globalproject_id, dord.delivered, dord.transaction_description, - dord.taxzone_id, dord.taxincluded, dord.terms, dord.curr AS currency + dord.taxzone_id, dord.taxincluded, dord.terms, (SELECT cu.name FROM currencies cu WHERE cu.id=dord.currency_id) AS currency FROM delivery_orders dord JOIN ${vc} cv ON (dord.${vc}_id = cv.id) LEFT JOIN employee e ON (dord.employee_id = e.id) @@ -640,9 +640,6 @@ sub retrieve { } $sth->finish(); - # remove any trailing whitespace - $form->{currency} =~ s/\s*$//; - $form->{donumber_array} =~ s/\s*$//g; $form->{saved_donumber} = $form->{donumber}; @@ -675,9 +672,6 @@ sub retrieve { delete $form->{id}; } - my %oid = ('Pg' => 'oid', - 'Oracle' => 'rowid'); - # retrieve individual items # this query looks up all information about the items # stuff different from the whole will not be overwritten, but saved with a suffix. @@ -696,7 +690,7 @@ sub retrieve { LEFT JOIN project pr ON (doi.project_id = pr.id) LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) WHERE doi.delivery_order_id IN ($do_ids_placeholders) - ORDER BY doi.$oid{$myconfig->{dbdriver}}|; + ORDER BY doi.oid|; $form->{form_details} = selectall_hashref_query($form, $dbh, $query, @do_ids); @@ -755,9 +749,6 @@ sub order_details { my $partsgroup; my $position = 0; - my %oid = ('Pg' => 'oid', - 'Oracle' => 'rowid'); - my (@project_ids, %projectnumbers, %projectdescriptions); push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"}); @@ -813,7 +804,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); @@ -822,6 +813,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]; @@ -857,6 +849,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 = ""; @@ -864,9 +863,9 @@ sub order_details { my $sortorder = ""; if ($form->{groupitems}) { $sortorder = - qq|ORDER BY pg.partsgroup, a.$oid{$myconfig->{dbdriver}}|; + qq|ORDER BY pg.partsgroup, a.oid|; } else { - $sortorder = qq|ORDER BY a.$oid{$myconfig->{dbdriver}}|; + $sortorder = qq|ORDER BY a.oid|; } do_statement($form, $h_pg, $q_pg, conv_i($form->{"id_$i"})); @@ -910,6 +909,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();