Bug 30515

Summary: Move Overdue transports to patron messaging preferences
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: CirculationAssignee: Jonathan Druart <jonathan.druart>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: 1joynelson, andrew, bugzilla, cbrannon, dcook, glasklas, gmcharlt, jonathan.druart, kyle, lucas, m.de.rooy, martin.renvoize, philip.orr
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12771
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33459
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36006
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on:    
Bug Blocks: 40791    
Attachments: Fetch patron specific message preferences for overdue messages and use them instead of patron category level preferences
Bug 30515: Move Overdue transports to patron messaging preferences
Bug 30515: Move Overdue transports to patron messaging preferences
Bug 30515: Move Overdue transports to patron messaging preferences
Bug 30515: Move Overdue transports to patron messaging preferences
Bug 30515: Fix messaging options order and add database changes
Bug 30515: Fix messaging options order and add database changes
Bug 30515: Move Overdue transports to patron messaging preferences
Bug 30515: Fix messaging options order and add database changes
Bug 30515: Fix messaging options order and add database changes
Bug 30515: (follow-up) Fix messaging options order and add database changes
Bug 30515: Fix OPAC form
Bug 30515: fix GetMessagingPreferences call
Bug 30515: Remove UsePatronPreferencesForOverdueNoticesPrint
Bug 30515: Use print if the patron's preference is empty
Bug 30515: Use print if the patron's preference is empty
Bug 30515: QA fixes
Bug 30515: Move Overdue transports to patron messaging preferences
Bug 30515: Fix messaging options order and add database changes
Bug 30515: (follow-up) Fix messaging options order and add database changes
Bug 30515: Fix OPAC form
Bug 30515: fix GetMessagingPreferences call
Bug 30515: Remove UsePatronPreferencesForOverdueNoticesPrint
Bug 30515: Use print if the patron's preference is empty
Bug 30515: QA fixes

Description Nick Clemens (kidclamp) 2022-04-12 15:47:55 UTC
The idea of this bug would be to allow patrons to choose which format they would like to receive their overdues in while maintaining at least one selection as mandatory
Comment 1 Katrin Fischer 2022-04-12 20:29:36 UTC
Some libraries need to send the third notice as print or even all of them. I like the idea of having at least one mandatory, so you can't opt out, but could we also have an option to not have it appear in the messaging preferences?
Comment 2 Nick Clemens (kidclamp) 2022-04-20 14:25:39 UTC
Do you mean an option to not have a given transport appear in preferences?
Or an option to not show preferences for ODUE2, and only ODUE1?

I think we envisioned a single preference for overdues - the triggers still controlling which ones we send
Comment 3 Katrin Fischer 2022-04-21 22:40:43 UTC
I'd like an option to not have the overdue notices appear at all or only as read only.

I think a single preference for all overdues notice levels would not work without regressions. At the moment you can set the transport preferences in staff individually for each notice and can even opt to have multiple transports for each (send by email AND print).
Comment 4 Joy Nelson 2022-06-14 16:47:58 UTC
Katrin, and all other interested parties!
We have written the following brief proposal below.  This proposal provides an option for libraries to allow patrons to select preferences for their overdue messages.  We are looking to balance the patron's ability to set a preference with the library's ability to control messaging related to overdues. 

We appreciate everyone's feedback on this proposal:
 

Add two checkboxes to each transport type in the Overdue Triggers matrix. 
   1.  Enabled:  Will the library send a notice in this transport type?
   2. Mandatory: When checked, this transport is the way that this message is sent.  (multiple transport types can be selected) Patron preferences will be ignored in favor of the transport the library has indicated as mandatory.

Add matrix of Overdue Message Preferences in the Patron Message Preference screen.  The matrix will contain the 3 Overdue messages (odue1,odue2,odue3) and patrons will be able to indicate their preferences for receiving these messages.  This matrix will appear on opac and staff side depending on EnhancedMessage System Preference.

