X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_bill_pkg_referral.html;h=a39fa57f6cdb1802b6ba341188949fe5d2030cc2;hb=b9491d5d5f06f41963c9e4d523a6bce7d8fa132b;hp=1bb6b9179d318a896629521bf31bc49f87328990;hpb=005424d0c899aa899f43f583a6c74deb13ea4be1;p=freeside.git diff --git a/httemplate/search/cust_bill_pkg_referral.html b/httemplate/search/cust_bill_pkg_referral.html index 1bb6b9179..a39fa57f6 100644 --- a/httemplate/search/cust_bill_pkg_referral.html +++ b/httemplate/search/cust_bill_pkg_referral.html @@ -41,8 +41,11 @@ 'classname', sub { # report_option my $cust_bill_pkg = shift; - my $pkgpart = $cust_bill_pkg->pkgpart_override - || $cust_bill_pkg->cust_pkg->pkgpart; + my $pkgpart = $cust_bill_pkg->pkgpart_override; + unless ( $pkgpart ) { + my $cust_pkg = $cust_bill_pkg->cust_pkg or return ''; + $pkgpart = $cust_pkg->pkgpart; + } if ( !exists($report_classes{$pkgpart}) ) { my $part_pkg = FS::part_pkg->by_key($pkgpart); my %opts = $part_pkg->options; @@ -135,8 +138,34 @@ 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).')'; +} + +# 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, unearned_detail.html, cust_credit.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 @where, 'COALESCE( cust_main.classnum, 0) IN ( '. + join(',', map { $_ || '0' } @classnums ). + ' )' + if @classnums; } if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {