diff options
author | Mark Wells <mark@freeside.biz> | 2014-05-20 18:15:18 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2014-05-20 18:15:18 -0700 |
commit | 523a0d904238cd573e4ae6a4a12dfcfea37cd703 (patch) | |
tree | 1714c4534bdccc56ac645699c3a21a347e7fcf9c /httemplate/search | |
parent | 2224bc4165a482da4bbaf4f09210f358cd825f99 (diff) |
search voided invoices, #28684
Diffstat (limited to 'httemplate/search')
-rwxr-xr-x | httemplate/search/cust_bill.html | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 473aed311..8d512f583 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -84,6 +84,20 @@ if ( $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/ ) { 'extra_sql' => $where, }; + if ( FS::Record->scalar_sql($count_query) == 0 ) { + + # check for a voided invoice + $count_query =~ s/cust_bill/cust_bill_void/g; + if ( FS::Record->scalar_sql($count_query) > 0 ) { + # Redirect to the void search. + my $url = $cgi->self_url; + $url =~ s(search/cust_bill)(search/cust_bill_void); + $m->clear_buffer; + $m->print($cgi->redirect($url)); + $m->abort; + } + } + } else { #some false laziness w/cust_bill::re_X @@ -156,15 +170,13 @@ if ( grep { $_ eq 'cust_classnum' } $cgi->param ) { } } - my $payby_sql = ''; - $payby_sql = ' AND (' . - join(' OR ', map { "cust_main.payby = '$_'" } $cgi->param('payby') ) . - ')' - if $cgi->param('payby'); + #payby + if ($cgi->param('payby')) { + $search{payby} = [ $cgi->param('payby') ]; + } - my $extra_sql = ' WHERE '. - FS::cust_bill->search_sql_where( \%search ). - $payby_sql; + my $extra_sql = FS::cust_bill->search_sql_where( \%search ); + $extra_sql = "WHERE $extra_sql" if $extra_sql; unless ( $count_query ) { $count_query = 'SELECT COUNT(*), '. join(', ', |