From b5cc3312f035c59e827974e8954be9bccea8b22c 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 Rebased-by: Victor Grousset/tuxayo --- 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 e0793084ecc..cdf4bb6f0ba 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -933,6 +933,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'); @@ -957,6 +958,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 ed977678b70..81921dab910 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 @@ -56,25 +56,31 @@ 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; my $command_line_options = join(" ",@ARGV); GetOptions( 'help|?' => \$help, - 'reason=s' => \$reason + 'notify' => \$notify, + 'reason=s' => \$reason, ) or pod2usage(1); pod2usage(1) if $help; cronlogaction({ info => $command_line_options }); -C4::Reserves::CancelExpiredReserves($reason); +C4::Reserves::CancelExpiredReserves($reason, $notify); cronlogaction({ action => 'End', info => "COMPLETED" }); -- 2.39.3 (Apple Git-146)