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 74-85
Link Here
|
74 |
<li> |
75 |
<li> |
75 |
<label for="searchtype_filter">Search type:</label> |
76 |
<label for="searchtype_filter">Search type:</label> |
76 |
<select name="searchtype" id="searchtype_filter"> |
77 |
<select name="searchtype" id="searchtype_filter"> |
77 |
[% IF searchtype == "start_with" %] |
78 |
[% IF searchtype == "starts_with" %] |
78 |
<option value='start_with' selected="selected">Starts with</option> |
79 |
<option value='starts_with' selected="selected">Starts with</option> |
79 |
<option value="contain">Contains</option> |
80 |
<option value="contains">Contains</option> |
80 |
[% ELSE %] |
81 |
[% ELSE %] |
81 |
<option value='start_with'>Starts with</option> |
82 |
<option value='starts_with'>Starts with</option> |
82 |
<option value="contain" selected="selected">Contains</option> |
83 |
<option value="contains" selected="selected">Contains</option> |
83 |
[% END %] |
84 |
[% END %] |
84 |
</select> |
85 |
</select> |
85 |
</li> |
86 |
</li> |
Lines 339-345
Link Here
|
339 |
} |
340 |
} |
340 |
let patterns = pattern.split(/[\s,]+/).filter(function(s){ return s.length }); |
341 |
let patterns = pattern.split(/[\s,]+/).filter(function(s){ return s.length }); |
341 |
|
342 |
|
342 |
let search_type = $("#searchtype_filter").val() || "contain"; |
343 |
let search_type = $("#searchtype_filter").val() || "contains"; |
343 |
let search_fields = $("#searchfieldstype_filter").val(); |
344 |
let search_fields = $("#searchfieldstype_filter").val(); |
344 |
if ( !search_fields ) { |
345 |
if ( !search_fields ) { |
345 |
search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,middle_name,surname,othernames,cardnumber,userid' | html %]"; |
346 |
search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,middle_name,surname,othernames,cardnumber,userid' | html %]"; |
Lines 349-355
Link Here
|
349 |
patterns.forEach(function(pattern,i){ |
350 |
patterns.forEach(function(pattern,i){ |
350 |
let sub_or = []; |
351 |
let sub_or = []; |
351 |
search_fields.split(',').forEach(function(attr,ii){ |
352 |
search_fields.split(',').forEach(function(attr,ii){ |
352 |
sub_or.push({["me."+attr]:{"like":(search_type == "contain" ? "%" : "" ) + pattern + "%"}}); |
353 |
sub_or.push({["me."+attr]:{"like":(search_type == "contains" ? "%" : "" ) + pattern + "%"}}); |
353 |
if ( attr == 'dateofbirth' ) { |
354 |
if ( attr == 'dateofbirth' ) { |
354 |
try { |
355 |
try { |
355 |
let d = $date_to_rfc3339(pattern); |
356 |
let d = $date_to_rfc3339(pattern); |
Lines 368-374
Link Here
|
368 |
patterns.forEach(function(pattern,i){ |
369 |
patterns.forEach(function(pattern,i){ |
369 |
let sub_or = []; |
370 |
let sub_or = []; |
370 |
sub_or.push({ |
371 |
sub_or.push({ |
371 |
"extended_attributes.value": { "like": "%" + pattern + (search_type == "contain" ? "%" : "" )}, |
372 |
"extended_attributes.value": { "like": "%" + pattern + (search_type == "contains" ? "%" : "" )}, |
372 |
"extended_attributes.code": extended_attribute_types |
373 |
"extended_attributes.code": extended_attribute_types |
373 |
}); |
374 |
}); |
374 |
subquery_and.push(sub_or); |
375 |
subquery_and.push(sub_or); |
Lines 758-764
Link Here
|
758 |
function update_search_description(){ |
759 |
function update_search_description(){ |
759 |
var searched = $("#searchfieldstype_filter").find("option:selected").text(); |
760 |
var searched = $("#searchfieldstype_filter").find("option:selected").text(); |
760 |
if ( $("#search_patron_filter").val() ) { |
761 |
if ( $("#search_patron_filter").val() ) { |
761 |
if ( $("#searchtype_filter").val() == 'start_with' ) { |
762 |
if ( $("#searchtype_filter").val() == 'starts_with' ) { |
762 |
searched += _(" starting with "); |
763 |
searched += _(" starting with "); |
763 |
} else { |
764 |
} else { |
764 |
searched += _(" containing "); |
765 |
searched += _(" containing "); |
Lines 846-852
Link Here
|
846 |
|
847 |
|
847 |
function clearFilters() { |
848 |
function clearFilters() { |
848 |
$("#searchfieldstype_filter option:first").prop("selected", true); |
849 |
$("#searchfieldstype_filter option:first").prop("selected", true); |
849 |
$("#searchtype_filter option[value='contain']").prop("selected", true); |
850 |
$("#searchtype_filter option[value='[% searchtype || 'contains' | html %]']").prop("selected", true); |
850 |
$("#categorycode_filter option:first").prop("selected", true); |
851 |
$("#categorycode_filter option:first").prop("selected", true); |
851 |
$("#branchcode_filter option:first").prop("selected", true); |
852 |
$("#branchcode_filter option:first").prop("selected", true); |
852 |
$("#sort1_filter").val('').trigger("change"); |
853 |
$("#sort1_filter").val('').trigger("change"); |