Bug 31203: Alter other cronjobs that currenlty use cronlogaction
[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 use Koha::Script -cron;
46 use C4::Reserves;
47 use C4::Log qw( cronlogaction );
48
49 =head1 OPTIONS
50
51 =over 8
52
53 =item B<--help>
54
55 Print a brief help message and exits.
56
57 =item B<--reason>
58
59 Optionally adds a reason for cancellation (which will trigger a notice to be sent to the patron)
60
61 =back
62
63 =cut
64
65 my $help = 0;
66 my $reason;
67
68 my $command_line_options = join(" ",@ARGV);
69
70 GetOptions(
71     'help|?'   => \$help,
72     'reason=s' => \$reason
73 ) or pod2usage(1);
74 pod2usage(1) if $help;
75
76 cronlogaction({ info => $command_line_options });
77
78 C4::Reserves::CancelExpiredReserves($reason);
79
80 cronlogaction({ action => 'End', info => "COMPLETED" });