Bug 8735 - Expire holds waiting only on days the library is open
Signed-off-by: Leila <koha.aixmarseille@gmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
e69d6dabc4
commit
3b092a899f
|
|
@ -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;
|
||||
|
||||
|
|
@ -979,17 +980,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({ reserve_id => $res->{'reserve_id'} });
|
||||
if ( $do_cancel ) {
|
||||
if ( $charge ) {
|
||||
manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge);
|
||||
}
|
||||
|
||||
CancelReserve({ reserve_id => $res->{'reserve_id'} });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
|
|||
('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'),
|
||||
('ExpireReservesMaxPickUpDelay','0','','Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay','YesNo'),
|
||||
('ExpireReservesMaxPickUpDelayCharge','0',NULL,'If ExpireReservesMaxPickUpDelay is enabled, and this field has a non-zero value, than a borrower whose waiting hold has expired will be charged this amount.','free'),
|
||||
('ExpireReservesOnHolidays', '1', NULL, 'If false, reserves at a library will not be canceled on days the library is not open.', 'YesNo'),
|
||||
('ExtendedPatronAttributes','0',NULL,'Use extended patron IDs and attributes','YesNo'),
|
||||
('FacetLabelTruncationLength','20',NULL,'Specify the facet max length in OPAC','Integer'),
|
||||
('FilterBeforeOverdueReport','0','','Do not run overdue report until filter selected','YesNo'),
|
||||
|
|
|
|||
|
|
@ -8712,6 +8712,13 @@ if ( CheckVersion($DBversion) ) {
|
|||
SetVersion($DBversion);
|
||||
}
|
||||
|
||||
$DBversion = "3.17.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);
|
||||
}
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=head2 TableExists($table)
|
||||
|
|
|
|||
|
|
@ -503,6 +503,12 @@ Circulation:
|
|||
yes: Allow
|
||||
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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue