X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_bill.cgi;h=6b61589434380b80337a6a560e39cf5af5bfc30e;hb=508721f2941f287c841f57e6b3077aa90265826c;hp=6d00593bdea1a6ba14dc3c1ed0fced4024ef4c2e;hpb=012523fcc0f3bc9994a429eb96b32eab6b3c04ce;p=freeside.git diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 6d00593bd..6b6158943 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -23,46 +23,55 @@ if ( $cgi->keywords ) { my @where; if ( $query eq 'invnum' ) { $sortby = \*invnum_sort; + $orderby = "ORDER BY cust_bill.invnum"; #@cust_bill = qsearch('cust_bill', {} ); } elsif ( $query eq 'date' ) { $sortby = \*date_sort; + $orderby = "ORDER BY cust_bill._date"; #@cust_bill = qsearch('cust_bill', {} ); } elsif ( $query eq 'custnum' ) { $sortby = \*custnum_sort; + $orderby = "ORDER BY cust_bill.custnum"; #@cust_bill = qsearch('cust_bill', {} ); } elsif ( $query eq 'OPEN_invnum' ) { $sortby = \*invnum_sort; + $orderby = "ORDER BY cust_bill.invnum"; #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); push @where, "0 != $owed"; } elsif ( $query eq 'OPEN_date' ) { $sortby = \*date_sort; + $orderby = "ORDER BY cust_bill._date"; #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); push @where, "0 != $owed"; } elsif ( $query eq 'OPEN_custnum' ) { $sortby = \*custnum_sort; + $orderby = "ORDER BY cust_bill.custnum"; #@cust_bill = grep $_->owed != 0, qsearch('cust_bill', {} ); push @where, "0 != $owed"; } elsif ( $query =~ /^OPEN(\d+)_invnum$/ ) { my $open = $1 * 86400; $sortby = \*invnum_sort; + $orderby = "ORDER BY cust_bill.invnum"; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - push @where, "0 != $owed". + push @where, "0 != $owed", "cust_bill._date < ". (time-$open); } elsif ( $query =~ /^OPEN(\d+)_date$/ ) { my $open = $1 * 86400; $sortby = \*date_sort; + $orderby = "ORDER BY cust_bill._date"; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - push @where, "0 != $owed". + push @where, "0 != $owed", "cust_bill._date < ". (time-$open); } elsif ( $query =~ /^OPEN(\d+)_custnum$/ ) { my $open = $1 * 86400; $sortby = \*custnum_sort; + $orderby = "ORDER BY cust_bill.custnum"; #@cust_bill = # grep $_->owed != 0 && $_->_date < time - $open, qsearch('cust_bill', {} ); - push @where, "0 != $owed". + push @where, "0 != $owed", "cust_bill._date < ". (time-$open); } else { die "unknown query string $query"; @@ -136,7 +145,11 @@ if ( $total == 1 ) { print header("Invoice Search Results", menubar( 'Main Menu', popurl(2) - )), "$total matching invoices found

$pager", &table(), <". + "\$$tot_balance total balance
". + "\$$tot_amount total amount
". + "
$pager". table(). < Balance @@ -148,7 +161,6 @@ if ( $total == 1 ) { END my(%saw, $cust_bill); -# my($tot_balance, $tot_amount) = (0, 0); #BOGUS foreach $cust_bill ( sort $sortby grep(!$saw{$_->invnum}++, @cust_bill) ) { @@ -160,9 +172,6 @@ END ); my $pdate = time2str("%b %d %Y", $date); - #$tot_balance += $owed; - #$tot_amount += $charged; - my $rowspan = 1; my $view = popurl(2). "view/cust_bill.cgi?$invnum"; @@ -195,10 +204,10 @@ END } $tot_balance = sprintf("%.2f", $tot_balance); $tot_amount = sprintf("%.2f", $tot_amount); - print <TotalTotal + print "$pager
". table(). <       Total
Balance
Total
Amount
\$$tot_balance\$$tot_amount - $pager + END