From f1b5279e0dec7474df7ccc7b04dcc7e4cb497572 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 6 Sep 2012 11:15:21 -0400 Subject: [PATCH] Bug 8735 - Expire holds waiting only on days the library is open --- C4/Reserves.pm | 24 ++++++++++++++++--- installer/data/mysql/sysprefs.sql | 4 +++ installer/data/mysql/updatedatabase.pl | 9 ++++++- .../en/modules/admin/preferences/circulation.pref | 6 +++++ 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index a380bf0..3d26cd9 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -36,6 +36,7 @@ use C4::Members qw(); use C4::Letters; use C4::Branch qw( GetBranchDetail ); use C4::Dates qw( format_date_in_iso ); +use C4::Calendar; use Koha::DateUtils; @@ -887,17 +888,32 @@ sub CancelExpiredReserves { if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) { my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge"); + my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); + + my $today = C4::Dates->new(); my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0"; $sth = $dbh->prepare( $query ); $sth->execute( $max_pickup_delay ); - while (my $res = $sth->fetchrow_hashref ) { - if ( $charge ) { - manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); + while ( my $res = $sth->fetchrow_hashref ) { + my $do_cancel = 1; + unless ( $cancel_on_holidays ) { + my $calendar = C4::Calendar->new( branchcode => $res->{'branchcode'} ); + my $is_holiday = $calendar->isHoliday( split( '/', $today->output('metric') ) ); + + if ( $is_holiday ) { + $do_cancel = 0; + } } - CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} ); + if ( $do_cancel ) { + if ( $charge ) { + manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); + } + + CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} ); + } } } diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index d5d15d7..a3d7be5 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -406,3 +406,7 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('NotesBlacklist','','List of notes fields that should not appear in the title notes/description separator of details',NULL,'free'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('SCOUserCSS', '', NULL, 'Add CSS to be included in the SCO module in an embedded