Add an additional System preference to control whether patron can edit the Overdue messaging preferences.
  If enabled -- Show a BOLD message that they can choose their preferences but library policies may override their choice (see Mandatory above)
    Patrons will be forced to select at least one transport type.
  If disabled -- Show a read only matrix of the patron's libraries (or default) transport types that are set in Overdue triggers and a note that other library policies may override the patron's libraries settings.
Comment 5 Andrew Fuerste-Henry 2022-09-30 13:52:48 UTC
(In reply to Joy Nelson from comment #4)
> Katrin, and all other interested parties!
> We have written the following brief proposal below.  This proposal provides
> an option for libraries to allow patrons to select preferences for their
> overdue messages.  We are looking to balance the patron's ability to set a
> preference with the library's ability to control messaging related to
> overdues. 
> 
> We appreciate everyone's feedback on this proposal:
>  
> 
> Add two checkboxes to each transport type in the Overdue Triggers matrix. 
>    1.  Enabled:  Will the library send a notice in this transport type?
>    2. Mandatory: When checked, this transport is the way that this message
> is sent.  (multiple transport types can be selected) Patron preferences will
> be ignored in favor of the transport the library has indicated as mandatory.
> 
> Add matrix of Overdue Message Preferences in the Patron Message Preference
> screen.  The matrix will contain the 3 Overdue messages (odue1,odue2,odue3)
> and patrons will be able to indicate their preferences for receiving these
> messages.  This matrix will appear on opac and staff side depending on
> EnhancedMessage System Preference.
> 
> Add an additional System preference to control whether patron can edit the
> Overdue messaging preferences.
>   If enabled -- Show a BOLD message that they can choose their preferences
> but library policies may override their choice (see Mandatory above)
>     Patrons will be forced to select at least one transport type.
>   If disabled -- Show a read only matrix of the patron's libraries (or
> default) transport types that are set in Overdue triggers and a note that
> other library policies may override the patron's libraries settings.

This sounds like a good balance of flexibility and control! +1 and then +1 again for good measure :)
Comment 6 Jonathan Druart 2022-10-14 13:41:57 UTC
I don't think we should hardcode the 3 codes. It will make harder to improve this area (like bug 12771).
Comment 7 Katrin Fischer 2023-10-29 10:01:32 UTC
I think the last bit about the display in the OPAC could maybe be simplified, but I like the optional/mandatory approach.

Right now the notices are hardcoded to 3 levels, we could try to make the code more flexible, but it feels like it might things more complex while there is no development on bug 12771. Maybe easier to do it once it's actually required.
Comment 8 David Gustafsson 2024-03-20 16:40:58 UTC
I'm currently going through our local branches that has not yet been submitted to bugzilla, and we have an implementation for enabling per patron overdue notice messaging preference. This was added before taking part of any of the discussion here and attaching it as is. With regards to the print behavior we added a setting to select whether to always print, print if no other transport is set, or never print. A third possible option could be to fallback to the print setting for the patron category and library. I'm not to familiar with how much flexibility is needed for printing, and the third option seems a little bit overkill, but if there is a use case it could be added.
Comment 9 David Gustafsson 2024-03-20 16:41:26 UTC
Created attachment 163564 [details] [review]
Fetch patron specific message preferences for overdue messages and use them instead of patron category level preferences
Comment 10 David Gustafsson 2024-03-20 17:23:53 UTC
Created attachment 163573 [details] [review]
Bug 30515: Move Overdue transports to patron messaging preferences

Add syspref for using patron specific message preferences for
overdue messages instead of patron category level preferences.

To test:
1) Set UsePatronPreferencesForOverdueNotices "individual patron preference"
2) Enable some transport for a patron in the messaging preferences form
2) Check out an item and set a due date that will result in an overdue notice
4) Run the overdue_notices.pl script
5) Verify that messages has been sent for the selected transport(s)
6) Run gather_print_notices.pl and verify a print notice is generated
7) Set UsePatronPreferencesForOverdueNotices to "when no other transport
   set"
