From 541745cb5ddcc0d20204827dabab98fd65d8f46f Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Tue, 11 Nov 2025 23:11:50 +0000 Subject: [PATCH] Bug 39646: Send overdue notice to guarantor when guarantee has no email Test plan: 1. Have a patron with no email address and an overdue item. 2. Add a guarantor to this patron. The guarantor must have an email address. 3. Enable the system preference RedirectGuaranteeEmail. 4. Set up overdue notice/status triggers 4.1 Go to tools -> Overdue notice/status triggers 4.2 For Default library - Delay: 1 - Letter: Overdue notice (ODUE) - Email: selected 5. Run ./misc/cronjobs/overdue_notices.pl. 6. In the staff interface, go to the guarantee patron > Notices. ---> Notice that only a print notice has been created. 7. Apply the patch. 8. Repeat steps 4 and 5. ---> Notice that an email message has been created. You can also verify in SQL Select message_transport_type,to_address from message_queue where letter_code = 'ODUE' and borrowernumber = 9. Run the script process_message_queue.pl. ---> Verify that the email has been sent to the guarantor's address. Signed-off-by: Bernard Scaife --- misc/cronjobs/overdue_notices.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index f6bd9b2449e..d48d4782694 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -754,6 +754,18 @@ END_SQL unless @message_transport_types; my $print_sent = 0; # A print notice is not yet sent for this patron + + if ( C4::Context->preference('RedirectGuaranteeEmail') && $patron ) { + + # Get guarantor addresses + my $guarantor_relationships = $patron->guarantor_relationships; + my @guarantors = $guarantor_relationships->guarantors->as_list; + foreach my $guarantor (@guarantors) { + my $address = $guarantor->notice_email_address; + push( @emails_to_use, $address ) if ($address); + } + } + for my $mtt (@message_transport_types) { next if $mtt eq 'itiva'; my $effective_mtt = $mtt; -- 2.39.5