Bug 26123

Summary: Show info about existing OPAC note/Patron message on patron's dashboard
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: OPACAssignee: Lucas Gass <lucas>
Status: Needs documenting --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: amit.gupta, amitddng135, caroline.cyr-la-rose, fridolin.somers, jonathan.druart, lucas, martin.renvoize, philip.orr, sally.healey, victor
Version: masterKeywords: Manual
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: philip.orr@lmscloud.de Documentation submission:
Text to go in the release notes:
Shows the number of messages and OPAC note from a patron record on the dashboard on the OPAC start page.
Version(s) released in:
21.05.00
Bug Depends on:    
Bug Blocks: 27325    
Attachments: Bug 26123: Add notice about new messages to the patron dashboard
Bug 26123: Add notice about new messages to the patron dashboard
Bug 26123: Add notice about new messages to the patron dashboard
Error
Bug 26123: Add OPAC note/patron message notice to dashboard
Bug 26123: Add message notification to patron dashboard
Bug 26123: Add message notification to patron dashboard
Bug 26123: Add message notification to patron dashboard
Bug 26123: Add message notification to patron dashboard
Bug 26123: Add message notification to patron dashboard

Description Katrin Fischer 2020-08-02 11:39:42 UTC
The patron dashboard visible on the start page of the OPAC when activated could also show a note about an existing OPAC note in the patron account. For privacy it might be nice to just show something like "you've got a message".
Comment 1 Lucas Gass 2020-08-02 22:34:03 UTC
Created attachment 107664 [details] [review]
Bug 26123: Add notice about new messages to the patron dashboard

This patch adds a notice to the patron OPAC when a logged on user of the OPAC has 1 or more OPAC messages.
Test plan:
1. Apply patch, restart_all.
2. Add some OPAC messages for a patron and login as that patron.
3. On the OPAC main page you should see a notice about your OPAC messages, incdicating how many you have.
4. Add multiple OPAC messages and make sure it all continues to work.
5. Test it with some other notices that would appear on the dashboard, checkouts, holds, overdues.
Comment 2 ByWater Sandboxes 2020-08-03 10:24:50 UTC
Created attachment 107685 [details] [review]
Bug 26123: Add notice about new messages to the patron dashboard

This patch adds a notice to the patron OPAC when a logged on user of the OPAC has 1 or more OPAC messages.
Test plan:
1. Apply patch, restart_all.
2. Add some OPAC messages for a patron and login as that patron.
3. On the OPAC main page you should see a notice about your OPAC messages, incdicating how many you have.
4. Add multiple OPAC messages and make sure it all continues to work.
5. Test it with some other notices that would appear on the dashboard, checkouts, holds, overdues.

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 3 Sally 2020-08-03 10:27:12 UTC
This works well - is it possible to change the bug title?

It seems to refer to the OPAC Note section (found when editing the patron), but this patch uses the Messages feature instead.
Comment 4 Katrin Fischer 2020-08-07 11:51:44 UTC
Hi Lucas, could you please fix the missing filter and include the OPAC note as well?
Also thanks for taking this on!
Comment 5 Lucas Gass 2020-08-17 23:20:38 UTC
Created attachment 108427 [details] [review]
Bug 26123: Add notice about new messages to the patron dashboard

This patch adds a notice to the patron OPAC when a logged on user of the OPAC has 1 or more OPAC messages, this includes both patron messages and the OPAC note. For privacy this doesn't show any of the messages/note on opac-main.tt. Instead it adds up the total number of patron messages + OPAC notes and displays that number in the dashboard
Test plan:
1. Apply patch, restart_all.
2. Add some OPAC messages for a patron and login as that patron.
3. On the OPAC main page you should see a notice about your OPAC messages, incdicating how many you have.
4. Add multiple OPAC messages and make sure it all continues to work.
5. Also add an OPAC note, this should add 1 to the total number of messages on the dashboard.
6. Try an OPAC without any messages.
7. Test it with some other notices that would appear on the dashboard, checkouts, holds, overdues.
Comment 6 Amit Gupta 2020-08-25 17:21:00 UTC
After applying the patch. If I am hitting 

http://localhost

OPAC page without login. I am getting error.

Software error:

Can't call method "unblessed" on an undefined value at /home/amit/kohaclonemaster/opac/opac-main.pl line 79.
Comment 7 Amit Gupta 2020-08-25 17:22:23 UTC
Created attachment 109122 [details]
Error
Comment 8 Amit Gupta 2020-08-25 17:42:58 UTC
QA comments