8) Run the overdue_notices.pl and gather_print_notices.pl and verify
   that no print notice is generated
9) Disable all transports for the patron
10) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that print notice is generated
11)  Set UsePatronPreferencesForOverdueNotices to "never"
12) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated
13) Enable some transport(s) for the patron
14) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated

Sponsored-by: Gothenburg University Library
Comment 11 David Gustafsson 2024-03-20 17:28:40 UTC
Created attachment 163574 [details] [review]
Bug 30515: Move Overdue transports to patron messaging preferences

Add syspref for using patron specific message preferences for
overdue messages instead of patron category level preferences.

To test:
1) Set UsePatronPreferencesForOverdueNotices to "individual patron preference"
2) Enable some transport for a patron in the messaging preferences form
2) Check out an item and set a due date that will result in an overdue notice
4) Run the overdue_notices.pl script
5) Verify that messages has been sent for the selected transport(s)
6) Run gather_print_notices.pl and verify a print notice is generated
7) Set UsePatronPreferencesForOverdueNotices to "when no other transport
   set"
8) Run the overdue_notices.pl and gather_print_notices.pl and verify
   that no print notice is generated
9) Disable all transports for the patron
10) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that print notice is generated
11)  Set UsePatronPreferencesForOverdueNotices to "never"
12) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated
13) Enable some transport(s) for the patron
14) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated
15) Set UsePatronPreferencesForOverdueNotices to "patron category"
16) Run the overdue_notices.pl and gather_print_notices.pl and verify
    the patron category and library setting is used

Sponsored-by: Gothenburg University Library
Comment 12 Lucas Gass (lukeg) 2024-03-21 18:16:12 UTC
Looks promising. 

With this patch applied and UsePatronPreferencesForOverdueNotices set to "individual patron preference" I do not see the Overdue messaging preferences on the patron form. 

Maybe GetMessagingOptions (C4/Members/Messaging.pm) needs to be updated so it can retrieve Overdue1, Overdue2, and Overdue3? 


Thanks for working on this!
Comment 13 David Gustafsson 2025-02-18 14:41:55 UTC
Created attachment 178276 [details] [review]
Bug 30515: Move Overdue transports to patron messaging preferences

Add syspref for using patron specific message preferences for
overdue messages instead of patron category level preferences.

To test:
1) Set UsePatronPreferencesForOverdueNotices to "individual patron preference"
2) Enable some transport for a patron in the messaging preferences form
2) Check out an item and set a due date that will result in an overdue notice
4) Run the overdue_notices.pl script
5) Verify that messages has been sent for the selected transport(s)
6) Run gather_print_notices.pl and verify a print notice is generated
7) Set UsePatronPreferencesForOverdueNotices to "when no other transport
   set"
8) Run the overdue_notices.pl and gather_print_notices.pl and verify
   that no print notice is generated
9) Disable all transports for the patron
10) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that print notice is generated
11)  Set UsePatronPreferencesForOverdueNotices to "never"
12) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated
13) Enable some transport(s) for the patron
14) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated
15) Set UsePatronPreferencesForOverdueNotices to "patron category"
16) Run the overdue_notices.pl and gather_print_notices.pl and verify
    the patron category and library setting is used

