|
Lines 366-383
sub longoverdue_sth {
Link Here
|
| 366 |
SELECT items.itemnumber, borrowernumber, date_due, itemlost |
366 |
SELECT items.itemnumber, borrowernumber, date_due, itemlost |
| 367 |
FROM issues, items |
367 |
FROM issues, items |
| 368 |
WHERE items.itemnumber = issues.itemnumber |
368 |
WHERE items.itemnumber = issues.itemnumber |
| 369 |
"; |
369 |
AND TO_DAYS(NOW())-TO_DAYS(issues.date_due) >= 0 |
| 370 |
if ( !C4::Context->preference('OverdueNoticeCalendar') ) { |
|
|
| 371 |
$query .= " |
| 372 |
AND DATE_SUB(CURDATE(), INTERVAL ? DAY) > date_due |
| 373 |
AND DATE_SUB(CURDATE(), INTERVAL ? DAY) <= date_due |
| 374 |
"; |
| 375 |
} else { |
| 376 |
$query .= " |
| 377 |
AND TO_DAYS(NOW())-TO_DAYS(issues.date_due) >= 0 |
| 378 |
"; |
| 379 |
} |
| 380 |
$query .= " |
| 381 |
AND itemlost <> ? |
370 |
AND itemlost <> ? |
| 382 |
$skip_lost_values_sql |
371 |
$skip_lost_values_sql |
| 383 |
ORDER BY date_due |
372 |
ORDER BY date_due |
|
Lines 495-505
foreach my $startrange ( sort keys %$lost ) {
Link Here
|
| 495 |
$verbose |
484 |
$verbose |
| 496 |
and printf "\nRange %s\nDue %3s - %3s days ago (%s to %s), lost => %s\n", ++$i, |
485 |
and printf "\nRange %s\nDue %3s - %3s days ago (%s to %s), lost => %s\n", ++$i, |
| 497 |
$startrange, $endrange, $date2, $date1, $lostvalue; |
486 |
$startrange, $endrange, $date2, $date1, $lostvalue; |
| 498 |
if ( C4::Context->preference('OverdueNoticeCalendar') ) { |
487 |
$sth_items->execute($lostvalue); |
| 499 |
$sth_items->execute($lostvalue); |
|
|
| 500 |
} else { |
| 501 |
$sth_items->execute( $startrange, $endrange, $lostvalue ); |
| 502 |
} |
| 503 |
$count = 0; |
488 |
$count = 0; |
| 504 |
ITEM: while ( my $row = $sth_items->fetchrow_hashref ) { |
489 |
ITEM: while ( my $row = $sth_items->fetchrow_hashref ) { |
| 505 |
my $patron; |
490 |
my $patron; |
|
Lines 526-531
foreach my $startrange ( sort keys %$lost ) {
Link Here
|
| 526 |
} |
511 |
} |
| 527 |
next ITEM unless ( $branches_to_process{$lib} ); |
512 |
next ITEM unless ( $branches_to_process{$lib} ); |
| 528 |
} |
513 |
} |
|
|
514 |
my $date = dt_from_string(); |
| 515 |
my $days_between = $date->delta_days( dt_from_string( $row->{date_due} ) ); |
| 529 |
if ( C4::Context->preference('OverdueNoticeCalendar') ) { |
516 |
if ( C4::Context->preference('OverdueNoticeCalendar') ) { |
| 530 |
my $lib; |
517 |
my $lib; |
| 531 |
if ( $circ_control_pref eq 'PatronLibrary' ) { |
518 |
if ( $circ_control_pref eq 'PatronLibrary' ) { |
|
Lines 533-554
foreach my $startrange ( sort keys %$lost ) {
Link Here
|
| 533 |
$lib = $patron->branchcode(); |
520 |
$lib = $patron->branchcode(); |
| 534 |
} elsif ( $circ_control_pref eq 'PickupLibrary' ) { |
521 |
} elsif ( $circ_control_pref eq 'PickupLibrary' ) { |
| 535 |
$lib = C4::Context->userenv->{'branch'}; |
522 |
$lib = C4::Context->userenv->{'branch'}; |
| 536 |
} else { # ( $circ_control_pref eq 'ItemHomeLibrary' ) |
523 |
} else { |
| 537 |
if ( $circ_control_pref eq 'homebranch' ) { |
524 |
if ( $circ_control_pref eq 'homebranch' ) { |
| 538 |
$lib = Koha::Items->find( $row->{itemnumber} )->homebranch(); |
525 |
$lib = Koha::Items->find( $row->{itemnumber} )->homebranch(); |
| 539 |
} else { # ( $circ_control_pref eq 'holdingbranch' ) |
526 |
} else { |
| 540 |
$lib = Koha::Items->find( $row->{itemnumber} )->holdingbranch(); |
527 |
$lib = Koha::Items->find( $row->{itemnumber} )->holdingbranch(); |
| 541 |
} |
528 |
} |
| 542 |
} |
529 |
} |
| 543 |
my $calendar = Koha::DiscreteCalendar->new({ branchcode => $lib }); |
530 |
if ($lib) { |
| 544 |
my $date_to_run = dt_from_string(); |
531 |
my $calendar = Koha::DiscreteCalendar->new( { branchcode => $lib } ); |
| 545 |
my $days_between = $calendar->days_between( dt_from_string( $row->{date_due} ), $date_to_run ); |
532 |
$days_between = $calendar->days_between( dt_from_string( $row->{date_due} ), $date ); |
| 546 |
$days_between = $days_between->in_units('days'); |
|
|
| 547 |
my $longoverdue_days = C4::Context->preference('DefaultLongOverdueDays'); |
| 548 |
if ( $days_between < $longoverdue_days ) { |
| 549 |
next; |
| 550 |
} |
533 |
} |
| 551 |
} |
534 |
} |
|
|
535 |
$days_between = $days_between->in_units('days'); |
| 536 |
next ITEM if ( $days_between < $startrange ); |
| 552 |
if ($filter_itemtypes) { |
537 |
if ($filter_itemtypes) { |
| 553 |
my $it = uc Koha::Items->find( $row->{itemnumber} )->effective_itemtype(); |
538 |
my $it = uc Koha::Items->find( $row->{itemnumber} )->effective_itemtype(); |
| 554 |
next ITEM unless ( $itemtype_to_process{$it} ); |
539 |
next ITEM unless ( $itemtype_to_process{$it} ); |
| 555 |
- |
|
|