From a1732efff9e28d09caf6ecd4dfcd9fcb67718421 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 7 Oct 2020 14:53:37 +0000 Subject: [PATCH] Bug 26123: Add message notification to patron dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt | 7 +++++++ opac/opac-main.pl | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt index 3ee0709b3f..06d4fb519c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt @@ -227,6 +227,13 @@ [% IF total_owing && total_owing > 0 %]
  • [% total_owing | $Price with_symbol => 1 %] due in fines and charges
  • [% END %] + [% IF patron_messages && patron_messages.count > 0 || opacnote %] + [% IF opacnote %] +
  • [% patron_messages.count + 1 | html %] message(s)
  • + [% ELSE %] +
  • [% patron_messages.count | html %] message(s)
  • + [% END %] + [% END %] [% END %] diff --git a/opac/opac-main.pl b/opac/opac-main.pl index 74755a05a5..14a0c0bb8d 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -30,6 +30,7 @@ use C4::Overdues; use Koha::Checkouts; use Koha::Holds; use Koha::News; +use Koha::Patron::Messages; my $input = new CGI; my $dbh = C4::Context->dbh; @@ -81,10 +82,11 @@ if ( $patron ) { my ( $overdues_count, $overdues ) = checkoverdues($borrowernumber); my $holds_pending = Koha::Holds->search({ borrowernumber => $borrowernumber, found => undef })->count; my $holds_waiting = Koha::Holds->search({ borrowernumber => $borrowernumber })->waiting->count; - + my $patron_messages = Koha::Patron::Messages->search({borrowernumber => $borrowernumber}); + my $patron_note = $patron->opacnote; my $total = $patron->account->balance; - if ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 ) { + if ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 || $patron_messages > 0 || $patron_note > 0 ) { $template->param( dashboard_info => 1, checkouts => $checkouts, @@ -92,6 +94,8 @@ if ( $patron ) { holds_pending => $holds_pending, holds_waiting => $holds_waiting, total_owing => $total, + patron_messages => $patron_messages, + opacnote => $patron_note, ); } } -- 2.11.0