From ca79d19802ece860a03283bdba9198b08a2677c7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 26 Nov 2020 13:19:32 +0000 Subject: [PATCH] Bug 26282: (QA follow-up) Allow notification via cancel_expired_holds Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi Signed-off-by: Josef Moravec --- C4/Reserves.pm | 2 ++ misc/cronjobs/holds/cancel_expired_holds.pl | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index e6bfc678aa..7b85b6d612 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -929,6 +929,7 @@ Cancels all reserves with an expiration date from before today. sub CancelExpiredReserves { my $cancellation_reason = shift; + my $notify = shift; my $today = dt_from_string(); my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay'); @@ -947,6 +948,7 @@ sub CancelExpiredReserves { my $cancel_params = {}; $cancel_params->{cancellation_reason} = $cancellation_reason if defined($cancellation_reason); + $cancel_params->{notify_patron} = $notify if defined($notify); if ( defined($hold->found) && $hold->found eq 'W' ) { $cancel_params->{charge_cancel_fee} = 1; } diff --git a/misc/cronjobs/holds/cancel_expired_holds.pl b/misc/cronjobs/holds/cancel_expired_holds.pl index 4932bbf346..4d1fba893d 100755 --- a/misc/cronjobs/holds/cancel_expired_holds.pl +++ b/misc/cronjobs/holds/cancel_expired_holds.pl @@ -25,12 +25,12 @@ cancel_expired_holds.pl - cron script to cancel holds as they expire =head1 SYNOPSIS ./cancel_expired_holds.pl - ./cancel_expired_holds.pl --reason="EXPIRED" + ./cancel_expired_holds.pl --reason="EXPIRED" --notify or, in crontab: 0 1 * * * cancel_expired_holds.pl - 0 1 * * * cancel_expired_holds.pl --reason="EXPIRED" + 0 1 * * * cancel_expired_holds.pl --reason="EXPIRED" --notify =head1 DESCRIPTION @@ -63,21 +63,27 @@ Print a brief help message and exits. =item B<--reason> -Optionally adds a reason for cancellation (which will trigger a notice to be sent to the patron) +Optionally adds a reason for cancellation + +=item B<--notify> + +Optionally trigger a notice to be sent to the patron =back =cut my $help = 0; +my $notify = 0; my $reason; GetOptions( 'help|?' => \$help, - 'reason=s' => \$reason + 'notify' => \$notify, + 'reason=s' => \$reason, ) or pod2usage(1); pod2usage(1) if $help; cronlogaction(); -CancelExpiredReserves($reason); +CancelExpiredReserves($reason, $notify); -- 2.20.1