X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_bill.cgi;h=6d00593bdea1a6ba14dc3c1ed0fced4024ef4c2e;hb=012523fcc0f3bc9994a429eb96b32eab6b3c04ce;hp=cb358f9e99ad20601ea3485747983630bef48c34;hpb=6e80f8889a13c47343d81de796f2a7ed4f036803;p=freeside.git diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index cb358f9e9..6d00593bd 100755 --- a/httemplate/search/cust_bill.cgi +++ b/httemplate/search/cust_bill.cgi @@ -70,11 +70,13 @@ if ( $cgi->keywords ) { my $extra_sql = scalar(@where) ? 'WHERE '. join(' AND ', @where) : ''; - my $statement = "SELECT COUNT(*) FROM cust_bill $extra_sql"; + my $statement = "SELECT COUNT(*), sum(charged), sum($owed) + FROM cust_bill $extra_sql"; my $sth = dbh->prepare($statement) or die dbh->errstr. " doing $statement"; $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; - $total = $sth->fetchrow_arrayref->[0]; + #$total = $sth->fetchrow_arrayref->[0]; + ( $total, $tot_amount, $tot_balance ) = @{$sth->fetchrow_arrayref}; @cust_bill = qsearch( 'cust_bill', @@ -91,8 +93,7 @@ if ( $cgi->keywords ) { } #if ( scalar(@cust_bill) == 1 ) { -if ( scalar(@cust_bill) == 1 && $total == 1) { -#if ( $total == 1 ) { +if ( $total == 1 ) { my $invnum = $cust_bill[0]->invnum; print $cgi->redirect(popurl(2). "view/cust_bill.cgi?$invnum"); #redirect } elsif ( scalar(@cust_bill) == 0 ) { @@ -147,20 +148,20 @@ if ( scalar(@cust_bill) == 1 && $total == 1) { END my(%saw, $cust_bill); - my($tot_balance, $tot_amount) = (0, 0); #BOGUS +# my($tot_balance, $tot_amount) = (0, 0); #BOGUS foreach $cust_bill ( sort $sortby grep(!$saw{$_->invnum}++, @cust_bill) ) { my($invnum, $owed, $charged, $date ) = ( $cust_bill->invnum, - sprintf("%.2f", $cust_bill->owed), + sprintf("%.2f", $cust_bill->getfield('owed')), sprintf("%.2f", $cust_bill->charged), $cust_bill->_date, ); my $pdate = time2str("%b %d %Y", $date); - $tot_balance += $owed; - $tot_amount += $charged; + #$tot_balance += $owed; + #$tot_amount += $charged; my $rowspan = 1;