Bug 38095 - Custom patron messages should have access to information about the logged-in library they were sent from
Summary: Custom patron messages should have access to information about the logged-in ...
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Notices (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Emily Lamancusa (emlam)
QA Contact: Testopia
URL:
Keywords:
Depends on: 29393
Blocks:
  Show dependency treegraph
 
Reported: 2024-10-04 14:19 UTC by Emily Lamancusa (emlam)
Modified: 2024-11-15 10:59 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 38095: Include logged-in branch in custom patron message (1.72 KB, patch)
2024-10-10 19:00 UTC, Emily Lamancusa (emlam)
Details | Diff | Splinter Review
Bug 38095: Include logged-in branch in custom patron message (1.77 KB, patch)
2024-10-10 19:12 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Emily Lamancusa (emlam) 2024-10-04 14:19:31 UTC
Bug 29393 added the ability to define custom notices that could be sent from the patron account page. It would be useful if these notices had access to information about the logged-in library from which the notice was triggered.

For example, we'd like to use this feature to add an email template for notifying a patron that a lost library card was found and turned in to the library. That notice should include which branch found the card and triggered the notice, which may not be the patron's home library.
Comment 1 Janusz Kaczmarek 2024-10-04 18:29:43 UTC
+1

I would need it too.

It seems that for the branch it would be enough to do this:

diff --git a/circ/add_message.pl b/circ/add_message.pl
index 08cf1e4d9f..3e6eb498d7 100755
--- a/circ/add_message.pl
+++ b/circ/add_message.pl
@@ -81,7 +81,7 @@ if ( $op eq 'cud-edit_message' && $message_id ) {
                 module      => 'add_message',
                 letter_code => $letter_code,
                 lang        => $patron->lang,
-                tables      => { 'borrowers' => $borrowernumber },
+                tables      => { 'borrowers' => $borrowernumber, 'branches' => $branchcode },
             );
         }


Will you prepare the patch, Emily (as assignee)?
Comment 2 Emily Lamancusa (emlam) 2024-10-10 19:00:05 UTC
Created attachment 172668 [details] [review]
Bug 38095: Include logged-in branch in custom patron message

To test:
1. Create a new notice template for a custom patron message
    i. Go to Tools > Notices and Slips
    ii. Create a new notice and choose Patrons (custom message) module
    iii. Add the following text to the email notice:
    You have a new notification from  [% branches.branchname %]
    iv. Fill in other fields and save
2. Find a patron and go to their details page
3. Send the custom notice you just created
    i. Click Add message
    ii. Under "add a message for", select the email option
    iii. Under "Patron notice", select the notice you just created
    iv. Click "Save"
4. Open the patron's notices tab and look at the notice that was sent
--> The branch name is left blank
5. Apply patch and refresh the patron page
6. Repeat steps 3-4
--> The branch code is now included in the notice
Comment 3 Janusz Kaczmarek 2024-10-10 19:12:30 UTC
Created attachment 172669 [details] [review]
Bug 38095: Include logged-in branch in custom patron message

To test:
1. Create a new notice template for a custom patron message
    i. Go to Tools > Notices and Slips
    ii. Create a new notice and choose Patrons (custom message) module
    iii. Add the following text to the email notice:
    You have a new notification from  [% branches.branchname %]
    iv. Fill in other fields and save
2. Find a patron and go to their details page
3. Send the custom notice you just created
    i. Click Add message
    ii. Under "add a message for", select the email option
    iii. Under "Patron notice", select the notice you just created
    iv. Click "Save"
4. Open the patron's notices tab and look at the notice that was sent
--> The branch name is left blank
5. Apply patch and refresh the patron page
6. Repeat steps 3-4
--> The branch code is now included in the notice

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Comment 4 Anneli Österman 2024-11-15 06:59:21 UTC
I tested this in sandbox and it kind of works but not with [% branches.branchname %] as instructed. If you want to add branch name, you had to use <<branches.branchname>> instead. Is that how it was intended to work?
Comment 5 Janusz Kaczmarek 2024-11-15 09:53:21 UTC
(In reply to Anneli Österman from comment #4)
> I tested this in sandbox and it kind of works but not with [%
> branches.branchname %] as instructed. If you want to add branch name, you
> had to use <<branches.branchname>> instead. Is that how it was intended to
> work?

I can confirm, that's true.  But this seems to be another issue.  [% borrowers.firstname %] does not work as well--seems to be a be a more general problem with letter templates interpretation (at least for custom patron messages).
Comment 6 Janusz Kaczmarek 2024-11-15 10:09:02 UTC
(In reply to Janusz Kaczmarek from comment #5)
> (In reply to Anneli Österman from comment #4)
> > I tested this in sandbox and it kind of works but not with [%
> > branches.branchname %] as instructed. If you want to add branch name, you
> > had to use <<branches.branchname>> instead. Is that how it was intended to
> > work?
> 
> I can confirm, that's true.  But this seems to be another issue.  [%
> borrowers.firstname %] does not work as well--seems to be a be a more
> general problem with letter templates interpretation (at least for custom
> patron messages).

Problem explained: for [% %] placeholders singular form should be used--it should be:
[% branch.branchname %]
[% borrower.firstname %]
etc.

whereas for <<  >> form the table name (usually plural: branches.column, borrowers.column etc.) is to be used.

Emily, would you correct the test plan please?  (The patch itself is fine).
Comment 7 Janusz Kaczmarek 2024-11-15 10:12:26 UTC
And of course comment #6 applies to all letter templates, not only to patron custom messages.
Comment 8 Anneli Österman 2024-11-15 10:59:34 UTC
Ahh, yes. It works with [% branch.branchname %].