1 # This file is part of Koha.
3 # Copyright (C) 2014 Hochschule für Gesundheit (hsg), Germany
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 automatic_renewals.pl - cron script to renew loans
24 ./automatic_renewals.pl
27 0 3 * * * automatic_renewals.pl
31 This script searches for issues scheduled for automatic renewal
32 (issues.auto_renew). If there are still renews left (Renewals allowed)
33 and the renewal isn't premature (No Renewal before) the issue is renewed.
46 my $dbh = C4::Context->dbh;
47 my ( $borrowernumber, $itemnumber, $branch, $ok, $error );
50 "SELECT borrowernumber, itemnumber, branchcode FROM issues WHERE auto_renew = 1";
51 my $sth = $dbh->prepare($query);
54 while ( ( $borrowernumber, $itemnumber, $branch ) = $sth->fetchrow_array ) {
56 # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script
57 ( $ok, $error ) = CanBookBeRenewed( $borrowernumber, $itemnumber );
58 AddRenewal( $borrowernumber, $itemnumber, $branch )
59 if ( $error eq "auto_renew" );