From 73c777d408e8825350d9477caf2478bbc066e035 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Tue, 25 Feb 2020 07:48:31 +0000
Subject: [PATCH] Bug 22821: Correct to_address for issue notes

This patch updates the controller and service code to use the newly
introduced 'get_effective_email' routine from bug 22823 to obtain the
branches most appropriate email address.
---
 opac/opac-issue-note.pl | 2 +-
 opac/svc/checkout_notes | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opac/opac-issue-note.pl b/opac/opac-issue-note.pl
index 64f07fefbd..e24e80024b 100755
--- a/opac/opac-issue-note.pl
+++ b/opac/opac-issue-note.pl
@@ -81,7 +81,7 @@ if ( $action eq 'issuenote' && C4::Context->preference('AllowCheckoutNotes') ) {
                 },
             );
 
-            my $to_address = $branch->branchemail || $branch->branchreplyto || C4::Context->ReplytoDefault || C4::Context->preference('KohaAdminEmailAddress');
+            my $to_address = $branch->get_effective_email;
             my $reply_address = $patron->email || $patron->emailpro || $patron->B_email;
 
             C4::Letters::EnqueueLetter({
diff --git a/opac/svc/checkout_notes b/opac/svc/checkout_notes
index 60b4d00bca..60adf6dccf 100755
--- a/opac/svc/checkout_notes
+++ b/opac/svc/checkout_notes
@@ -91,7 +91,7 @@ if ($is_ajax) {
                     },
                 );
 
-                my $to_address = $branch->branchemail || $branch->branchreplyto || C4::Context->preference('ReplytoDefault') || C4::Context->preference('KohaAdminEmailAddress');
+                my $to_address = $branch->get_effective_email;
                 my $reply_address = $patron->email || $patron->emailpro || $patron->B_email;
 
                 C4::Letters::EnqueueLetter({
-- 
2.20.1