Auth.pm cosmetics: Entfernen von $::lxdebug->enter_sub/leave_sub
[kivitendo-erp.git] / SL / PE.pm
index 9906a72..4d7176d 100644 (file)
--- a/SL/PE.pm
+++ b/SL/PE.pm
@@ -59,6 +59,9 @@ sub partsgroups {
     $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) |;
   }
 
@@ -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();
 }
 
@@ -172,7 +181,7 @@ sub pricegroups {
     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 .=
@@ -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 = ?) |;