From 08a4166a123b02aff8159d65fe4fe62e3ea7c7ec Mon Sep 17 00:00:00 2001
From: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Date: Fri, 27 Sep 2024 19:20:58 +0000
Subject: [PATCH] Bug 36112: Port default CHECKOUT_NOTE notice to TT

Port the default notice text to Template Toolkit. Also, add access to
item information in order to give more useful information about the
checked-out item that the note refers to (in this case, the item barcode
instead of the biblionumber)

To test:
1. Apply patch and reset all
2. Enable the system preference AllowCheckoutNotes
3. Go to Administration > Libraries and edit the current logged-in
   library to ensure that there is a value in the Email field
4. Check out an item to a patron
5. Ensure the patron has values in the first name and surname fields
6. Log into the OPAC as that patron
7. Click to display the patron's current checkouts
8. Click the + button to the right of a checkout
9. Click the "Add Note" button beneath the table
10. Add some text and submit the note
11. Return to the staff interface and go to the Notices tab for the patron
--> Confirm that there is a notice called "Checkout note" with all the
correct information

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
---
 installer/data/mysql/en/mandatory/sample_notices.yml | 3 ++-
 opac/opac-issue-note.pl                              | 4 +++-
 opac/svc/checkout_notes                              | 5 +++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml
index ec0e2386dab..4006843b695 100644
--- a/installer/data/mysql/en/mandatory/sample_notices.yml
+++ b/installer/data/mysql/en/mandatory/sample_notices.yml
@@ -647,7 +647,8 @@ tables:
           message_transport_type: email
           lang: default
           content:
-            - "<<borrowers.firstname>> <<borrowers.surname>> has added a note to the item <<biblio.title>> - <<biblio.author>> (<<biblio.biblionumber>>)."
+            - "[% borrower.firstname %] [% borrower.surname %] has added a note to the item [% biblio.title %] by [% biblio.author %] ([% item.barcode %]):"
+            - "[% checkout.note %]"
 
         - module: circulation
           code: DUE
diff --git a/opac/opac-issue-note.pl b/opac/opac-issue-note.pl
index c3e6c40799f..59d6ce8387d 100755
--- a/opac/opac-issue-note.pl
+++ b/opac/opac-issue-note.pl
@@ -81,8 +81,10 @@ if ( $op eq 'cud-issuenote' && C4::Context->preference('AllowCheckoutNotes') &&
                 branchcode => $branch,
                 lang => $patron->lang,
                 tables => {
-                    'biblio' => $biblio->biblionumber,
+                    'biblio'    => $biblio->biblionumber,
                     'borrowers' => $borrowernumber,
+                    'issues'    => $issue->itemnumber,
+                    'items'     => $issue->itemnumber,
                 },
             );
 
diff --git a/opac/svc/checkout_notes b/opac/svc/checkout_notes
index e8281d90fce..46b15e14e71 100755
--- a/opac/svc/checkout_notes
+++ b/opac/svc/checkout_notes
@@ -85,9 +85,10 @@ if ($is_ajax) {
                     letter_code => 'CHECKOUT_NOTE',
                     branchcode => $branch,
                     tables => {
-                        'biblio' => $biblionumber,
+                        'biblio'    => $biblionumber,
                         'borrowers' => $borrowernumber,
-                        'issues' => $issue->itemnumber,
+                        'issues'    => $issue->itemnumber,
+                        'items'     => $issue->itemnumber,
                     },
                 );
 
-- 
2.39.2