From beee2fa1e8e79fb782ff31df5ddf187db483aa59 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 21 Oct 2022 13:03:07 +0000 Subject: [PATCH] Bug 31908: Only count local suggestions if there is a userenv --- koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt | 2 +- mainpage.pl | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 1c657872be..50f17ddc6e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -187,7 +187,7 @@ [% Branches.GetLoggedInBranchname | html %]: [% pendingsuggestions | html %] - [% IF (all_pendingsuggestions > 0) %] + [% IF (pendingsuggestions && all_pendingsuggestions > 0 && all_pendingsuggestions != pendingsuggestions ) %] / All libraries: [% all_pendingsuggestions | html %] diff --git a/mainpage.pl b/mainpage.pl index f5872e65bb..47214cb2f2 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -85,11 +85,14 @@ if( C4::Context->only_my_library ){ $template->param( pendingsuggestions => $local_pendingsuggestions_count ); } else { my $pendingsuggestions = Koha::Suggestions->search({ status => "ASKED" }); - my $local_pendingsuggestions_count = $pendingsuggestions->search({ 'me.branchcode' => C4::Context->userenv()->{'branch'} })->count(); + if( C4::Context->userenv() && C4::Context->userenv()->{branch} ){ + my $local_pendingsuggestions_count = $pendingsuggestions->search({ 'me.branchcode' => C4::Context->userenv()->{'branch'} })->count(); + $template->param( pendingsuggestions => $local_pendingsuggestions_count ); + } + my $pendingsuggestions_count = $pendingsuggestions->count(); $template->param( - all_pendingsuggestions => $pendingsuggestions_count != $local_pendingsuggestions_count ? $pendingsuggestions_count : 0, - pendingsuggestions => $local_pendingsuggestions_count + all_pendingsuggestions => $pendingsuggestions_count, ); } -- 2.30.2