Bugzilla – Attachment 7357 Details for
Bug 7408
Expire holds that have been waiting too long
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed Patch
0001-ENH-7408-Expire-holds-that-have-been-waiting-too-lon.patch (text/plain), 4.25 KB, created by
Ian Walls
on 2012-01-27 22:07:16 UTC
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Ian Walls
Created:
2012-01-27 22:07:16 UTC
Size:
4.25 KB
patch
obsolete
>From 0e8640ec46e7a92cfff0686469406206c633ad07 Mon Sep 17 00:00:00 2001 >From: Ian Walls <ian.walls@bywatersolutions.com> >Date: Thu, 5 Jan 2012 16:07:43 -0500 >Subject: [PATCH] ENH 7408: Expire holds that have been waiting too long > >This script updates all holds that have been waiting for pickup longer >than ReservesMaxPickupDelay days, and sets the expiration date to today. > >The script can also take an optional parameter --charge that will fine >the patron the amount specified. The fine will appear as type 'F', with >the description "Hold waiting too long", and a link back to the item that >was used to fill the hold. > >This script is intended to be run right before cronjobs/holds/cancel_expired_holds.pl >If that script is not run, the expiration date will be updated again when this >script runs, and the patron will be charged again (if --charge is set). > >To Test: >1. run perl misc/cronjobs/holds/expire_holds_over.pl -v --charge 1.25 > you should get a message confirming how much you're charging, and how many holds > were updated >2. View the Holds Awaiting Pickup page, and the Holds Over tab > For each hold over, clicking to the title's Holds page should show the hold now has > an expiration date of today. >3. Clicking over to the patron should show a fine of 1.25, with a link back to the item > that had be waiting for them >4. Running cancel_expired_holds.pl then this script again should result in 0 holds modified >--- > 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 > >diff --git a/misc/cronjobs/holds/expire_holds_over.pl b/misc/cronjobs/holds/expire_holds_over.pl >new file mode 100644 >index 0000000..e0a6675 >--- /dev/null >+++ b/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 <<amount>>: charge the patron <<amount>> 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); >-- >1.7.4.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7408
:
7357
|
7838
|
7839
|
7840
|
7841
|
7856
|
8022
|
8101
|
8241
|
8242
|
8323
|
8325