Bug 17600: Standardize our EXPORT_OK
[koha.git] / misc / cronjobs / holds / cancel_expired_holds.pl
1 #!/usr/bin/perl
2
3 # Copyright 2009-2010 Kyle Hall
4 # Copyright 2020 PTFS Europe
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20
21 =head1 NAME
22
23 cancel_expired_holds.pl - cron script to cancel holds as they expire
24
25 =head1 SYNOPSIS
26
27   ./cancel_expired_holds.pl
28   ./cancel_expired_holds.pl --reason="EXPIRED"
29
30 or, in crontab:
31
32   0 1 * * * cancel_expired_holds.pl
33   0 1 * * * cancel_expired_holds.pl --reason="EXPIRED"
34
35 =head1 DESCRIPTION
36
37 This script calls C4::Reserves::CancelExpiredReserves which will find and cancel all expired reseves in the system.
38
39 =cut
40
41 use Modern::Perl;
42 use Getopt::Long qw( GetOptions );
43 use Pod::Usage qw( pod2usage );
44
45 BEGIN {
46     # find Koha's Perl modules
47     # test carefully before changing this
48     use FindBin ();
49     eval { require "$FindBin::Bin/../kohalib.pl" };
50 }
51
52 use Koha::Script -cron;
53 use C4::Reserves;
54 use C4::Log qw( cronlogaction );
55
56 =head1 OPTIONS
57
58 =over 8
59
60 =item B<--help>
61
62 Print a brief help message and exits.
63
64 =item B<--reason>
65
66 Optionally adds a reason for cancellation (which will trigger a notice to be sent to the patron)
67
68 =back
69
70 =cut
71
72 my $help = 0;
73 my $reason;
74
75 GetOptions(
76     'help|?'   => \$help,
77     'reason=s' => \$reason
78 ) or pod2usage(1);
79 pod2usage(1) if $help;
80
81 cronlogaction();
82
83 CancelExpiredReserves($reason);