Sponsored-by: Gothenburg University Library
Comment 14 David Gustafsson 2025-02-18 14:48:28 UTC
(In reply to Lucas Gass (lukeg) from comment #12)
> Looks promising. 
> 
> With this patch applied and UsePatronPreferencesForOverdueNotices set to
> "individual patron preference" I do not see the Overdue messaging
> preferences on the patron form. 
> 
> Maybe GetMessagingOptions (C4/Members/Messaging.pm) needs to be updated so
> it can retrieve Overdue1, Overdue2, and Overdue3? 
> 
> 
> Thanks for working on this!

Thanks for the feedback, it was a while since I had a look at this so spontaneously don't know what the issue could be, but I will try too look into to it and have a look at your suggestion.
Comment 15 David Gustafsson 2025-02-24 12:46:36 UTC
Created attachment 178548 [details] [review]
Bug 30515: Move Overdue transports to patron messaging preferences

Add syspref for using patron specific message preferences for
overdue messages instead of patron category level preferences.

To test:
1) Set UsePatronPreferencesForOverdueNotices to "individual patron preference"
2) Enable some transport for a patron in the messaging preferences form
2) Check out an item and set a due date that will result in an overdue notice
4) Run the overdue_notices.pl script
5) Verify that messages has been sent for the selected transport(s)
6) Run gather_print_notices.pl and verify a print notice is generated
7) Set UsePatronPreferencesForOverdueNotices to "when no other transport
   set"
8) Run the overdue_notices.pl and gather_print_notices.pl and verify
   that no print notice is generated
9) Disable all transports for the patron
10) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that print notice is generated
11)  Set UsePatronPreferencesForOverdueNotices to "never"
12) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated
13) Enable some transport(s) for the patron
14) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated
15) Set UsePatronPreferencesForOverdueNotices to "patron category"
16) Run the overdue_notices.pl and gather_print_notices.pl and verify
    the patron category and library setting is used

Sponsored-by: Gothenburg University Library
Comment 16 David Gustafsson 2025-02-24 12:46:39 UTC
Created attachment 178549 [details] [review]
Bug 30515: Fix messaging options order and add database changes
Comment 17 David Gustafsson 2025-02-24 12:59:11 UTC
The issue was there was some entries in message_transports and message_attributes missing that I guess for hour installation we have added manually without including in the patch, now added to atomic update. Database entries also needed to be added to sample_notices_message_attributes.sql and sample_notices_message_transports.sql.

The patch assumes there exists ODUE2 and ODUE3, so added default samples in sample_notices.yml. The content is equivalent to ODUE, except I added "This is the second reminder", and "This is the third reminder" suggestions are welcome if it should differ in some other way.

Order for Overdue1, Overdue2, and Overdue3 is now also set in GetMessagingOptions, so the preferences are listed in the correct order.
Comment 18 David Gustafsson 2025-02-24 12:59:54 UTC
Created attachment 178550 [details] [review]
Bug 30515: Fix messaging options order and add database changes
Comment 19 David Gustafsson 2025-02-24 13:01:04 UTC
(In reply to David Gustafsson from comment #17)
> The issue was there was some entries in message_transports and
> message_attributes missing that I guess for hour installation we have added
> manually without including in the patch, now added to atomic update.
> Database entries also needed to be added to
> sample_notices_message_attributes.sql and
> sample_notices_message_transports.sql.
> 
> The patch assumes there exists ODUE2 and ODUE3, so added default samples in
> sample_notices.yml. The content is equivalent to ODUE, except I added "This
> is the second reminder", and "This is the third reminder" suggestions are
> welcome if it should differ in some other way.
> 
> Order for Overdue1, Overdue2, and Overdue3 is now also set in
> GetMessagingOptions, so the preferences are listed in the correct order.

Mistyped, should be "This is the final reminder".
Comment 20 Philip Orr 2025-04-30 08:11:02 UTC
Seems it doesn't apply:
Using index info to reconstruct a base tree...
M       C4/Members/Messaging.pm
M       installer/data/mysql/en/mandatory/sample_notices.yml
Falling back to patching base and 3-way merge...
Auto-merging installer/data/mysql/en/mandatory/sample_notices.yml
CONFLICT (content): Merge conflict in installer/data/mysql/en/mandatory/sample_notices.yml
Removing installer/data/mysql/atomicupdate/bug_30515-add_system_preferences.pl
Auto-merging C4/Members/Messaging.pm
error: Failed to merge in the changes.
Patch failed at 0001 Bug 30515: Fix messaging options order and add database changes

Happy to sign off if you rebase :)
Comment 21 Jonathan Druart 2025-09-04 12:39:50 UTC
Created attachment 186143 [details] [review]
Bug 30515: Move Overdue transports to patron messaging preferences

