From b9d86ba9e80e28bca93f0c216e7ab5c7cfb78e93 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 Content-Type: text/plain; charset="utf-8" --- C4/Reserves.pm | 23 +++++++++++++++++++---- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 585d1e5..aafac88 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -887,17 +887,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 35f92cc..13b2cac 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -371,3 +371,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo'); +INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesOnHolidays', '1', NULL, 'If false, reserves at a library will not be canceled on days the library is not open.', 'YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 25cd367..9cec7f3 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5696,6 +5696,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion($DBversion); } +$DBversion ="3.09.00.034"; +if(C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesOnHolidays', '1', NULL, 'If false, reserves at a library will not be canceled on days the library is not open.', 'YesNo')"); + print "Upgrade to $DBversion done (Add syspref ExpireReservesOnHolidays\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) -- 1.7.2.5