View | Details | Raw Unified | Return to bug 11577
Collapse All | Expand All

(-)a/misc/cronjobs/automatic_renewals.pl (+60 lines)
Line 0 Link Here
1
# This file is part of Koha.
2
#
3
# Copyright (C) 2014 Hochschule für Gesundheit (hsg), Germany
4
#
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.
9
#
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.
14
#
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>.
17
18
=head1 NAME
19
20
automatic_renewals.pl - cron script to renew loans
21
22
=head1 SYNOPSIS
23
24
./automatic_renewals.pl
25
26
or, in crontab:
27
0 3 * * * automatic_renewals.pl
28
29
=head1 DESCRIPTION
30
31
This script searches for issues sheduled 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.
34
35
=head1 OPTIONS
36
37
No options.
38
39
=cut
40
41
use Modern::Perl;
42
43
use C4::Circulation;
44
use C4::Context;
45
46
my $dbh = C4::Context->dbh;
47
my ( $borrowernumber, $itemnumber, $branch, $ok, $error );
48
49
my $query =
50
"SELECT borrowernumber, itemnumber, branchcode FROM issues WHERE auto_renew = 1";
51
my $sth = $dbh->prepare($query);
52
$sth->execute();
53
54
while ( ( $borrowernumber, $itemnumber, $branch ) = $sth->fetchrow_array ) {
55
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" );
60
}
(-)a/misc/cronjobs/crontab.example (-1 / +3 lines)
Lines 85-87 KOHA_CRON_PATH = /usr/share/koha/bin/cronjobs Link Here
85
85
86
# delete old purchase suggestions weekly. Replace XX with a number to define the age of suggestions to delete.
86
# delete old purchase suggestions weekly. Replace XX with a number to define the age of suggestions to delete.
87
@weekly	__KOHA_USER__  $KOHA_CRON_PATH/purge_suggestions.pl --days XX > /dev/null 2>&1
87
@weekly	__KOHA_USER__  $KOHA_CRON_PATH/purge_suggestions.pl --days XX > /dev/null 2>&1
88
- 
88
89
# every day at 3AM renew all issues sheduled for automatic renewal
90
0 3 * * *  __KOHA_USER__ $KOHA_CRON_PATH/automatic_renewals.pl

Return to bug 11577