From: ivan Date: Sun, 7 Jul 2002 14:00:49 +0000 (+0000) Subject: try for correct totals X-Git-Tag: freeside_1_4_0~30 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=012523fcc0f3bc9994a429eb96b32eab6b3c04ce try for correct totals --- diff --git a/httemplate/search/cust_bill.cgi b/httemplate/search/cust_bill.cgi index 3b6b8fad9..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 ) { @@ -159,8 +160,8 @@ END ); my $pdate = time2str("%b %d %Y", $date); - $tot_balance += $owed; - $tot_amount += $charged; + #$tot_balance += $owed; + #$tot_amount += $charged; my $rowspan = 1;