Bug 40367: Improve display of messages on patron account

When displaying messages on a patron account, group the messages by
type and label which are OPAC messages and which are internal staff
messages.

To test:
1. Find a patron and add several messages to their account, alternating
   between internal staff messages and OPAC messages
--> Note that the messages display in the order that they are added and
    not explicitly labeled
2. Apply patch and refresh page
--> Confirm that all staff messages display first and all OPAC messages
    display underneath
--> Confirm that messages are now labeled "Staff note" or "OPAC"
3. Play around on the patron account and confirm that the message
   display is consistent after taking different actions:
   - On the Details page
   - On the Check out page
   - After adding a new staff message
   - After adding a new OPAC message

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Emily Lamancusa 2025-07-16 10:10:21 -04:00 committed by Lucas Gass
parent 5594945339
commit f30bed0d79
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
3 changed files with 11 additions and 6 deletions

View File

@ -695,9 +695,10 @@ if ($patron) {
my $patron_messages = $patron->messages->search(
{},
{
join => 'manager',
'+select' => [ 'manager.surname', 'manager.firstname' ],
'+as' => [ 'manager_surname', 'manager_firstname' ],
join => 'manager',
'+select' => [ 'manager.surname', 'manager.firstname' ],
'+as' => [ 'manager_surname', 'manager_firstname' ],
'order_by' => { -desc => 'me.message_type' },
}
);
$template->param( patron_messages => $patron_messages );

View File

@ -327,12 +327,15 @@
[% FOREACH patron_message IN patron_messages %]
<li>
[% SET span_class = '' %]
[% SET msg_type = 'OPAC' %]
[% IF(patron_message.message_type == "L") %]
[% span_class = 'circ-hlt' %]
[% msg_type = 'Staff note' %]
[% END %]
<span class="[% span_class | html %]">
[% patron_message.message_date | $KohaDates %]
[% Branches.GetName( patron_message.branchcode ) | html %]
- [% t(msg_type) | html %]
[% IF patron_message.manager_id %]
(
<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron_message.manager_id | uri %]"

View File

@ -186,9 +186,10 @@ my $patron_messages = Koha::Patron::Messages->search(
'me.borrowernumber' => $patron->borrowernumber,
},
{
join => 'manager',
'+select' => [ 'manager.surname', 'manager.firstname' ],
'+as' => [ 'manager_surname', 'manager_firstname' ],
join => 'manager',
'+select' => [ 'manager.surname', 'manager.firstname' ],
'+as' => [ 'manager_surname', 'manager_firstname' ],
'order_by' => { -desc => 'me.message_type' },
}
);