X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDO.pm;h=76a0ec075e0016235970d2518e00c98e31a83b05;hb=79c048aa6a9699c5a994d7e21f4fd3ec8fa29693;hp=237d523d911c269760562acccaa7b3cd83cf5b8d;hpb=cc8edd18013d3ee0668e5650aeb8a7866641f47a;p=kivitendo-erp.git diff --git a/SL/DO.pm b/SL/DO.pm index 237d523d9..76a0ec075 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -61,18 +61,22 @@ sub transactions { my $vc = $form->{vc} eq "customer" ? "customer" : "vendor"; my $query = - qq|SELECT dord.id, dord.donumber, dord.ordnumber, dord.transdate, + qq|SELECT dord.id, dord.donumber, dord.ordnumber, + dord.transdate, dord.reqdate, ct.${vc}number, ct.name, dord.${vc}_id, dord.globalproject_id, dord.closed, dord.delivered, dord.shippingpoint, dord.shipvia, dord.transaction_description, pr.projectnumber AS globalprojectnumber, + dep.description AS department, e.name AS employee, sm.name AS salesman FROM delivery_orders dord LEFT JOIN $vc ct ON (dord.${vc}_id = ct.id) LEFT JOIN employee e ON (dord.employee_id = e.id) LEFT JOIN employee sm ON (dord.salesman_id = sm.id) - LEFT JOIN project pr ON (dord.globalproject_id = pr.id)|; + LEFT JOIN project pr ON (dord.globalproject_id = pr.id) + LEFT JOIN department dep ON (dord.department_id = dep.id) +|; push @where, ($form->{type} eq 'sales_delivery_order' ? '' : 'NOT ') . qq|COALESCE(dord.is_sales, FALSE)|; @@ -140,6 +144,7 @@ sub transactions { my %allowed_sort_columns = ( "transdate" => "dord.transdate", + "reqdate" => "dord.reqdate", "id" => "dord.id", "donumber" => "dord.donumber", "ordnumber" => "dord.ordnumber", @@ -147,7 +152,8 @@ sub transactions { "employee" => "e.name", "salesman" => "sm.name", "shipvia" => "dord.shipvia", - "transaction_description" => "dord.transaction_description" + "transaction_description" => "dord.transaction_description", + "department" => "lower(dep.description)", ); my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC'; @@ -289,6 +295,13 @@ sub save { do_statement($form, $h_item_id, $q_item_id); my ($item_id) = $h_item_id->fetchrow_array(); + # Get pricegroup_id and save it. Unfortunately the interface + # also uses ID "0" for signalling that none is selected, but "0" + # must not be stored in the database. Therefore we cannot simply + # use conv_i(). + my $pricegroup_id = $form->{"pricegroup_id_$i"} * 1; + $pricegroup_id = undef if !$pricegroup_id; + # save detail record in delivery_order_items table @values = (conv_i($item_id), conv_i($form->{id}), conv_i($form->{"id_$i"}), $form->{"description_$i"}, $form->{"longdescription_$i"}, @@ -301,7 +314,7 @@ sub save { $form->{"lastcost_$i"}, conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"marge_price_factor_$i"}), - conv_i($form->{"pricegroup_id_$i"})); + $pricegroup_id); do_statement($form, $h_item, $q_item, @values); my $stock_info = DO->unpack_stock_information('packed' => $form->{"stock_${in_out}_$i"}); @@ -729,10 +742,7 @@ sub retrieve { sub order_details { $main::lxdebug->enter_sub(); - my ($self) = @_; - - my $myconfig = \%main::myconfig; - my $form = $main::form; + my ($self, $myconfig, $form) = @_; # connect to database my $dbh = $form->get_standard_dbh($myconfig); @@ -797,13 +807,13 @@ sub order_details { my $ic_cvar_configs = CVar->get_configs(module => 'IC'); $form->{TEMPLATE_ARRAYS} = { }; - IC->prepare_parts_for_printing(); + IC->prepare_parts_for_printing(myconfig => $myconfig, form => $form); my @arrays = 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); @@ -812,6 +822,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]; @@ -847,6 +858,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 = ""; @@ -863,13 +881,13 @@ sub order_details { while (my $ref = $h_pg->fetchrow_hashref("NAME_lc")) { if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) { - map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays)); + map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays)); $sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--"; - push(@{ $form->{description} }, $sameitem); + push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, $sameitem); } - push(@{ $form->{description} }, $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}) . qq|, $ref->{partnumber}, $ref->{description}|); + push(@{ $form->{TEMPLATE_ARRAYS}->{"description"} }, $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}) . qq| -- $ref->{partnumber}, $ref->{description}|); - map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays)); + map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays)); } } @@ -900,6 +918,9 @@ sub order_details { for @{ $ic_cvar_configs }; } + $form->{totalweight} = $form->format_amount($myconfig, $totalweight, 3); + $form->{totalweight_nofmt} = $totalweight; + $h_pg->finish(); $h_bin_wh->finish();