@@ -, +, @@ you should get a message confirming how much you're charging, and how many holds were updated For each hold over, clicking to the title's Holds page should show the hold now has an expiration date of today. that had be waiting for them --- misc/cronjobs/holds/expire_holds_over.pl | 71 ++++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-) create mode 100644 misc/cronjobs/holds/expire_holds_over.pl --- a/misc/cronjobs/holds/expire_holds_over.pl +++ a/misc/cronjobs/holds/expire_holds_over.pl @@ -0,0 +1,71 @@ +#!/usr/bin/perl + +# Copyright 2012 Ian Walls & ByWater Solutions +# +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +#use strict; +#use warnings; FIXME - Bug 2505 + +BEGIN { + # find Koha's Perl modules + # test carefully before changing this + use FindBin; + eval { require "$FindBin::Bin/../kohalib.pl" }; +} + +use Getopt::Long; +use C4::Context; +use C4::Accounts qw(manualinvoice); + +my ($help, $verbose, $charge); +my $count = 0; +my $maxdelay = C4::Context->preference("ReservesMaxPickupDelay"); + +GetOptions( 'h|help' => \$help, + 'v|verbose' => \$verbose, + 'charge:f' => \$charge + ); +my $usage = << 'ENDUSAGE'; + +This script expires all holds over ReservesMaxPickupDelay, and +can charge the patron a fee for not picking up the material in +time. + +This script has the following parameters : + -h --help: this message + -v --verbose + -charge <>: charge the patron <> for not + picking up the hold + +ENDUSAGE +die $usage if $help; + +print sprintf "Charging patrons \$%.2f for each hold waiting too long...\n",$charge if (defined $verbose); + +my $dbh = C4::Context->dbh; +my $sth = $dbh->prepare("SELECT * FROM reserves WHERE TO_DAYS( NOW() )-TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0"); +$sth->execute($maxdelay); +my $sth_update = $dbh->prepare("UPDATE reserves SET expirationdate = NOW() WHERE borrowernumber = ? and itemnumber = ?"); +while (my $row = $sth->fetchrow_hashref ) { + if ($charge) { + manualinvoice($row->{'borrowernumber'}, $row->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); + } + $sth_update->execute($row->{'borrowernumber'}, $row->{'itemnumber'}); + $count++; +} + +print "A total of $count holds expired\n" if (defined $verbose); --