X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIC.pm;h=0bf015f3fc5db1bfcd4ad0086b85f9e0870ccc7b;hb=8f64093b4d58bd4bd72cd7465b7e402ad949eaf1;hp=c710af9fc6651df2198fab18d4e5afaf30fc0f9a;hpb=6d06b2c53d68b0b93ae96c112fb77fb2e9bda8f6;p=kivitendo-erp.git diff --git a/SL/IC.pm b/SL/IC.pm index c710af9fc..0bf015f3f 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -41,6 +41,8 @@ use YAML; use SL::CVar; use SL::DBUtils; +use strict; + sub get_part { $main::lxdebug->enter_sub(); @@ -792,8 +794,8 @@ sub all_parts { pfac => 'LEFT JOIN price_factors pfac ON (pfac.id = p.price_factor_id)', invoice_oi => q|LEFT JOIN ( - SELECT parts_id, description, serialnumber, trans_id, unit, sellprice, qty, assemblyitem, deliverydate, 'invoice' AS ioi FROM invoice UNION - SELECT parts_id, description, serialnumber, trans_id, unit, sellprice, qty, FALSE AS assemblyitem, NULL AS deliverydate, 'orderitems' AS ioi FROM orderitems + SELECT parts_id, description, serialnumber, trans_id, unit, sellprice, qty, assemblyitem, deliverydate, 'invoice' AS ioi, id FROM invoice UNION + SELECT parts_id, description, serialnumber, trans_id, unit, sellprice, qty, FALSE AS assemblyitem, NULL AS deliverydate, 'orderitems' AS ioi, id FROM orderitems ) AS ioi ON ioi.parts_id = p.id|, apoe => q|LEFT JOIN ( @@ -824,6 +826,8 @@ sub all_parts { serialnumber => 'ioi.', quotation => 'apoe.', cv => 'cv.', + "ioi.id" => ' ', + "ioi.ioi" => ' ', ); # if the join condition in these blocks are met, the column @@ -835,12 +839,15 @@ sub all_parts { [ 'deliverydate', 'ioi.', 'invoice_oi' ], [ 'transdate', 'apoe.', 'apoe' ], [ 'unit', 'ioi.', 'invoice_oi' ], + [ 'sellprice', 'ioi.', 'invoice_oi' ], ); # careful with renames. these are HARD, and any filters done on the original column will break my %renamed_columns = ( 'factor' => 'price_factor', 'SUM(ioi.qty)' => 'soldtotal', + 'ioi.id' => 'ioi_id', + 'ioi.ioi' => 'ioi', ); if (($form->{searchitems} eq 'assembly') && $form->{l_lastcost}) { @@ -937,7 +944,7 @@ sub all_parts { my $bsooqr = any { $form->{$_} } @oe_flags; my @bsooqr_tokens = (); - push @select_tokens, @qsooqr_flags, 'quotation', 'cv' if $bsooqr; + push @select_tokens, @qsooqr_flags, 'quotation', 'cv', 'ioi.id', 'ioi.ioi' if $bsooqr; push @select_tokens, @deliverydate_flags if $bsooqr && $form->{l_deliverydate}; push @select_tokens, $q_assembly_lastcost if ($form->{searchitems} eq 'assembly') && $form->{l_lastcost}; push @bsooqr_tokens, q|module = 'ir' AND NOT ioi.assemblyitem| if $form->{bought}; @@ -1005,7 +1012,15 @@ sub all_parts { push @bind_vars, @cvar_values; } - my $query = qq|SELECT DISTINCT $select_clause FROM parts p $join_clause WHERE $where_clause $group_clause $order_clause $limit_clause|; + my $query = <<" SQL"; + SELECT DISTINCT $select_clause + FROM parts p + $join_clause + WHERE $where_clause + $group_clause + $order_clause + $limit_clause + SQL $form->{parts} = selectall_hashref_query($form, $dbh, $query, @bind_vars);