diff options
author | Mark Wells <mark@freeside.biz> | 2014-05-20 18:14:58 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2014-05-20 18:14:58 -0700 |
commit | 8b1320ce3eca72830fe8b138f07b22968e349f96 (patch) | |
tree | 8f2a668754a84f72e65dc014ee82496b1b28e18b /httemplate | |
parent | 24b3cded842823df810e6bee6ef66237c783f033 (diff) |
search voided invoices, #28684
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/elements/menu.html | 3 | ||||
-rwxr-xr-x | httemplate/search/cust_bill.html | 28 | ||||
-rwxr-xr-x | httemplate/view/cust_bill-logo.cgi | 8 |
3 files changed, 28 insertions, 11 deletions
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 07e0da54b..78388bfc8 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -132,6 +132,9 @@ tie my %report_invoices, 'Tie::IxHash', 'Advanced invoice reports' => [ $fsurl.'search/report_cust_bill.html', 'by agent, date range, etc.' ], 'separator' => '', 'Line items' => [ $fsurl. 'search/report_cust_bill_pkg.html', 'Individual line item detail' ], + 'separator' => '', + 'Voided invoices' => [ $fsurl.'search/report_cust_bill_void.html', 'Search for voided invoices' ], + ; tie my %report_discounts, 'Tie::IxHash', 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(', ', diff --git a/httemplate/view/cust_bill-logo.cgi b/httemplate/view/cust_bill-logo.cgi index d55ec041e..dc8b674ec 100755 --- a/httemplate/view/cust_bill-logo.cgi +++ b/httemplate/view/cust_bill-logo.cgi @@ -9,10 +9,12 @@ my $conf; my $templatename; my $agentnum = ''; -if ( $cgi->param('invnum') ) { +if ( $cgi->param('invnum') =~ /^(\d+)$/ ) { + my $invnum = $1; $templatename = $cgi->param('template') || $cgi->param('templatename'); - my $cust_bill = qsearchs('cust_bill', { 'invnum' => $cgi->param('invnum') } ) - or die 'unknown invnum'; + my $cust_bill = FS::cust_bill->by_key($invnum) + || FS::cust_bill_void->by_key($invnum); + die 'unknown invnum' unless $cust_bill; $conf = $cust_bill->conf; $agentnum = $cust_bill->cust_main->agentnum; } else { |