epic-ts
[kivitendo-erp.git] / SL / IC.pm
index a09d740..f36ca04 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -481,7 +481,7 @@ sub all_parts {
 
   my $token_builder = $make_token_builder->(\%joins_needed);
 
-  my @sort_cols    = (@simple_filters, qw(id priceupdate onhand invnumber ordnumber quonumber name serialnumber soldtotal deliverydate insertdate shop));
+  my @sort_cols    = (@simple_filters, qw(id onhand invnumber ordnumber quonumber name serialnumber soldtotal deliverydate insertdate shop));
      $form->{sort} = 'id' unless grep { $form->{"l_$_"} } grep { $form->{sort} eq $_ } @sort_cols; # sort by id if unknown or invisible column
   my $sort_order   = ($form->{revers} ? ' DESC' : ' ASC');
   my $order_clause = " ORDER BY " . $token_builder->($form->{sort}) . ($form->{revers} ? ' DESC' : ' ASC');
@@ -526,13 +526,13 @@ sub all_parts {
   if ($form->{bom} eq '2' && $form->{l_assembly}) {
     # nuke where clause and bind vars
     $where_clause = ' 1=1 AND p.id in (SELECT id from assembly where parts_id IN ' .
-                    ' (select id from parts where 1=1 AND ';
+                    ' (select id from parts where 1=1';
     @bind_vars    = ();
     # use only like filter for items used in assemblies
     foreach (@like_filters) {
       next unless $form->{$_};
       $form->{"l_$_"} = '1'; # show the column
-      $where_clause .= " $_ ILIKE ? ";
+      $where_clause .= " AND $_ ILIKE ? ";
       push @bind_vars,    like($form->{$_});
     }
     $where_clause .='))';
@@ -547,7 +547,6 @@ sub all_parts {
     $order_clause
     $limit_clause
   SQL
-
   $form->{parts} = selectall_hashref_query($form, $dbh, $query, @bind_vars);
 
   map { $_->{onhand} *= 1 } @{ $form->{parts} };
@@ -567,7 +566,7 @@ sub all_parts {
       qq|SELECT p.id, p.partnumber, p.description, a.qty AS onhand,
            p.unit, p.notes, p.itime::DATE as insertdate,
            p.sellprice, p.listprice, p.lastcost,
-           p.rop, p.weight, p.priceupdate,
+           p.rop, p.weight,
            p.image, p.drawing, p.microfiche,
            pfac.factor
          FROM parts p