@@ -, +, @@ reserves and old_reserves +------+---------------+-------------+ +------+---------------+-------------+ +------+---------------+-------------+ --- reports/reserves_stats.pl | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) --- a/reports/reserves_stats.pl +++ a/reports/reserves_stats.pl @@ -275,17 +275,20 @@ sub calculate { @sqlparams=(@sqlparams,@sqlorparams); $dbcalc->execute(@sqlparams,@sqlparams); my ($emptycol,$emptyrow); - my $data = $dbcalc->fetchall_hashref([qw(line col)]); - my %cols_hash; - foreach my $row (keys %$data){ - push @loopline, $row; - foreach my $col (keys %{$$data{$row}}){ - $$data{$row}{totalrow}+=$$data{$row}{$col}{calculation}; - $grantotal+=$$data{$row}{$col}{calculation}; - $cols_hash{$col}=1 ; - } - } my $urlbase="do_it=1&".join("&",map{"filter_$_=$$filters_hashref{$_}"} keys %$filters_hashref); + + my $results = $dbcalc->fetchall_arrayref({}); + my %cols_hash; + my $data; + foreach my $r (@$results){ + my $row = $r->{line}; + $data->{$row}{$r->{col}}{calculation} += $r->{calculation}; + $data->{$row}{totalrow} += $r->{calculation}; + $grantotal += $r->{calculation}; + $cols_hash{$r->{col}}=1 ; + } + @loopline = keys $data; + foreach my $row (sort @loopline) { my @loopcell; #@loopcol ensures the order for columns is common with column titles --