Lines 313-335
sub calculate {
Link Here
|
313 |
if($line_attribute_type) { |
313 |
if($line_attribute_type) { |
314 |
$strsth = "SELECT attribute FROM borrower_attributes WHERE code = '$line_attribute_type' "; |
314 |
$strsth = "SELECT attribute FROM borrower_attributes WHERE code = '$line_attribute_type' "; |
315 |
} else { |
315 |
} else { |
316 |
$strsth = "SELECT distinctrow $linefield FROM statistics, "; |
316 |
$strsth = "SELECT distinctrow $linefield FROM statistics "; |
317 |
|
317 |
|
318 |
# get stats on items if ccode or location, otherwise borrowers. |
318 |
# get stats on items if ccode or location, otherwise borrowers. |
319 |
$strsth .= |
319 |
$strsth .= |
320 |
( $linesource eq 'items' ) |
320 |
( $linesource eq 'items' ) |
321 |
? " items WHERE (statistics.itemnumber=items.itemnumber) " |
321 |
? " LEFT JOIN items ON (statistics.itemnumber = items.itemnumber) " |
322 |
: " borrowers WHERE (statistics.borrowernumber=borrowers.borrowernumber) "; |
322 |
: " LEFT JOIN borrowers ON (statistics.borrowernumber = borrowers.borrowernumber) "; |
323 |
} |
323 |
} |
324 |
$strsth .= " AND $line is not null "; |
324 |
$strsth .= " WHERE $line is not null "; |
325 |
|
325 |
|
326 |
if ( $line =~ /datetime/ ) { |
326 |
if ( $line =~ /datetime/ ) { |
327 |
if ( $linefilter[1] and ( $linefilter[0] ) ) { |
327 |
if ( $linefilter[1] and ( $linefilter[0] ) ) { |
328 |
$strsth .= " AND $line between ? AND ? "; |
328 |
$strsth .= " AND $line between ? AND ? "; |
329 |
} elsif ( $linefilter[1] ) { |
329 |
} elsif ( $linefilter[1] ) { |
330 |
$strsth .= " AND $line < ? "; |
330 |
$strsth .= " AND $line <= ? "; |
331 |
} elsif ( $linefilter[0] ) { |
331 |
} elsif ( $linefilter[0] ) { |
332 |
$strsth .= " AND $line > ? "; |
332 |
$strsth .= " AND $line >= ? "; |
333 |
} |
333 |
} |
334 |
$strsth .= " AND type ='" . $type . "' " if $type; |
334 |
$strsth .= " AND type ='" . $type . "' " if $type; |
335 |
$strsth .= " AND dayname(datetime) ='" . $daysel . "' " if $daysel; |
335 |
$strsth .= " AND dayname(datetime) ='" . $daysel . "' " if $daysel; |
Lines 342-349
sub calculate {
Link Here
|
342 |
$debug and warn $strsth; |
342 |
$debug and warn $strsth; |
343 |
push @loopfilter, { crit => 'SQL =', sql => 1, filter => $strsth }; |
343 |
push @loopfilter, { crit => 'SQL =', sql => 1, filter => $strsth }; |
344 |
my $sth = $dbh->prepare($strsth); |
344 |
my $sth = $dbh->prepare($strsth); |
345 |
if ( (@linefilter) and ( $linefilter[1] ) ) { |
345 |
if ( (@linefilter) and ($linefilter[0]) and ($linefilter[1]) ) { |
346 |
$sth->execute( $linefilter[0], $linefilter[1] ); |
346 |
$sth->execute( $linefilter[0], $linefilter[1] . " 23:59:59" ); |
|
|
347 |
} elsif ( $linefilter[1] ) { |
348 |
$sth->execute( $linefilter[1] . " 23:59:59" ); |
347 |
} elsif ( $linefilter[0] ) { |
349 |
} elsif ( $linefilter[0] ) { |
348 |
$sth->execute( $linefilter[0] ); |
350 |
$sth->execute( $linefilter[0] ); |
349 |
} else { |
351 |
} else { |
Lines 399-421
sub calculate {
Link Here
|
399 |
if($column_attribute_type) { |
401 |
if($column_attribute_type) { |
400 |
$strsth2 = "SELECT attribute FROM borrower_attributes WHERE code = '$column_attribute_type' "; |
402 |
$strsth2 = "SELECT attribute FROM borrower_attributes WHERE code = '$column_attribute_type' "; |
401 |
} else { |
403 |
} else { |
402 |
$strsth2 = "SELECT distinctrow $colfield FROM statistics, "; |
404 |
$strsth2 = "SELECT distinctrow $colfield FROM statistics "; |
403 |
|
405 |
|
404 |
# get stats on items if ccode or location, otherwise borrowers. |
406 |
# get stats on items if ccode or location, otherwise borrowers. |
405 |
$strsth2 .= |
407 |
$strsth2 .= |
406 |
( $colsource eq 'items' ) |
408 |
( $colsource eq 'items' ) |
407 |
? "items WHERE (statistics.itemnumber=items.itemnumber) " |
409 |
? "LEFT JOIN items ON (statistics.itemnumber = items.itemnumber) " |
408 |
: "borrowers WHERE (statistics.borrowernumber=borrowers.borrowernumber) "; |
410 |
: "LEFT JOIN borrowers ON (statistics.borrowernumber = borrowers.borrowernumber) "; |
409 |
} |
411 |
} |
410 |
$strsth2 .= " AND $column IS NOT NULL "; |
412 |
$strsth2 .= " WHERE $column IS NOT NULL "; |
411 |
|
413 |
|
412 |
if ( $column =~ /datetime/ ) { |
414 |
if ( $column =~ /datetime/ ) { |
413 |
if ( ( $colfilter[1] ) and ( $colfilter[0] ) ) { |
415 |
if ( ( $colfilter[1] ) and ( $colfilter[0] ) ) { |
414 |
$strsth2 .= " AND $column BETWEEN ? AND ? "; |
416 |
$strsth2 .= " AND $column BETWEEN ? AND ? "; |
415 |
} elsif ( $colfilter[1] ) { |
417 |
} elsif ( $colfilter[1] ) { |
416 |
$strsth2 .= " AND $column < ? "; |
418 |
$strsth2 .= " AND $column <= ? "; |
417 |
} elsif ( $colfilter[0] ) { |
419 |
} elsif ( $colfilter[0] ) { |
418 |
$strsth2 .= " AND $column > ? "; |
420 |
$strsth2 .= " AND $column >= ? "; |
419 |
} |
421 |
} |
420 |
$strsth2 .= " AND type ='". $type ."' " if $type; |
422 |
$strsth2 .= " AND type ='". $type ."' " if $type; |
421 |
$strsth2 .= " AND dayname(datetime) ='". $daysel ."' " if $daysel; |
423 |
$strsth2 .= " AND dayname(datetime) ='". $daysel ."' " if $daysel; |
Lines 429-436
sub calculate {
Link Here
|
429 |
$debug and warn $strsth2; |
431 |
$debug and warn $strsth2; |
430 |
push @loopfilter, { crit => 'SQL =', sql => 1, filter => $strsth2 }; |
432 |
push @loopfilter, { crit => 'SQL =', sql => 1, filter => $strsth2 }; |
431 |
my $sth2 = $dbh->prepare($strsth2); |
433 |
my $sth2 = $dbh->prepare($strsth2); |
432 |
if ( (@colfilter) and ( $colfilter[1] ) ) { |
434 |
if ( (@colfilter) and ($colfilter[0]) and ($colfilter[1]) ) { |
433 |
$sth2->execute( $colfilter[0], $colfilter[1] ); |
435 |
$sth2->execute( $colfilter[0], $colfilter[1] . " 23:59:59" ); |
|
|
436 |
} elsif ( $colfilter[1] ) { |
437 |
$sth2->execute( $colfilter[1] . " 23:59:59" ); |
434 |
} elsif ( $colfilter[0] ) { |
438 |
} elsif ( $colfilter[0] ) { |
435 |
$sth2->execute( $colfilter[0] ); |
439 |
$sth2->execute( $colfilter[0] ); |
436 |
} else { |
440 |
} else { |
Lines 594-605
sub calculate {
Link Here
|
594 |
my $value = table_get(\%table, $row->{rowtitle}, $col->{coltitle}); |
598 |
my $value = table_get(\%table, $row->{rowtitle}, $col->{coltitle}); |
595 |
push @loopcell, { value => $value }; |
599 |
push @loopcell, { value => $value }; |
596 |
} |
600 |
} |
597 |
my $rowtitle = ( $row->{rowtitle} eq "NULL" ) ? "zzEMPTY" : $row->{rowtitle}; |
|
|
598 |
push @looprow, |
601 |
push @looprow, |
599 |
{ 'rowtitle_display' => $row->{rowtitle_display}, |
602 |
{ 'rowtitle_display' => $row->{rowtitle_display}, |
600 |
'rowtitle' => $rowtitle, |
603 |
'rowtitle' => $row->{rowtitle}, |
601 |
'loopcell' => \@loopcell, |
604 |
'loopcell' => \@loopcell, |
602 |
'totalrow' => table_get(\%table, $rowtitle, 'totalrow'), |
605 |
'totalrow' => table_get(\%table, $row->{rowtitle}, 'totalrow'), |
603 |
}; |
606 |
}; |
604 |
} |
607 |
} |
605 |
for my $col (@loopcol) { |
608 |
for my $col (@loopcol) { |
Lines 626-636
sub calculate {
Link Here
|
626 |
return [ ( \%globalline ) ]; |
629 |
return [ ( \%globalline ) ]; |
627 |
} |
630 |
} |
628 |
|
631 |
|
629 |
sub null_to_zzempty ($) { |
632 |
sub null_to_zzempty { |
630 |
my $string = shift; |
633 |
my $string = shift; |
631 |
defined($string) or return 'zzEMPTY'; |
634 |
|
632 |
($string eq "NULL") and return 'zzEMPTY'; |
635 |
if (!defined($string) or $string eq '' or uc($string) eq 'NULL') { |
633 |
return $string; # else return the valid value |
636 |
return 'zzEMPTY'; |
|
|
637 |
} |
638 |
|
639 |
return $string; |
634 |
} |
640 |
} |
635 |
|
641 |
|
636 |
sub table_set { |
642 |
sub table_set { |
637 |
- |
|
|