X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/3b9c2119792ae678e9368a0141d7f8646fd6ef42..ad9b15c2da87c6ee98f0990b49c8dff0f09cf581:/SL/DO.pm diff --git a/SL/DO.pm b/SL/DO.pm index 15f1c8d08..bc651c8ed 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -130,6 +130,11 @@ sub transactions { push @where, ($form->{delivered} ? "" : "NOT ") . "COALESCE(dord.delivered, FALSE)"; } + if ($form->{serialnumber}) { + push @where, 'dord.id IN (SELECT doi.delivery_order_id FROM delivery_order_items doi WHERE doi.serialnumber LIKE ?)'; + push @values, '%' . $form->{serialnumber} . '%'; + } + if($form->{transdatefrom}) { push @where, qq|dord.transdate >= ?|; push @values, conv_date($form->{transdatefrom}); @@ -140,6 +145,16 @@ sub transactions { push @values, conv_date($form->{transdateto}); } + if($form->{reqdatefrom}) { + push @where, qq|dord.reqdate >= ?|; + push @values, conv_date($form->{reqdatefrom}); + } + + if($form->{reqdateto}) { + push @where, qq|dord.reqdate <= ?|; + push @values, conv_date($form->{reqdateto}); + } + if (@where) { $query .= " WHERE " . join(" AND ", map { "($_)" } @where); } @@ -352,7 +367,8 @@ 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 = ?, currency_id = (SELECT id FROM currencies WHERE name = ?) + is_sales = ?, taxzone_id = ?, taxincluded = ?, terms = ?, currency_id = (SELECT id FROM currencies WHERE name = ?), + delivery_term_id = ? WHERE id = ?|; @values = ($form->{donumber}, $form->{ordnumber}, @@ -367,6 +383,7 @@ sub save { $form->{transaction_description}, $form->{type} =~ /^sales/ ? 't' : 'f', conv_i($form->{taxzone_id}), $form->{taxincluded} ? 't' : 'f', conv_i($form->{terms}), $form->{currency}, + conv_i($form->{delivery_term_id}), conv_i($form->{id})); do_query($form, $dbh, $query, @values); @@ -577,7 +594,8 @@ 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, (SELECT cu.name FROM currencies cu WHERE cu.id=dord.currency_id) AS currency + dord.taxzone_id, dord.taxincluded, dord.terms, (SELECT cu.name FROM currencies cu WHERE cu.id=dord.currency_id) AS currency, + dord.delivery_term_id FROM delivery_orders dord JOIN ${vc} cv ON (dord.${vc}_id = cv.id) LEFT JOIN employee e ON (dord.employee_id = e.id) @@ -707,6 +725,8 @@ sub order_details { my @partsgroup = (); my $partsgroup; my $position = 0; + my $subtotal_header = 0; + my $subposition = 0; my (@project_ids, %projectnumbers, %projectdescriptions); @@ -779,8 +799,6 @@ sub order_details { next if (!$form->{"id_$i"}); - $position++; - if ($item->[1] ne $sameitem) { push(@{ $form->{description} }, qq|$item->[1]|); $sameitem = $item->[1]; @@ -791,6 +809,19 @@ sub order_details { $form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"}); # add number, description and qty to $form->{number}, .... + if ($form->{"subtotal_$i"} && !$subtotal_header) { + $subtotal_header = $i; + $position = int($position); + $subposition = 0; + $position++; + } elsif ($subtotal_header) { + $subposition += 1; + $position = int($position); + $position = $position.".".$subposition; + } else { + $position = int($position); + $position++; + } my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 }; @@ -808,6 +839,10 @@ sub order_details { push @{ $form->{TEMPLATE_ARRAYS}{projectdescription} }, $projectdescriptions{$form->{"project_id_$i"}}; + if ($form->{"subtotal_$i"} && $subtotal_header && ($subtotal_header != $i)) { + $subtotal_header = 0; + } + my $lineweight = $form->{"qty_$i"} * $form->{"weight_$i"}; $totalweight += $lineweight; push @{ $form->{TEMPLATE_ARRAYS}->{weight} }, $form->format_amount($myconfig, $form->{"weight_$i"}, 3); @@ -876,6 +911,9 @@ sub order_details { $h_pg->finish(); $h_bin_wh->finish(); + $form->{delivery_term} = SL::DB::Manager::DeliveryTerm->find_by(id => $form->{delivery_term_id} || undef); + $form->{delivery_term}->description_long($form->{delivery_term}->translated_attribute('description_long', $form->{language_id})) if $form->{delivery_term} && $form->{language_id}; + $form->{username} = $myconfig->{name}; $main::lxdebug->leave_sub();