Add syspref for using patron specific message preferences for
overdue messages instead of patron category level preferences.

To test:
1) Set UsePatronPreferencesForOverdueNotices to "individual patron preference"
2) Enable some transport for a patron in the messaging preferences form
2) Check out an item and set a due date that will result in an overdue notice
4) Run the overdue_notices.pl script
5) Verify that messages has been sent for the selected transport(s)
6) Run gather_print_notices.pl and verify a print notice is generated
7) Set UsePatronPreferencesForOverdueNotices to "when no other transport
   set"
8) Run the overdue_notices.pl and gather_print_notices.pl and verify
   that no print notice is generated
9) Disable all transports for the patron
10) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that print notice is generated
11)  Set UsePatronPreferencesForOverdueNotices to "never"
12) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated
13) Enable some transport(s) for the patron
14) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated
15) Set UsePatronPreferencesForOverdueNotices to "patron category"
16) Run the overdue_notices.pl and gather_print_notices.pl and verify
    the patron category and library setting is used

Sponsored-by: Gothenburg University Library
Comment 22 Jonathan Druart 2025-09-04 12:39:52 UTC
Created attachment 186144 [details] [review]
Bug 30515: Fix messaging options order and add database changes
Comment 23 Jonathan Druart 2025-09-04 12:43:43 UTC
Created attachment 186145 [details] [review]
Bug 30515: Fix messaging options order and add database changes
Comment 24 Jonathan Druart 2025-09-04 12:50:30 UTC
Created attachment 186146 [details] [review]
Bug 30515: (follow-up) Fix messaging options order and add database changes
Comment 25 Jonathan Druart 2025-09-04 12:50:32 UTC
Created attachment 186147 [details] [review]
Bug 30515: Fix OPAC form
Comment 26 Jonathan Druart 2025-09-04 12:58:21 UTC
Patches rebased and added a couple of bug fixes, so Philip can test :)
Comment 27 Philip Orr 2025-09-08 12:35:05 UTC
Thanks joubu!
Running "qa" gives the following result:

Result:
[PASS] C4/Members/Messaging.pm
[FAIL] installer/data/mysql/atomicupdate/bug_30515-add_system_preferences.pl
   FAIL   git_manipulation
                The file has been added and deleted or renamed in the same patchset
[FAIL] installer/data/mysql/atomicupdate/bug_30515-move_overdue_transports_to_patron_messaging_preferences.pl
   FAIL   file_permissions
                File must have the exec flag
   FAIL   tidiness
                File is not tidy, please run `perl misc/devel/tidy.pl installer/data/mysql/atomicupdate/bug_30515-move_overdue_transports_to_patron_messaging_preferences.pl`
[PASS] installer/data/mysql/en/mandatory/sample_notices.yml
[PASS] installer/data/mysql/mandatory/sample_notices_message_attributes.sql
[PASS] installer/data/mysql/mandatory/sample_notices_message_transports.sql
[PASS] installer/data/mysql/mandatory/sysprefs.sql
[PASS] koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc
[PASS] koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt
[PASS] koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
[PASS] koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt
[FAIL] misc/cronjobs/overdue_notices.pl
   FAIL   tidiness
                File is not tidy, please run `perl misc/devel/tidy.pl misc/cronjobs/overdue_notices.pl`

Processing additional checks PASS!
Comment 28 Philip Orr 2025-09-08 12:40:52 UTC Comment hidden (obsolete)
Comment 29 Philip Orr 2025-09-08 12:43:28 UTC Comment hidden (obsolete)
Comment 30 Philip Orr 2025-09-08 12:49:31 UTC
At step 4), when running overdue_notices.pl, I get the following error:

