From 1860309caa8032f3bfb7d82721abe712ea639dd9 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 | 2 + installer/data/mysql/updatedatabase.pl | 7 +++++ .../en/modules/admin/preferences/circulation.pref | 6 +++++ 4 files changed, 35 insertions(+), 4 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 9032bfa..08800f0 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -388,6 +388,7 @@ INSERT INTO systempreferences (variable,value,explanation,type) VALUES('OPACdidy INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdidyoumean',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free'); INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('BlockReturnOfWithdrawnItems', '1', '0', 'If enabled, items that are marked as withdrawn cannot be returned.', 'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HoldsToPullStartDate','2','Set the default start date for the Holds to pull list to this many days ago',NULL,'Integer'); +<<<<<<< HEAD INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('alphabet','A B C D E F G H I J K L M N O P Q R S T U V W X Y Z','Alphabet than can be expanded into browse links, e.g. on Home > Patrons',NULL,'free'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RefundLostItemFeeOnReturn', '1', 'If enabled, the lost item fee charged to a borrower will be refunded when the lost item is returned.', NULL, 'YesNo'); INSERT INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES @@ -411,3 +412,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReviews','0','Display book review snippets from IDreamBooks.com','','YesNo'); INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo'); INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','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 ed922b8..d403f4e 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6038,6 +6038,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $sth->execute( $new_syspref_value ); print "Upgrade to $DBversion done (Bug 8832, Set the syspref gist with the existing values)\n"; + SetVersion ($DBversion); +} + +$DBversion ="3.09.00.XXX"; +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); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 82c1c02..c41f3c0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -442,6 +442,12 @@ Circulation: no: "Don't allow" - holds to be suspended from the OPAC. - + - pref: ExpireReservesOnHolidays + choices: + yes: Allow + no: "Don't allow" + - expired holds to be canceled on days the library is closed.. + - - pref: decreaseLoanHighHolds choices: yes: Enable -- 1.7.2.5