summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2011-08-18 00:33:40 +0000
committerivan <ivan>2011-08-18 00:33:40 +0000
commit357524c1a93e1a8fbba1cce6f282bcf2fa747459 (patch)
tree14754b5decc94afab3321520f622aa109698f60a
parent67cc29cf8d4ce046599a857437b6b3c105820e08 (diff)
allow multiple classnums in package search, RT#13922
-rw-r--r--FS/FS/cust_pkg.pm62
-rwxr-xr-xhttemplate/search/cust_pkg.cgi7
2 files changed, 40 insertions, 29 deletions
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index c2b3c04b5..868ee1c2b 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -1795,7 +1795,7 @@ sub h_cust_svc {
FS::h_cust_svc->sql_h_search(@_),
) ]
);
- if ( $mode eq 'I' ) {
+ if ( defined($mode) && $mode eq 'I' ) {
my %hidden_svcpart = map { $_->svcpart => $_->hidden } $self->part_svc;
return grep { !$hidden_svcpart{$_->svcpart} } @cust_svc;
} else {
@@ -2950,34 +2950,42 @@ sub search {
# parse package class
###
- #false lazinessish w/graph/cust_bill_pkg.cgi
- my $classnum = 0;
- my @pkg_class = ();
- if ( exists($params->{'classnum'})
- && $params->{'classnum'} =~ /^(\d*)$/
- )
- {
- $classnum = $1;
- if ( $classnum ) { #a specific class
- push @where, "part_pkg.classnum = $classnum";
-
- #@pkg_class = ( qsearchs('pkg_class', { 'classnum' => $classnum } ) );
- #die "classnum $classnum not found!" unless $pkg_class[0];
- #$title .= $pkg_class[0]->classname.' ';
-
- } elsif ( $classnum eq '' ) { #the empty class
-
- push @where, "part_pkg.classnum IS NULL";
- #$title .= 'Empty class ';
- #@pkg_class = ( '(empty class)' );
- } elsif ( $classnum eq '0' ) {
- #@pkg_class = qsearch('pkg_class', {} ); # { 'disabled' => '' } );
- #push @pkg_class, '(empty class)';
- } else {
- die "illegal classnum";
+ if ( exists($params->{'classnum'}) ) {
+
+ my @classnum = ();
+ if ( ref($params->{'classnum'}) ) {
+
+ if ( ref($params->{'classnum'}) eq 'HASH' ) {
+ @classnum = grep $params->{'classnum'}{$_}, keys %{ $params->{'classnum'} };
+ } elsif ( ref($params->{'classnum'}) eq 'ARRAY' ) {
+ @classnum = @{ $params->{'classnum'} };
+ } else {
+ die 'unhandled classnum ref '. $params->{'classnum'};
+ }
+
+
+ } elsif ( $params->{'classnum'} =~ /^(\d*)$/ && $1 ne '0' ) {
+ @classnum = ( $1 );
}
+
+ if ( @classnum ) {
+
+ my @c_where = ();
+ my @nums = grep $_, @classnum;
+ push @c_where, 'part_pkg.classnum IN ('. join(',',@nums). ')' if @nums;
+ my $null = scalar( grep { $_ eq '' } @classnum );
+ push @c_where, 'part_pkg.classnum IS NULL' if $null;
+
+ if ( scalar(@c_where) == 1 ) {
+ push @where, @c_where;
+ } elsif ( @c_where ) {
+ push @where, ' ( '. join(' OR ', @c_where). ' ) ';
+ }
+
+ }
+
+
}
- #eslaf
###
# parse package report options
diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi
index aec04880f..9ec0c8425 100755
--- a/httemplate/search/cust_pkg.cgi
+++ b/httemplate/search/cust_pkg.cgi
@@ -168,11 +168,14 @@ my %search_hash = ();
$search_hash{'query'} = $cgi->keywords;
#scalars
-for (qw( agentnum custnum magic status classnum custom cust_fields pkgbatch )) {
+for (qw( agentnum custnum magic status custom cust_fields pkgbatch )) {
$search_hash{$_} = $cgi->param($_) if $cgi->param($_);
}
-$search_hash{'pkgpart'} = [ $cgi->param('pkgpart') ];
+#arrays
+for (qw( pkgpart classnum )) {
+ $search_hash{$_} = [ $cgi->param($_) ];
+}
for my $param ( qw(censustract) ) {
$search_hash{$param} = $cgi->param($param) || ''