Lines 218-233
sub calculate {
Link Here
|
218 |
# preparing calculation |
218 |
# preparing calculation |
219 |
my $strcalc = "(SELECT $linesql line, $colsql col, "; |
219 |
my $strcalc = "(SELECT $linesql line, $colsql col, "; |
220 |
$strcalc .= ($process == 1) ? " COUNT(*) calculation" : |
220 |
$strcalc .= ($process == 1) ? " COUNT(*) calculation" : |
221 |
($process == 2) ? "(COUNT(DISTINCT reserves.borrowernumber)) calculation" : |
221 |
($process == 2) ? "(COUNT(DISTINCT all_reserves.borrowernumber)) calculation" : |
222 |
($process == 3) ? "(COUNT(DISTINCT reserves.itemnumber)) calculation" : |
222 |
($process == 3) ? "(COUNT(DISTINCT all_reserves.itemnumber)) calculation" : |
223 |
($process == 4) ? "(COUNT(DISTINCT reserves.biblionumber)) calculation" : '*'; |
223 |
($process == 4) ? "(COUNT(DISTINCT all_reserves.biblionumber)) calculation" : '*'; |
224 |
$strcalc .= " |
224 |
$strcalc .= " |
225 |
FROM reserves |
225 |
FROM (select * from reserves union select * from old_reserves) all_reserves |
226 |
LEFT JOIN borrowers USING (borrowernumber) |
226 |
LEFT JOIN borrowers USING (borrowernumber) |
227 |
"; |
227 |
"; |
228 |
$strcalc .= "LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber " |
228 |
$strcalc .= "LEFT JOIN biblio ON all_reserves.biblionumber=biblio.biblionumber " |
229 |
if ($linefield =~ /^biblio\./ or $colfield =~ /^biblio\./ or any {$_=~/biblio/}keys %$filters_hashref); |
229 |
if ($linefield =~ /^biblio\./ or $colfield =~ /^biblio\./ or any {$_=~/biblio/}keys %$filters_hashref); |
230 |
$strcalc .= "LEFT JOIN items ON reserves.itemnumber=items.itemnumber " |
230 |
$strcalc .= "LEFT JOIN items ON all_reserves.itemnumber=items.itemnumber " |
231 |
if ($linefield =~ /^items\./ or $colfield =~ /^items\./ or any {$_=~/items/}keys %$filters_hashref); |
231 |
if ($linefield =~ /^items\./ or $colfield =~ /^items\./ or any {$_=~/items/}keys %$filters_hashref); |
232 |
|
232 |
|
233 |
my @sqlparams; |
233 |
my @sqlparams; |
Lines 267-275
sub calculate {
Link Here
|
267 |
$strcalc .= " WHERE ".join(" AND ",@sqlwhere) if (@sqlwhere); |
267 |
$strcalc .= " WHERE ".join(" AND ",@sqlwhere) if (@sqlwhere); |
268 |
$strcalc .= " AND (".join(" OR ",@sqlor).")" if (@sqlor); |
268 |
$strcalc .= " AND (".join(" OR ",@sqlor).")" if (@sqlor); |
269 |
$strcalc .= " GROUP BY line, col )"; |
269 |
$strcalc .= " GROUP BY line, col )"; |
270 |
my $strcalc_old=$strcalc; |
|
|
271 |
$strcalc_old=~s/reserves/old_reserves/g; |
272 |
$strcalc.=qq{ UNION $strcalc_old ORDER BY line, col}; |
273 |
($debug) and print STDERR $strcalc; |
270 |
($debug) and print STDERR $strcalc; |
274 |
my $dbcalc = $dbh->prepare($strcalc); |
271 |
my $dbcalc = $dbh->prepare($strcalc); |
275 |
push @loopfilter, {crit=>'SQL =', sql=>1, filter=>$strcalc}; |
272 |
push @loopfilter, {crit=>'SQL =', sql=>1, filter=>$strcalc}; |
276 |
- |
|
|