From 506d669424fd85edb7986fd045bde0821964bc1f Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 2 Aug 2017 23:25:35 +0000 Subject: [PATCH] Bug 2093: (follow-up) Add OPAC dashboard for logged-in users This patch: - hides the dashboard if there is no dashboard information to display - changes '5.00 due' to '5.00 due in fines and charges' for translation - uses Koha::Holds in place of deprecated C4::Reserves methods To test, confirm all the right information for holds still shows, and confirm the dashboard is hidden if there are no checkouts, holds, fines or overdues. Signed-off-by: Hugo Agud Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- .../bootstrap/en/modules/opac-main.tt | 12 ++++++------ opac/opac-main.pl | 19 +++++++++---------- 2 files changed, 15 insertions(+), 16 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 817dad6725..3399c3812a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt @@ -135,24 +135,24 @@ [% END # /casAuthentication %] [% ELSE %] - [% IF Koha.Preference('OPACUserSummary') %] + [% IF Koha.Preference('OPACUserSummary') && dashboard_info %]

Welcome, [% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]

diff --git a/opac/opac-main.pl b/opac/opac-main.pl index d63392b864..33e100f361 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -27,8 +27,8 @@ use C4::Languages qw(getTranslatedLanguages accept_language); use C4::Koha qw( GetDailyQuote ); use C4::Members; use C4::Overdues; -use C4::Reserves; use Koha::Checkouts; +use Koha::Holds; my $input = new CGI; my $dbh = C4::Context->dbh; @@ -66,23 +66,22 @@ my $koha_news_count = scalar @$all_koha_news; my $quote = GetDailyQuote(); # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha +# For dashboard my $checkouts = Koha::Checkouts->search({ borrowernumber => $borrowernumber })->count; my ( $overdues_count, $overdues ) = checkoverdues($borrowernumber); -my @holds = GetReservesFromBorrowernumber($borrowernumber); -my $holds_pending = 0; -foreach my $hold (@holds) { - if (not defined($hold->{found})){ - $holds_pending++; - } -} -my @holds_waiting = GetReservesFromBorrowernumber($borrowernumber, 'W'); +my $holds_pending = Koha::Holds->search({ borrowernumber => $borrowernumber, found => undef })->count; +my $holds_waiting = Koha::Holds->search({ borrowernumber => $borrowernumber })->waiting->count; my ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber ); +if ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 ) { + $template->param( dashboard_info => 1 ); +} + $template->param( checkouts => $checkouts, overdues => $overdues_count, holds_pending => $holds_pending, - holds_waiting => scalar @holds_waiting, + holds_waiting => $holds_waiting, total_owing => $total, koha_news => $all_koha_news, koha_news_count => $koha_news_count, -- 2.39.5