From: ivan Date: Wed, 19 Sep 2007 00:12:05 +0000 (+0000) Subject: fix at least one small problem with reprint/email/fax functionality: now should under... X-Git-Tag: TRIXBOX_2_6~361 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=ed722b852f9f24a023bd1f1aa4a16ec39230e22c fix at least one small problem with reprint/email/fax functionality: now should understand the "most recent invoice per customer" and invoice # min/max options --- diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index f6dbc3df0..b9c0b5fb4 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -2693,6 +2693,12 @@ sub re_X { if ( $param{'end'} =~ /^(\d+)$/ ) { push @where, "cust_bill._date < $1"; } + if ( $param{'invnum_min'} =~ /^(\d+)$/ ) { + push @where, "cust_bill.invnum >= $1"; + } + if ( $param{'invnum_max'} =~ /^(\d+)$/ ) { + push @where, "cust_bill.invnum <= $1"; + } if ( $param{'agentnum'} =~ /^(\d+)$/ ) { push @where, "cust_main.agentnum = $1"; } @@ -2716,7 +2722,6 @@ sub re_X { if ( $param{'newest_percust'} ) { $distinct = 'DISTINCT ON ( cust_bill.custnum )'; $orderby = 'ORDER BY cust_bill.custnum ASC, cust_bill._date DESC'; - #$count_query = "SELECT COUNT(DISTINCT cust_bill.custnum), 'N/A', 'N/A'"; } my @cust_bill = qsearch( 'cust_bill', diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 7b9386ec6..aa4b2f108 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -58,11 +58,13 @@ my $join_cust_main = 'LEFT JOIN cust_main USING ( custnum )'; my $agentnums_sql = $FS::CurrentUser::CurrentUser->agentnums_sql; my( $count_query, $sql_query ); -my( $count_addl ) = ( '' ); -my( $distinct ) = ( '' ); +my $count_addl = ''; +my $distinct = ''; my($begin, $end) = ( '', '' ); -my($agentnum) = ( '' ); +my $agentnum = ''; my($open, $days) = ( '', '' ); +my($invnum_min, $invnum_max) = ( '', '' ); +my $newest_percust = ''; if ( $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/ ) { $count_query = "SELECT COUNT(*) FROM cust_bill $join_cust_main". @@ -106,9 +108,11 @@ if ( $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/ ) { } if ( $cgi->param('invnum_min') =~ /^\s*(\d+)\s*$/ ) { + $invnum_min = $1; push @where, "cust_bill.invnum >= $1"; } if ( $cgi->param('invnum_max') =~ /^\s*(\d+)\s*$/ ) { + $invnum_max = $1; push @where, "cust_bill.invnum <= $1"; } @@ -142,6 +146,7 @@ if ( $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/ ) { my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; if ( $cgi->param('newest_percust') ) { + $newest_percust = 1; $distinct = 'DISTINCT ON ( cust_bill.custnum )'; $orderby = 'ORDER BY cust_bill.custnum ASC, cust_bill._date DESC'; #$count_query = "SELECT 'N/A', 'N/A', 'N/A'"; #XXXXXXX fix @@ -187,17 +192,22 @@ my $html_init = join("\n", map { ( my $action = $_ ) =~ s/_$//; include('/elements/progress-init.html', $_.'form', - [ 'begin', 'end', 'agentnum', 'open', 'days', 'newest_percust' ], + [ 'begin', 'end', 'agentnum', 'open', 'days', + 'invnum_min', 'invnum_max', 'newest_percust', + ], "../misc/${_}invoices.cgi", { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but... $_, #key ), qq!
!, - qq!!, - qq!!, - qq!!, - qq!!, - qq!!, + qq!!, + qq!!, + qq!!, + qq!!, + qq!!, + qq!!, + qq!!, + qq!!, qq!
! } qw( print_ email_ fax_ ) ).