Bug 15986 - Add a script for sending hold waiting reminder notices
Summary: Add a script for sending hold waiting reminder notices
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement with 10 votes (vote)
Assignee: Nick Clemens
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-04 20:33 UTC by Nick Clemens
Modified: 2021-01-01 17:59 UTC (History)
18 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Small patch
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 15986 - Add a script for sending hold waiting reminder notices (30.00 KB, patch)
2016-07-12 17:28 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 15986 - Add a script for sending hold waiting reminder notices (29.60 KB, patch)
2016-07-13 00:21 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 15986 - Add a script for sending hold waiting reminder notices (30.64 KB, patch)
2016-07-21 16:40 UTC, Nick Clemens
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 15986 - Add a script for sending hold waiting reminder notices (30.70 KB, patch)
2016-09-20 16:19 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 15986: Add a script for sending hold waiting reminder notices (21.28 KB, patch)
2019-07-25 13:58 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 15986: Add a script for sending hold waiting reminder notices (22.22 KB, patch)
2019-07-25 14:40 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 15986: Add a script for sending hold waiting reminder notices (22.21 KB, patch)
2020-03-02 14:21 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 15986: Add a script for sending hold waiting reminder notices (22.26 KB, patch)
2020-04-10 13:15 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 15986: Add a script for sending hold waiting reminder notices (22.33 KB, patch)
2020-04-14 11:55 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 15986: Add a script for sending hold waiting reminder notices (22.17 KB, patch)
2020-07-16 16:54 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 15986: Update for bug 24159 (1.15 KB, patch)
2020-07-16 16:54 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 15986: Rename send_notice to queue_notice and update test count (7.17 KB, patch)
2020-07-16 16:54 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 15986: Add a script for sending hold waiting reminder notices (22.22 KB, patch)
2020-11-04 14:49 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 15986: Update for bug 24159 (1.20 KB, patch)
2020-11-04 14:49 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 15986: Rename send_notice to queue_notice and update test count (7.22 KB, patch)
2020-11-04 14:49 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2016-03-04 20:33:46 UTC
Write a script that will take two parameters:

a) Length of time hold has been waiting ( in days )

b) Letter code of notice to be emailed

2) Script will take these two parameters and send the specified notice for each hold a patron has.
Comment 1 Nick Clemens 2016-07-12 17:28:42 UTC Comment hidden (obsolete)
Comment 2 Nick Clemens 2016-07-13 00:21:13 UTC Comment hidden (obsolete)
Comment 3 Chris Cormack 2016-07-18 03:24:51 UTC
Comment on attachment 53354 [details] [review]
Bug 15986 - Add a script for sending hold waiting reminder notices

Review of attachment 53354 [details] [review]:
-----------------------------------------------------------------

::: misc/cronjobs/holds_reminder.pl
@@ +1,4 @@
> +#!/usr/bin/perl
> +
> +# Copyright 2008 Liblime
> +# Copyright 2010 BibLibre

Can we please fix the copyright notices, this is a new script right?
Comment 4 Chris Cormack 2016-07-18 03:26:34 UTC
Just a general comment, we have a setting where borrowers can opt in/out of holds filled notices.
Should this script respect that preference, IE if they don't get a hold filled notice will they be happy getting one saying it's waiting. Annoying patrons is something libraries generally like to avoid :)

It should be easy enough to use the check we have for holds filled in circulation I hope
Comment 5 Nick Clemens 2016-07-21 16:40:42 UTC
Created attachment 53594 [details] [review]
Bug 15986 - Add a script for sending hold waiting reminder notices

This patch adds a script for sending holds reminder notice to patrons.
Essentially it is a modification of the overdue_notices.pl script

To test:
1 - Create a hold reminder notice (Koha module: Holds)
2 - Set some waiting holds for patrons
3 - Run the script with various options and verify correct data is
    generated
4 - Verify that with 'optout' switch set only patrons who have email
hold filled notices specified will recieve a reminder

