Bug 40791 - Allow choice of which Overdue messages can be patron preferences
Summary: Allow choice of which Overdue messages can be patron preferences
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on: 30515
Blocks:
  Show dependency treegraph
 
Reported: 2025-09-11 10:42 UTC by Philip Orr
Modified: 2025-10-02 09:26 UTC (History)
3 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40791: Allow choice of which Overdue messages can be patron preferences (11.01 KB, patch)
2025-09-23 13:08 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40791: Allow choice of which Overdue messages can be patron preferences (11.05 KB, patch)
2025-10-02 08:40 UTC, Philip Orr
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Orr 2025-09-11 10:42:30 UTC
In Bug 30515, we are discussing adding a new system preference UsePatronPreferencesForOverdueNotices to let patrons control which overdue messages are sent by mail in their messaging preferences.
For many libraries it would still be necessary to set a certain overdue notice (say the third overdue notice) as "mandatory for print message".
Jonathan suggested to reuse the aforementioned pref and make it multivaluated with 3 values possible: ODUE, ODUE2, ODUE3. Then:
- if at least one is selected then patrons can edit it/them 
- if none selected, we don't allow the patrons to modify any
This would be the simplest way to extend the functionality of Bug 30515.
Comment 1 Jonathan Druart 2025-09-23 13:08:02 UTC
Created attachment 186799 [details] [review]
Bug 40791: Allow choice of which Overdue messages can be patron preferences

In Bug 30515, we are discussing adding a new system preference
UsePatronPreferencesForOverdueNotices to let patrons control which
overdue messages are sent by mail in their messaging preferences.
For many libraries it would still be necessary to set a certain overdue
notice (say the third overdue notice) as "mandatory for print message".

On this patch we reuse the aforementioned pref and make it multivaluated with
3 values possible: Overdue1, Overdue2 and Overdue 3.

Then:
- if at least one is selected then patrons can edit it/them
- if none selected, we don't allow the patrons to modify any

Test plan:
Select 2 values of the pref and confirm that it does not appear from the
messaging form (staff and opac)
Run the cronjob script and confirm that the patron's preferences are
taken into account for the 2 values you selected.
Comment 2 Philip Orr 2025-10-02 08:30:32 UTC
After applying the patch, "updatedatabase" warns:

Use of uninitialized value $type in string ne at /kohadevbox/koha/installer/data/mysql/atomicupdate/bug_40791.pl line 13.

Don't know if that's important.
QA passes with no fails.
Comment 3 Philip Orr 2025-10-02 08:40:03 UTC
Created attachment 187245 [details] [review]
Bug 40791: Allow choice of which Overdue messages can be patron preferences

In Bug 30515, we are discussing adding a new system preference
UsePatronPreferencesForOverdueNotices to let patrons control which
overdue messages are sent by mail in their messaging preferences.
For many libraries it would still be necessary to set a certain overdue
notice (say the third overdue notice) as "mandatory for print message".

On this patch we reuse the aforementioned pref and make it multivaluated with
3 values possible: Overdue1, Overdue2 and Overdue 3.

Then:
- if at least one is selected then patrons can edit it/them
- if none selected, we don't allow the patrons to modify any

Test plan:
Select 2 values of the pref and confirm that it does not appear from the
messaging form (staff and opac)
Run the cronjob script and confirm that the patron's preferences are
taken into account for the 2 values you selected.

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 4 Philip Orr 2025-10-02 08:45:45 UTC
For the test plan:
1. You will need three different ODUE.. notices
2. make sure they all have different "Email" and "Print" content,
this way it is easier to spot later
3. Set up overdue notice triggers with all three set to print for a certain patron type
4. Select the first two in UsePatronPreferencesForOverdueNotices
5. build three test cases for patrons of that type with overdue items
6. on one of them, in their messaging prefs, set both "overdue 1" and "overdue 2" to mail and make sure they have a mail address entered in their data
6a. this patron should get 1 and 2 per mail and 3 per print
7. on another, give them a mail address but do not check any boxes in their messaging prefs
7a. this patron should get all 3 per print
8. on the third patron, set the preferences but make sure they don't have a mail address
8a. this patron should also get all 3 per print
9. run overdue_notices.pl and gather_print_notices.pl
10. check if each patron got the proper transport type for their notices.

(I also tested checking only "overdue 1" and leaving "overdue 2" unchecked, that also results as expected in 1 = mail and 2 and 3 = both print.)
Works as expected.
Comment 5 Jonathan Druart 2025-10-02 09:26:11 UTC
(In reply to Philip Orr from comment #2)
> After applying the patch, "updatedatabase" warns:
> 
> Use of uninitialized value $type in string ne at
> /kohadevbox/koha/installer/data/mysql/atomicupdate/bug_40791.pl line 13.
> 
> Don't know if that's important.
> QA passes with no fails.

Hum I don't see this warning. It means that "type" for UsePatronPreferencesForOverdueNotices in not defined. It is supposed to be "YesNo".

It could happen if this db rev is run before the one from 30515, but it should not happen as they are run in order.

Koha/Installer.pm
 75     my $update_dir = $intranetdir . '/installer/data/mysql/atomicupdate/';                            
 76     opendir( my $dirh, $update_dir );                                                                 
 77     my @stuff = sort readdir $dirh;