|
Lines 27-33
use C4::Koha;
Link Here
|
| 27 |
use C4::Circulation; |
27 |
use C4::Circulation; |
| 28 |
use C4::Members; |
28 |
use C4::Members; |
| 29 |
use C4::Reports; |
29 |
use C4::Reports; |
| 30 |
use C4::Debug; |
|
|
| 31 |
|
30 |
|
| 32 |
use Koha::DateUtils; |
31 |
use Koha::DateUtils; |
| 33 |
use Koha::ItemTypes; |
32 |
use Koha::ItemTypes; |
|
Lines 41-48
plugin that shows a stats on borrowers
Link Here
|
| 41 |
|
40 |
|
| 42 |
=cut |
41 |
=cut |
| 43 |
|
42 |
|
| 44 |
$debug and open my $debugfh, '>', '/tmp/bor_issues_top.debug.log'; |
|
|
| 45 |
|
| 46 |
my $input = CGI->new; |
43 |
my $input = CGI->new; |
| 47 |
my $fullreportname = "reports/bor_issues_top.tt"; |
44 |
my $fullreportname = "reports/bor_issues_top.tt"; |
| 48 |
my $do_it = $input->param('do_it'); |
45 |
my $do_it = $input->param('do_it'); |
|
Lines 223-247
sub calculate {
Link Here
|
| 223 |
$strsth2 .=" GROUP BY $colfield"; |
220 |
$strsth2 .=" GROUP BY $colfield"; |
| 224 |
$strsth2 .=" ORDER BY $colorder"; |
221 |
$strsth2 .=" ORDER BY $colorder"; |
| 225 |
|
222 |
|
| 226 |
$debug and print $debugfh "bor_issues_top (old_issues) SQL: $strsth2\n"; |
|
|
| 227 |
my $sth2 = $dbh->prepare($strsth2); |
223 |
my $sth2 = $dbh->prepare($strsth2); |
| 228 |
$sth2->execute; |
224 |
$sth2->execute; |
| 229 |
print $debugfh "rows: ", $sth2->rows, "\n"; |
|
|
| 230 |
while (my @row = $sth2->fetchrow) { |
225 |
while (my @row = $sth2->fetchrow) { |
| 231 |
$columns{($row[0] ||'NULL')}++; |
226 |
$columns{($row[0] ||'NULL')}++; |
| 232 |
push @loopcol, { coltitle => $row[0] || 'NULL' }; |
227 |
push @loopcol, { coltitle => $row[0] || 'NULL' }; |
| 233 |
} |
228 |
} |
| 234 |
|
229 |
|
| 235 |
$strsth2 =~ s/old_issues/issues/g; |
230 |
$strsth2 =~ s/old_issues/issues/g; |
| 236 |
$debug and print $debugfh "bor_issues_top (issues) SQL: $strsth2\n"; |
|
|
| 237 |
$sth2 = $dbh->prepare($strsth2); |
231 |
$sth2 = $dbh->prepare($strsth2); |
| 238 |
$sth2->execute; |
232 |
$sth2->execute; |
| 239 |
$debug and print $debugfh "rows: ", $sth2->rows, "\n"; |
|
|
| 240 |
while (my @row = $sth2->fetchrow) { |
233 |
while (my @row = $sth2->fetchrow) { |
| 241 |
$columns{($row[0] ||'NULL')}++; |
234 |
$columns{($row[0] ||'NULL')}++; |
| 242 |
push @loopcol, { coltitle => $row[0] || 'NULL' }; |
235 |
push @loopcol, { coltitle => $row[0] || 'NULL' }; |
| 243 |
} |
236 |
} |
| 244 |
$debug and print $debugfh "full array: ", Dumper(\%columns), "\n"; |
|
|
| 245 |
}else{ |
237 |
}else{ |
| 246 |
$columns{''} = 1; |
238 |
$columns{''} = 1; |
| 247 |
} |
239 |
} |
|
Lines 278-287
sub calculate {
Link Here
|
| 278 |
$strcalc .= ",$colfield " if ($colfield); |
270 |
$strcalc .= ",$colfield " if ($colfield); |
| 279 |
$strcalc .= " LIMIT $limit" if ($limit); |
271 |
$strcalc .= " LIMIT $limit" if ($limit); |
| 280 |
|
272 |
|
| 281 |
$debug and print $debugfh "(old_issues) SQL : $strcalc\n"; |
|
|
| 282 |
my $dbcalc = $dbh->prepare($strcalc); |
273 |
my $dbcalc = $dbh->prepare($strcalc); |
| 283 |
$dbcalc->execute; |
274 |
$dbcalc->execute; |
| 284 |
$debug and print $debugfh "rows: ", $dbcalc->rows, "\n"; |
|
|
| 285 |
my %patrons = (); |
275 |
my %patrons = (); |
| 286 |
# DATA STRUCTURE is going to look like this: |
276 |
# DATA STRUCTURE is going to look like this: |
| 287 |
# (2253=> {name=>"John Doe", |
277 |
# (2253=> {name=>"John Doe", |
|
Lines 300-309
sub calculate {
Link Here
|
| 300 |
use Data::Dumper; |
290 |
use Data::Dumper; |
| 301 |
|
291 |
|
| 302 |
$strcalc =~ s/old_issues/issues/g; |
292 |
$strcalc =~ s/old_issues/issues/g; |
| 303 |
$debug and print $debugfh "(issues) SQL : $strcalc\n"; |
|
|
| 304 |
$dbcalc = $dbh->prepare($strcalc); |
293 |
$dbcalc = $dbh->prepare($strcalc); |
| 305 |
$dbcalc->execute; |
294 |
$dbcalc->execute; |
| 306 |
$debug and print $debugfh "rows: ", $dbcalc->rows, "\n"; |
|
|
| 307 |
while (my @data = $dbcalc->fetchrow) { |
295 |
while (my @data = $dbcalc->fetchrow) { |
| 308 |
my ($row, $rank, $id, $col) = @data; |
296 |
my ($row, $rank, $id, $col) = @data; |
| 309 |
$col = "zzEMPTY" if (!defined($col)); |
297 |
$col = "zzEMPTY" if (!defined($col)); |
|
Lines 322-328
sub calculate {
Link Here
|
| 322 |
$patrons{$id}->{total} += $count; |
310 |
$patrons{$id}->{total} += $count; |
| 323 |
} |
311 |
} |
| 324 |
} |
312 |
} |
| 325 |
$debug and print $debugfh "\n\npatrons: ", Dumper(\%patrons); |
|
|
| 326 |
|
313 |
|
| 327 |
my $i = 1; |
314 |
my $i = 1; |
| 328 |
my @cols_in_order = sort keys %columns; # if you want to order the columns, do something here |
315 |
my @cols_in_order = sort keys %columns; # if you want to order the columns, do something here |
|
Lines 368-373
sub calculate {
Link Here
|
| 368 |
return [\%globalline]; # reference to a 1 element array: that element is a hashref |
355 |
return [\%globalline]; # reference to a 1 element array: that element is a hashref |
| 369 |
} |
356 |
} |
| 370 |
|
357 |
|
| 371 |
$debug and close $debugfh; |
|
|
| 372 |
1; |
358 |
1; |
| 373 |
__END__ |
359 |
__END__ |
| 374 |
- |
|
|