From c00d67dd0e9a0e7b00d22e505d24082e8a736a28 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 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 --- C4/Circulation.pm | 2 +- misc/cronjobs/advance_notices.pl | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0b2b57e3754..624b91f5d69 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3130,7 +3130,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 5c1236981a2..9b4ab00f1e3 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,11 @@ 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 +412,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} } ); @@ -608,6 +612,7 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %{ $params->{digests} } ) @letters = (); my $count = $digest->{count}; my $from_address = $digest->{email}; + my $reply_address = $digest->{reply}; my %branch_info; my $branchcode; @@ -686,6 +691,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