filter by customer class on all financial reports, #20573
[freeside.git] / httemplate / search / cust_bill_pkg_referral.html
index 1bb6b91..1289ff7 100644 (file)
@@ -135,8 +135,30 @@ my @where = ( $agentnums_sql,
               "cust_bill._date <= $ending",
             );
 
-if ( $cgi->param('status') =~ /^([a-z]+)$/ ) {
-  push @where, FS::cust_pkg->cust_status_sql . " = '$1'";
+my @status_where;
+foreach my $status ($cgi->param('status')) {
+  if ( $status =~ /^([- a-z]+)$/ ) { #"one-time charge"
+    push @status_where, "'$status'";
+  }
+}
+if ( @status_where ) {
+  push @where, '('. FS::cust_pkg->status_sql.
+    ') IN (' . join(',', @status_where) .')';
+}
+
+my @refnum;
+foreach my $refnum ($cgi->param('refnum')) {
+  if ( $refnum =~ /^\d+$/ ) {
+    push @refnum, $refnum;
+  }
+}
+if ( @refnum ) {
+  push @where, 'cust_main.refnum IN ('.join(',', @refnum).')';
+}
+
+my @cust_classnums = grep /^\d+$/, $cgi->param('cust_classnum');
+if ( @cust_classnums ) {
+  push @where, 'cust_main.classnum IN ('.join(',', @cust_classnums).')';
 }
 
 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {