Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to hold-expiration process
This patch adds a expirationdate column to reserves and old_reserves, to set more-firm rather than calculated-on-the-fly expirations, and creates a cronjob to move expired holds out of the queue, and to the old_reserves table. The expiration date is manually enterable in several places, and displays are updated to show the date. Several places that were using on-the-fly calculations of the date were revised to use the table value, and the calculation of table values was set to take advantage of the library calendar, so that holds will not expire on a closed day. Be sure to execute the following SQL for an upgrade to this patch: ALTER TABLE reserves ADD expirationdate date; ALTER TABLE old_reserves ADD expirationdate date;
- Loading branch information
Showing
9 changed files
with
181 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/perl | ||
# run nightly -- remove holds that are later than waitingdate + | ||
# ReservesMaxPickUpDelay from the reserves table. | ||
# | ||
# This file is part of Koha. | ||
# | ||
# Koha is free software; you can redistribute it and/or modify it under the | ||
# terms of the GNU General Public License as published by the Free Software | ||
# Foundation; either version 2 of the License, or (at your option) any later | ||
# version. | ||
# | ||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, | ||
# Suite 330, Boston, MA 02111-1307 USA | ||
|
||
=head1 NAME | ||
expireholds.pl - cron script to remove expired holds from the reserves table | ||
=head1 SYNOPSIS | ||
./expireholds.pl | ||
or, in crontab: | ||
0 1 * * * $KOHA_CRON_DIR/holds/expireholds.pl | ||
=head1 DESCRIPTION | ||
This script simply removes holds in the reserves table that have expired. | ||
Previously, the ReservesMaxPickUpDelay syspref was being used to display | ||
that holds had expired, but they were not being deleted from the reserves | ||
table. This script corrects that problem. | ||
=cut | ||
|
||
use strict; | ||
BEGIN { | ||
# find Koha's Perl modules | ||
# test carefully before changing this | ||
use FindBin; | ||
eval { require "$FindBin::Bin/../kohalib.pl" }; | ||
} | ||
|
||
use C4::Context; | ||
use C4::Dates; | ||
my $today = C4::Dates->new(); | ||
my $today_iso = $today->output('iso'); | ||
|
||
my $dbh = C4::Context->dbh; | ||
my $query = "SELECT * FROM reserves | ||
WHERE expirationdate < ?"; | ||
my $sth = $dbh->prepare($query); | ||
$sth->execute($today_iso); | ||
while (my $expref = $sth->fetchrow_hashref) { | ||
my $insert_fields = ''; | ||
my $value_fields = ''; | ||
foreach my $column ('borrowernumber','reservedate','biblionumber','constrainttype','branchcode','notificationdate','reminderdate','cancellationdate','reservenotes','priority','found','itemnumber','waitingdate','expirationdate') { | ||
if (defined($expref->{$column})) { | ||
if (length($insert_fields)) { | ||
$insert_fields .= ",$column"; | ||
$value_fields .= ",\'$expref->{$column}\'"; | ||
} | ||
else { | ||
$insert_fields .= "$column"; | ||
$value_fields .= "\'$expref->{$column}\'"; | ||
} | ||
} | ||
} | ||
my $inssql = "INSERT INTO old_reserves ($insert_fields) | ||
VALUES ($value_fields)"; | ||
my $sth2 = $dbh->prepare($inssql); | ||
$sth2->execute(); | ||
my $delsql = "DELETE FROM reserves | ||
WHERE reservenumber = ?"; | ||
$sth2 = $dbh->prepare($delsql); | ||
$sth2->execute($expref->{reservenumber}); | ||
} | ||
$dbh->disconnect(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters