From: Sven Schöling Date: Fri, 10 Jun 2011 13:57:02 +0000 (+0200) Subject: Part::type_filter kommt nun auch mit mehreren werten klar. X-Git-Tag: release-2.7.0beta1~250 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=60009b978dd3d0a84e5fbd8d56330618f7016b39;p=kivitendo-erp.git Part::type_filter kommt nun auch mit mehreren werten klar. --- diff --git a/SL/DB/Manager/Part.pm b/SL/DB/Manager/Part.pm index e6aca1f71..50219cb61 100644 --- a/SL/DB/Manager/Part.pm +++ b/SL/DB/Manager/Part.pm @@ -7,32 +7,36 @@ use base qw(SL::DB::Helper::Manager); use Carp; use SL::DBUtils; +use SL::MoreCommon qw(listify); sub object_class { 'SL::DB::Part' } __PACKAGE__->make_manager_methods; sub type_filter { - my $class = shift; - my $type = lc(shift || ''); - - if ($type =~ m/^part/) { - return (and => [ or => [ assembly => 0, assembly => undef ], - '!inventory_accno_id' => 0, - '!inventory_accno_id' => undef, - ]); - - } elsif ($type =~ m/^service/) { - return (and => [ or => [ assembly => 0, assembly => undef ], - or => [ inventory_accno_id => 0, inventory_accno_id => undef ], - ]); - - } elsif ($type =~ m/^assembl/) { - return (assembly => 1); - + my ($class, $type) = @_; + + return () unless $type; + + my @types = listify($type); + my @filter; + + for my $type (@types) { + if ($type =~ m/^part/) { + push @filter, (and => [ or => [ assembly => 0, assembly => undef ], + '!inventory_accno_id' => 0, + '!inventory_accno_id' => undef, + ]); + } elsif ($type =~ m/^service/) { + push @filter, (and => [ or => [ assembly => 0, assembly => undef ], + or => [ inventory_accno_id => 0, inventory_accno_id => undef ], + ]); + } elsif ($type =~ m/^assembl/) { + push @filter, (assembly => 1); + } } - return (); + return @filter ? (or => \@filter) : (); } sub get_ordered_qty {