Lines 36-41
use C4::Members qw();
Link Here
|
36 |
use C4::Letters; |
36 |
use C4::Letters; |
37 |
use C4::Branch qw( GetBranchDetail ); |
37 |
use C4::Branch qw( GetBranchDetail ); |
38 |
use C4::Dates qw( format_date_in_iso ); |
38 |
use C4::Dates qw( format_date_in_iso ); |
|
|
39 |
use C4::Calendar; |
39 |
|
40 |
|
40 |
use Koha::DateUtils; |
41 |
use Koha::DateUtils; |
41 |
|
42 |
|
Lines 887-903
sub CancelExpiredReserves {
Link Here
|
887 |
if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) { |
888 |
if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) { |
888 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
889 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
889 |
my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge"); |
890 |
my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge"); |
|
|
891 |
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); |
892 |
|
893 |
my $today = C4::Dates->new(); |
890 |
|
894 |
|
891 |
my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0"; |
895 |
my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0"; |
892 |
$sth = $dbh->prepare( $query ); |
896 |
$sth = $dbh->prepare( $query ); |
893 |
$sth->execute( $max_pickup_delay ); |
897 |
$sth->execute( $max_pickup_delay ); |
894 |
|
898 |
|
895 |
while (my $res = $sth->fetchrow_hashref ) { |
899 |
while ( my $res = $sth->fetchrow_hashref ) { |
896 |
if ( $charge ) { |
900 |
my $do_cancel = 1; |
897 |
manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
901 |
unless ( $cancel_on_holidays ) { |
|
|
902 |
my $calendar = C4::Calendar->new( branchcode => $res->{'branchcode'} ); |
903 |
my $is_holiday = $calendar->isHoliday( split( '/', $today->output('metric') ) ); |
904 |
|
905 |
if ( $is_holiday ) { |
906 |
$do_cancel = 0; |
907 |
} |
898 |
} |
908 |
} |
899 |
|
909 |
|
900 |
CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} ); |
910 |
if ( $do_cancel ) { |
|
|
911 |
if ( $charge ) { |
912 |
manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
913 |
} |
914 |
|
915 |
CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} ); |
916 |
} |
901 |
} |
917 |
} |
902 |
} |
918 |
} |
903 |
|
919 |
|