Undefined subroutine &main::GetMessagingPreferences called at overdue_notices.pl line 753.

I was testing to see what happens when a patron sets the preferences to "Email" but forgets to actually provide their email address (that is, leaves all their email fields empty). But I get the error no matter if there is an address defined or not, so I don't think it's related to that.
Comment 31 Jonathan Druart 2025-09-08 13:36:52 UTC
Created attachment 186258 [details] [review]
Bug 30515: fix GetMessagingPreferences call

It's not exported
Comment 32 Jonathan Druart 2025-09-08 13:37:40 UTC
(In reply to Philip Orr from comment #27)
> Thanks joubu!
> Running "qa" gives the following result:

Let's ignore for now, it's just cosmetics.

(In reply to Philip Orr from comment #30)
> At step 4), when running overdue_notices.pl, I get the following error:
> 
> Undefined subroutine &main::GetMessagingPreferences called at
> overdue_notices.pl line 753.

Last patch *should* fix that error.
Comment 33 Philip Orr 2025-09-08 14:19:21 UTC
Yes, that fixed it!
On to the next error:
at step 4) Running overdue_notices.pl now gives the following error:

No circulation ODUE letter transported by shift at /kohadevbox/koha/C4/Letters.pm line 601.

I tested with a patron who had set her messaging preference for "Overdue 1" to "Mail".
However the e-mail version of the ODUE letter was indeed created, so it worked as intended aside from the error.
Maybe the error is more related to the print version of the letter not being created, because I tested it with another patron, this time no check mark set for "Overdue 1" and with the overdue notice/status trigger for overdue 1 set to "print only"; and got the same error. So step 6) is currently failing for me, as (of course after running gather_print_notices.pl) there was still no print notice for this patron.
Comment 34 Jonathan Druart 2025-09-09 08:14:02 UTC
(In reply to Philip Orr from comment #33)
> Yes, that fixed it!
> On to the next error:
> at step 4) Running overdue_notices.pl now gives the following error:
> 
> No circulation ODUE letter transported by shift at
> /kohadevbox/koha/C4/Letters.pm line 601.

For the record, this error is fixed with the following change:

diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl
index e7977108116..f090631cc3c 100755
--- a/misc/cronjobs/overdue_notices.pl
+++ b/misc/cronjobs/overdue_notices.pl
@@ -759,7 +759,7 @@ END_SQL
                     if (   $print_behavior eq 'always'
                         || $print_behavior eq 'fallback' && !@message_transport_types )
                     {
-                        unshift( @message_transport_types, 'shift' );
+                        unshift( @message_transport_types, 'print' );
                     }
                 } else {
                     my @message_transport_types =
Comment 35 Jonathan Druart 2025-09-09 08:16:14 UTC
However I don't understand the point of this syspref (UsePatronPreferencesForOverdueNoticesPrint), or at least it's not correctly handled in the different places (like why do you let patrons chose "email" if "print" will be forced anyway?).

I think it would be better to restart here with only UsePatronPreferencesForOverdueNotices, then iterate on a separate bug if we want the "force print" behaviour.
Comment 36 Jonathan Druart 2025-09-09 08:22:16 UTC
(In reply to Jonathan Druart from comment #35)
> However I don't understand the point of this syspref
> (UsePatronPreferencesForOverdueNoticesPrint), or at least it's not correctly
> handled in the different places (like why do you let patrons chose "email"
> if "print" will be forced anyway?).

Actually one "email" and one "print" notices are sent to the patron if  UsePatronPreferencesForOverdueNoticesPrint = always.
Comment 37 Jonathan Druart 2025-09-09 08:24:50 UTC
Created attachment 186272 [details] [review]
Bug 30515: Remove UsePatronPreferencesForOverdueNoticesPrint
Comment 38 Philip Orr 2025-09-09 09:08:24 UTC
Step 7 is no longer needed as the syspref doesn't have this option anymore:
7) Set UsePatronPreferencesForOverdueNotices to "when no other transport
   set"
Comment 39 Philip Orr 2025-09-09 09:15:43 UTC
Tests were successful now after the changes, no more errors.
That said:
I think I now know why UsePatronPreferencesForOverdueNoticesPrint was added.

If you have "UsePatronPreferencesForOverdueNotices" set to "Patron preference", but the patron has not checked any of the boxes for the Overdue notices in their preferences, then simply no overdue notice will be generated for them at all.
Neither mail nor print.

I would expect not checking the box to be equivalent to saying "I want the print notice".
That is:
if box is checked - mail
if box is not checked - print
(if box is checked but patron doesn't even have a mail address - also print)
Comment 40 Philip Orr 2025-09-09 09:16:31 UTC
(and for the record, I don't think UsePatronPreferencesForOverdueNoticesPrint would be the right way to do that, because it was always creating a print version no matter what the patron had set in their preferences!)
Comment 41 Jonathan Druart 2025-09-09 09:47:46 UTC
Created attachment 186278 [details] [review]
Bug 30515: Use print if the patron's preference is empty

If the patron has not selected a transport type we still want to print.
ie. the patrons cannot totally opt out.
Comment 42 Philip Orr 2025-09-09 09:52:23 UTC
Running overdue_notices.pl now gives the following error:

[]
Warning: something's wrong at overdue_notices.pl line 761.
[]
Warning: something's wrong at overdue_notices.pl line 767.
[
    [0] "print"
]
print at overdue_notices.pl line 773.
Comment 43 Jonathan Druart 2025-09-09 10:01:38 UTC
Created attachment 186280 [details] [review]
Bug 30515: Use print if the patron's preference is empty

If the patron has not selected a transport type we still want to print.
ie. the patrons cannot totally opt out.
Comment 44 Jonathan Druart 2025-09-09 10:01:46 UTC
(In reply to Philip Orr from comment #42)
> Running overdue_notices.pl now gives the following error:

Oops, not errors but debugging statements.
Comment 45 Philip Orr 2025-09-09 10:57:37 UTC Comment hidden (obsolete)
Comment 46 Philip Orr 2025-09-09 11:59:40 UTC Comment hidden (obsolete)
Comment 47 Philip Orr 2025-09-09 12:06:44 UTC Comment hidden (obsolete)
Comment 48 Philip Orr 2025-09-09 12:12:25 UTC
Oops, nevermind that comment either.
ODUE2 and ODUE3 were just missing the [%- USE Price -%] at the top of the content.
After fixing that it now works. :)
Comment 49 Philip Orr 2025-09-09 12:18:17 UTC
OK, I went through the test plan and it now all works as expected.
Happy to sign off on it after the QA polishing / fixes.
Comment 50 Jonathan Druart 2025-09-09 12:34:24 UTC
Created attachment 186287 [details] [review]
Bug 30515: QA fixes

[FAIL] installer/data/mysql/atomicupdate/bug_30515-add_system_preferences.pl
   FAIL   git_manipulation
                The file has been added and deleted or renamed in the same patchset

=> Keeping for ownership

[FAIL] installer/data/mysql/atomicupdate/bug_30515-move_overdue_transports_to_patron_messaging_preferences.pl
   FAIL   file_permissions
                File must have the exec flag

=> Fixed

   FAIL   forbidden_patterns
                forbidden pattern: Have you considered sharing the new syspref to HEA? (see bug 23849 and C4/UsageStats.pm) (line 39)

=> We ignore this for now

[FAIL] installer/data/mysql/mandatory/sysprefs.sql
   FAIL   semicolon
                semicolon found instead of comma at line 896

=> Invalid (because of "no new line")
Comment 51 Philip Orr 2025-09-09 12:54:03 UTC
Created attachment 186288 [details] [review]
Bug 30515: Move Overdue transports to patron messaging preferences

Add syspref for using patron specific message preferences for
overdue messages instead of patron category level preferences.

To test:
1) Set UsePatronPreferencesForOverdueNotices to "individual patron preference"
2) Enable some transport for a patron in the messaging preferences form
2) Check out an item and set a due date that will result in an overdue notice
4) Run the overdue_notices.pl script
5) Verify that messages has been sent for the selected transport(s)
6) Run gather_print_notices.pl and verify a print notice is generated
7) Set UsePatronPreferencesForOverdueNotices to "when no other transport
   set"
