Bug 7408 - Expire holds that have been waiting too long
If the new syspref ExpireReservesMaxPickUpDelay is enabled, this will cancel holds that have been waiting for longer than the number of days specified in the syspref ReservesMaxPickupDelay. If ExpireReservesMaxPickUpDelayCharge is set, the borrower charged the fee set therein. Signed-off-by: Ian Walls <koha.sekjal@gmail.com> Altered circulation.pref to include currency class and [% local_currency %] param
This commit is contained in:
parent
6846bdb519
commit
0717f8300a
|
|
@ -861,6 +861,7 @@ Cancels all reserves with an expiration date from before today.
|
|||
|
||||
sub CancelExpiredReserves {
|
||||
|
||||
# Cancel reserves that have passed their expiration date.
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth = $dbh->prepare( "
|
||||
SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() )
|
||||
|
|
@ -872,6 +873,24 @@ sub CancelExpiredReserves {
|
|||
CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
|
||||
}
|
||||
|
||||
# Cancel reserves that have been waiting too long
|
||||
if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
|
||||
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
|
||||
my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
=head2 CancelReserve
|
||||
|
|
@ -1138,13 +1157,9 @@ sub ModReserveStatus {
|
|||
|
||||
#first : check if we have a reservation for this item .
|
||||
my ($itemnumber, $newstatus) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = " UPDATE reserves
|
||||
SET found=?,waitingdate = now()
|
||||
WHERE itemnumber=?
|
||||
AND found IS NULL
|
||||
AND priority = 0
|
||||
";
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
my $query = "UPDATE reserves SET found = ?, waitingdate = NOW() WHERE itemnumber = ? AND found IS NULL AND priority = 0";
|
||||
my $sth_set = $dbh->prepare($query);
|
||||
$sth_set->execute( $newstatus, $itemnumber );
|
||||
|
||||
|
|
@ -1197,15 +1212,15 @@ sub ModReserveAffect {
|
|||
}
|
||||
else {
|
||||
# affect the reserve to Waiting as well.
|
||||
$query = "
|
||||
UPDATE reserves
|
||||
SET priority = 0,
|
||||
found = 'W',
|
||||
waitingdate=now(),
|
||||
itemnumber = ?
|
||||
WHERE borrowernumber = ?
|
||||
AND biblionumber = ?
|
||||
";
|
||||
$query = "
|
||||
UPDATE reserves
|
||||
SET priority = 0,
|
||||
found = 'W',
|
||||
waitingdate = NOW(),
|
||||
itemnumber = ?
|
||||
WHERE borrowernumber = ?
|
||||
AND biblionumber = ?
|
||||
";
|
||||
}
|
||||
$sth = $dbh->prepare($query);
|
||||
$sth->execute( $itemnumber, $borrowernumber,$biblionumber);
|
||||
|
|
@ -1908,7 +1923,6 @@ sub MergeHolds {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
=head2 ReserveSlip
|
||||
|
||||
ReserveSlip($branchcode, $borrowernumber, $biblionumber)
|
||||
|
|
|
|||
|
|
@ -346,3 +346,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('
|
|||
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerRelink',1,'If ON the authority linker will relink headings that have previously been linked every time it runs.',NULL,'YesNo');
|
||||
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerKeepStale',0,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.',NULL,'YesNo');
|
||||
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogModuleRelink',0,'If OFF the linker will never replace the authids that are set in the cataloging module.',NULL,'YesNo');
|
||||
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelay', '0', '', 'Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay', 'YesNo');
|
||||
INSERT INTO systempreferences` (variable,value,options,explanation,type) VALUES ('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')
|
||||
|
|
|
|||
|
|
@ -4884,6 +4884,14 @@ Date due: <<issues.date_due>><br />
|
|||
SetVersion($DBversion);
|
||||
}
|
||||
|
||||
$DBversion = "3.07.00.024";
|
||||
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
|
||||
$dbh->do("INSERT INTO systempreferences` (variable,value,options,explanation,type) VALUES ('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')");
|
||||
$dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelay', '0', '', 'Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay', 'YesNo')");
|
||||
print "Upgrade to $DBversion done (Added system preference ExpireReservesMaxPickUpDelay, system preference ExpireReservesMaxPickUpDelayCharge, add reseves.charge_if_expired)\n";
|
||||
SetVersion($DBversion);
|
||||
}
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=head2 DropAllForeignKeys($table)
|
||||
|
|
|
|||
|
|
@ -283,6 +283,17 @@ Circulation:
|
|||
- pref: ReservesMaxPickUpDelay
|
||||
class: integer
|
||||
- days.
|
||||
-
|
||||
- pref: ExpireReservesMaxPickUpDelay
|
||||
choices:
|
||||
yes: Allow
|
||||
no: "Don't allow"
|
||||
- "holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay"
|
||||
-
|
||||
- If using ExpireReservesMaxPickUpDelay, charge a borrower who allows his or her waiting hold to expire a fee of
|
||||
- pref: ExpireReservesMaxPickUpDelayCharge
|
||||
class: currency
|
||||
- [% local_currency %].
|
||||
-
|
||||
- Satisfy holds from the libraries
|
||||
- pref: StaticHoldsQueueWeight
|
||||
|
|
|
|||
Loading…
Reference in New Issue