Lines 20-26
Link Here
|
20 |
[%# - branch: select library list %] |
20 |
[%# - branch: select library list %] |
21 |
[%# - category: select patron category list %] |
21 |
[%# - category: select patron category list %] |
22 |
[%# - search_field: select patron field list %] |
22 |
[%# - search_field: select patron field list %] |
23 |
[%# - search_type: select 'contain' or 'start with' %] |
23 |
[%# - search_type: select 'contains' or 'starts with' %] |
|
|
24 |
[%- SET searchtype = Koha.Preference('DefaultPatronSearchMethod') -%] |
24 |
[% BLOCK patron_search_filters %] |
25 |
[% BLOCK patron_search_filters %] |
25 |
<form id="patron_search_form"> |
26 |
<form id="patron_search_form"> |
26 |
<fieldset class="brief"> |
27 |
<fieldset class="brief"> |
Lines 64-75
Link Here
|
64 |
<li> |
65 |
<li> |
65 |
<label for="searchtype_filter">Search type:</label> |
66 |
<label for="searchtype_filter">Search type:</label> |
66 |
<select name="searchtype" id="searchtype_filter"> |
67 |
<select name="searchtype" id="searchtype_filter"> |
67 |
[% IF searchtype == "start_with" %] |
68 |
[% IF searchtype == "starts_with" %] |
68 |
<option value='start_with' selected="selected">Starts with</option> |
69 |
<option value='starts_with' selected="selected">Starts with</option> |
69 |
<option value="contain">Contains</option> |
70 |
<option value="contains">Contains</option> |
70 |
[% ELSE %] |
71 |
[% ELSE %] |
71 |
<option value='start_with'>Starts with</option> |
72 |
<option value='starts_with'>Starts with</option> |
72 |
<option value="contain" selected="selected">Contains</option> |
73 |
<option value="contains" selected="selected">Contains</option> |
73 |
[% END %] |
74 |
[% END %] |
74 |
</select> |
75 |
</select> |
75 |
</li> |
76 |
</li> |
Lines 303-309
Link Here
|
303 |
let patterns = pattern.split(/[\s,]+/).filter(function(s){ return s.length }); |
304 |
let patterns = pattern.split(/[\s,]+/).filter(function(s){ return s.length }); |
304 |
|
305 |
|
305 |
let filters = []; |
306 |
let filters = []; |
306 |
let search_type = $("#searchtype_filter").val() || "contain"; |
307 |
let search_type = $("#searchtype_filter").val() || "contains"; |
307 |
let search_fields = $("#searchfieldstype_filter").val(); |
308 |
let search_fields = $("#searchfieldstype_filter").val(); |
308 |
if ( !search_fields ) { |
309 |
if ( !search_fields ) { |
309 |
search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,middle_name,surname,othernames,cardnumber,userid' | html %]"; |
310 |
search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,middle_name,surname,othernames,cardnumber,userid' | html %]"; |
Lines 313-319
Link Here
|
313 |
patterns.forEach(function(pattern,i){ |
314 |
patterns.forEach(function(pattern,i){ |
314 |
let sub_or = []; |
315 |
let sub_or = []; |
315 |
search_fields.split(',').forEach(function(attr,ii){ |
316 |
search_fields.split(',').forEach(function(attr,ii){ |
316 |
sub_or.push({["me."+attr]:{"like":(search_type == "contain" ? "%" : "" ) + pattern + "%"}}); |
317 |
sub_or.push({["me."+attr]:{"like":(search_type == "contains" ? "%" : "" ) + pattern + "%"}}); |
317 |
if ( attr == 'dateofbirth' ) { |
318 |
if ( attr == 'dateofbirth' ) { |
318 |
try { |
319 |
try { |
319 |
let d = $date_to_rfc3339(pattern); |
320 |
let d = $date_to_rfc3339(pattern); |
Lines 332-338
Link Here
|
332 |
patterns.forEach(function(pattern,i){ |
333 |
patterns.forEach(function(pattern,i){ |
333 |
let sub_or = []; |
334 |
let sub_or = []; |
334 |
sub_or.push({ |
335 |
sub_or.push({ |
335 |
"extended_attributes.value": { "like": "%" + pattern + (search_type == "contain" ? "%" : "" )}, |
336 |
"extended_attributes.value": { "like": "%" + pattern + (search_type == "contains" ? "%" : "" )}, |
336 |
"extended_attributes.code": extended_attribute_types |
337 |
"extended_attributes.code": extended_attribute_types |
337 |
}); |
338 |
}); |
338 |
subquery_and.push(sub_or); |
339 |
subquery_and.push(sub_or); |
Lines 717-723
Link Here
|
717 |
function update_search_description(){ |
718 |
function update_search_description(){ |
718 |
var searched = $("#searchfieldstype_filter").find("option:selected").text(); |
719 |
var searched = $("#searchfieldstype_filter").find("option:selected").text(); |
719 |
if ( $("#search_patron_filter").val() ) { |
720 |
if ( $("#search_patron_filter").val() ) { |
720 |
if ( $("#searchtype_filter").val() == 'start_with' ) { |
721 |
if ( $("#searchtype_filter").val() == 'starts_with' ) { |
721 |
searched += _(" starting with "); |
722 |
searched += _(" starting with "); |
722 |
} else { |
723 |
} else { |
723 |
searched += _(" containing "); |
724 |
searched += _(" containing "); |
Lines 787-793
Link Here
|
787 |
|
788 |
|
788 |
function clearFilters() { |
789 |
function clearFilters() { |
789 |
$("#searchfieldstype_filter option:first").prop("selected", true); |
790 |
$("#searchfieldstype_filter option:first").prop("selected", true); |
790 |
$("#searchtype_filter option[value='contain']").prop("selected", true); |
791 |
$("#searchtype_filter option[value='[% searchtype || 'contains' | html %]']").prop("selected", true); |
791 |
$("#categorycode_filter option:first").prop("selected", true); |
792 |
$("#categorycode_filter option:first").prop("selected", true); |
792 |
$("#branchcode_filter option:first").prop("selected", true); |
793 |
$("#branchcode_filter option:first").prop("selected", true); |
793 |
$("#firstletter_filter").val(''); |
794 |
$("#firstletter_filter").val(''); |