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() )
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
#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 );
}
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);
}
}
-
=head2 ReserveSlip
ReserveSlip($branchcode, $borrowernumber, $biblionumber)
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')
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)
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
class: multi