|
Lines 351-368
sub longoverdue_sth {
Link Here
|
| 351 |
SELECT items.itemnumber, borrowernumber, date_due, itemlost |
351 |
SELECT items.itemnumber, borrowernumber, date_due, itemlost |
| 352 |
FROM issues, items |
352 |
FROM issues, items |
| 353 |
WHERE items.itemnumber = issues.itemnumber |
353 |
WHERE items.itemnumber = issues.itemnumber |
| 354 |
"; |
354 |
AND TO_DAYS(NOW())-TO_DAYS(issues.date_due) >= 0 |
| 355 |
if ( !C4::Context->preference('OverdueNoticeCalendar') ) { |
|
|
| 356 |
$query .= " |
| 357 |
AND DATE_SUB(CURDATE(), INTERVAL ? DAY) > date_due |
| 358 |
AND DATE_SUB(CURDATE(), INTERVAL ? DAY) <= date_due |
| 359 |
"; |
| 360 |
} else { |
| 361 |
$query .= " |
| 362 |
AND TO_DAYS(NOW())-TO_DAYS(issues.date_due) >= 0 |
| 363 |
"; |
| 364 |
} |
| 365 |
$query .= " |
| 366 |
AND itemlost <> ? |
355 |
AND itemlost <> ? |
| 367 |
$skip_lost_values_sql |
356 |
$skip_lost_values_sql |
| 368 |
ORDER BY date_due |
357 |
ORDER BY date_due |
|
Lines 482-492
foreach my $startrange ( sort keys %$lost ) {
Link Here
|
| 482 |
$verbose |
471 |
$verbose |
| 483 |
and printf "\nRange %s\nDue %3s - %3s days ago (%s to %s), lost => %s\n", ++$i, |
472 |
and printf "\nRange %s\nDue %3s - %3s days ago (%s to %s), lost => %s\n", ++$i, |
| 484 |
$startrange, $endrange, $date2, $date1, $lostvalue; |
473 |
$startrange, $endrange, $date2, $date1, $lostvalue; |
| 485 |
if ( C4::Context->preference('OverdueNoticeCalendar') ) { |
474 |
$sth_items->execute($lostvalue); |
| 486 |
$sth_items->execute($lostvalue); |
|
|
| 487 |
} else { |
| 488 |
$sth_items->execute( $startrange, $endrange, $lostvalue ); |
| 489 |
} |
| 490 |
$count = 0; |
475 |
$count = 0; |
| 491 |
ITEM: while ( my $row = $sth_items->fetchrow_hashref ) { |
476 |
ITEM: while ( my $row = $sth_items->fetchrow_hashref ) { |
| 492 |
my $patron; |
477 |
my $patron; |
|
Lines 513-518
foreach my $startrange ( sort keys %$lost ) {
Link Here
|
| 513 |
} |
498 |
} |
| 514 |
next ITEM unless ( $branches_to_process{$lib} ); |
499 |
next ITEM unless ( $branches_to_process{$lib} ); |
| 515 |
} |
500 |
} |
|
|
501 |
my $date = dt_from_string(); |
| 502 |
my $days_between = $date->delta_days( dt_from_string( $row->{date_due} ) ); |
| 516 |
if ( C4::Context->preference('OverdueNoticeCalendar') ) { |
503 |
if ( C4::Context->preference('OverdueNoticeCalendar') ) { |
| 517 |
my $lib; |
504 |
my $lib; |
| 518 |
if ( $circ_control_pref eq 'PatronLibrary' ) { |
505 |
if ( $circ_control_pref eq 'PatronLibrary' ) { |
|
Lines 520-541
foreach my $startrange ( sort keys %$lost ) {
Link Here
|
| 520 |
$lib = $patron->branchcode(); |
507 |
$lib = $patron->branchcode(); |
| 521 |
} elsif ( $circ_control_pref eq 'PickupLibrary' ) { |
508 |
} elsif ( $circ_control_pref eq 'PickupLibrary' ) { |
| 522 |
$lib = C4::Context->userenv->{'branch'}; |
509 |
$lib = C4::Context->userenv->{'branch'}; |
| 523 |
} else { # ( $circ_control_pref eq 'ItemHomeLibrary' ) |
510 |
} else { |
| 524 |
if ( $circ_control_pref eq 'homebranch' ) { |
511 |
if ( $circ_control_pref eq 'homebranch' ) { |
| 525 |
$lib = Koha::Items->find( $row->{itemnumber} )->homebranch(); |
512 |
$lib = Koha::Items->find( $row->{itemnumber} )->homebranch(); |
| 526 |
} else { # ( $circ_control_pref eq 'holdingbranch' ) |
513 |
} else { |
| 527 |
$lib = Koha::Items->find( $row->{itemnumber} )->holdingbranch(); |
514 |
$lib = Koha::Items->find( $row->{itemnumber} )->holdingbranch(); |
| 528 |
} |
515 |
} |
| 529 |
} |
516 |
} |
| 530 |
my $calendar = Koha::DiscreteCalendar->new({ branchcode => $lib }); |
517 |
if ($lib) { |
| 531 |
my $date_to_run = dt_from_string(); |
518 |
my $calendar = Koha::DiscreteCalendar->new( { branchcode => $lib } ); |
| 532 |
my $days_between = $calendar->days_between( dt_from_string( $row->{date_due} ), $date_to_run ); |
519 |
$days_between = $calendar->days_between( dt_from_string( $row->{date_due} ), $date ); |
| 533 |
$days_between = $days_between->in_units('days'); |
|
|
| 534 |
my $longoverdue_days = C4::Context->preference('DefaultLongOverdueDays'); |
| 535 |
if ( $days_between < $longoverdue_days ) { |
| 536 |
next; |
| 537 |
} |
520 |
} |
| 538 |
} |
521 |
} |
|
|
522 |
$days_between = $days_between->in_units('days'); |
| 523 |
next ITEM if ( $days_between < $startrange ); |
| 539 |
if ($filter_itemtypes) { |
524 |
if ($filter_itemtypes) { |
| 540 |
my $it = uc Koha::Items->find( $row->{itemnumber} )->effective_itemtype(); |
525 |
my $it = uc Koha::Items->find( $row->{itemnumber} )->effective_itemtype(); |
| 541 |
next ITEM unless ( $itemtype_to_process{$it} ); |
526 |
next ITEM unless ( $itemtype_to_process{$it} ); |
| 542 |
- |
|
|