From 84fa072f80feb3ad2feaaa95869d0deaab23d694 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 17 Dec 2021 15:49:17 +0000 Subject: [PATCH] Bug 29704: Add a triggered option to holds_reminder.pl This patch adds an option to only trigger notices matching the number of days waiting specified You will need to define HOLD_REMINDER notices for the specific branch of the patron and ensure the patron has hold reminder notices in their messaging preferences TO test: 1 - Place a hold for a patron and check in to confirm 2 - Set the waiting date back a few days: update reserves set waitingdate = DATE_SUB(CURDATE(), INTERVAL 5 DAY); 3 - Run the cron and see that patron would be notified if running for 4 days weaiting perl misc/cronjobs/holds/holds_reminder.pl -v --days 4 4 - Apply patch 5 - perl misc/cronjobs/holds/holds_reminder.pl -v --days 4 --triggered 6 - Note patron would not be notified 7 - perl misc/cronjobs/holds/holds_reminder.pl -v --days 5 --triggered 8 - Note patron is notified when days waiting matches exactly --- misc/cronjobs/holds/holds_reminder.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/misc/cronjobs/holds/holds_reminder.pl b/misc/cronjobs/holds/holds_reminder.pl index 3402dd16ec..5a005c3493 100755 --- a/misc/cronjobs/holds/holds_reminder.pl +++ b/misc/cronjobs/holds/holds_reminder.pl @@ -50,6 +50,7 @@ holds_reminder.pl -v verbose -c --confirm confirm, if not set no email will be sent -days days waiting to deal with + -t --triggered include only holds days waiting, and not longer -lettercode predefined notice to use, default is HOLD_REMINDER -library only deal with holds from this library (repeatable : several libraries can be given) -holidays use the calendar to not count holidays as waiting days @@ -86,6 +87,13 @@ Optional parameter, number of days an items has been 'waiting' on hold to send a message for. If not included a notice will be sent to all patrons with waiting holds. +=item B<-triggered> + +Optional parameter, only sned notices for holds exactly waiting. +If not included a notice will be sent to all patrons with waiting holds +equal to OR greater than . This option is useful if the cron is +being run daily to avoid spamming the patrons. + =item B<-lettercode> Optional parameter, choose a notice to use. Default is 'HOLD_REMINDER'. @@ -160,6 +168,7 @@ my $man = 0; my $verbose = 0; my $confirm = 0; my $days ; +my $triggered = 0; my $lettercode; my @branchcodes; # Branch(es) passed as parameter my $use_calendar = 0; @@ -173,6 +182,7 @@ GetOptions( 'v' => \$verbose, 'c|confirm' => \$confirm, 'days=s' => \$days, + 'triggered' => \$triggered, 'lettercode=s' => \$lettercode, 'library=s' => \@branchcodes, 'date=s' => \$date_input, @@ -244,8 +254,9 @@ foreach my $branchcode (@branchcodes) { #BEGIN BRANCH LOOP # Find all the holds waiting since this date for the current branch my $dtf = Koha::Database->new->schema->storage->datetime_parser; my $waiting_since = $dtf->format_date( $waiting_date ); + my $comparator = $triggered ? '=' : '<='; my $reserves = Koha::Holds->search({ - waitingdate => {'<=' => $waiting_since }, + waitingdate => {$comparator => $waiting_since }, 'me.branchcode' => $branchcode, },{ prefetch => 'patron' }); -- 2.20.1