8) Run the overdue_notices.pl and gather_print_notices.pl and verify
   that no print notice is generated
9) Disable all transports for the patron
10) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that print notice is generated
11)  Set UsePatronPreferencesForOverdueNotices to "never"
12) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated
13) Enable some transport(s) for the patron
14) Run the overdue_notices.pl and gather_print_notices.pl and verify
    that no print notice is generated
15) Set UsePatronPreferencesForOverdueNotices to "patron category"
16) Run the overdue_notices.pl and gather_print_notices.pl and verify
    the patron category and library setting is used

Sponsored-by: Gothenburg University Library
Signed-off-by: krimsonkharne <philip.orr@posteo.de>
Comment 52 Philip Orr 2025-09-09 12:54:06 UTC
Created attachment 186289 [details] [review]
Bug 30515: Fix messaging options order and add database changes

Signed-off-by: krimsonkharne <philip.orr@posteo.de>
Comment 53 Philip Orr 2025-09-09 12:54:09 UTC
Created attachment 186290 [details] [review]
Bug 30515: (follow-up) Fix messaging options order and add database changes

Signed-off-by: krimsonkharne <philip.orr@posteo.de>
Comment 54 Philip Orr 2025-09-09 12:54:11 UTC
Created attachment 186291 [details] [review]
Bug 30515: Fix OPAC form

Signed-off-by: krimsonkharne <philip.orr@posteo.de>
Comment 55 Philip Orr 2025-09-09 12:54:14 UTC
Created attachment 186292 [details] [review]
Bug 30515: fix GetMessagingPreferences call

It's not exported

Signed-off-by: krimsonkharne <philip.orr@posteo.de>
Comment 56 Philip Orr 2025-09-09 12:54:16 UTC
Created attachment 186293 [details] [review]
Bug 30515: Remove UsePatronPreferencesForOverdueNoticesPrint

Signed-off-by: krimsonkharne <philip.orr@posteo.de>
Comment 57 Philip Orr 2025-09-09 12:54:19 UTC
Created attachment 186294 [details] [review]
Bug 30515: Use print if the patron's preference is empty

If the patron has not selected a transport type we still want to print.
ie. the patrons cannot totally opt out.

Signed-off-by: krimsonkharne <philip.orr@posteo.de>
Comment 58 Philip Orr 2025-09-09 12:54:21 UTC
Created attachment 186295 [details] [review]
Bug 30515: QA fixes

[FAIL] installer/data/mysql/atomicupdate/bug_30515-add_system_preferences.pl
   FAIL   git_manipulation
                The file has been added and deleted or renamed in the same patchset

=> Keeping for ownership

[FAIL] installer/data/mysql/atomicupdate/bug_30515-move_overdue_transports_to_patron_messaging_preferences.pl
   FAIL   file_permissions
                File must have the exec flag

=> Fixed

   FAIL   forbidden_patterns
                forbidden pattern: Have you considered sharing the new syspref to HEA? (see bug 23849 and C4/UsageStats.pm) (line 39)

=> We ignore this for now

[FAIL] installer/data/mysql/mandatory/sysprefs.sql
   FAIL   semicolon
                semicolon found instead of comma at line 896

=> Invalid (because of "no new line")

Signed-off-by: krimsonkharne <philip.orr@posteo.de>
Comment 59 Philip Orr 2025-09-11 10:43:41 UTC
For the "set a certain notice as mandatory" part:
I made a new bug for that, Bug 40791.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40791