X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/3d967be3d2f32e2b00f5f55769edcbf5be866ce6..9c5f94c0359a8f2c0dba93b5e9bdef99f332fcc8:/SL/PE.pm diff --git a/SL/PE.pm b/SL/PE.pm index 31a8bd507..2eb720150 100644 --- a/SL/PE.pm +++ b/SL/PE.pm @@ -52,13 +52,16 @@ sub partsgroups { if ($form->{partsgroup}) { $where .= qq| AND partsgroup ILIKE ?|; - push(@values, '%' . $form->{partsgroup} . '%'); + push(@values, like($form->{partsgroup})); } if ($form->{status} eq 'orphaned') { $where .= qq| AND id NOT IN | . qq| (SELECT DISTINCT partsgroup_id FROM parts | . + qq| WHERE NOT partsgroup_id ISNULL | . + qq| UNION | . + qq| SELECT DISTINCT partsgroup_id FROM custom_variable_config_partsgroups | . qq| WHERE NOT partsgroup_id ISNULL) |; } @@ -96,7 +99,7 @@ sub save_partsgroup { if ($form->{id}) { $query = qq|UPDATE partsgroup SET partsgroup = ? WHERE id = ?|; - push(@values, $form->{id}); + push(@values, $form->{id}); } else { $query = qq|INSERT INTO partsgroup (partsgroup) VALUES (?)|; } @@ -129,6 +132,12 @@ sub get_partsgroup { $dbh->disconnect; + # also not orphaned if partsgroup is selected for a cvar filter + if ($form->{orphaned}) { + my $cvar_count = scalar( @{ SL::DB::PartsGroup->new(id => $form->{id})->custom_variable_configs } ); + $form->{orphaned} = !$cvar_count; + } + $main::lxdebug->leave_sub(); } @@ -165,14 +174,14 @@ sub pricegroups { if ($form->{pricegroup}) { $where .= qq| AND pricegroup ILIKE ?|; - push(@values, '%' . $form->{pricegroup} . '%'); + push(@values, like($form->{pricegroup})); } if ($form->{status} eq 'orphaned') { my $first = 1; $where .= qq| AND id NOT IN (|; - foreach my $table (qw(invoice orderitems prices rmaitems)) { + foreach my $table (qw(invoice orderitems prices)) { $where .= "UNION " unless ($first); $first = 0; $where .= @@ -219,7 +228,7 @@ sub save_pricegroup { if ($form->{id}) { $query = qq|UPDATE pricegroup SET pricegroup = ? WHERE id = ? |; - push(@values, $form->{id}); + push(@values, $form->{id}); } else { $query = qq|INSERT INTO pricegroup (pricegroup) VALUES (?)|; } @@ -253,7 +262,7 @@ sub get_pricegroup { my @values = (); $query = qq|SELECT |; - foreach my $table (qw(invoice orderitems prices rmaitems)) { + foreach my $table (qw(invoice orderitems prices)) { $query .= " + " unless ($first); $first = 0; $query .= qq|(SELECT COUNT(*) FROM $table WHERE pricegroup_id = ?) |;