+if ( $cgi->param('credbatch') =~ /^([\w\-\/\.\:]+)$/ ) {
+ push @search, "cust_credit.credbatch = '$1'";
+}
+
+# commission_salesnum
+if ( $cgi->param('commission_salesnum') =~ /^(\d+)$/ ) {
+ push @search, "commission_salesnum = $1";
+}
+
+# commission agentnum
+if ( $cgi->param('commission_agentnum') =~ /^(\d+)$/ ) {
+ push @search, "commission_agentnum = $1";
+}
+
+# commission_classnum
+if ( grep { $_ eq 'commission_classnum' } $cgi->param ) {
+ $cgi->param('commission_classnum') =~ /^(\d*)$/ or die 'guru meditation #13';
+ my $classnum = $1;
+ push @search, "part_pkg.classnum ". ( $classnum ? " = $classnum"
+ : " IS NULL " );
+
+ $addl_from .=
+ ' LEFT JOIN cust_pkg ON ( commission_pkgnum = cust_pkg.pkgnum ) '.
+ ' LEFT JOIN part_pkg USING ( pkgpart ) ';
+}
+
+if ( $cgi->param('refnum') && $cgi->param('refnum') =~ /^(\d+)$/ ) {
+ push @search, "refnum = $1";
+ my $part_referral = qsearchs('part_referral', { 'refnum' => $1 } );
+ die "unknown refnum $1" unless $part_referral;
+ $title = $part_referral->referral. " $title";
+}
+
+
+# cust_classnum (false laziness w/ elements/cust_main_dayranges.html, elements/cust_pay_or_refund.html, prepaid_income.html, cust_bill_pay.html, cust_bill_pkg.html, cust_bill_pkg_referral.html, unearned_detail.html, cust_credit_refund.html, cust_main::Search::search_sql)
+if ( grep { $_ eq 'cust_classnum' } $cgi->param ) {
+ my @classnums = grep /^\d*$/, $cgi->param('cust_classnum');
+ push @search, 'COALESCE( cust_main.classnum, 0) IN ( '.
+ join(',', map { $_ || '0' } @classnums ).
+ ' )'
+ if @classnums;
+}
+