View | Details | Raw Unified | Return to bug 6078
Collapse All | Expand All

(-)a/reports/borrowers_out.pl (-13 / +6 lines)
Lines 230-247 sub calculate { Link Here
230
    @$filters[0]=~ s/\*/%/g if (@$filters[0]);
230
    @$filters[0]=~ s/\*/%/g if (@$filters[0]);
231
    $strcalc .= " AND borrowers.categorycode like '" . @$filters[0] ."'" if ( @$filters[0] );
231
    $strcalc .= " AND borrowers.categorycode like '" . @$filters[0] ."'" if ( @$filters[0] );
232
232
233
    my $strqueryfilter = "SELECT DISTINCT borrowernumber FROM  ";
233
    $strcalc .= " AND NOT EXISTS (SELECT * FROM issues WHERE issues.borrowernumber=borrowers.borrowernumber ";
234
    $strqueryfilter .= "(SELECT borrowernumber from old_issues WHERE borrowernumber IS NOT NULL ";
234
    $strcalc .= " AND issues.timestamp> '" . @$filters[1] . "'" if (@$filters[1]);
235
    if ($filters->[1]){
235
    $strcalc .= ") ";
236
        $strqueryfilter .= "AND old_issues.timestamp> '$filters->[1]' ";
236
    $strcalc .= " AND NOT EXISTS (SELECT * FROM old_issues WHERE old_issues.borrowernumber=borrowers.borrowernumber ";
237
    }
237
    $strcalc .= " AND old_issues.timestamp> '" . @$filters[1] . "'" if (@$filters[1]);
238
    $strqueryfilter .= "UNION SELECT borrowernumber FROM issues WHERE 1 ";
238
    $strcalc .= ") ";
239
    if ($filters->[1]){
240
        $strqueryfilter .= "AND issues.timestamp> '$filters->[1]' ";
241
    }
242
    $strqueryfilter .= ") active_borrowers";
243
244
    $strcalc .= " AND borrowers.borrowernumber not in ($strqueryfilter)";
245
    $strcalc .= " group by borrowers.borrowernumber";
239
    $strcalc .= " group by borrowers.borrowernumber";
246
    $strcalc .= ", $colfield" if ($column);
240
    $strcalc .= ", $colfield" if ($column);
247
    $strcalc .= " order by $colfield " if ($colfield);
241
    $strcalc .= " order by $colfield " if ($colfield);
248
- 

Return to bug 6078