Lines 231-244
if ($noreport) {
Link Here
|
231 |
$bornamefilter =~ s/\*/\%/g; |
231 |
$bornamefilter =~ s/\*/\%/g; |
232 |
$bornamefilter =~ s/\?/\_/g; |
232 |
$bornamefilter =~ s/\?/\_/g; |
233 |
|
233 |
|
234 |
# Escape single quote |
|
|
235 |
$bornamefilter =~s/'/\\'/g; |
236 |
$itemtypefilter =~s/'/\\'/g; |
237 |
$borcatfilter =~s/'/\\'/g; |
238 |
$holdingbranchfilter =~s/'/\\'/g; |
239 |
$homebranchfilter =~s/'/\\'/g; |
240 |
$branchfilter =~s/'/\\'/g; |
241 |
|
242 |
my $strsth = "SELECT date_due, |
234 |
my $strsth = "SELECT date_due, |
243 |
borrowers.title as borrowertitle, |
235 |
borrowers.title as borrowertitle, |
244 |
borrowers.surname, |
236 |
borrowers.surname, |
Lines 284-305
if ($noreport) {
Link Here
|
284 |
WHERE 1=1 "; # placeholder, since it is possible that none of the additional |
276 |
WHERE 1=1 "; # placeholder, since it is possible that none of the additional |
285 |
# conditions will be selected by user |
277 |
# conditions will be selected by user |
286 |
$strsth .= " AND date_due < '" . $todaysdate . "' " unless ( $showall or $datedueto ); |
278 |
$strsth .= " AND date_due < '" . $todaysdate . "' " unless ( $showall or $datedueto ); |
287 |
$strsth .= |
|
|
288 |
" AND (borrowers.firstname like '" |
289 |
. $bornamefilter |
290 |
. "%' or borrowers.surname like '" |
291 |
. $bornamefilter |
292 |
. "%' or borrowers.cardnumber like '" |
293 |
. $bornamefilter . "%')" |
294 |
if ($bornamefilter); |
295 |
$strsth .= " AND borrowers.categorycode = '" . $borcatfilter . "' " if $borcatfilter; |
296 |
|
279 |
|
|
|
280 |
my @bind_values; |
281 |
if ($bornamefilter) { |
282 |
$strsth .= " AND (borrowers.firstname like ? or borrowers.surname like ? or borrowers.cardnumber like ?)"; |
283 |
push @bind_values, "$bornamefilter%", "$bornamefilter%", "$bornamefilter%"; |
284 |
} |
285 |
if ($borcatfilter) { |
286 |
$strsth .= " AND borrowers.categorycode = ? "; |
287 |
push @bind_values, $borcatfilter; |
288 |
} |
297 |
if ($itemtypefilter) { |
289 |
if ($itemtypefilter) { |
298 |
if ( C4::Context->preference('item-level_itypes') ) { |
290 |
if ( C4::Context->preference('item-level_itypes') ) { |
299 |
$strsth .= " AND items.itype = '" . $itemtypefilter . "' "; |
291 |
$strsth .= " AND items.itype = ? "; |
300 |
} else { |
292 |
} else { |
301 |
$strsth .= " AND biblioitems.itemtype = '" . $itemtypefilter . "' "; |
293 |
$strsth .= " AND biblioitems.itemtype = ? "; |
302 |
} |
294 |
} |
|
|
295 |
push @bind_values, $itemtypefilter; |
303 |
} |
296 |
} |
304 |
if ( $borflagsfilter eq 'gonenoaddress' ) { |
297 |
if ( $borflagsfilter eq 'gonenoaddress' ) { |
305 |
$strsth .= " AND borrowers.gonenoaddress <> 0"; |
298 |
$strsth .= " AND borrowers.gonenoaddress <> 0"; |
Lines 308-318
if ($noreport) {
Link Here
|
308 |
} elsif ( $borflagsfilter eq 'lost' ) { |
301 |
} elsif ( $borflagsfilter eq 'lost' ) { |
309 |
$strsth .= " AND borrowers.lost <> 0"; |
302 |
$strsth .= " AND borrowers.lost <> 0"; |
310 |
} |
303 |
} |
311 |
$strsth .= " AND borrowers.branchcode = '" . $branchfilter . "' " if $branchfilter; |
304 |
if ($branchfilter) { |
312 |
$strsth .= " AND items.homebranch = '" . $homebranchfilter . "' " if $homebranchfilter; |
305 |
$strsth .= " AND borrowers.branchcode = ? "; |
313 |
$strsth .= " AND items.holdingbranch = '" . $holdingbranchfilter . "' " if $holdingbranchfilter; |
306 |
push @bind_values, $branchfilter; |
314 |
$strsth .= " AND date_due >= ?" if $dateduefrom; |
307 |
} |
315 |
$strsth .= " AND date_due <= ?" if $datedueto; |
308 |
if ($homebranchfilter) { |
|
|
309 |
$strsth .= " AND items.homebranch = ? "; |
310 |
push @bind_values, $homebranchfilter; |
311 |
} |
312 |
if ($holdingbranchfilter) { |
313 |
$strsth .= " AND items.holdingbranch = ? "; |
314 |
push @bind_values, $holdingbranchfilter; |
315 |
} |
316 |
if ($dateduefrom) { |
317 |
$strsth .= " AND date_due >= ?"; |
318 |
push @bind_values, DateTime::Format::MySQL->format_datetime($dateduefrom); |
319 |
} |
320 |
if ($datedueto) { |
321 |
$strsth .= " AND date_due <= ?"; |
322 |
push @bind_values, DateTime::Format::MySQL->format_datetime($datedueto); |
323 |
} |
316 |
|
324 |
|
317 |
# restrict patrons (borrowers) to those matching the patron attribute filter(s), if any |
325 |
# restrict patrons (borrowers) to those matching the patron attribute filter(s), if any |
318 |
my $bnlist = $have_pattr_filter_data ? join( ',', keys %borrowernumber_to_attributes ) : ''; |
326 |
my $bnlist = $have_pattr_filter_data ? join( ',', keys %borrowernumber_to_attributes ) : ''; |
Lines 322-331
if ($noreport) {
Link Here
|
322 |
$strsth .= " ORDER BY date_due, surname, firstname"; |
330 |
$strsth .= " ORDER BY date_due, surname, firstname"; |
323 |
$template->param( sql => $strsth ); |
331 |
$template->param( sql => $strsth ); |
324 |
my $sth = $dbh->prepare($strsth); |
332 |
my $sth = $dbh->prepare($strsth); |
325 |
$sth->execute( |
333 |
$sth->execute(@bind_values); |
326 |
( $dateduefrom ? DateTime::Format::MySQL->format_datetime($dateduefrom) : () ), |
|
|
327 |
( $datedueto ? DateTime::Format::MySQL->format_datetime($datedueto) : () ), |
328 |
); |
329 |
|
334 |
|
330 |
my @overduedata; |
335 |
my @overduedata; |
331 |
while ( my $data = $sth->fetchrow_hashref ) { |
336 |
while ( my $data = $sth->fetchrow_hashref ) { |
332 |
- |
|
|