|
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 filters = []; |
|
|
344 |
let search_type = $("#searchtype_filter").val() || "contains"; |
| 343 |
let search_fields = $("#searchfieldstype_filter").val(); |
345 |
let search_fields = $("#searchfieldstype_filter").val(); |
| 344 |
if ( !search_fields ) { |
346 |
if ( !search_fields ) { |
| 345 |
search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,middle_name,surname,othernames,cardnumber,userid' | html %]"; |
347 |
search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,middle_name,surname,othernames,cardnumber,userid' | html %]"; |
|
Lines 349-355
Link Here
|
| 349 |
patterns.forEach(function(pattern,i){ |
351 |
patterns.forEach(function(pattern,i){ |
| 350 |
let sub_or = []; |
352 |
let sub_or = []; |
| 351 |
search_fields.split(',').forEach(function(attr,ii){ |
353 |
search_fields.split(',').forEach(function(attr,ii){ |
| 352 |
sub_or.push({["me."+attr]:{"like":(search_type == "contain" ? "%" : "" ) + pattern + "%"}}); |
354 |
sub_or.push({["me."+attr]:{"like":(search_type == "contains" ? "%" : "" ) + pattern + "%"}}); |
| 353 |
if ( attr == 'dateofbirth' ) { |
355 |
if ( attr == 'dateofbirth' ) { |
| 354 |
try { |
356 |
try { |
| 355 |
let d = $date_to_rfc3339(pattern); |
357 |
let d = $date_to_rfc3339(pattern); |
|
Lines 368-374
Link Here
|
| 368 |
patterns.forEach(function(pattern,i){ |
370 |
patterns.forEach(function(pattern,i){ |
| 369 |
let sub_or = []; |
371 |
let sub_or = []; |
| 370 |
sub_or.push({ |
372 |
sub_or.push({ |
| 371 |
"extended_attributes.value": { "like": "%" + pattern + (search_type == "contain" ? "%" : "" )}, |
373 |
"extended_attributes.value": { "like": "%" + pattern + (search_type == "contains" ? "%" : "" )}, |
| 372 |
"extended_attributes.code": extended_attribute_types |
374 |
"extended_attributes.code": extended_attribute_types |
| 373 |
}); |
375 |
}); |
| 374 |
subquery_and.push(sub_or); |
376 |
subquery_and.push(sub_or); |
|
Lines 753-759
Link Here
|
| 753 |
function update_search_description(){ |
755 |
function update_search_description(){ |
| 754 |
var searched = $("#searchfieldstype_filter").find("option:selected").text(); |
756 |
var searched = $("#searchfieldstype_filter").find("option:selected").text(); |
| 755 |
if ( $("#search_patron_filter").val() ) { |
757 |
if ( $("#search_patron_filter").val() ) { |
| 756 |
if ( $("#searchtype_filter").val() == 'start_with' ) { |
758 |
if ( $("#searchtype_filter").val() == 'starts_with' ) { |
| 757 |
searched += _(" starting with "); |
759 |
searched += _(" starting with "); |
| 758 |
} else { |
760 |
} else { |
| 759 |
searched += _(" containing "); |
761 |
searched += _(" containing "); |
|
Lines 841-847
Link Here
|
| 841 |
|
843 |
|
| 842 |
function clearFilters() { |
844 |
function clearFilters() { |
| 843 |
$("#searchfieldstype_filter option:first").prop("selected", true); |
845 |
$("#searchfieldstype_filter option:first").prop("selected", true); |
| 844 |
$("#searchtype_filter option[value='contain']").prop("selected", true); |
846 |
$("#searchtype_filter option[value='[% searchtype || 'contains' | html %]']").prop("selected", true); |
| 845 |
$("#categorycode_filter option:first").prop("selected", true); |
847 |
$("#categorycode_filter option:first").prop("selected", true); |
| 846 |
$("#branchcode_filter option:first").prop("selected", true); |
848 |
$("#branchcode_filter option:first").prop("selected", true); |
| 847 |
$("#sort1_filter").val('').trigger("change"); |
849 |
$("#sort1_filter").val('').trigger("change"); |