From a883320e8e5ae6079b571367da370f635e7b21fe Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 5 Dec 2025 20:04:05 +0000 Subject: [PATCH] Bug 41393: Set the correct reply to address for advance notices Content-Type: text/plain; charset=utf-8 This patch additionally fetches the reply to address for advance notices To test: 1 - Have some issues that will be due soon for a patron(s) Checkout with the due date set to tomorrow 2 - Verify the patron(s) have an email defined, verify the issuing branch has a reply to set 3 - Verify the patron(s) have messaging preference set to receive Advance notices by email 1 day in advance 4 - perl misc/cronjobs/advance_notices.pl -v -c 5 - Check the message queue SELECT * FROM message_queue WHERE borrowernumber={##} 6 - Note no rpely to is set 7 - Apply patch 8 - perl misc/cronjobs/advance_notices.pl -v -c 9 - Check the message queue 10 - Confirm newer message has the reply to populated 11 - Ensure the issued item has a different homebranch with a reply to address se 12 - perl misc/cronjobs/advance_notices.pl -v -c --frombranch item-homebranch 13 - Confirm message has correct reply to 14 - Set patron to want digest in messaging preferences 15 - Generate notices 16 - Confirm digets has the right reply to Signed-off-by: Roman Dolny Signed-off-by: Marcel de Rooy Tidied inline --- C4/Circulation.pm | 2 +- misc/cronjobs/advance_notices.pl | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 9fa3c9e874..7208e78ab9 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3159,7 +3159,7 @@ sub GetUpcomingDueIssues { my $dbh = C4::Context->dbh; my $statement; $statement = q{ - SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail + SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail, branches.branchreplyto FROM issues LEFT JOIN items USING (itemnumber) LEFT JOIN branches ON branches.branchcode = diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl index 5c1236981a..9195895890 100755 --- a/misc/cronjobs/advance_notices.pl +++ b/misc/cronjobs/advance_notices.pl @@ -262,9 +262,10 @@ my $admin_adress = C4::Context->preference('KohaAdminEmailAddress'); my @letters; UPCOMINGITEM: foreach my $upcoming (@$upcoming_dues) { @letters = (); - warn 'examining ' . $upcoming->{'itemnumber'} . ' upcoming due items' if $verbose; + warn 'examining upcoming due itemnumber: ' . $upcoming->{'itemnumber'} if $verbose; - my $from_address = $upcoming->{branchemail} || $admin_adress; + my $from_address = $upcoming->{branchemail} || $admin_adress; + my $reply_address = $upcoming->{branchreplyto} || undef; my $borrower_preferences; if ( 0 == $upcoming->{'days_until_due'} ) { @@ -344,9 +345,12 @@ UPCOMINGITEM: foreach my $upcoming (@$upcoming_dues) { # cache this one to process after we've run through all of the items. if ($digest_per_branch) { $upcoming_digest->{ $upcoming->{branchcode} }->{ $upcoming->{borrowernumber} }->{email} = $from_address; + $upcoming_digest->{ $upcoming->{branchcode} }->{ $upcoming->{borrowernumber} }->{reply} = + $reply_address; $upcoming_digest->{ $upcoming->{branchcode} }->{ $upcoming->{borrowernumber} }->{count}++; } else { $upcoming_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address; + $upcoming_digest->{ $upcoming->{borrowernumber} }->{reply} = $reply_address; $upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++; } } else { @@ -409,6 +413,7 @@ UPCOMINGITEM: foreach my $upcoming (@$upcoming_dues) { letter => $letter, borrowernumber => $upcoming->{'borrowernumber'}, from_address => $from_address, + reply_address => $reply_address, message_transport_type => $letter->{message_transport_type} } ); @@ -606,8 +611,9 @@ sub send_digests { PATRON: while ( my ( $borrowernumber, $digest ) = each %{ $params->{digests} } ) { @letters = (); - my $count = $digest->{count}; - my $from_address = $digest->{email}; + my $count = $digest->{count}; + my $from_address = $digest->{email}; + my $reply_address = $digest->{reply}; my %branch_info; my $branchcode; @@ -686,6 +692,7 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %{ $params->{digests} } ) letter => $letter, borrowernumber => $borrowernumber, from_address => $from_address, + reply_address => $reply_address, message_transport_type => $letter->{message_transport_type} } ); -- 2.39.5