|
Lines 68-90
if ($do_it) {
Link Here
|
| 68 |
-filename=>"$basename.csv" ); |
68 |
-filename=>"$basename.csv" ); |
| 69 |
my $cols = @$results[0]->{loopcol}; |
69 |
my $cols = @$results[0]->{loopcol}; |
| 70 |
my $lines = @$results[0]->{looprow}; |
70 |
my $lines = @$results[0]->{looprow}; |
| 71 |
# header top-right |
71 |
# header top-left |
| 72 |
print @$results[0]->{line} ."/". @$results[0]->{column} .$sep; |
72 |
print @$results[0]->{line} ."/". @$results[0]->{column} .$sep; |
|
|
73 |
print "Patron".$sep; |
| 74 |
print "Total".$sep; |
| 73 |
# Other header |
75 |
# Other header |
| 74 |
print join($sep, map {$_->{coltitle}} @$cols); |
76 |
print join($sep, map {$_->{coltitle}} @$cols); |
| 75 |
print $sep . "Total\n"; |
77 |
print "\n"; |
| 76 |
# Table |
78 |
# Table |
| 77 |
foreach my $line ( @$lines ) { |
79 |
foreach my $line ( @$lines ) { |
| 78 |
my $x = $line->{loopcell}; |
80 |
my $x = $line->{loopcell}; |
| 79 |
print $line->{rowtitle}.$sep; |
81 |
print $line->{rowtitle}.$sep; |
| 80 |
print join($sep, map {$_->{value}} @$x); |
82 |
print '"'.$line->{patron}.'"'.$sep; |
| 81 |
print $sep,$line->{totalrow}; |
83 |
print join($sep, map {$_->{count}} @$x); |
| 82 |
print "\n"; |
84 |
print "\n"; |
| 83 |
} |
85 |
} |
| 84 |
# footer |
86 |
# footer |
| 85 |
print "TOTAL"; |
87 |
print "TOTAL"; |
| 86 |
$cols = @$results[0]->{loopfooter}; |
88 |
$cols = @$results[0]->{loopfooter}; |
| 87 |
print join($sep, map {$_->{totalcol}} @$cols); |
89 |
print join($sep, map {$_->{total}} @$cols); |
| 88 |
print $sep.@$results[0]->{total}; |
90 |
print $sep.@$results[0]->{total}; |
| 89 |
} |
91 |
} |
| 90 |
exit; |
92 |
exit; |
|
Lines 148-154
sub calculate {
Link Here
|
| 148 |
my $colorder; |
150 |
my $colorder; |
| 149 |
if ($column){ |
151 |
if ($column){ |
| 150 |
$column = "old_issues." .$column if (($column=~/branchcode/) or ($column=~/timestamp/)); |
152 |
$column = "old_issues." .$column if (($column=~/branchcode/) or ($column=~/timestamp/)); |
| 151 |
$column = "biblioitems.".$column if $column=~/itemtype/; |
153 |
$column = "items.itype" if $column=~/itemtype/; |
| 152 |
$column = "borrowers." .$column if $column=~/categorycode/; |
154 |
$column = "borrowers." .$column if $column=~/categorycode/; |
| 153 |
my @colfilter ; |
155 |
my @colfilter ; |
| 154 |
if ($column =~ /timestamp/) { |
156 |
if ($column =~ /timestamp/) { |
|
Lines 245-251
sub calculate {
Link Here
|
| 245 |
'old_issues.returndate >', |
247 |
'old_issues.returndate >', |
| 246 |
'old_issues.returndate <', |
248 |
'old_issues.returndate <', |
| 247 |
'old_issues.branchcode like', |
249 |
'old_issues.branchcode like', |
| 248 |
'biblioitems.itemtype like', |
250 |
'items.itype like', |
| 249 |
'borrowers.categorycode like', |
251 |
'borrowers.categorycode like', |
| 250 |
); |
252 |
); |
| 251 |
foreach ((@$filters)[0..9]) { |
253 |
foreach ((@$filters)[0..9]) { |
|
Lines 309-332
sub calculate {
Link Here
|
| 309 |
foreach my $id (@ranked_ids) { |
311 |
foreach my $id (@ranked_ids) { |
| 310 |
my @loopcell; |
312 |
my @loopcell; |
| 311 |
|
313 |
|
| 312 |
foreach my $key (@cols_in_order) { |
314 |
if($column){ |
| 313 |
if($column){ |
315 |
# Total |
| 314 |
push @loopcell, { |
316 |
push @loopcell, { |
| 315 |
value => $patrons{$id}->{name}, |
317 |
count => $patrons{$id}->{total}, |
| 316 |
reference => $id, |
318 |
}; |
| 317 |
count => $patrons{$id}->{allcols}->{$key}, |
319 |
foreach my $key (@cols_in_order) { |
| 318 |
}; |
320 |
push @loopcell, { |
| 319 |
}else{ |
321 |
count => $patrons{$id}->{allcols}->{$key}, |
| 320 |
push @loopcell, { |
322 |
}; |
| 321 |
value => $patrons{$id}->{name}, |
323 |
$grantotal += $patrons{$id}->{allcols}->{$key}; |
| 322 |
reference => $id, |
324 |
} |
| 323 |
count => $patrons{$id}->{total}, |
325 |
}else{ |
| 324 |
}; |
326 |
push @loopcell, { |
| 325 |
} |
327 |
count => $patrons{$id}->{total}, |
|
|
328 |
}; |
| 329 |
$grantotal += $patrons{$id}->{total}; |
| 326 |
} |
330 |
} |
| 327 |
push @looprow,{ 'rowtitle' => $i++ , |
331 |
push @looprow,{ 'rowtitle' => $i++ , |
| 328 |
'loopcell' => \@loopcell, |
332 |
'loopcell' => \@loopcell, |
| 329 |
'hilighted' => ($i%2), |
333 |
'hilighted' => ($i%2), |
|
|
334 |
'patron' => $patrons{$id}->{name}, |
| 335 |
'reference' => $id, |
| 330 |
}; |
336 |
}; |
| 331 |
# use a limit, if a limit is defined |
337 |
# use a limit, if a limit is defined |
| 332 |
last if $i > $limit and $limit |
338 |
last if $i > $limit and $limit |
|
Lines 336-342
sub calculate {
Link Here
|
| 336 |
$globalline{loopfilter}=\@loopfilter; |
342 |
$globalline{loopfilter}=\@loopfilter; |
| 337 |
# the core of the table |
343 |
# the core of the table |
| 338 |
$globalline{looprow} = \@looprow; |
344 |
$globalline{looprow} = \@looprow; |
| 339 |
$globalline{loopcol} = [ map {{coltitle=>$_}} @cols_in_order ]; |
345 |
$globalline{loopcol} = [ map {{coltitle=>$_}} @cols_in_order ] if ($column); |
| 340 |
# the foot (totals by borrower type) |
346 |
# the foot (totals by borrower type) |
| 341 |
$globalline{loopfooter} = []; |
347 |
$globalline{loopfooter} = []; |
| 342 |
$globalline{total}= $grantotal; # FIXME: useless |
348 |
$globalline{total}= $grantotal; # FIXME: useless |
| 343 |
- |
|
|