I think need to correction for ex:

-my $borr = $patron->unblessed;
-    my $patron_note = $borr->{opacnote};
+    my $patron_note = $patron->opacnote;
Comment 9 Lucas Gass 2020-08-26 01:45:56 UTC
Created attachment 109134 [details] [review]
Bug 26123: Add OPAC note/patron message notice to dashboard

I seperated OPAC note and patron message into two distinct categories with seperate notices for each. Slightly altered test plan

Test plan:
1. Apply patch, restartgit
2. Add some OPAC messages by clicking 'Add a message' on Home › Circulation › Checkouts › patron
3. Log into the OPAC as that patron and you should see a notice about how many messages you have with a link to opac-user.pl
4. Add multiple OPAC messages and make sure it all continues to work.
5. Also add an OPAC note from memberentry.pl. Refrsh the OPAC and you should see a notice like '1 note'. There is never more than a single OPAC note.
6. Try an OPAC without any messages.
7. Test it with some other notices that would appear on the dashboard, checkouts, holds, overdues.
Comment 10 Lucas Gass 2020-08-26 01:47:02 UTC
Amit,

Thank you! I believe you were correct when suggesting: my $patron_note = $patron->opacnote;
Comment 11 Owen Leonard 2020-08-26 12:25:22 UTC
Would it be possible to combine the count of notes and messages? The distinction from the patron's point of view is meaningless.

