From 3410cdb795d6adc7cfe40d6b2597856b8252267c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 15 Jan 2018 12:02:16 -0300 Subject: [PATCH] Bug 19938: Do not fetch dashboard's info if no logged in --- opac/opac-main.pl | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/opac/opac-main.pl b/opac/opac-main.pl index 33e100f361..2637ffa7a0 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -67,22 +67,26 @@ 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_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 ( $borrowernumber ) { + my $checkouts = Koha::Checkouts->search({ borrowernumber => $borrowernumber })->count; + 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 ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber ); -if ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 ) { - $template->param( dashboard_info => 1 ); + if ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 ) { + $template->param( + dashboard_info => 1, + checkouts => $checkouts, + overdues => $overdues_count, + holds_pending => $holds_pending, + holds_waiting => $holds_waiting, + total_owing => $total, + ); + } } $template->param( - checkouts => $checkouts, - overdues => $overdues_count, - holds_pending => $holds_pending, - holds_waiting => $holds_waiting, - total_owing => $total, koha_news => $all_koha_news, koha_news_count => $koha_news_count, branchcode => $homebranch, -- 2.11.0