From fe4314f52981641fa3d9a0732b0de7cd17d37018 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 Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Tomas Cohen Arazi Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall (cherry picked from commit b392547ab6937abafcd2e964f9d7490f1426a51c) Signed-off-by: Andrew Fuerste-Henry --- 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 49bccfdcde..9bd65fec13 100755 --- a/misc/cronjobs/holds/holds_reminder.pl +++ b/misc/cronjobs/holds/holds_reminder.pl @@ -57,6 +57,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 @@ -93,6 +94,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'. @@ -167,6 +175,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; @@ -180,6 +189,7 @@ GetOptions( 'v' => \$verbose, 'c|confirm' => \$confirm, 'days=s' => \$days, + 'triggered' => \$triggered, 'lettercode=s' => \$lettercode, 'library=s' => \@branchcodes, 'date=s' => \$date_input, @@ -242,8 +252,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.39.5