X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/259775be91430bf760db9f6cc8bcec0f710cf9cf..ee8cd3160941dd808b75b8f06e7138eaca90c9af:/SL/IC.pm diff --git a/SL/IC.pm b/SL/IC.pm index a27cc52e4..092a24d0f 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -861,10 +861,15 @@ sub all_parts { $where .= qq| AND (p.onhand < p.rop)|; } + my @subcolumns; foreach my $column (qw(make model)) { - next unless ($form->{$column}); - $where .= qq| AND p.id IN (SELECT DISTINCT m.parts_id FROM makemodel WHERE $column ILIKE ?)|; - push(@values, '%' . $form->{$column} . '%'); + push @subcolumns, $column if $form->{$column}; + } + if (@subcolumns) { + $where .= qq| AND p.id IN (SELECT DISTINCT parts_id FROM makemodel WHERE |; + $where .= join " AND ", map { "($_ ILIKE ?)"; } @subcolumns; + $where .= qq|)|; + push @values, map { '%' . $form->{$_} . '%' } @subcolumns; } if ($form->{l_soldtotal}) {