including Null Values and improving result display

This commit is contained in:
hdl 2005-03-08 18:14:40 +00:00
parent e22946e8f4
commit b6724d9442
2 changed files with 9 additions and 8 deletions

View file

@ -11,7 +11,7 @@
<!-- /TMPL_LOOP -->
<!-- /TMPL_IF NAME="loopfilter"-->
<br>
<table>
<table border="1">
<tr >
<th class="reports"><!-- TMPL_VAR name="line" --> / <!-- TMPL_VAR name="column" --></th>
<!-- TMPL_LOOP NAME="loopcol" -->

View file

@ -583,9 +583,9 @@ sub calculate {
my $emptycol;
while (my ($row, $col, $value) = $dbcalc->fetchrow) {
# warn "filling table $row / $col / $value ";
$row = "zzEMPTY" if ($row eq undef);
$col = "zzEMPTY" if ($col eq undef);
$emptycol = 1 if ($col eq undef);
$col = "zzEMPTY" if ($col eq undef);
$row = "zzEMPTY" if ($row eq undef);
$table{$row}->{$col}+=$value;
$table{$row}->{totalrow}+=$value;
@ -597,18 +597,19 @@ sub calculate {
# undef %cell;
# my %cell;
# %cell = {coltitle => "zzEMPTY"};
push @loopcol,{coltitle => "zzEMPTY"} if ($emptycol);
push @loopcol,{coltitle => "NULL"} if ($emptycol);
foreach my $row ( sort keys %table ) {
my @loopcell;
#@loopcol ensures the order for columns is common with column titles
# and the number matches the number of columns
foreach my $col ( @loopcol ) {
push @loopcell, {value => $table{$row}->{$col->{coltitle}}} ;
my $value =$table{$row}->{($col->{coltitle} eq "NULL")?"zzEMPTY":$col->{coltitle}};
push @loopcell, {value => ($value)?$value:"" } ;
}
push @looprow,{ 'rowtitle' => $row,
push @looprow,{ 'rowtitle' => ($row eq "zzEMPTY")?"NULL":$row,
'loopcell' => \@loopcell,
'hilighted' => 1 ,
'hilighted' => ($hilighted >0),
'totalrow' => $table{$row}->{totalrow}
};
$hilighted = -$hilighted;
@ -618,7 +619,7 @@ sub calculate {
foreach my $col ( @loopcol ) {
my $total=0;
foreach my $row ( @looprow ) {
$total += $table{$row->{rowtitle}}->{$col->{coltitle}};
$total += $table{($row->{rowtitle} eq "NULL")?"zzEMPTY":$row->{rowtitle}}->{($col->{coltitle} eq "NULL")?"zzEMPTY":$col->{coltitle}};
# warn "value added ".$table{$row->{rowtitle}}->{$col->{coltitle}}. "for line ".$row->{rowtitle};
}
# warn "summ for column ".$col->{coltitle}." = ".$total;