Bugzilla – Attachment 31205 Details for
Bug 11577
Automatic renewals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 11577: Add an automatic renewal cronjob
PASSED-QA-Bug-11577-Add-an-automatic-renewal-cronj.patch (text/plain), 4.55 KB, created by
Martin Renvoize (ashimema)
on 2014-08-27 17:36:43 UTC
(
hide
)
Description:
[PASSED QA] Bug 11577: Add an automatic renewal cronjob
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2014-08-27 17:36:43 UTC
Size:
4.55 KB
patch
obsolete
>From 777cf5d82b26e994693fdb64eabb26b5d093f193 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Holger=20Mei=C3=9Fner?= <h.meissner.82@web.de> >Date: Fri, 16 May 2014 13:14:32 +0200 >Subject: [PATCH] [PASSED QA] Bug 11577: Add an automatic renewal cronjob >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds a new cron script automatic_renewals.pl and a new >entry in crontab.example. > >To test: > >1) You need a few issues, some with automatic renewal and some without. >2) Confirm that each time you run misc/cronjobs/automatic_renewals.pl > those issues are renewed that meet all of the following criteria: > - automatic renewal has been scheduled either by issuing rule or by > checkbox on the checkout page > - the number of allowed renewals isn't exceeded > - renewal isn't premature (No renewal before) >3) Confirm that all other issues are not affected. > >Sponsored-by: Hochschule für Gesundheit (hsg), Germany >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > debian/koha-common.cron.daily | 1 + > misc/cronjobs/automatic_renewals.pl | 60 +++++++++++++++++++++++++++++++++++ > misc/cronjobs/crontab.example | 3 ++ > 3 files changed, 64 insertions(+) > create mode 100644 misc/cronjobs/automatic_renewals.pl > >diff --git a/debian/koha-common.cron.daily b/debian/koha-common.cron.daily >index 2f899b0..f62ad53 100644 >--- a/debian/koha-common.cron.daily >+++ b/debian/koha-common.cron.daily >@@ -23,4 +23,5 @@ koha-foreach --enabled /usr/share/koha/bin/cronjobs/services_throttle.pl > /dev/ > koha-foreach --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --sessions --zebraqueue 10 --list-invites > koha-foreach --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_database.pl --mail > koha-foreach --enabled /usr/share/koha/bin/cronjobs/holds/auto_unsuspend_holds.pl > /dev/null 2>&1 >+koha-foreach --enabled /usr/share/koha/bin/cronjobs/automatic_renewals.pl > koha-run-backups --days 2 --output /var/spool/koha >diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl >new file mode 100644 >index 0000000..1ecfc47 >--- /dev/null >+++ b/misc/cronjobs/automatic_renewals.pl >@@ -0,0 +1,60 @@ >+# This file is part of Koha. >+# >+# Copyright (C) 2014 Hochschule für Gesundheit (hsg), Germany >+# >+# 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 3 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, see <http://www.gnu.org/licenses>. >+ >+=head1 NAME >+ >+automatic_renewals.pl - cron script to renew loans >+ >+=head1 SYNOPSIS >+ >+./automatic_renewals.pl >+ >+or, in crontab: >+0 3 * * * automatic_renewals.pl >+ >+=head1 DESCRIPTION >+ >+This script searches for issues scheduled for automatic renewal >+(issues.auto_renew). If there are still renews left (Renewals allowed) >+and the renewal isn't premature (No Renewal before) the issue is renewed. >+ >+=head1 OPTIONS >+ >+No options. >+ >+=cut >+ >+use Modern::Perl; >+ >+use C4::Circulation; >+use C4::Context; >+ >+my $dbh = C4::Context->dbh; >+my ( $borrowernumber, $itemnumber, $branch, $ok, $error ); >+ >+my $query = >+"SELECT borrowernumber, itemnumber, branchcode FROM issues WHERE auto_renew = 1"; >+my $sth = $dbh->prepare($query); >+$sth->execute(); >+ >+while ( ( $borrowernumber, $itemnumber, $branch ) = $sth->fetchrow_array ) { >+ >+# CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script >+ ( $ok, $error ) = CanBookBeRenewed( $borrowernumber, $itemnumber ); >+ AddRenewal( $borrowernumber, $itemnumber, $branch ) >+ if ( $error eq "auto_renew" ); >+} >diff --git a/misc/cronjobs/crontab.example b/misc/cronjobs/crontab.example >index a937bf0..5ef68cb 100644 >--- a/misc/cronjobs/crontab.example >+++ b/misc/cronjobs/crontab.example >@@ -85,3 +85,6 @@ KOHA_CRON_PATH = /usr/share/koha/bin/cronjobs > > # delete old purchase suggestions weekly. Replace XX with a number to define the age of suggestions to delete. > @weekly __KOHA_USER__ $KOHA_CRON_PATH/purge_suggestions.pl --days XX > /dev/null 2>&1 >+ >+# every day at 3AM renew all issues scheduled for automatic renewal >+0 3 * * * __KOHA_USER__ $KOHA_CRON_PATH/automatic_renewals.pl >-- >1.7.10.4
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 11577
:
28425
|
28426
|
28427
|
28428
|
28429
|
28430
|
28431
|
28432
|
28433
|
28434
|
28454
|
28595
|
28596
|
28597
|
28598
|
28599
|
28600
|
28601
|
28602
|
28603
|
28604
|
29393
|
29394
|
29395
|
29396
|
29397
|
29398
|
29399
|
29400
|
29401
|
29402
|
29966
|
29967
|
29968
|
29969
|
29970
|
29971
|
29972
|
29973
|
29974
|
29975
|
30248
|
30249
|
30250
|
30251
|
30252
|
30253
|
30254
|
30255
|
30256
|
30257
|
30258
|
30692
|
30693
|
30694
|
30695
|
30696
|
30697
|
30698
|
30699
|
30700
|
30701
|
30702
|
31076
|
31077
|
31078
|
31079
|
31080
|
31081
|
31082
|
31083
|
31084
|
31085
|
31086
|
31198
|
31199
|
31200
|
31201
|
31202
|
31203
|
31204
|
31205
|
31206
|
31207
|
31208
|
31209
|
31640
|
31641
|
31642
|
31643
|
31644
|
31645
|
31646
|
31647
|
31648
|
31649
|
31650
|
31651
|
31652
|
31653
|
31654
|
31655
|
31656
|
31657
|
31658
|
31659
|
31660
|
31661
|
31662
|
31663
|
57734