From 02174f9dc2a4cdbbaa014f77b6edc9c824afa8a8 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 10 Sep 2024 15:39:53 +0000 Subject: [PATCH] Bug 37883: Add ability to filter search results location column by logged in location --- catalogue/search.pl | 3 ++ .../prog/css/src/staff-global.scss | 7 ++++- .../prog/en/modules/catalogue/results.tt | 30 +++++++++++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index ebb78bcfb6e..8ecbe49e9ab 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -198,6 +198,9 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({ my $lang = C4::Languages::getlanguage($cgi); +my $userenv_branch = C4::Context->userenv->{'branch'} || ''; +$template->param( userbranch => $userenv_branch ); + if (C4::Context->preference("marcflavour") eq "UNIMARC" ) { $template->param('UNIMARC' => 1); } diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 2bc5c5db27a..38eb560b915 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -1942,7 +1942,6 @@ li { &.unavailable { clear: left; - display: block; } } @@ -1959,6 +1958,12 @@ li { display: block; } } + .all { + display: block; + } + .branch_specific { + display: none; + } } #searchresults, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index e2dcdb6ff87..95d0b1391ca 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -451,7 +451,7 @@
[% INCLUDE 'page-numbers.inc' %] - +
[% IF ( searchdesc ) %] [% FOREACH QUERY_INPUT IN QUERY_INPUTS %] @@ -611,7 +611,10 @@ [% END %] - [% tnx('{count} item', '{count} items', SEARCH_RESULT.items_count, {count = SEARCH_RESULT.items_count}) | html %][% IF ( SEARCH_RESULT.availablecount ) %], [% SEARCH_RESULT.availablecount | html %] available:[% ELSE %], None available[% END %] +
[% tnx('{count} item', '{count} items', SEARCH_RESULT.items_count, {count = SEARCH_RESULT.items_count}) | html %][% IF ( SEARCH_RESULT.availablecount ) %], [% SEARCH_RESULT.availablecount | html %] available:[% ELSE %], None available[% END %]
+ [% IF SEARCH_RESULT.branchtotalcount > 0 %] +
[% tnx('{count} item', '{count} items', SEARCH_RESULT.branchtotalcount, {count = SEARCH_RESULT.branchtotalcount}) | html %][% IF ( SEARCH_RESULT.branchavailablecount ) %], [% SEARCH_RESULT.branchavailablecount | html %] available:[% ELSE %], None available[% END %]
+ [% END %] [% IF MaxSearchResultsItemsPerRecordStatusCheck && SEARCH_RESULT.items_count > MaxSearchResultsItemsPerRecordStatusCheck %]
@@ -621,11 +624,13 @@ [% BLOCK search_result_items %] [% IF status_count == "onloancount" %] [% IF SEARCH_RESULT.${status_count} > 0 %] -
[% SEARCH_RESULT.${status_count} | html %] checked out:
+
[% SEARCH_RESULT.${status_count} | html %] checked out:
+
[% SEARCH_RESULT.branchonloancount | html %] checked out:
[% END %] [% ELSIF status_count == "othercount" %] [% IF SEARCH_RESULT.${status_count} > 0 %] -
[% SEARCH_RESULT.${status_count} | html %] unavailable:
+
[% SEARCH_RESULT.${status_count} | html %] unavailable:
+
[% SEARCH_RESULT.branchothercount | html %] unavailable:
[% END %] [% END %] [% IF SEARCH_RESULT.${items_loop}.size > 0 %] @@ -704,9 +709,12 @@ [% END %] [% ELSE %] - No items + No items [% END %] [% END # /IF ( SEARCH_RESULT.items_count ) %] + [% IF SEARCH_RESULT.branchtotalcount == 0 %] + No items + [% END %]
@@ -816,6 +824,18 @@ var biblionumber = "[% biblionumber | html %]"; var holdfor_cardnumber = "[% holdfor_patron.cardnumber | html %]"; var holdforclub = "[% holdforclub | html %]"; + var userbranch = "[% userbranch | html %]"; + + $('#toggleitems').click( function() { + $('#toggleitems').text() === 'Show local items only' ? $('#toggleitems').text("Show items in all libraries") : $('#toggleitems').text("Show local items only"); + $('.branch_specific').toggle(); + $('.all').toggle(); + $('ul[class*="_loop_items"] li').each( function() { + if ( !$(this).hasClass(userbranch) ) { + $(this).toggle(); + } + }); + }); [% IF SEARCH_RESULTS %] var SEARCH_RESULTS = 1; [% ELSE %] -- 2.39.2