From 4daeaf55968af0139ec4b715b86a970487cc4adf Mon Sep 17 00:00:00 2001 From: Andreas Roussos Date: Fri, 3 Dec 2021 15:23:20 +0100 Subject: [PATCH] Bug 29628: (follow-up) fix for rare edge case When the number of pending suggestions in the currently selected branch is equal to the number of pending suggestions across all branches, the `all_pendingsuggestions` template parameter is equal to 0. This results in the "Suggestions pending approval:" block not being printed at all. This follow-up patch fixes that. Also fixed is the display of pending suggestions in Home > Acquisitions. Test plan: 1) Apply this patch. 2) Create two Library branches; submit two suggestions in each one. 3) Visit the Home page, and also visit Home > Acquisitions: you should only see "${BRANCH_CODE}: 2" suggestions pending approval, regardless of the branch you have selected using the 'Set library' menu option. 4) Delete both suggestions from the 1st branch, and set your library to be the 1st branch. 5) Visit the same pages: this time "${BRANCH_CODE}: 0 / All libraries: 2" is displayed. 6) Set your library to be the 2nd branch, and visit the same two pages: this time "${BRANCH_CODE}: 2" is displayed. Signed-off-by: David Nind --- acqui/acqui-home.pl | 7 ++++--- .../intranet-tmpl/prog/en/modules/acqui/acqui-home.tt | 10 +++++----- .../intranet-tmpl/prog/en/modules/intranet-main.tt | 10 +++++----- mainpage.pl | 7 ++++--- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/acqui/acqui-home.pl b/acqui/acqui-home.pl index 3010c6a3a3..6ee6fe0d0f 100755 --- a/acqui/acqui-home.pl +++ b/acqui/acqui-home.pl @@ -51,14 +51,15 @@ my $status = $query->param('status') || "ASKED"; # both to template if( C4::Context->only_my_library ){ my $local_pendingsuggestions_count = Koha::Suggestions->search({ status => "ASKED", branchcode => C4::Context->userenv()->{'branch'} })->count(); - $template->param( suggestions_count => $local_pendingsuggestions_count ); + $template->param( local_suggestions_count => $local_pendingsuggestions_count ); } else { my $pendingsuggestions = Koha::Suggestions->search({ status => "ASKED" }); my $local_pendingsuggestions_count = $pendingsuggestions->search({ 'me.branchcode' => C4::Context->userenv()->{'branch'} })->count(); my $pendingsuggestions_count = $pendingsuggestions->count(); $template->param( - all_pendingsuggestions => $pendingsuggestions_count != $local_pendingsuggestions_count ? $pendingsuggestions_count : 0, - suggestions_count => $local_pendingsuggestions_count + suggestions_counts_differ => $pendingsuggestions_count != $local_pendingsuggestions_count ? 1 : 0, + all_suggestions_count => $pendingsuggestions_count, + local_suggestions_count => $local_pendingsuggestions_count ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt index 02f0bbac29..6663f1e0c3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt @@ -41,7 +41,7 @@ [% END %] [% END %]
- [% IF ( suggestion && suggestions_count ) %] + [% IF ( all_suggestions_count ) %]
[% ELSE %]
@@ -58,7 +58,7 @@
-[% IF ( CAN_user_suggestions_suggestions_manage && suggestion && suggestions_count ) %] +[% IF ( CAN_user_suggestions_suggestions_manage && all_suggestions_count ) %]
@@ -66,12 +66,12 @@

Manage suggestions: - [% Branches.GetLoggedInBranchname | html %]: [% suggestions_count | html %] + [% Branches.GetLoggedInBranchname | html %]: [% local_suggestions_count | html %] - [% IF (all_pendingsuggestions > 0) %] + [% IF (suggestions_counts_differ) %] / - All libraries: [% all_pendingsuggestions | html %] + All libraries: [% all_suggestions_count | html %] [% END %]

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 6978be0f68..fd001e1ff8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -165,7 +165,7 @@
[%# Following statement must be in one line for translatability %] - [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && all_pendingsuggestions ) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs %] + [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && all_suggestions_count ) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs %]
[% IF pending_article_requests %]
@@ -175,17 +175,17 @@
[% END %] - [% IF ( CAN_user_suggestions_suggestions_manage && all_pendingsuggestions ) %] + [% IF ( CAN_user_suggestions_suggestions_manage && all_suggestions_count ) %] diff --git a/mainpage.pl b/mainpage.pl index 6972d39871..5f3b3b10bc 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -81,14 +81,15 @@ my $pendingtags = get_count_by_tag_status(0); if( C4::Context->only_my_library ){ my $local_pendingsuggestions_count = Koha::Suggestions->search({ status => "ASKED", branchcode => C4::Context->userenv()->{'branch'} })->count(); - $template->param( pendingsuggestions => $local_pendingsuggestions_count ); + $template->param( local_suggestions_count => $local_pendingsuggestions_count ); } else { my $pendingsuggestions = Koha::Suggestions->search({ status => "ASKED" }); my $local_pendingsuggestions_count = $pendingsuggestions->search({ 'me.branchcode' => C4::Context->userenv()->{'branch'} })->count(); my $pendingsuggestions_count = $pendingsuggestions->count(); $template->param( - all_pendingsuggestions => $pendingsuggestions_count != $local_pendingsuggestions_count ? $pendingsuggestions_count : 0, - pendingsuggestions => $local_pendingsuggestions_count + suggestions_counts_differ => $pendingsuggestions_count != $local_pendingsuggestions_count ? 1 : 0, + all_suggestions_count => $pendingsuggestions_count, + local_suggestions_count => $local_pendingsuggestions_count ); } -- 2.20.1