Sponsored by: The Hotchkiss School (http://www.hotchkiss.org/)
Comment 6 Nick Clemens 2016-07-21 16:47:17 UTC
(In reply to Chris Cormack from comment #4)
> Just a general comment, we have a setting where borrowers can opt in/out of
> holds filled notices.
> Should this script respect that preference, IE if they don't get a hold
> filled notice will they be happy getting one saying it's waiting. Annoying
> patrons is something libraries generally like to avoid :)

Good point, I added it as a switch, some libraries charge fines for holds not picked up etc, so they may want to force the notification, I figure this way makes it flexible
Comment 7 Chris Cormack 2016-07-21 21:31:25 UTC
Yep sounds good, I'll give it a test when I'm back at work
Comment 8 Kyle M Hall 2016-09-20 16:19:01 UTC
Created attachment 55723 [details] [review]
[SIGNED-OFF] Bug 15986 - Add a script for sending hold waiting reminder notices

This patch adds a script for sending holds reminder notice to patrons.
Essentially it is a modification of the overdue_notices.pl script

To test:
1 - Create a hold reminder notice (Koha module: Holds)
2 - Set some waiting holds for patrons
3 - Run the script with various options and verify correct data is
    generated
4 - Verify that with 'optout' switch set only patrons who have email
hold filled notices specified will recieve a reminder

Sponsored by: The Hotchkiss School (http://www.hotchkiss.org/)

Signed-off-by: Robert <rhilliker@hotchkiss.org>
Comment 9 Katrin Fischer 2016-11-01 23:02:59 UTC
I love the amount of documentation for this script!

I didn't get to test this yet, but while reading through it I wondered:
There is a lot of work done in order to allow exporting in different formats. I was wondering if it might be better to leave the job of creating a printable version to gather_print_notices.pl working towards a more unified workflow for all the printed letters.
Comment 10 Marcel de Rooy 2016-11-02 15:36:55 UTC
I like the feature, but would love to see less (new) code in cron scripts and more code in our modules. With advantages of testing etc.
Comment 11 Sally 2017-01-16 14:13:59 UTC
This is a really exciting feature.

I know it's been sent back to discussion from being signed off - what's the next step for moving it forward?  We think this would make a fantastic addition to Koha.
Comment 12 Chris Cormack 2017-01-17 04:09:38 UTC
(In reply to Sally Healey from comment #11)
> This is a really exciting feature.
> 
> I know it's been sent back to discussion from being signed off - what's the
> next step for moving it forward?  We think this would make a fantastic
> addition to Koha.

To move it forward it needs comment 10 addressed, and a lot of the code moved out of the .pl file into a module, with unit tests written. 
This shouldn't be a big job, but will mean way less chance of breakage/maintenance in the future.
As well as a signoff from outside of the sponsoring library.

I think comment 9 could be a future enhancement. But mostly comment 10 (moving the code to a module and writing tests) and an independent sign off are what are need
Comment 13 Katrin Fischer 2017-01-17 23:38:25 UTC
I think if we do #9 later it will introduce a change in workflow - if we did it from the beginning, we could safe people from having to change their setups. But I am not blocking this, just explaining my point of view maybe also for future enh.
Comment 14 Nick Clemens 2019-07-25 13:58:31 UTC
Created attachment 91767 [details] [review]
Bug 15986: Add a script for sending hold waiting reminder notices

This patch adds a script for sending holds reminder notice to patrons.

We add a 'send_notice' routine to Koha::Patrons - this will either send using the patron's
email prefs, or allow forcing of a single method via the cron

To test:
 1 - Create an email hold reminder notice for a single library (Koha module: Holds, code HOLDREMINDER, branch: CPL)
 2 - Set some waiting holds today for patrons at CPL, ensure those patrons have 'email' as the transport for hold filled notices
 3 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL
 4 - You should see the patrons here would have received emails
 5 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL
 6 - You should see the emails that were sent
 7 - Check the patron notices tab to confirm
 8 - Note a ptron with two holds waiting receives only one notice
 9 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
10 - No notices are sent
11 - Adjust the waiting date for the holds:
    UPDATE reserves SET waitingdate=DATE_SUB(CURDATE(), INTERVAL 3 DAYS) WHERE waitingdate = CURDATE();
12 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
13 - Confirm the holds are now reminded
14 - Set yesterday as a holiday for CPL
15 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 3
16 - Notices should not be sent
17 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 4
18 - Notices should be sent again
19 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4
20 - Should get feedback that notice was not found for other libraries
21 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4 -mtt sms
22 - Notice is not found
23 - Add the notice for sms
24 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4 -mtt sms
25 - The notice should be sent
26 - Check patrons messaging tab to confirm
27 - prove -v t/db_dependent/Koha/Patrons.t

Sponsored by: The Hotchkiss School (http://www.hotchkiss.org/)
Comment 15 Nick Clemens 2019-07-25 14:00:10 UTC
(In reply to Chris Cormack from comment #12)
> I think comment 9 could be a future enhancement. But mostly comment 10
> (moving the code to a module and writing tests) and an independent sign off
> are what are need

Code for sending moved to Koha::Patron::send_notice
Comment 16 Nick Clemens 2019-07-25 14:25:52 UTC
(In reply to Katrin Fischer from comment #13)
> I think if we do #9 later it will introduce a change in workflow - if we did
> it from the beginning, we could safe people from having to change their
> setups. But I am not blocking this, just explaining my point of view maybe
> also for future enh.

Removed the option to print out notices, now fallback to print if no email/sms
Comment 17 Nick Clemens 2019-07-25 14:40:24 UTC
Created attachment 91768 [details] [review]
Bug 15986: Add a script for sending hold waiting reminder notices

This patch adds a script for sending holds reminder notice to patrons.

We add a 'send_notice' routine to Koha::Patrons - this will either send using the patron's
email prefs, or allow forcing of a single method via the cron

To test:
 1 - Create an email hold reminder notice for a single library (Koha module: Holds, code HOLDREMINDER, branch: CPL)
 2 - Set some waiting holds today for patrons at CPL, ensure those patrons have 'email' as the transport for hold filled notices
 3 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL
 4 - You should see the patrons here would have received emails
 5 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL
 6 - You should see the emails that were sent
 7 - Check the patron notices tab to confirm
 8 - Note a ptron with two holds waiting receives only one notice
 9 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
10 - No notices are sent
11 - Adjust the waiting date for the holds:
    UPDATE reserves SET waitingdate=DATE_SUB(CURDATE(), INTERVAL 3 DAYS) WHERE waitingdate = CURDATE();
12 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
13 - Confirm the holds are now reminded
14 - Set yesterday as a holiday for CPL
15 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 3
16 - Notices should not be sent
17 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 4
18 - Notices should be sent again
19 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4
20 - Should get feedback that notice was not found for other libraries
21 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4 -mtt sms
22 - Notice is not found
23 - Add the notice for sms
24 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4 -mtt sms
25 - The notice should be sent
26 - Check patrons messaging tab to confirm
27 - prove -v t/db_dependent/Koha/Patrons.t

Sponsored by: The Hotchkiss School (http://www.hotchkiss.org/)
Comment 18 David Nind 2020-02-17 08:23:15 UTC
Patch no longer applies
Comment 19 Nick Clemens 2020-03-02 14:21:19 UTC
Created attachment 99919 [details] [review]
Bug 15986: Add a script for sending hold waiting reminder notices

This patch adds a script for sending holds reminder notice to patrons.

We add a 'send_notice' routine to Koha::Patrons - this will either send using the patron's
email prefs, or allow forcing of a single method via the cron

To test:
 1 - Create an email hold reminder notice for a single library (Koha module: Holds, code HOLDREMINDER, branch: CPL)
 2 - Set some waiting holds today for patrons at CPL, ensure those patrons have 'email' as the transport for hold filled notices
 3 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL
 4 - You should see the patrons here would have received emails
 5 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL
 6 - You should see the emails that were sent
 7 - Check the patron notices tab to confirm
 8 - Note a ptron with two holds waiting receives only one notice
 9 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
10 - No notices are sent
11 - Adjust the waiting date for the holds:
    UPDATE reserves SET waitingdate=DATE_SUB(CURDATE(), INTERVAL 3 DAYS) WHERE waitingdate = CURDATE();
12 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
13 - Confirm the holds are now reminded
14 - Set yesterday as a holiday for CPL
15 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 3
16 - Notices should not be sent
17 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 4
18 - Notices should be sent again
19 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4
20 - Should get feedback that notice was not found for other libraries
21 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4 -mtt sms
22 - Notice is not found
23 - Add the notice for sms
24 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4 -mtt sms
25 - The notice should be sent
26 - Check patrons messaging tab to confirm
27 - prove -v t/db_dependent/Koha/Patrons.t

Sponsored by: The Hotchkiss School (http://www.hotchkiss.org/)
Comment 20 Jonathan Druart 2020-03-02 14:57:04 UTC
Is the test_mode parameter of the method really useful?
Comment 21 Nick Clemens 2020-04-07 14:35:21 UTC
(In reply to Jonathan Druart from comment #20)
> Is the test_mode parameter of the method really useful?

Yes.
Comment 22 David Nind 2020-04-08 20:23:30 UTC
Things move too fast 8-) - patch no longer applies:

root@5e1d1195a414:koha(bz15986)$ git bz apply 15986
Bug 15986 - Add a script for sending hold waiting reminder notices

99919 - Bug 15986: Add a script for sending hold waiting reminder notices

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 15986: Add a script for sending hold waiting reminder notices
Using index info to reconstruct a base tree...
M	C4/Letters.pm
M	Koha/Patron.pm
M	t/db_dependent/Koha/Patrons.t
Falling back to patching base and 3-way merge...
Auto-merging t/db_dependent/Koha/Patrons.t
CONFLICT (content): Merge conflict in t/db_dependent/Koha/Patrons.t
Auto-merging Koha/Patron.pm
CONFLICT (content): Merge conflict in Koha/Patron.pm
Auto-merging C4/Letters.pm
error: Failed to merge in the changes.
Patch failed at 0001 Bug 15986: Add a script for sending hold waiting reminder notices

Also noticed that there is a holds subfolder in misc/cronjobs - should the script go in that?
Comment 23 Nick Clemens 2020-04-10 13:15:09 UTC
Created attachment 102723 [details] [review]
Bug 15986: Add a script for sending hold waiting reminder notices

This patch adds a script for sending holds reminder notice to patrons.

We add a 'send_notice' routine to Koha::Patrons - this will either send using the patron's
email prefs, or allow forcing of a single method via the cron

To test:
 1 - Create an email hold reminder notice for a single library (Koha module: Holds, code HOLDREMINDER, branch: CPL)
 2 - Set some waiting holds today for patrons at CPL, ensure those patrons have 'email' as the transport for hold filled notices
 3 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL
 4 - You should see the patrons here would have received emails
 5 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL
 6 - You should see the emails that were sent
 7 - Check the patron notices tab to confirm
 8 - Note a ptron with two holds waiting receives only one notice
 9 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
10 - No notices are sent
11 - Adjust the waiting date for the holds:
    UPDATE reserves SET waitingdate=DATE_SUB(CURDATE(), INTERVAL 3 DAYS) WHERE waitingdate = CURDATE();
12 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
13 - Confirm the holds are now reminded
14 - Set yesterday as a holiday for CPL
15 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 3
16 - Notices should not be sent
17 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 4
18 - Notices should be sent again
19 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4
20 - Should get feedback that notice was not found for other libraries
21 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4 -mtt sms
22 - Notice is not found
23 - Add the notice for sms
24 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4 -mtt sms
25 - The notice should be sent
26 - Check patrons messaging tab to confirm
27 - prove -v t/db_dependent/Koha/Patrons.t

Sponsored by: The Hotchkiss School (http://www.hotchkiss.org/)
Comment 24 David Nind 2020-04-14 11:17:02 UTC
For step 17, 19, 21, and 24 I'm getting an error message when running the script:

perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 3
branch CPL passed on parameter
Can't locate object method "in_units" via package "-3" (perhaps you forgot to load "-3"?) at /kohadevbox/koha/Koha/Calendar.pm line 193.
Comment 25 David Nind 2020-04-14 11:22:09 UTC
Also, in step 11 '..INTERVAL 3 DAYS)..' should be '..INTERVAL 3 DAY)..' (that is, DAYS should be DAY).
Comment 26 Nick Clemens 2020-04-14 11:55:15 UTC
Created attachment 102926 [details] [review]
Bug 15986: Add a script for sending hold waiting reminder notices

This patch adds a script for sending holds reminder notice to patrons.

We add a 'send_notice' routine to Koha::Patrons - this will either send using the patron's
email prefs, or allow forcing of a single method via the cron

To test:
 1 - Create an email hold reminder notice for a single library (Koha module: Holds, code HOLDREMINDER, branch: CPL)
 2 - Set some waiting holds today for patrons at CPL, ensure those patrons have 'email' as the transport for hold filled notices
 3 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL
 4 - You should see the patrons here would have received emails
 5 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL
 6 - You should see the emails that were sent
 7 - Check the patron notices tab to confirm
 8 - Note a ptron with two holds waiting receives only one notice
 9 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
10 - No notices are sent
11 - Adjust the waiting date for the holds:
    UPDATE reserves SET waitingdate=DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE waitingdate = CURDATE();
12 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
13 - Confirm the holds are now reminded
14 - Set yesterday as a holiday for CPL
15 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 3
16 - Notices should not be sent
17 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 4
18 - Notices should be sent again
19 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4
20 - Should get feedback that notice was not found for other libraries
21 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4 -mtt sms
22 - Notice is not found
23 - Add the notice for sms
24 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4 -mtt sms
25 - The notice should be sent
26 - Check patrons messaging tab to confirm
27 - prove -v t/db_dependent/Koha/Patrons.t

Sponsored by: The Hotchkiss School (http://www.hotchkiss.org/)
Comment 27 Nick Clemens 2020-04-14 11:55:44 UTC
(In reply to David Nind from comment #24)
> For step 17, 19, 21, and 24 I'm getting an error message when running the
> script:
> 
> perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL
> -holidays -days 3
> branch CPL passed on parameter
> Can't locate object method "in_units" via package "-3" (perhaps you forgot
> to load "-3"?) at /kohadevbox/koha/Koha/Calendar.pm line 193.

Fixed, thanks David!
Comment 28 David Nind 2020-04-15 17:53:59 UTC
Thanks Nick!

I can now get most things to work, except for steps 17 and 21 - not sure what I'm doing wrong here.

There are reserves table entries: current date = 2020-04-15, waitingdate for items = 2020-04-12, holiday date set (day = 14, month =4, yeare = 20204

Step 17:

perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 4
branch CPL passed on parameter
No reserves found for CPL

Step 21:

perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 4 -mtt sms
No reserves found for CPL
Message 'HOLDREMINDER' content not found for FFL
Message 'HOLDREMINDER' content not found for FPL
...
Comment 29 Martin Renvoize 2020-04-20 13:20:04 UTC
Comment on attachment 102926 [details] [review]
Bug 15986: Add a script for sending hold waiting reminder notices

Review of attachment 102926 [details] [review]:
-----------------------------------------------------------------

::: Koha/Patron.pm
@@ +1695,4 @@
>      };
>  }
>  
> +=head3 send_notice

Hmm, feels like this should be 'queue_notice' rather than 'send_notice'.. that paves the way for a later 'send_notice' which sends immediately vs waiting in the queue.
Comment 30 Katrin Fischer 2020-04-20 16:47:36 UTC
(In reply to Martin Renvoize from comment #29)
> Comment on attachment 102926 [details] [review] [review]
> Bug 15986: Add a script for sending hold waiting reminder notices
> 
> Review of attachment 102926 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> ::: Koha/Patron.pm
> @@ +1695,4 @@
> >      };
> >  }
> >  
> > +=head3 send_notice
> 
> Hmm, feels like this should be 'queue_notice' rather than 'send_notice'..
> that paves the way for a later 'send_notice' which sends immediately vs
> waiting in the queue.

We already have a way to send directly without waiting through the queue - it's used by the self registration and password reset emails: bug 21390

+            my $num_letters_attempted = C4::Letters::SendQueuedMessages( {
+                    letter_code => 'OPAC_REG_VERIFY'
+                    } );
Comment 31 Andrew Fuerste-Henry 2020-05-18 12:25:23 UTC
I'm also getting stuck at step 17. I have my reserves with waiting date set to curdate-3. They properly trigger a notice when not worrying about holidays. But once I set the -holidays flag in the command I cannot get notices to generate, no matter how many days I give it.
Comment 32 Nick Clemens 2020-07-16 16:54:10 UTC
Created attachment 106962 [details] [review]
Bug 15986: Add a script for sending hold waiting reminder notices

This patch adds a script for sending holds reminder notice to patrons.

We add a 'send_notice' routine to Koha::Patrons - this will either send using the patron's
email prefs, or allow forcing of a single method via the cron

To test:
 1 - Create an email hold reminder notice for a single library (Koha module: Holds, code HOLDREMINDER, branch: CPL)
 2 - Set some waiting holds today for patrons at CPL, ensure those patrons have 'email' as the transport for hold filled notices
 3 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL
 4 - You should see the patrons here would have received emails
 5 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL
 6 - You should see the emails that were sent
 7 - Check the patron notices tab to confirm
 8 - Note a ptron with two holds waiting receives only one notice
 9 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
10 - No notices are sent
11 - Adjust the waiting date for the holds:
    UPDATE reserves SET waitingdate=DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE waitingdate = CURDATE();
12 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
13 - Confirm the holds are now reminded
14 - Set yesterday as a holiday for CPL
15 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 3
16 - Notices should not be sent
17 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 2
18 - Notices should be sent again
19 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 2
20 - Should get feedback that notice was not found for other libraries
21 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 2 -mtt sms
22 - Notice is not found
23 - Add the notice for sms
24 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 2 -mtt sms
25 - The notice should be sent
26 - Check patrons messaging tab to confirm
27 - prove -v t/db_dependent/Koha/Patrons.t

Sponsored by: The Hotchkiss School (http://www.hotchkiss.org/)
Comment 33 Nick Clemens 2020-07-16 16:54:13 UTC
Created attachment 106963 [details] [review]
Bug 15986: Update for bug 24159

The job is concerned with holds waiting and takes days, I think using days_mode 'Calendar'
makes sense as we are not calculating due dates
Comment 34 Nick Clemens 2020-07-16 16:54:17 UTC
Created attachment 106964 [details] [review]
Bug 15986: Rename send_notice to queue_notice and update test count
Comment 35 Nick Clemens 2020-07-16 17:04:13 UTC
Adding a holiday means the holds are waiting 1-less day, not 1 more :-)

Fixed the math in the test plan :-)
Comment 36 Séverine Queune 2020-11-03 17:34:10 UTC
This patch works fine !
But I won't sign it because of 2 points : 
- I can't test the sms part, I don't know how it works and how to use the feature
- I've got a question about the content of the message : when there several holds, only the informations about the oldest reserve (for what I saw) are displayed. Fields coming from the items or biblio tables can't be used. I know it's happening for some other notices so don't Failed the patch because of this point, but I regret I couldn't use the <<count>> or <<items.content>> datas as it is recommended for some other notices, I think it could be useful for patron to have some details about the waiting holds.
Comment 37 Andrew Fuerste-Henry 2020-11-04 14:49:08 UTC
Created attachment 112999 [details] [review]
Bug 15986: Add a script for sending hold waiting reminder notices

This patch adds a script for sending holds reminder notice to patrons.

We add a 'send_notice' routine to Koha::Patrons - this will either send using the patron's
email prefs, or allow forcing of a single method via the cron

To test:
 1 - Create an email hold reminder notice for a single library (Koha module: Holds, code HOLDREMINDER, branch: CPL)
 2 - Set some waiting holds today for patrons at CPL, ensure those patrons have 'email' as the transport for hold filled notices
 3 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL
 4 - You should see the patrons here would have received emails
 5 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL
 6 - You should see the emails that were sent
 7 - Check the patron notices tab to confirm
 8 - Note a ptron with two holds waiting receives only one notice
 9 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
10 - No notices are sent
11 - Adjust the waiting date for the holds:
    UPDATE reserves SET waitingdate=DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE waitingdate = CURDATE();
12 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -li CPL -days 3
13 - Confirm the holds are now reminded
14 - Set yesterday as a holiday for CPL
15 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 3
16 - Notices should not be sent
17 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -li CPL -holidays -days 2
18 - Notices should be sent again
19 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 2
20 - Should get feedback that notice was not found for other libraries
21 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 2 -mtt sms
22 - Notice is not found
23 - Add the notice for sms
24 - perl misc/cronjobs/holds_reminder.pl -v -lettercode HOLDREMINDER -n -holidays -days 2 -mtt sms
25 - The notice should be sent
26 - Check patrons messaging tab to confirm
27 - prove -v t/db_dependent/Koha/Patrons.t

Sponsored by: The Hotchkiss School (http://www.hotchkiss.org/)

Signed-off-by: Kim Gnerre <kgnerre@hotchkiss.org>
Comment 38 Andrew Fuerste-Henry 2020-11-04 14:49:11 UTC
Created attachment 113000 [details] [review]
Bug 15986: Update for bug 24159

The job is concerned with holds waiting and takes days, I think using days_mode 'Calendar'
makes sense as we are not calculating due dates

Signed-off-by: Kim Gnerre <kgnerre@hotchkiss.org>
Comment 39 Andrew Fuerste-Henry 2020-11-04 14:49:15 UTC
Created attachment 113001 [details] [review]
Bug 15986: Rename send_notice to queue_notice and update test count

Signed-off-by: Kim Gnerre <kgnerre@hotchkiss.org>
Comment 40 Nick Clemens 2020-11-04 15:24:03 UTC
(In reply to Séverine Queune from comment #36)
> This patch works fine !
> But I won't sign it because of 2 points : 
> - I can't test the sms part, I don't know how it works and how to use the
> feature
> - I've got a question about the content of the message : when there several
> holds, only the informations about the oldest reserve (for what I saw) are
> displayed. Fields coming from the items or biblio tables can't be used. I
> know it's happening for some other notices so don't Failed the patch because
> of this point, but I regret I couldn't use the <<count>> or
> <<items.content>> datas as it is recommended for some other notices, I think
> it could be useful for patron to have some details about the waiting holds.

- sms part works exactly like email up to the sending of the message, so testing is the same, just need to confirm it makes it into the queue

- the notice supports template toolkit, so you can get other holds information like:
Dear [% borrower.firstname %] [% borrower.surname %],

Your hold for [% hold.biblio.title %] is waiting since [% hold.waitingdate %]

[% IF borrower.holds.count > 0 %]
  You also have other holds:
  [% FOREACH hold IN borrower.holds %]
    [% hold.biblio.title %] : [% hold.found %]
  [% END %]
[% END %]

That could be cleaned up and made fancier, but just to give an idea
Comment 41 Séverine Queune 2020-11-04 15:28:01 UTC
(In reply to Nick Clemens from comment #40)
> (In reply to Séverine Queune from comment #36)
> > This patch works fine !
> > But I won't sign it because of 2 points : 
> > - I can't test the sms part, I don't know how it works and how to use the
> > feature
> > - I've got a question about the content of the message : when there several
> > holds, only the informations about the oldest reserve (for what I saw) are
> > displayed. Fields coming from the items or biblio tables can't be used. I
> > know it's happening for some other notices so don't Failed the patch because
> > of this point, but I regret I couldn't use the <<count>> or
> > <<items.content>> datas as it is recommended for some other notices, I think
> > it could be useful for patron to have some details about the waiting holds.
> 
> - sms part works exactly like email up to the sending of the message, so
> testing is the same, just need to confirm it makes it into the queue
> 
> - the notice supports template toolkit, so you can get other holds
> information like:
> Dear [% borrower.firstname %] [% borrower.surname %],
> 
> Your hold for [% hold.biblio.title %] is waiting since [% hold.waitingdate %]
> 
> [% IF borrower.holds.count > 0 %]
>   You also have other holds:
>   [% FOREACH hold IN borrower.holds %]
>     [% hold.biblio.title %] : [% hold.found %]
>   [% END %]
> [% END %]
> 
> That could be cleaned up and made fancier, but just to give an idea

Thanks Nick !
I completely forgot we could use template toolkit
#ashamed... 
Do you need a second sign off for that one ?
Comment 42 Victor Grousset/tuxayo 2020-12-29 15:23:50 UTC
Can't QA this one but got a question about -holidays, why is it better to not take them into account by default? I don't have much functional experience so I might miss something obvious ^^
Comment 43 Andrew Fuerste-Henry 2020-12-29 15:29:13 UTC
The various sysprefs that determine whether or not to consult the calendar for various tasks are inconsistent in a new install -- some are on and some are off. However, ExcludeHolidaysFromMaxPickUpDelay defaults to off. That's not exactly the same as the --holiday flag here, but seems close enough that I'm happy to make this new feature keep the same default choice.
Comment 44 Victor Grousset/tuxayo 2020-12-29 21:08:34 UTC
> The various sysprefs that determine whether or not to consult the calendar for various tasks are inconsistent in a new install

:o

> However, ExcludeHolidaysFromMaxPickUpDelay defaults to off. That's not exactly the same as the --holiday flag here, but seems close enough that I'm happy to make this new feature keep the same default choice.

Thanks for the analysis. Is there an obviously less surprising default choice there? Or does it depend too much?
Comment 45 Andrew Fuerste-Henry 2020-12-29 21:21:29 UTC
I don't really get the sense one option is more standard or more likely to be correct for any given library -- it's just one of those things one ends up asking every new library about. Same with UseDaysMode, finesCalendar, OverdueNoticeCalendar, etc.
Comment 46 Victor Grousset/tuxayo 2021-01-01 17:59:25 UTC
Good, there doesn't seem to be a bad choice.
Thanks for the info Andrew, that was my 2 cents, I'll leave the rest to more knowledgeable people ^^"