Bug 35127: Fix 'Search type' for patron search

We need to fallback on the syspref DefaultPatronSearchMethod but keep
the value when one is passed!

Test plan:
Search for patrons, and use the "search type". Set it to different
values than DefaultPatronSearchMethod and confirm that the value is
kept.
Fix is expected when searching for patrons in the header (use the
options to select a different value and run the search)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit e08bf3bb4c)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit e9363693e0)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2023-10-24 15:32:53 +02:00 committed by Matt Blenkinsop
parent 5cbaec63a3
commit 21462582f5
4 changed files with 7 additions and 5 deletions

View file

@ -4,7 +4,7 @@
[% USE Koha %] [% USE Koha %]
[% PROCESS 'patronfields.inc' %] [% PROCESS 'patronfields.inc' %]
[% IF CAN_user_borrowers_edit_borrowers %] [% IF CAN_user_borrowers_edit_borrowers %]
[%- SET searchtype = Koha.Preference('DefaultPatronSearchMethod') -%] [%- SET searchtype = searchtype || Koha.Preference('DefaultPatronSearchMethod') -%]
[% IF( bs_tab_active ) %] [% IF( bs_tab_active ) %]
<div id="patron_search" role="tabpanel" class="tab-pane active"> <div id="patron_search" role="tabpanel" class="tab-pane active">
[% ELSE %] [% ELSE %]

View file

@ -23,7 +23,7 @@
[%# - sort2: select patron sort2 field %] [%# - sort2: select patron sort2 field %]
[%# - search_field: select patron field list %] [%# - search_field: select patron field list %]
[%# - search_type: select 'contains' or 'starts with' %] [%# - search_type: select 'contains' or 'starts with' %]
[%- SET searchtype = Koha.Preference('DefaultPatronSearchMethod') -%] [%- searchtype = searchtype || Koha.Preference('DefaultPatronSearchMethod') -%]
[% BLOCK patron_search_filters %] [% BLOCK patron_search_filters %]
<form id="patron_search_form"> <form id="patron_search_form">
<fieldset class="brief"> <fieldset class="brief">
@ -318,7 +318,7 @@
"-and": function(){ "-and": function(){
let filters = []; let filters = [];
let search_type = $("#searchtype_filter").val() || "contains"; let search_type = $("#searchtype_filter").val();
let search_fields = $("#searchfieldstype_filter").val(); let search_fields = $("#searchfieldstype_filter").val();
let pattern = $("#search_patron_filter").val(); let pattern = $("#search_patron_filter").val();
@ -815,7 +815,7 @@
function clearFilters() { function clearFilters() {
$("#searchfieldstype_filter option:first").prop("selected", true); $("#searchfieldstype_filter option:first").prop("selected", true);
$("#searchtype_filter option[value='[% searchtype || 'contains' | html %]']").prop("selected", true); $("#searchtype_filter option[value='[% searchtype | html %]']").prop("selected", true);
$("#categorycode_filter option:first").prop("selected", true); $("#categorycode_filter option:first").prop("selected", true);
$("#branchcode_filter option:first").prop("selected", true); $("#branchcode_filter option:first").prop("selected", true);
$("#sort1_filter").val('').trigger("change"); $("#sort1_filter").val('').trigger("change");

View file

@ -9,7 +9,7 @@
[% SET libraries = Branches.all %] [% SET libraries = Branches.all %]
[% SET categories = Categories.all.unblessed %] [% SET categories = Categories.all.unblessed %]
[% SET columns = ['cardnumber', 'name-address', 'dateofbirth', 'branch', 'category', 'dateexpiry', 'checkouts', 'account_balance', 'borrowernotes', 'action'] %] [% SET columns = ['cardnumber', 'name-address', 'dateofbirth', 'branch', 'category', 'dateexpiry', 'checkouts', 'account_balance', 'borrowernotes', 'action'] %]
[% SET searchtype = Koha.Preference('DefaultPatronSearchMethod') %] [% SET searchtype = searchtype || Koha.Preference('DefaultPatronSearchMethod') %]
[% PROCESS 'patron-search.inc' %] [% PROCESS 'patron-search.inc' %]
[% INCLUDE 'doc-head-open.inc' %] [% INCLUDE 'doc-head-open.inc' %]
<title>Patrons[% IF ( searching ) %] &rsaquo; Search results[% END %] &rsaquo; Koha</title> <title>Patrons[% IF ( searching ) %] &rsaquo; Search results[% END %] &rsaquo; Koha</title>

View file

@ -65,6 +65,7 @@ if ( $quicksearch and $searchmember && !$circsearch ) {
} }
my $searchfieldstype = $input->param('searchfieldstype') || 'standard'; my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
my $searchtype = $input->param('searchtype');
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ); $template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
@ -75,6 +76,7 @@ $template->param(
searchmember => $searchmember, searchmember => $searchmember,
branchcode_filter => scalar $input->param('branchcode_filter'), branchcode_filter => scalar $input->param('branchcode_filter'),
categorycode_filter => scalar $input->param('categorycode_filter'), categorycode_filter => scalar $input->param('categorycode_filter'),
searchtype => $searchtype,
searchfieldstype => $searchfieldstype, searchfieldstype => $searchfieldstype,
PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20, PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
do_not_defer_loading => !$defer_loading, do_not_defer_loading => !$defer_loading,