Lines 7-17
Link Here
|
7 |
[% USE Asset %] |
7 |
[% USE Asset %] |
8 |
[% USE To %] |
8 |
[% USE To %] |
9 |
|
9 |
|
|
|
10 |
[% SET search_results_block_id = 'searchresults' %] |
11 |
|
10 |
[%# Display a simple form %] |
12 |
[%# Display a simple form %] |
11 |
[% BLOCK patron_search_filters_simple %] |
13 |
[% BLOCK patron_search_filters_simple %] |
12 |
<form id="patron_search_form"> |
14 |
<form class="patron_search_form"> |
13 |
<div class="hint">Enter patron card number or partial name:</div> |
15 |
<div class="hint">Enter patron card number or partial name:</div> |
14 |
<input type="text" size="40" id="search_patron_filter" class="focus" autocomplete="off" /> |
16 |
<input type="text" size="40" class="search_patron_filter" class="focus" autocomplete="off" /> |
15 |
<input type="submit" class="btn btn-primary" value="Search" /> |
17 |
<input type="submit" class="btn btn-primary" value="Search" /> |
16 |
</form> |
18 |
</form> |
17 |
[% END %] |
19 |
[% END %] |
Lines 27-39
Link Here
|
27 |
[%# - search_type: select 'contains' or 'starts with' %] |
29 |
[%# - search_type: select 'contains' or 'starts with' %] |
28 |
[%- searchtype = searchtype || Koha.Preference('DefaultPatronSearchMethod') -%] |
30 |
[%- searchtype = searchtype || Koha.Preference('DefaultPatronSearchMethod') -%] |
29 |
[% BLOCK patron_search_filters %] |
31 |
[% BLOCK patron_search_filters %] |
30 |
<form id="patron_search_form"> |
32 |
|
|
|
33 |
<form class="patron_search_form"> |
31 |
<fieldset class="brief"> |
34 |
<fieldset class="brief"> |
32 |
<h3>Search for patron</h3> |
35 |
<h3>Search for patron</h3> |
33 |
<ol> |
36 |
<ol> |
34 |
<li> |
37 |
<li> |
35 |
<label for="search_patron_filter">Search:</label> |
38 |
<label for="search_patron_filter">Search:</label> |
36 |
<input type="text" id="search_patron_filter" value="[% search_filter | html %]" class="focus" /> |
39 |
<input type="text" class="search_patron_filter" value="[% search_filter | html %]" class="focus" /> |
37 |
</li> |
40 |
</li> |
38 |
|
41 |
|
39 |
[% FOR f IN filters %] |
42 |
[% FOR f IN filters %] |
Lines 41-47
Link Here
|
41 |
[% CASE 'branch' %] |
44 |
[% CASE 'branch' %] |
42 |
<li> |
45 |
<li> |
43 |
<label for="branchcode_filter">Library:</label> |
46 |
<label for="branchcode_filter">Library:</label> |
44 |
<select id="branchcode_filter"> |
47 |
<select class="branchcode_filter"> |
45 |
[% SET libraries = Branches.all( only_from_group => 1 ) %] |
48 |
[% SET libraries = Branches.all( only_from_group => 1 ) %] |
46 |
[% IF libraries.size != 1 %] |
49 |
[% IF libraries.size != 1 %] |
47 |
<option value="">Any</option> |
50 |
<option value="">Any</option> |
Lines 54-60
Link Here
|
54 |
[% CASE 'category' %] |
57 |
[% CASE 'category' %] |
55 |
<li> |
58 |
<li> |
56 |
<label for="categorycode_filter">Category:</label> |
59 |
<label for="categorycode_filter">Category:</label> |
57 |
<select id="categorycode_filter"> |
60 |
<select class="categorycode_filter"> |
58 |
<option value="">Any</option> |
61 |
<option value="">Any</option> |
59 |
[% FOREACH category IN Categories.limited.unblessed %] |
62 |
[% FOREACH category IN Categories.limited.unblessed %] |
60 |
<option value="[% category.categorycode | html %]">[% category.description | html %]</option> |
63 |
<option value="[% category.categorycode | html %]">[% category.description | html %]</option> |
Lines 64-75
Link Here
|
64 |
[% CASE 'sort1' %] |
67 |
[% CASE 'sort1' %] |
65 |
<li> |
68 |
<li> |
66 |
<label for="sort1_filter">Sort 1:</label> |
69 |
<label for="sort1_filter">Sort 1:</label> |
67 |
[% PROCESS 'av-build-dropbox.inc' name="sort1_filter", category="Bsort1", empty=1, size = 20 %] |
70 |
[% PROCESS 'av-build-dropbox.inc' no_id => 1, name="sort1_filter", category="Bsort1", empty=1, size = 20 %] |
68 |
</li> |
71 |
</li> |
69 |
[% CASE 'sort2' %] |
72 |
[% CASE 'sort2' %] |
70 |
<li> |
73 |
<li> |
71 |
<label for="sort2_filter">Sort 2:</label> |
74 |
<label for="sort2_filter">Sort 2:</label> |
72 |
[% PROCESS 'av-build-dropbox.inc' name="sort2_filter", category="Bsort2", empty=1, size = 20 %] |
75 |
[% PROCESS 'av-build-dropbox.inc' no_id => 1, name="sort2_filter", category="Bsort2", empty=1, size = 20 %] |
73 |
</li> |
76 |
</li> |
74 |
[% CASE 'search_field' %] |
77 |
[% CASE 'search_field' %] |
75 |
<li> |
78 |
<li> |
Lines 78-84
Link Here
|
78 |
[% CASE 'search_type' %] |
81 |
[% CASE 'search_type' %] |
79 |
<li> |
82 |
<li> |
80 |
<label for="searchtype_filter">Search type:</label> |
83 |
<label for="searchtype_filter">Search type:</label> |
81 |
<select name="searchtype" id="searchtype_filter"> |
84 |
<select name="searchtype" class="searchtype_filter"> |
82 |
[% IF searchtype == "starts_with" %] |
85 |
[% IF searchtype == "starts_with" %] |
83 |
<option value='starts_with' selected="selected">Starts with</option> |
86 |
<option value='starts_with' selected="selected">Starts with</option> |
84 |
<option value="contains">Contains</option> |
87 |
<option value="contains">Contains</option> |
Lines 93-99
Link Here
|
93 |
</ol> |
96 |
</ol> |
94 |
<fieldset class="action"> |
97 |
<fieldset class="action"> |
95 |
<input type="submit" class="btn btn-primary" value="Search" /> |
98 |
<input type="submit" class="btn btn-primary" value="Search" /> |
96 |
<input type="button" value="Clear" id="clear_search" /> |
99 |
<input type="button" value="Clear" class="clear_search" /> |
97 |
</fieldset> |
100 |
</fieldset> |
98 |
</fieldset> |
101 |
</fieldset> |
99 |
</form> |
102 |
</form> |
Lines 135-148
Link Here
|
135 |
[% END %] |
138 |
[% END %] |
136 |
</div> |
139 |
</div> |
137 |
|
140 |
|
138 |
<h3 style="display: none;">Patrons found for: <span id="searchpattern"></span></h3> |
141 |
<h3 style="display: none;">Patrons found for: <span class="searchpattern"></span></h3> |
139 |
|
142 |
|
140 |
<div id="[% table_id | html %]_search_results" style="display:none;"> |
143 |
<div id="[% table_id | html %]_search_results" style="display:none;"> |
141 |
|
144 |
|
142 |
<div id="info" class="dialog message" style="display: none;"></div> |
145 |
<div class="info" class="dialog message" style="display: none;"></div> |
143 |
<div id="error" class="dialog alert" style="display: none;"></div> |
146 |
<div class="error" class="dialog alert" style="display: none;"></div> |
144 |
|
147 |
|
145 |
<input type="hidden" id="firstletter_filter" value="" /> |
148 |
<input type="hidden" class="firstletter_filter" value="" /> |
146 |
[% IF open_on_row_click %] |
149 |
[% IF open_on_row_click %] |
147 |
<table id="[% table_id | html %]" class="selections-table"> |
150 |
<table id="[% table_id | html %]" class="selections-table"> |
148 |
[% ELSE %] |
151 |
[% ELSE %] |
Lines 203-208
Link Here
|
203 |
[%# sticky_header and sticky_to: If we need a sticky header %] |
206 |
[%# sticky_header and sticky_to: If we need a sticky header %] |
204 |
[%# callback: name of the JS function that will be called when a patron is selected. Only work with action=select %] |
207 |
[%# callback: name of the JS function that will be called when a patron is selected. Only work with action=select %] |
205 |
[%# display_search_description: boolean, default off. Display the description of the search %] |
208 |
[%# display_search_description: boolean, default off. Display the description of the search %] |
|
|
209 |
[%# adjust_history: boolean, default off. Change the current url when a first letter is selected %] |
206 |
[% BLOCK patron_search_js %] |
210 |
[% BLOCK patron_search_js %] |
207 |
|
211 |
|
208 |
[% IF redirect_if_one_result && !redirect_url %] |
212 |
[% IF redirect_if_one_result && !redirect_url %] |
Lines 212-244
Link Here
|
212 |
<script> |
216 |
<script> |
213 |
[% SET libraries = Branches.all %] |
217 |
[% SET libraries = Branches.all %] |
214 |
[% SET categories = Categories.limited.unblessed %] |
218 |
[% SET categories = Categories.limited.unblessed %] |
215 |
let categories = [% To.json(categories) | $raw %].map(e => { |
219 |
var categories = [% To.json(categories) | $raw %].map(e => { |
216 |
e['_id'] = e.categorycode.toLowerCase(); |
220 |
e['_id'] = e.categorycode.toLowerCase(); |
217 |
e['_str'] = e.description; |
221 |
e['_str'] = e.description; |
218 |
return e; |
222 |
return e; |
219 |
}); |
223 |
}); |
220 |
let categories_map = categories.reduce((map, e) => { |
224 |
var categories_map = categories.reduce((map, e) => { |
221 |
map[e._id] = e; |
225 |
map[e._id] = e; |
222 |
return map; |
226 |
return map; |
223 |
}, {}); |
227 |
}, {}); |
224 |
let libraries = [% To.json(libraries) | $raw %].map(e => { |
228 |
var libraries = [% To.json(libraries) | $raw %].map(e => { |
225 |
e['_id'] = e.branchcode; |
229 |
e['_id'] = e.branchcode; |
226 |
e['_str'] = e.branchname; |
230 |
e['_str'] = e.branchname; |
227 |
return e; |
231 |
return e; |
228 |
}); |
232 |
}); |
229 |
let libraries_map = libraries.reduce((map, e) => { |
233 |
var libraries_map = libraries.reduce((map, e) => { |
230 |
map[e._id] = e; |
234 |
map[e._id] = e; |
231 |
return map; |
235 |
return map; |
232 |
}, {}); |
236 |
}, {}); |
233 |
|
237 |
|
234 |
[% IF Koha.Preference('ExtendedPatronAttributes') %] |
238 |
[% IF Koha.Preference('ExtendedPatronAttributes') %] |
235 |
[% SET extended_attribute_types = [ ExtendedAttributeTypes.codes( staff_searchable => 1, searched_by_default => 1 ) ] %] |
239 |
[% SET extended_attribute_types = [ ExtendedAttributeTypes.codes( staff_searchable => 1, searched_by_default => 1 ) ] %] |
236 |
let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; |
240 |
var extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; |
237 |
[% END %] |
241 |
[% END %] |
238 |
|
242 |
|
239 |
$(document).ready(function() { |
243 |
$(document).ready(function() { |
240 |
$('select#sort1_filter').select2({allowClear:true}); |
244 |
$('select[name="sort1_filter"]').select2({allowClear:true}); |
241 |
$('select#sort2_filter').select2({allowClear:true}); |
245 |
$('select[name="sort2_filter"]').select2({allowClear:true}); |
242 |
}); |
246 |
}); |
243 |
</script> |
247 |
</script> |
244 |
|
248 |
|
Lines 251-260
Link Here
|
251 |
[% END %] |
255 |
[% END %] |
252 |
|
256 |
|
253 |
<script> |
257 |
<script> |
254 |
var first_draw = 0; |
258 |
{ |
|
|
259 |
|
260 |
function get_patron_search_form(){ |
261 |
let parent_block = $("#[% search_results_block_id | html %]"); |
262 |
let patron_search_form = parent_block.siblings(".patron_search_form"); |
263 |
if ( !patron_search_form.length ) patron_search_form = $(".patron_search_form"); |
264 |
return patron_search_form; |
265 |
} |
266 |
let first_draw = 0; |
255 |
let patrons_table; |
267 |
let patrons_table; |
256 |
var Sticky; |
268 |
let Sticky; |
257 |
var singleBranchMode = '[% singleBranchMode | html %]'; |
269 |
let singleBranchMode = '[% singleBranchMode | html %]'; |
258 |
let logged_in_library_id = "[% Branches.GetLoggedInBranchcode | html %]"; |
270 |
let logged_in_library_id = "[% Branches.GetLoggedInBranchcode | html %]"; |
259 |
[% IF do_not_defer_loading %] |
271 |
[% IF do_not_defer_loading %] |
260 |
let defer_loading = 0; |
272 |
let defer_loading = 0; |
Lines 262-271
Link Here
|
262 |
let defer_loading = 1; |
274 |
let defer_loading = 1; |
263 |
[% END %] |
275 |
[% END %] |
264 |
|
276 |
|
265 |
/* popstate event triggered by forward and back button. Need to refresh search */ |
277 |
[% IF adjust_history %] |
266 |
window.addEventListener('popstate', (event) => { |
278 |
/* popstate event triggered by forward and back button. Need to refresh search */ |
267 |
getSearchByLocation( false ); |
279 |
window.addEventListener('popstate', (event) => { |
268 |
}); |
280 |
getSearchByLocation( false ); |
|
|
281 |
}); |
282 |
[% END %] |
269 |
|
283 |
|
270 |
[% SWITCH filter %] |
284 |
[% SWITCH filter %] |
271 |
[% CASE 'suggestions_managers' %] |
285 |
[% CASE 'suggestions_managers' %] |
Lines 283-293
Link Here
|
283 |
[% END %] |
297 |
[% END %] |
284 |
$(document).ready(function(){ |
298 |
$(document).ready(function(){ |
285 |
|
299 |
|
286 |
$("#info").hide(); |
300 |
let parent_block = $("#[% search_results_block_id | html %]"); |
287 |
$("#error").hide(); |
301 |
let patron_search_form = get_patron_search_form(); |
|
|
302 |
|
303 |
parent_block.find(".info").hide(); |
304 |
parent_block.find(".error").hide(); |
288 |
|
305 |
|
289 |
// Build the aLengthMenu |
306 |
// Build the aLengthMenu |
290 |
var aLengthMenu = [ |
307 |
let aLengthMenu = [ |
291 |
[% Koha.Preference('PatronsPerPage') | html %], 10, 20, 50, 100, -1 |
308 |
[% Koha.Preference('PatronsPerPage') | html %], 10, 20, 50, 100, -1 |
292 |
]; |
309 |
]; |
293 |
jQuery.unique(aLengthMenu); |
310 |
jQuery.unique(aLengthMenu); |
Lines 300-306
Link Here
|
300 |
} |
317 |
} |
301 |
return parseInt(a) < parseInt(b) ? -1 : 1;} |
318 |
return parseInt(a) < parseInt(b) ? -1 : 1;} |
302 |
); |
319 |
); |
303 |
var aLengthMenuLabel = []; |
320 |
let aLengthMenuLabel = []; |
304 |
$(aLengthMenu).each(function(){ |
321 |
$(aLengthMenu).each(function(){ |
305 |
if ( this == -1 ) { |
322 |
if ( this == -1 ) { |
306 |
// Label for -1 is "All" |
323 |
// Label for -1 is "All" |
Lines 312-327
Link Here
|
312 |
|
329 |
|
313 |
let additional_filters = { |
330 |
let additional_filters = { |
314 |
surname: function(){ |
331 |
surname: function(){ |
315 |
let start_with = $("#firstletter_filter").val() |
332 |
let start_with = parent_block.find(".firstletter_filter").val() |
316 |
if (!start_with) return ""; |
333 |
if (!start_with) return ""; |
317 |
return { "like": start_with + "%" } |
334 |
return { "like": start_with + "%" } |
318 |
}, |
335 |
}, |
319 |
"-and": function(){ |
336 |
"-and": function(){ |
320 |
let filters = []; |
337 |
let filters = []; |
321 |
|
338 |
|
322 |
let search_type = $("#searchtype_filter").val(); |
339 |
let search_type = patron_search_form.find(".searchtype_filter").val(); |
323 |
let search_fields = $("#searchfieldstype_filter").val() || "standard"; |
340 |
let search_fields = patron_search_form.find(".searchfieldstype_filter").val() || "standard"; |
324 |
let pattern = $("#search_patron_filter").val(); |
341 |
let pattern = patron_search_form.find(".search_patron_filter").val(); |
325 |
|
342 |
|
326 |
filters = buildPatronSearchQuery( |
343 |
filters = buildPatronSearchQuery( |
327 |
pattern, |
344 |
pattern, |
Lines 332-344
Link Here
|
332 |
} |
349 |
} |
333 |
); |
350 |
); |
334 |
|
351 |
|
335 |
let f_sort1 = $("#sort1_filter").val(); |
352 |
let f_sort1 = patron_search_form.find("select[name='sort1_filter']").val(); |
336 |
if ( f_sort1 ) { |
353 |
if ( f_sort1 ) { |
337 |
filters.push({ |
354 |
filters.push({ |
338 |
"me.sort1": f_sort1 |
355 |
"me.sort1": f_sort1 |
339 |
}); |
356 |
}); |
340 |
} |
357 |
} |
341 |
let f_sort2 = $("#sort2_filter").val(); |
358 |
let f_sort2 = patron_search_form.find("select[name='sort2_filter']").val(); |
342 |
if ( f_sort2 ) { |
359 |
if ( f_sort2 ) { |
343 |
filters.push({ |
360 |
filters.push({ |
344 |
"me.sort2": f_sort2 |
361 |
"me.sort2": f_sort2 |
Lines 410-416
Link Here
|
410 |
"searchable": false, |
427 |
"searchable": false, |
411 |
"orderable": false, |
428 |
"orderable": false, |
412 |
"render": function( data, type, row, meta ) { |
429 |
"render": function( data, type, row, meta ) { |
413 |
return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />"; |
430 |
return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' class='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />"; |
414 |
} |
431 |
} |
415 |
} |
432 |
} |
416 |
[% CASE 'cardnumber' %] |
433 |
[% CASE 'cardnumber' %] |
Lines 597-607
Link Here
|
597 |
[% CASE 'select' %] |
614 |
[% CASE 'select' %] |
598 |
let patron_str = JSON.stringify(row); |
615 |
let patron_str = JSON.stringify(row); |
599 |
action_node += '<a href="#" class="btn btn-default btn-xs select_user" data-borrowernumber="' + patron_id + '">' + _("Select") + '</a>'; |
616 |
action_node += '<a href="#" class="btn btn-default btn-xs select_user" data-borrowernumber="' + patron_id + '">' + _("Select") + '</a>'; |
600 |
let input_node = $('<input type="hidden" id="borrower_data' + patron_id + '" name="borrower_data'+ patron_id + '"/>'); |
617 |
let input_node = $('<input type="hidden" name="borrower_data'+ patron_id + '"/>'); |
601 |
$(input_node).val(patron_str); |
618 |
$(input_node).val(patron_str); |
602 |
action_node += $(input_node).prop('outerHTML'); |
619 |
action_node += $(input_node).prop('outerHTML'); |
603 |
[% CASE 'add' %] |
620 |
[% CASE 'add' %] |
604 |
action_node += '<a href="#" class="btn btn-default btn-xs add_user" data-borrowernumber="' + patron_id + '" data-firstname="' + encodeURIComponent(row.firstname) + '" data-surname="' + encodeURIComponent(row.surname) + '">' + _("Add") + '</a><input type="hidden" id="borrower_data' + patron_id + '" name="borrower_data'+ patron_id + '" />'; |
621 |
action_node += '<a href="#" class="btn btn-default btn-xs add_user" data-borrowernumber="' + patron_id + '" data-firstname="' + encodeURIComponent(row.firstname) + '" data-surname="' + encodeURIComponent(row.surname) + '">' + _("Add") + '</a><input type="hidden" name="borrower_data'+ patron_id + '" />'; |
605 |
[% CASE 'edit' %] |
622 |
[% CASE 'edit' %] |
606 |
action_node += '<a href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=' + patron_id + '" class="btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> ' + _("Edit") + '</a>'; |
623 |
action_node += '<a href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=' + patron_id + '" class="btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> ' + _("Edit") + '</a>'; |
607 |
[% CASE 'checkout' %] |
624 |
[% CASE 'checkout' %] |
Lines 637-664
Link Here
|
637 |
[% END %] |
654 |
[% END %] |
638 |
}, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters); |
655 |
}, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters); |
639 |
|
656 |
|
640 |
$("#patron_search_form").on('submit', filter); |
657 |
patron_search_form.on('submit', filter); |
641 |
$("#patron_search_form").on('submit', update_search_type); |
658 |
patron_search_form.on('submit', update_search_type); |
|
|
659 |
|
642 |
$(".filterByLetter").on("click",function(e){ |
660 |
$(".filterByLetter").on("click",function(e){ |
643 |
e.preventDefault(); |
661 |
e.preventDefault(); |
644 |
filterByFirstLetterSurname($(this).text(), true); |
662 |
filterByFirstLetterSurname($(this).text(), true); |
645 |
}); |
663 |
}); |
646 |
$("body").on("click",".add_user",function(e){ |
664 |
patrons_table.on("click",".add_user",function(e){ |
647 |
e.preventDefault(); |
665 |
e.preventDefault(); |
648 |
var borrowernumber = $(this).data("borrowernumber"); |
666 |
var borrowernumber = $(this).data("borrowernumber"); |
649 |
var firstname = $(this).data("firstname"); |
667 |
var firstname = $(this).data("firstname"); |
650 |
var surname = $(this).data("surname"); |
668 |
var surname = $(this).data("surname"); |
651 |
modal_add_user( borrowernumber, firstname + " " + surname ); |
669 |
modal_add_user( borrowernumber, firstname + " " + surname ); |
652 |
}); |
670 |
}); |
653 |
$("body").on("click",".select_user",function(e){ |
671 |
patrons_table.on("click",".select_user",function(e){ |
654 |
e.preventDefault(); |
672 |
e.preventDefault(); |
655 |
var borrowernumber = $(this).data("borrowernumber"); |
673 |
var borrowernumber = $(this).data("borrowernumber"); |
656 |
var borrower_data = $("#borrower_data"+borrowernumber).val(); |
674 |
var borrower_data = patrons_table.find("input[name='borrower_data"+borrowernumber+"']").val(); |
657 |
modal_select_user( borrowernumber, JSON.parse(borrower_data) ); |
675 |
modal_select_user( borrowernumber, JSON.parse(borrower_data) ); |
658 |
$(this).closest(".modal").modal('hide'); |
676 |
$(this).closest(".modal").modal('hide'); |
659 |
}); |
677 |
}); |
660 |
|
678 |
|
661 |
$("body").on("click",".patron_preview", function( e ){ |
679 |
patrons_table.on("click",".patron_preview", function( e ){ |
662 |
e.preventDefault(); |
680 |
e.preventDefault(); |
663 |
var borrowernumber = $(this).data("borrowernumber"); |
681 |
var borrowernumber = $(this).data("borrowernumber"); |
664 |
var page = "/cgi-bin/koha/members/moremember.pl?print=brief&borrowernumber=" + borrowernumber; |
682 |
var page = "/cgi-bin/koha/members/moremember.pl?print=brief&borrowernumber=" + borrowernumber; |
Lines 674-755
Link Here
|
674 |
$("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading"); |
692 |
$("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading"); |
675 |
}); |
693 |
}); |
676 |
|
694 |
|
677 |
$("#clear_search").on("click",function(e){ |
695 |
patron_search_form.find(".clear_search").on("click",function(e){ |
678 |
e.preventDefault(); |
696 |
e.preventDefault(); |
679 |
clearFilters(); |
697 |
clearFilters(); |
680 |
$("#searchpattern").parent().hide(); |
698 |
patron_search_form.find(".searchpattern").parent().hide(); |
681 |
}); |
699 |
}); |
682 |
|
700 |
|
683 |
if ( !defer_loading ) { |
701 |
if ( !defer_loading ) { |
684 |
$("#patron_search_form").submit(); |
702 |
patron_search_form.submit(); |
685 |
} |
703 |
} |
686 |
|
704 |
|
687 |
/* Initial page load does not trigger the popstate event, so we explicitly call this */ |
705 |
[% IF adjust_history %] |
688 |
getSearchByLocation( false ); |
706 |
/* Initial page load does not trigger the popstate event, so we explicitly call this */ |
689 |
|
707 |
getSearchByLocation( false ); |
|
|
708 |
[% END %] |
690 |
}); |
709 |
}); |
691 |
|
710 |
|
692 |
function getSearchByLocation( setstate ){ |
711 |
[% IF adjust_history %] |
693 |
/* Check to see if the URL contains a search parameter */ |
712 |
function getSearchByLocation( setstate ){ |
694 |
if( location.search != ""){ |
713 |
/* Check to see if the URL contains a search parameter */ |
695 |
var params = new URLSearchParams( location.search ); |
714 |
if( location.search != ""){ |
696 |
var firstletter = params.get("firstletter"); |
715 |
var params = new URLSearchParams( location.search ); |
697 |
/* Check to see if search is a first letter param */ |
716 |
var firstletter = params.get("firstletter"); |
698 |
if( firstletter ){ |
717 |
/* Check to see if search is a first letter param */ |
699 |
/* Trigger function to return search results by letter */ |
718 |
if( firstletter ){ |
700 |
filterByFirstLetterSurname( firstletter, setstate ); |
719 |
/* Trigger function to return search results by letter */ |
|
|
720 |
filterByFirstLetterSurname( firstletter, setstate ); |
721 |
} |
701 |
} |
722 |
} |
702 |
} |
723 |
} |
703 |
} |
724 |
[% END %] |
704 |
|
725 |
|
705 |
function update_search_type(){ |
726 |
function update_search_type(){ |
706 |
$("#searchtype").val($("#searchtype_filter").val()); |
727 |
$("#searchtype").val($("#searchtype_filter").val()); |
707 |
} |
728 |
} |
708 |
|
729 |
|
709 |
function update_search_description(){ |
730 |
function update_search_description(){ |
710 |
var searched = $("#searchfieldstype_filter").find("option:selected").text(); |
731 |
let parent_block = $("#[% search_results_block_id | html %]"); |
711 |
if ( $("#search_patron_filter").val() ) { |
732 |
let patron_search_form = get_patron_search_form(); |
712 |
if ( $("#searchtype_filter").val() == 'starts_with' ) { |
733 |
var searched = patron_search_form.find(".searchfieldstype_filter").find("option:selected").text(); |
|
|
734 |
let pattern = patron_search_form.find(".search_patron_filter").val(); |
735 |
if ( pattern ) { |
736 |
if ( patron_search_form.find(".searchtype_filter").val() == 'starts_with' ) { |
713 |
searched += _(" starting with "); |
737 |
searched += _(" starting with "); |
714 |
} else { |
738 |
} else { |
715 |
searched += _(" containing "); |
739 |
searched += _(" containing "); |
716 |
} |
740 |
} |
717 |
searched += "'" + $("#search_patron_filter").val() + "'"; |
741 |
searched += "'" + pattern + "'"; |
718 |
} |
742 |
} |
719 |
if ( $("#firstletter_filter").val() ) { |
743 |
let firstletter_filter = parent_block.find(".firstletter_filter").val(); |
720 |
searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'"; |
744 |
if ( firstletter_filter ) { |
|
|
745 |
searched += _(" begins with ") + "'" + firstletter_filter +"'"; |
721 |
} |
746 |
} |
722 |
if ( $("#categorycode_filter").val() ) { |
747 |
|
723 |
searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'"; |
748 |
if ( patron_search_form.find(".categorycode_filter").val() ) { |
|
|
749 |
searched += _(" with category ") + "'" + patron_search_form.find(".categorycode_filter option:selected").text() + "'"; |
724 |
} |
750 |
} |
725 |
if ( $("#branchcode_filter").val() ) { |
751 |
if ( patron_search_form.find(".branchcode_filter").val() ) { |
726 |
searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text(); |
752 |
searched += _(" in library ") + patron_search_form.find(".branchcode_filter option:selected").text(); |
727 |
} |
753 |
} |
728 |
if ( $("#sort1_filter").val() ) { |
754 |
if ( patron_search_form.find("select[name='sort1_filter']").val() ) { |
729 |
searched += _(" with sort1 ") |
755 |
searched += _(" with sort1 ") |
730 |
if ( $("select#sort1_filter") ) { |
756 |
if ( patron_search_form.find("select[name='sort1_filter']") ) { |
731 |
searched += $("select#sort1_filter").find("option:selected").text(); |
757 |
searched += patron_search_form.find("select[name='sort1_filter'] option:selected").text(); |
732 |
} |
758 |
} |
733 |
else { |
759 |
else { |
734 |
searched += $("#sort1_filter").val(); |
760 |
searched += paron_search_form.find("select[name='sort1_filter']").val(); |
735 |
} |
761 |
} |
736 |
} |
762 |
} |
737 |
if ( $("#sort2_filter").val() ) { |
763 |
if ( patron_search_form.find("select[name='sort2_filter']").val() ) { |
738 |
searched += _(" with sort2 "); |
764 |
searched += _(" with sort2 ") |
739 |
if ( $("select#sort2_filter") ) { |
765 |
if ( patron_search_form.find("select[name='sort2_filter']") ) { |
740 |
searched += $("select#sort2_filter").find("option:selected").text(); |
766 |
searched += patron_search_form.find("select[name='sort2_filter'] option:selected").text(); |
741 |
} |
767 |
} |
742 |
else { |
768 |
else { |
743 |
searched += $("#sort2_filter").val(); |
769 |
searched += paron_search_form.find("select[name='sort2_filter']").val(); |
744 |
} |
770 |
} |
745 |
} |
771 |
} |
746 |
$("#searchpattern").text(searched); |
772 |
patron_search_form.find(".searchpattern").text(searched); |
747 |
$("#searchpattern").parent().show(); |
773 |
patron_search_form.find(".searchpattern").parent().show(); |
748 |
} |
774 |
} |
749 |
|
775 |
|
750 |
function filter() { |
776 |
function filter() { |
|
|
777 |
let parent_block = $("#[% search_results_block_id | html %]"); |
778 |
let patron_search_form = get_patron_search_form(); |
751 |
[% IF redirect_if_attribute_equal %] |
779 |
[% IF redirect_if_attribute_equal %] |
752 |
let filter = $("#search_patron_filter").val(); |
780 |
let filter = patron_search_form.find(".search_patron_filter").val(); |
753 |
if ( filter ) { |
781 |
if ( filter ) { |
754 |
$.ajax({ |
782 |
$.ajax({ |
755 |
data: { cardnumber: filter, _match: 'exact' }, |
783 |
data: { cardnumber: filter, _match: 'exact' }, |
Lines 770-787
Link Here
|
770 |
}); |
798 |
}); |
771 |
} |
799 |
} |
772 |
[% END %] |
800 |
[% END %] |
773 |
$("#firstletter_filter").val(''); |
801 |
parent_block.find(".firstletter_filter").val(''); |
774 |
$("#[% table_id | html %]_search_results").show(); |
802 |
$("#[% table_id | html %]_search_results").show(); |
775 |
|
803 |
|
776 |
let table_dt = patrons_table.DataTable(); |
804 |
let table_dt = patrons_table.DataTable(); |
777 |
[% FOR c IN columns %] |
805 |
[% FOR c IN columns %] |
778 |
[% SWITCH c %] |
806 |
[% SWITCH c %] |
779 |
[% CASE 'branch' %] |
807 |
[% CASE 'branch' %] |
780 |
library_id = $("#branchcode_filter").val() || ""; |
808 |
let library_id = patron_search_form.find(".branchcode_filter").val() || ""; |
781 |
patrons_table.find('thead tr:eq(1) th[data-filter="libraries"] select').val(library_id); |
809 |
patrons_table.find('thead tr:eq(1) th[data-filter="libraries"] select').val(library_id); |
782 |
table_dt.column([% loop.count - 1 %]).search(library_id ? '^'+library_id+'$' : ''); |
810 |
table_dt.column([% loop.count - 1 %]).search(library_id ? '^'+library_id+'$' : ''); |
783 |
[% CASE 'category' %] |
811 |
[% CASE 'category' %] |
784 |
let category_id = $("#categorycode_filter").val() || ""; |
812 |
let category_id = patron_search_form.find(".categorycode_filter").val() || ""; |
785 |
patrons_table.find('thead tr:eq(1) th[data-filter="categories"] select').val(category_id.toLowerCase()); |
813 |
patrons_table.find('thead tr:eq(1) th[data-filter="categories"] select').val(category_id.toLowerCase()); |
786 |
table_dt.column([% loop.count - 1 %]).search(category_id ? '^'+category_id+'$' : ''); |
814 |
table_dt.column([% loop.count - 1 %]).search(category_id ? '^'+category_id+'$' : ''); |
787 |
[% END %] |
815 |
[% END %] |
Lines 796-811
Link Here
|
796 |
} |
824 |
} |
797 |
|
825 |
|
798 |
function clearFilters() { |
826 |
function clearFilters() { |
799 |
$("#searchfieldstype_filter option:first").prop("selected", true); |
827 |
let parent_block = $("#[% search_results_block_id | html %]"); |
800 |
$("#searchtype_filter option[value='[% searchtype | html %]']").prop("selected", true); |
828 |
let patron_search_form = get_patron_search_form(); |
801 |
$("#categorycode_filter option:first").prop("selected", true); |
829 |
patron_search_form.find(".searchfieldstype_filter option:first").prop("selected", true); |
802 |
$("#branchcode_filter option:first").prop("selected", true); |
830 |
patron_search_form.find(".searchtype_filter option[value='[% searchtype | html %]']").prop("selected", true); |
803 |
$("#sort1_filter").val('').trigger("change"); |
831 |
patron_search_form.find(".categorycode_filter option:first").prop("selected", true); |
804 |
$("#sort2_filter").val('').trigger("change"); |
832 |
patron_search_form.find(".branchcode_filter option:first").prop("selected", true); |
805 |
$("#firstletter_filter").val(''); |
833 |
patron_search_form.find("select[name='sort1_filter']").val('').trigger("change"); |
806 |
$("#search_patron_filter").val(''); |
834 |
patron_search_form.find("select[name='sort2_filter']").val('').trigger("change"); |
807 |
/* remove any search string added by firstletter search */ |
835 |
parent_block.find(".firstletter_filter").val(''); |
808 |
history.pushState( {}, null, window.location.href.split("?" )[0]); |
836 |
patron_search_form.find(".search_patron_filter").val(''); |
|
|
837 |
[% IF adjust_history %] |
838 |
/* remove any search string added by firstletter search */ |
839 |
history.pushState( {}, null, window.location.href.split("?" )[0]); |
840 |
[% END %] |
809 |
$("#[% table_id | html %]_search_results").hide(); |
841 |
$("#[% table_id | html %]_search_results").hide(); |
810 |
[% IF display_search_description %] |
842 |
[% IF display_search_description %] |
811 |
update_search_description(); |
843 |
update_search_description(); |
Lines 814-826
Link Here
|
814 |
|
846 |
|
815 |
// User has clicked on a letter |
847 |
// User has clicked on a letter |
816 |
function filterByFirstLetterSurname(letter, setstate ) { |
848 |
function filterByFirstLetterSurname(letter, setstate ) { |
817 |
$("#firstletter_filter").val(letter); |
849 |
let parent_block = $("#[% search_results_block_id | html %]"); |
|
|
850 |
parent_block.find(".firstletter_filter").val(letter); |
818 |
|
851 |
|
819 |
$("#[% table_id | html %]_search_results").show(); |
852 |
$("#[% table_id | html %]_search_results").show(); |
820 |
|
853 |
|
821 |
if ( setstate ) { |
854 |
[% IF adjust_history %] |
822 |
history.pushState( null, null, "?firstletter=" + letter ); |
855 |
if ( setstate ) { |
823 |
} |
856 |
history.pushState( null, null, "?firstletter=" + letter ); |
|
|
857 |
} |
858 |
[% END %] |
824 |
|
859 |
|
825 |
patrons_table.DataTable().draw(); |
860 |
patrons_table.DataTable().draw(); |
826 |
[% IF display_search_description %] |
861 |
[% IF display_search_description %] |
Lines 831-844
Link Here
|
831 |
// modify parent window owner element |
866 |
// modify parent window owner element |
832 |
function modal_add_user(borrowernumber, borrowername) { |
867 |
function modal_add_user(borrowernumber, borrowername) { |
833 |
[%# Note that add_user could sent data instead of borrowername too %] |
868 |
[%# Note that add_user could sent data instead of borrowername too %] |
834 |
$("#info").hide(); |
869 |
let parent_block = $("#[% search_results_block_id | html %]"); |
835 |
$("#error").hide(); |
870 |
parent_block.find(".info").hide(); |
|
|
871 |
parent_block.find(".error").hide(); |
836 |
if ( add_user(borrowernumber, borrowername) < 0 ) { |
872 |
if ( add_user(borrowernumber, borrowername) < 0 ) { |
837 |
$("#error").html(_("Patron '%s' is already in the list.").format(borrowername)); |
873 |
parent_block.find(".error").html(_("Patron '%s' is already in the list.").format(borrowername)).show(); |
838 |
$("#error").show(); |
|
|
839 |
} else { |
874 |
} else { |
840 |
$("#info").html(_("Patron '%s' added.").format(borrowername)); |
875 |
parent_block.find(".info").html(_("Patron '%s' added.").format(borrowername)).show(); |
841 |
$("#info").show(); |
|
|
842 |
} |
876 |
} |
843 |
} |
877 |
} |
844 |
function modal_select_user(borrowernumber, data) { |
878 |
function modal_select_user(borrowernumber, data) { |
Lines 852-857
Link Here
|
852 |
[% END %] |
886 |
[% END %] |
853 |
} |
887 |
} |
854 |
} |
888 |
} |
|
|
889 |
} |
855 |
</script> |
890 |
</script> |
856 |
[% END %] |
891 |
[% END %] |
857 |
|
892 |
|
Lines 860-865
Link Here
|
860 |
[% UNLESS patron_search_modal_id %] |
895 |
[% UNLESS patron_search_modal_id %] |
861 |
[% patron_search_modal_id = "patron_search_modal" %] |
896 |
[% patron_search_modal_id = "patron_search_modal" %] |
862 |
[% END %] |
897 |
[% END %] |
|
|
898 |
[% UNLESS table_id %] |
899 |
[% table_id = "memberresultst" %] |
900 |
[% END %] |
901 |
|
902 |
[% search_results_block_id = patron_search_modal_id _ '_searchresults' %] |
903 |
|
863 |
<div id="[% patron_search_modal_id | html %]" class="modal modal-full" tabindex="-1" role="dialog" aria-labelledby="patronSearchLabel" aria-hidden="true" data-backdrop=""> |
904 |
<div id="[% patron_search_modal_id | html %]" class="modal modal-full" tabindex="-1" role="dialog" aria-labelledby="patronSearchLabel" aria-hidden="true" data-backdrop=""> |
864 |
<div class="modal-dialog" role="document"> |
905 |
<div class="modal-dialog" role="document"> |
865 |
<div class="modal-content"> |
906 |
<div class="modal-content"> |
Lines 870-876
Link Here
|
870 |
<div class="modal-body"> |
911 |
<div class="modal-body"> |
871 |
[% PROCESS patron_search_filters filters => ['branch','category','sort1','sort2'] %] |
912 |
[% PROCESS patron_search_filters filters => ['branch','category','sort1','sort2'] %] |
872 |
|
913 |
|
873 |
<div id="searchresults"> |
914 |
<div id="[% search_results_block_id | html %]"> <!-- FIXME removed style from #searchresults, is that bad? --> |
874 |
[% IF columns.grep('checkbox').size %] |
915 |
[% IF columns.grep('checkbox').size %] |
875 |
<div class="searchheader fh-fixedHeader" id="searchheader" style="display:none;"> |
916 |
<div class="searchheader fh-fixedHeader" id="searchheader" style="display:none;"> |
876 |
<div> |
917 |
<div> |
Lines 883-889
Link Here
|
883 |
</div> |
924 |
</div> |
884 |
</div> |
925 |
</div> |
885 |
[% END %] |
926 |
[% END %] |
886 |
[% PROCESS patron_search_table table_id => 'memberresultst' columns => columns %] |
927 |
[% PROCESS patron_search_table table_id => table_id, columns => columns %] |
887 |
</div> |
928 |
</div> |
888 |
</div> |
929 |
</div> |
889 |
<div class="modal-footer"> |
930 |
<div class="modal-footer"> |