From cb93587496a80b148178bedd45deb59fd80c9fda Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Tue, 23 Apr 2013 12:32:03 -0400
Subject: [PATCH] Bug 8735 - Expire holds waiting only on days the library is open - Followup - Switch from C4::Calendar to Koha::Calendar
Test Plan:
1) Set ExpireReservesMaxPickUpDelay
2) Set ReservesMaxPickUpDelay to 1
3) Place a hold, set it to waiting
4) Using the MySQL console, modify the waiting date and set it to the
day before yesterday.
5) Set today as a holiday for the pickup branch in question.
6) Run misc/cronjobs/holds/cancel_expired_holds.pl
7) The hold should remain unchanged
8) Remove today as a holiday
9) Run misc/cronjobs/holds/cancel_expired_holds.pl again
10) The hold should now be canceled
---
C4/Reserves.pm | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/C4/Reserves.pm b/C4/Reserves.pm
index 39df9fd..124062c 100644
--- a/C4/Reserves.pm
+++ b/C4/Reserves.pm
@@ -36,9 +36,9 @@ 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;
+use Koha::Calendar;
use List::MoreUtils qw( firstidx );
@@ -982,7 +982,7 @@ sub CancelExpiredReserves {
my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
- my $today = C4::Dates->new();
+ my $today = dt_from_string();
my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0";
$sth = $dbh->prepare( $query );
@@ -991,8 +991,8 @@ sub CancelExpiredReserves {
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') ) );
+ my $calendar = Koha::Calendar->new( branchcode => $res->{'branchcode'} );
+ my $is_holiday = $calendar->is_holiday( $today );
if ( $is_holiday ) {
$do_cancel = 0;
--
1.7.2.5