Bug 29230

Summary: Patron's messages not accessible from template notices
Product: Koha Reporter: Marie-Luce Laflamme <marie-luce.laflamme>
Component: NoticesAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: minor    
Priority: P5 - low CC: andrewfh, jonathan.druart, kyle, m.de.rooy, stina.hallin, tomascohen
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00,21.11.03
Bug Depends on: 29785    
Bug Blocks: 30099    
Attachments: Bug 29230: Add Koha::Patron->messages
Bug 29230: Add Koha::Patron->messages
Bug 29230: Add Koha::Patron->messages
Bug 29230: Add Koha::Patron->messages
Bug 29230: Add Koha::Patron->messages

Description Marie-Luce Laflamme 2021-10-13 16:17:38 UTC
If you add borrowers.borrowernotes and borrowers.opacnote fields in the HOLD_SLIP template, Koha won’t print out the patron account notes on the slip.

Test
1. Add borrowers.borrowernotes and borrowers.opacnote fields in the HOLD_SLIP template (Tools > Notices & slips)
2. Add a borrowernotes, then an opacnote in a patron account
3. Place an item on hold
4. Check-in the item
5. Select the «print slip…» option to confirm the hold

Unfortunately, these two fields are not displayed on the slip.


It would be nice to see the borrowernotes since some libraries use this field to add details about patron special needs.
Comment 1 Jonathan Druart 2021-10-19 09:13:40 UTC
I've tried right now on master with <<borrowers.borrowernotes>> and it's working. Which version of Koha are you using? Did you confirm the problem on a sandbox?
Comment 2 Marie-Luce Laflamme 2021-10-19 21:30:19 UTC
(In reply to Jonathan Druart from comment #1)

I've tried the master, the branch 20.05 and the PTFS-E Sandboxes. Unfortunately, none of them could print the borrowers.borrowernotes and borrowers.opacnote fields.

Prior to my test, I did add the following terms in the HOLD_SLIP template email and print tabs:
intranet notes: <<borrowers.borrowernotes>>
opac notes: <<borrowers.opacnote>>

The reserves.notes works fine, but the other note fields aren't showing up on the slip.
Comment 3 Jonathan Druart 2021-10-20 08:10:45 UTC
Go to http://staff-flame.sandboxes.ptfs-europe.co.uk/cgi-bin/koha/circ/returns.pl

Check in 39999000004731, click "print slip, transfer, and confirm"

=> You see the note

What did you try?
Comment 4 Marie-Luce Laflamme 2021-10-20 17:05:14 UTC
(In reply to Jonathan Druart from comment #3)
> Go to
> http://staff-flame.sandboxes.ptfs-europe.co.uk/cgi-bin/koha/circ/returns.pl
> 
> Check in 39999000004731, click "print slip, transfer, and confirm"
> 
> => You see the note
> 
> What did you try?


Hi Jonathan,

You're right, I can see your notes. My mistakes. After a recheck, I was testing with the intranet_message or opac_message fields, not the borrowers.*notes.

sorry for the confusion

Is there a way to add a borrowers message on the hold slip?

thanks

in the same sandboxe
try to return 39999000003154
for this patron 23529000120056
Comment 5 Jonathan Druart 2021-10-21 08:01:49 UTC
Created attachment 126641 [details] [review]
Bug 29230: Add Koha::Patron->messages

Add methods to return the messages attached to a patron.

It will add the capability to access them from notice templates.

Test plan:
Define some messages for a given patron
Go to the circulation page of the patron and confirm that they are still
displayed

Test the notice templates:
Add to HOLD_SLIP the following content
"""
[% SET messages = borrower.messages %]
[% IF messages.count %]
Messages:
<ul>
  [% FOR m IN messages.search( message_type => 'L' ) %]
    <li>[% m.message %]</li>
  [% END %]
</ul>
[% END %]
"""

To display all the messages from staff ('L')

Adapt following your needs.
Comment 6 Jonathan Druart 2021-10-21 08:02:48 UTC
This patch adds what's needed to access the messages from notice templates.
Comment 7 Fridolin Somers 2021-11-16 07:12:11 UTC
Created attachment 127678 [details] [review]
Bug 29230: Add Koha::Patron->messages

Add methods to return the messages attached to a patron.

It will add the capability to access them from notice templates.

Test plan:
Define some messages for a given patron
Go to the circulation page of the patron and confirm that they are still
displayed

Test the notice templates:
Add to HOLD_SLIP the following content
"""
[% SET messages = borrower.messages %]
[% IF messages.count %]
Messages:
<ul>
  [% FOR m IN messages.search( message_type => 'L' ) %]
    <li>[% m.message %]</li>
  [% END %]
</ul>
[% END %]
"""

To display all the messages from staff ('L')

Adapt following your needs.

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Comment 8 PTFS Europe Sandboxes 2021-12-02 13:45:36 UTC
Created attachment 128162 [details] [review]
Bug 29230: Add Koha::Patron->messages

Add methods to return the messages attached to a patron.

It will add the capability to access them from notice templates.

Test plan:
Define some messages for a given patron
Go to the circulation page of the patron and confirm that they are still
displayed

Test the notice templates:
Add to HOLD_SLIP the following content
"""
[% SET messages = borrower.messages %]
[% IF messages.count %]
Messages:
<ul>
  [% FOR m IN messages.search( message_type => 'L' ) %]
    <li>[% m.message %]</li>
  [% END %]
</ul>
[% END %]
"""

To display all the messages from staff ('L')

Adapt following your needs.

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Comment 9 Stina Hallin 2021-12-02 13:47:01 UTC
Signed off using a sandbox.
Comment 10 Marcel de Rooy 2021-12-22 15:51:39 UTC
Although it looks good to me on itself, we have a clash with Koha::Object::messages.

cc: Tomas
Comment 11 Jonathan Druart 2022-01-03 11:14:58 UTC
(In reply to Marcel de Rooy from comment #10)
> Although it looks good to me on itself, we have a clash with
> Koha::Object::messages.
> 
> cc: Tomas

In my opinion Koha::Object->messages should be renamed. ->_messages maybe?
Comment 12 Tomás Cohen Arazi 2022-01-03 11:16:52 UTC
(In reply to Jonathan Druart from comment #11)
> (In reply to Marcel de Rooy from comment #10)
> > Although it looks good to me on itself, we have a clash with
> > Koha::Object::messages.
> > 
> > cc: Tomas
> 
> In my opinion Koha::Object->messages should be renamed. ->_messages maybe?

Maybe, but you need to think of an accessor? Or maybe bug 29746 is the way to avoid it completely?
Comment 13 Jonathan Druart 2022-01-04 13:28:17 UTC
I opened bug 29785 to rename it.
Comment 14 Tomás Cohen Arazi 2022-01-31 16:24:29 UTC
Marcel, let me know if you are not going to work on this one in a short term, please. Thanks!
Comment 15 Marcel de Rooy 2022-02-01 12:07:50 UTC
(In reply to Tomás Cohen Arazi from comment #14)
> Marcel, let me know if you are not going to work on this one in a short
> term, please. Thanks!

Thanks for your patience. I will have another look.
Comment 16 Marcel de Rooy 2022-02-01 12:25:04 UTC
Back to blocked: base report fails qa.
Comment 17 Jonathan Druart 2022-02-01 14:40:43 UTC
Created attachment 130044 [details] [review]
Bug 29230: Add Koha::Patron->messages

Add methods to return the messages attached to a patron.

It will add the capability to access them from notice templates.

Test plan:
Define some messages for a given patron
Go to the circulation page of the patron and confirm that they are still
displayed

Test the notice templates:
Add to HOLD_SLIP the following content
"""
[% SET messages = borrower.messages %]
[% IF messages.count %]
Messages:
<ul>
  [% FOR m IN messages.search( message_type => 'L' ) %]
    <li>[% m.message %]</li>
  [% END %]
</ul>
[% END %]
"""

To display all the messages from staff ('L')

Adapt following your needs.

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>
Comment 18 Marcel de Rooy 2022-02-02 13:00:38 UTC
Created attachment 130097 [details] [review]
Bug 29230: Add Koha::Patron->messages

Add methods to return the messages attached to a patron.

It will add the capability to access them from notice templates.

Test plan:
Define some messages for a given patron
Go to the circulation page of the patron and confirm that they are still
displayed

Test the notice templates:
Add to HOLD_SLIP the following content
"""
[% SET messages = borrower.messages %]
[% IF messages.count %]
Messages:
<ul>
  [% FOR m IN messages.search( message_type => 'L' ) %]
    <li>[% m.message %]</li>
  [% END %]
</ul>
[% END %]
"""

To display all the messages from staff ('L')

Adapt following your needs.

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Stina Hallin <stina.hallin@ub.lu.se>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 19 Marcel de Rooy 2022-02-02 13:01:45 UTC
Do we actually have a rule for empty test descriptions? :)

# Subtest: messages
    1..4
    ok 1 - No message yet
    ok 2 - There are two messages for this patron
    ok 3
    ok 4
ok 14 - messages
Comment 20 Jonathan Druart 2022-02-02 13:31:19 UTC
(In reply to Marcel de Rooy from comment #19)
> Do we actually have a rule for empty test descriptions? :)

IMO the descriptions are like comments, they should be there when it's not obvious.
Comment 21 Fridolin Somers 2022-02-10 08:03:11 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 22 Kyle M Hall 2022-02-11 11:58:49 UTC
Pushed to 21.11.x for 21.11.03
Comment 23 Andrew Fuerste-Henry 2022-02-21 16:49:16 UTC
Doesn't apply cleanly to 21.05, please rebase if needed