Lines 36-42
BEGIN {
Link Here
|
36 |
|
36 |
|
37 |
use Getopt::Long; |
37 |
use Getopt::Long; |
38 |
use Pod::Usage; |
38 |
use Pod::Usage; |
39 |
use List::Util qw/ any /; |
|
|
40 |
|
39 |
|
41 |
use C4::Circulation qw/LostItem MarkIssueReturned/; |
40 |
use C4::Circulation qw/LostItem MarkIssueReturned/; |
42 |
use C4::Context; |
41 |
use C4::Context; |
Lines 298-303
sub bounds {
Link Here
|
298 |
|
297 |
|
299 |
# FIXME - This sql should be inside the API. |
298 |
# FIXME - This sql should be inside the API. |
300 |
sub longoverdue_sth { |
299 |
sub longoverdue_sth { |
|
|
300 |
my ( $params ) = @_; |
301 |
my $skip_lost_values = $params->{skip_lost_values}; |
302 |
|
303 |
my $skip_lost_values_sql = q{}; |
304 |
if ( @$skip_lost_values ) { |
305 |
my $values = join( ',', map { qq{'$_'} } @$skip_lost_values ); |
306 |
$skip_lost_values_sql = "AND itemlost NOT IN ( $values )" |
307 |
} |
308 |
|
301 |
my $query = " |
309 |
my $query = " |
302 |
SELECT items.itemnumber, borrowernumber, date_due, itemlost |
310 |
SELECT items.itemnumber, borrowernumber, date_due, itemlost |
303 |
FROM issues, items |
311 |
FROM issues, items |
Lines 305-310
sub longoverdue_sth {
Link Here
|
305 |
AND DATE_SUB(CURDATE(), INTERVAL ? DAY) > date_due |
313 |
AND DATE_SUB(CURDATE(), INTERVAL ? DAY) > date_due |
306 |
AND DATE_SUB(CURDATE(), INTERVAL ? DAY) <= date_due |
314 |
AND DATE_SUB(CURDATE(), INTERVAL ? DAY) <= date_due |
307 |
AND itemlost <> ? |
315 |
AND itemlost <> ? |
|
|
316 |
$skip_lost_values_sql |
308 |
ORDER BY date_due |
317 |
ORDER BY date_due |
309 |
"; |
318 |
"; |
310 |
return C4::Context->dbh->prepare($query); |
319 |
return C4::Context->dbh->prepare($query); |
Lines 376-382
my $i = 0;
Link Here
|
376 |
# FIXME - The item is only marked returned if you supply --charge . |
385 |
# FIXME - The item is only marked returned if you supply --charge . |
377 |
# We need a better way to handle this. |
386 |
# We need a better way to handle this. |
378 |
# |
387 |
# |
379 |
my $sth_items = longoverdue_sth(); |
388 |
my $sth_items = longoverdue_sth({ skip_lost_values => \@skip_lost_values }); |
380 |
|
389 |
|
381 |
foreach my $startrange (sort keys %$lost) { |
390 |
foreach my $startrange (sort keys %$lost) { |
382 |
if( my $lostvalue = $lost->{$startrange} ) { |
391 |
if( my $lostvalue = $lost->{$startrange} ) { |
Lines 389-398
foreach my $startrange (sort keys %$lost) {
Link Here
|
389 |
$sth_items->execute($startrange, $endrange, $lostvalue); |
398 |
$sth_items->execute($startrange, $endrange, $lostvalue); |
390 |
$count=0; |
399 |
$count=0; |
391 |
ITEM: while (my $row=$sth_items->fetchrow_hashref) { |
400 |
ITEM: while (my $row=$sth_items->fetchrow_hashref) { |
392 |
if ( @skip_lost_values ) { |
|
|
393 |
next ITEM if any { $_ eq $row->{itemlost} } @skip_lost_values; |
394 |
} |
395 |
|
396 |
if( $filter_borrower_categories ) { |
401 |
if( $filter_borrower_categories ) { |
397 |
my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode(); |
402 |
my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode(); |
398 |
next ITEM unless ( $category_to_process{ $category } ); |
403 |
next ITEM unless ( $category_to_process{ $category } ); |
399 |
- |
|
|