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

(-)a/reports/borrowers_out.pl (-14 / +6 lines)
Lines 229-247 sub calculate { Link Here
229
    $strcalc .= "WHERE 1 ";
229
    $strcalc .= "WHERE 1 ";
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
    $strcalc .= " AND NOT EXISTS (SELECT * FROM issues WHERE issues.borrowernumber=borrowers.borrowernumber ";
233
    my $strqueryfilter = "SELECT DISTINCT borrowernumber FROM  ";
233
    $strcalc .= " AND issues.timestamp> '" . @$filters[1] . "'" if (@$filters[1]);
234
    $strqueryfilter .= "(SELECT borrowernumber from old_issues WHERE borrowernumber IS NOT NULL ";
234
    $strcalc .= ") ";
235
    if ($filters->[1]){
235
    $strcalc .= " AND NOT EXISTS (SELECT * FROM old_issues WHERE old_issues.borrowernumber=borrowers.borrowernumber ";
236
        $strqueryfilter .= "AND old_issues.timestamp> '$filters->[1]' ";
236
    $strcalc .= " AND old_issues.timestamp> '" . @$filters[1] . "'" if (@$filters[1]);
237
    }
237
    $strcalc .= ") ";
238
    $strqueryfilter .= "UNION SELECT borrowernumber FROM issues WHERE 1 ";
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";
238
    $strcalc .= " group by borrowers.borrowernumber";
246
    $strcalc .= ", $colfield" if ($column);
239
    $strcalc .= ", $colfield" if ($column);
247
    $strcalc .= " order by $colfield " if ($colfield);
240
    $strcalc .= " order by $colfield " if ($colfield);
248
- 

Return to bug 6123