From 93bca003436536478d8bea78ff8b38077b6a4777 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 26 Feb 2025 23:07:56 +0000 Subject: [PATCH] Bug 37883: Add ability to filter search results location column by logged in location To test: 1. Apply patch, restart_all, and regenerate CSS ( https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_interface ) I also recommend clearing your browser cache. 2. Do a catalog search and notice the 'Show local items only' button above the "Location" column. 3. Click it to show information ( in that column ) that is only related to the branch you are currently logged in at. 4. In the same result set have some items that are checked out, withdrawn, lost, damaged, and notforlaon. 5. Play more with the search results and ensure everything is accurate. --- catalogue/search.pl | 3 + .../prog/css/src/staff-global.scss | 8 +++ .../prog/en/modules/catalogue/results.tt | 58 +++++++++++++++---- 3 files changed, 59 insertions(+), 10 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index b64f0551b05..91ce2fa0908 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -200,6 +200,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 47e85450abc..283b2f4d60f 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -2026,6 +2026,14 @@ 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 ade947fd89d..53e1360e2e3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -554,7 +554,7 @@ [% ELSE # /IF scan %]
[% INCLUDE 'page-numbers.inc' %] - +
[% IF ( searchdesc ) %] [% FOREACH QUERY_INPUT IN QUERY_INPUTS %] @@ -747,17 +747,39 @@
[% IF MaxSearchResultsItemsPerRecordStatusCheck && SEARCH_RESULT.items_count > MaxSearchResultsItemsPerRecordStatusCheck %] +
+ [% 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 %] +
+ [% ELSE %] +
[% 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 %] - - [% ELSE %] - [% 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 +
+ [% 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 %] [% END %]
@@ -766,11 +788,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 %] @@ -848,9 +872,12 @@ [% END %] [% ELSE %] - No items + No items [% END %] [% END # /IF ( SEARCH_RESULT.items_count ) %] + [% IF SEARCH_RESULT.branchtotalcount == 0 %] + No items + [% END %]
@@ -935,6 +962,17 @@ 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.5