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

(-)a/C4/Reserves.pm (+2 lines)
Lines 901-906 Cancels all reserves with an expiration date from before today. Link Here
901
=cut
901
=cut
902
902
903
sub CancelExpiredReserves {
903
sub CancelExpiredReserves {
904
    my $cancellation_reason = shift;
904
    my $today = dt_from_string();
905
    my $today = dt_from_string();
905
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
906
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
906
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
907
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
Lines 918-923 sub CancelExpiredReserves { Link Here
918
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
919
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
919
920
920
        my $cancel_params = {};
921
        my $cancel_params = {};
922
        $cancel_params->{cancellation_reason} = $cancellation_reason if defined($cancellation_reason);
921
        if ( $hold->found eq 'W' ) {
923
        if ( $hold->found eq 'W' ) {
922
            $cancel_params->{charge_cancel_fee} = 1;
924
            $cancel_params->{charge_cancel_fee} = 1;
923
        }
925
        }
(-)a/misc/cronjobs/holds/cancel_expired_holds.pl (-4 / +49 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2009-2010 Kyle Hall
3
# Copyright 2009-2010 Kyle Hall
4
# Copyright 2020 PTFS Europe
4
#
5
#
5
# This file is part of Koha.
6
# This file is part of Koha.
6
#
7
#
Lines 17-23 Link Here
17
# You should have received a copy of the GNU General Public License
18
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
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
20
use Modern::Perl;
41
use Modern::Perl;
42
use Getopt::Long;
43
use Pod::Usage;
21
44
22
BEGIN {
45
BEGIN {
23
    # find Koha's Perl modules
46
    # find Koha's Perl modules
Lines 26-37 BEGIN { Link Here
26
    eval { require "$FindBin::Bin/../kohalib.pl" };
49
    eval { require "$FindBin::Bin/../kohalib.pl" };
27
}
50
}
28
51
29
# cancel all expired hold requests
30
31
use Koha::Script -cron;
52
use Koha::Script -cron;
32
use C4::Reserves;
53
use C4::Reserves;
33
use C4::Log;
54
use C4::Log;
34
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
35
cronlogaction();
81
cronlogaction();
36
82
37
CancelExpiredReserves();
83
CancelExpiredReserves($reason);
38
- 

Return to bug 12656