Notes and messages both displayed together in the same area on the user's page with no indication that they're different kinds of messages, so two different counts don't make sense.
Comment 12 Lucas Gass 2020-08-26 15:00:30 UTC
(In reply to Owen Leonard from comment #11)
> Would it be possible to combine the count of notes and messages? The
> distinction from the patron's point of view is meaningless.
> 
> Notes and messages both displayed together in the same area on the user's
> page with no indication that they're different kinds of messages, so two
> different counts don't make sense.

Owen, I was wondering about that too after I submitted the patch. I will combine them into one.
Comment 13 Lucas Gass 2020-10-07 14:58:21 UTC
Created attachment 111336 [details] [review]
Bug 26123: Add message notification to patron dashboard

Test plan:
1. Apply patch, restart_all
2. Add some OPAC messages by clicking 'Add a message' on Home › Circulation › Checkouts › patron
3. Log into the OPAC as that patron and you should see a notice about how many messages you have with a link to opac-user.pl
4. Add multiple OPAC messages and make sure it all continues to work.
5. Also add an OPAC note from memberentry.pl. Refresh the OPAC and you should see a 1 message added to the total
6. Try an OPAC without any messages.
7. Test it with some other notices that would appear on the dashboard, checkouts, holds, overdues.
Comment 14 Fridolin Somers 2020-10-08 06:37:27 UTC
Nice job.

Just my opinion :

Would be great to send Koha::Patron object to template.
So call in template [% patron.opacnote %].

Also add in Koha::Patron a method messages() to get : Koha::Patron::Messages->search({borrowernumber => $borrowernumber})
Like it exists for checkouts, holds ...
So in template you just add [% patron.messages.count %]
Comment 15 Katrin Fischer 2020-10-16 01:31:18 UTC
Hi Lucas, I think you need to limit the messages to the OPAC ones (they can be either for OPAC or staff only.
Comment 16 Lucas Gass 2020-10-22 02:54:18 UTC
Created attachment 112139 [details] [review]
Bug 26123: Add message notification to patron dashboard

Test plan:
1. Apply patch, restart_all
2. Add some OPAC messages by clicking 'Add a message' on Home › Circulation › Checkouts › patron
3. Log into the OPAC as that patron and you should see a notice about how many messages you have with a link to opac-user.pl
4. Add multiple OPAC messages and make sure it all continues to work.
5. Also add an OPAC note from memberentry.pl. Refresh the OPAC and you should see a 1 message added to the total
6. Try an OPAC without any messages.
7. Add a 'staff - internal' note. It should not count towards your total messages in the dashboard.
8. Test it with some other notices that would appear on the dashboard, checkouts, holds, overdues.
Comment 17 Séverine Queune 2020-10-23 06:40:44 UTC
Created attachment 112227 [details] [review]
Bug 26123: Add message notification to patron dashboard

Test plan:
1. Apply patch, restart_all
2. Add some OPAC messages by clicking 'Add a message' on Home › Circulation › Checkouts › patron
3. Log into the OPAC as that patron and you should see a notice about how many messages you have with a link to opac-user.pl
4. Add multiple OPAC messages and make sure it all continues to work.
5. Also add an OPAC note from memberentry.pl. Refresh the OPAC and you should see a 1 message added to the total
6. Try an OPAC without any messages.
7. Add a 'staff - internal' note. It should not count towards your total messages in the dashboard.
8. Test it with some other notices that would appear on the dashboard, checkouts, holds, overdues.

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 18 Katrin Fischer 2020-10-23 10:30:49 UTC
Hi Lucas, I believe there is something wrong about this line here, as the empty box shows when no notes, checkouts, holds, etc are on the account now, when it should be hidden:

+    if  ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 || $patron_messages > 0 || $patron_note > 0 ) {

I suspect the $patron_messages > 0 might not be working. What do you think?
Comment 19 Lucas Gass 2020-10-26 14:16:12 UTC
(In reply to Katrin Fischer from comment #18)
> Hi Lucas, I believe there is something wrong about this line here, as the
> empty box shows when no notes, checkouts, holds, etc are on the account now,
> when it should be hidden:
> 
> +    if  ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 ||
> $holds_waiting > 0 || $total > 0 || $patron_messages > 0 || $patron_note > 0
> ) {
> 
> I suspect the $patron_messages > 0 might not be working. What do you think?

Cait, you're right. I think 'patron_messages > 0' needs to be $patron_messages->count

Also $patron_note, having only one possible note, can be $patron_note instead of $patron_note > 0.
Comment 20 Lucas Gass 2020-10-26 14:16:53 UTC
Created attachment 112519 [details] [review]
Bug 26123: Add message notification to patron dashboard

Test plan:
1. Apply patch, restart_all
2. Add some OPAC messages by clicking 'Add a message' on Home › Circulation › Checkouts › patron
3. Log into the OPAC as that patron and you should see a notice about how many messages you have with a link to opac-user.pl
4. Add multiple OPAC messages and make sure it all continues to work.
5. Also add an OPAC note from memberentry.pl. Refresh the OPAC and you should see a 1 message added to the total
6. Try an OPAC without any messages. If there are no messages or any other kind of notification the dashboard should NOT appear at all.
7. Add a 'staff - internal' note. It should not count towards your total messages in the dashboard.
8. Test it with some other notices that would appear on the dashboard, checkouts, holds, overdues.

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 21 Victor Grousset/tuxayo 2020-12-28 20:49:17 UTC
IIUC the dashboard will mention the messages until the opac note is cleared and/or the old messages are purged by bug 24541 for example.

That's ok right? Even if it looks like a "new messages" feature, it's consistent with the patron page that will display them all, old or new. So it won't add much confusion.

Other opinions on that?
Comment 22 Katrin Fischer 2021-01-03 14:35:25 UTC
I've filed bug 27325 for a possible follow-up. No blocker here for me, as this patch follows the existing pattern and I think we should fix them all together which is out of scope here.
Comment 23 Katrin Fischer 2021-01-03 14:36:40 UTC
Created attachment 114769 [details] [review]
Bug 26123: Add message notification to patron dashboard

Test plan:
1. Apply patch, restart_all
2. Add some OPAC messages by clicking 'Add a message' on Home › Circulation › Checkouts › patron
3. Log into the OPAC as that patron and you should see a notice about how many messages you have with a link to opac-user.pl
4. Add multiple OPAC messages and make sure it all continues to work.
5. Also add an OPAC note from memberentry.pl. Refresh the OPAC and you should see a 1 message added to the total
6. Try an OPAC without any messages. If there are no messages or any other kind of notification the dashboard should NOT appear at all.
7. Add a 'staff - internal' note. It should not count towards your total messages in the dashboard.
8. Test it with some other notices that would appear on the dashboard, checkouts, holds, overdues.

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 24 Jonathan Druart 2021-01-04 14:22:26 UTC
Is it ok to consider the "OPAC note" a message?
Comment 25 Katrin Fischer 2021-01-04 21:56:49 UTC
(In reply to Jonathan Druart from comment #24)
> Is it ok to consider the "OPAC note" a message?

Yes, it prominently shows in the same spot as the "younger" messages feature. The  OPAC note can be easily bulk added, while you can't bulk add the messages. Same for setting the note on patron import. So both options are used for messages to patrons still.
Comment 26 Jonathan Druart 2021-01-12 15:48:00 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 27 Fridolin Somers 2021-01-18 14:44:10 UTC
Enhancement not pushed to 20.11.x