Lines 1-6
Link Here
|
1 |
[% USE Koha %] |
1 |
[% USE Koha %] |
|
|
2 |
[% USE I18N %] |
2 |
[% USE Branches %] |
3 |
[% USE Branches %] |
3 |
[% USE raw %] |
4 |
[% USE raw %] |
|
|
5 |
[% USE Asset %] |
4 |
[% USE To %] |
6 |
[% USE To %] |
5 |
|
7 |
|
6 |
[% BLOCK patron_search_filters_simple %] |
8 |
[% BLOCK patron_search_filters_simple %] |
Lines 18-29
Link Here
|
18 |
<ol> |
20 |
<ol> |
19 |
<li> |
21 |
<li> |
20 |
<label for="search_patron_filter">Search:</label> |
22 |
<label for="search_patron_filter">Search:</label> |
21 |
<div class="hint">Enter patron card number or partial name:</div> |
|
|
22 |
<input type="text" id="search_patron_filter" value="[% search_filter | html %]" class="focus" /> |
23 |
<input type="text" id="search_patron_filter" value="[% search_filter | html %]" class="focus" /> |
23 |
</li> |
24 |
</li> |
24 |
|
25 |
|
25 |
[% FOR column IN columns %] |
26 |
[% FOR f IN filters %] |
26 |
[% SWITCH column %] |
27 |
[% SWITCH f %] |
27 |
[% CASE 'branch' %] |
28 |
[% CASE 'branch' %] |
28 |
<li> |
29 |
<li> |
29 |
<label for="branchcode_filter">Library:</label> |
30 |
<label for="branchcode_filter">Library:</label> |
Lines 47-57
Link Here
|
47 |
[% END %] |
48 |
[% END %] |
48 |
</select> |
49 |
</select> |
49 |
</li> |
50 |
</li> |
|
|
51 |
[% CASE 'search_field' %] |
52 |
<li> |
53 |
<label for="searchfieldstype_filter">Search field:</label> |
54 |
<select name="searchfieldstype" id="searchfieldstype_filter"> |
55 |
[% pref_fields = Koha.Preference('DefaultPatronSearchFields').split(',') %] |
56 |
[% default_fields = [ 'surname,firstname,othernames,cardnumber,userid', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %] |
57 |
[% search_options = default_fields.merge(pref_fields).unique %] |
58 |
[% FOREACH s_o IN search_options %] |
59 |
[% display_name = PROCESS patron_fields name=s_o %] |
60 |
[% NEXT IF !display_name %] |
61 |
[% IF searchfieldstype == s_o %] |
62 |
<option selected="selected" value=[% s_o | html %]>[% display_name | $raw %]</option> |
63 |
[% ELSE %] |
64 |
<option value=[% s_o | html %]>[% display_name | $raw %]</option> |
65 |
[% END %] |
66 |
[% END %] |
67 |
</select> |
68 |
</li> |
69 |
[% CASE 'search_type' %] |
70 |
<li> |
71 |
<label for="searchtype_filter">Search type:</label> |
72 |
<select name="searchtype" id="searchtype_filter"> |
73 |
[% IF searchtype == "start_with" %] |
74 |
<option value='start_with' selected="selected">Starts with</option> |
75 |
<option value="contain">Contains</option> |
76 |
[% ELSE %] |
77 |
<option value='start_with'>Starts with</option> |
78 |
<option value="contain" selected="selected">Contains</option> |
79 |
[% END %] |
80 |
</select> |
81 |
</li> |
50 |
[% END %] |
82 |
[% END %] |
51 |
[% END %] |
83 |
[% END %] |
52 |
</ol> |
84 |
</ol> |
53 |
<fieldset class="action"> |
85 |
<fieldset class="action"> |
54 |
<input type="submit" value="Search" /> |
86 |
<input type="submit" value="Search" /> |
|
|
87 |
<input type="button" value="Clear" id="clear_search" /> |
55 |
</fieldset> |
88 |
</fieldset> |
56 |
</fieldset> |
89 |
</fieldset> |
57 |
</form> |
90 |
</form> |
Lines 78-89
Link Here
|
78 |
[% END %] |
111 |
[% END %] |
79 |
</div> |
112 |
</div> |
80 |
|
113 |
|
|
|
114 |
|
115 |
<h3 style="display: none;">Patrons found for: <span id="searchpattern"></span></h3> |
116 |
|
81 |
<div id="[% table_id | html %]_search_results" style="display:none;"> |
117 |
<div id="[% table_id | html %]_search_results" style="display:none;"> |
82 |
|
118 |
|
83 |
<div id="info" class="dialog message" style="display: none;"></div> |
119 |
<div id="info" class="dialog message" style="display: none;"></div> |
84 |
<div id="error" class="dialog alert" style="display: none;"></div> |
120 |
<div id="error" class="dialog alert" style="display: none;"></div> |
85 |
|
121 |
|
86 |
|
|
|
87 |
<input type="hidden" id="firstletter_filter" value="" /> |
122 |
<input type="hidden" id="firstletter_filter" value="" /> |
88 |
[% IF open_on_row_click %] |
123 |
[% IF open_on_row_click %] |
89 |
<table id="[% table_id | html %]" class="selections-table"> |
124 |
<table id="[% table_id | html %]" class="selections-table"> |
Lines 94-99
Link Here
|
94 |
<tr> |
129 |
<tr> |
95 |
[% FOR column IN columns %] |
130 |
[% FOR column IN columns %] |
96 |
[% SWITCH column %] |
131 |
[% SWITCH column %] |
|
|
132 |
[% CASE 'checkbox' %]<th class="noExport"></th> |
97 |
[% CASE 'cardnumber' %]<th>Card</th> |
133 |
[% CASE 'cardnumber' %]<th>Card</th> |
98 |
[% CASE 'dateofbirth' %]<th>Date of birth</th> |
134 |
[% CASE 'dateofbirth' %]<th>Date of birth</th> |
99 |
[% CASE 'name' %]<th>Name</th> |
135 |
[% CASE 'name' %]<th>Name</th> |
Lines 166-182
Link Here
|
166 |
[% INCLUDE 'js-patron-get-age.inc' %] |
202 |
[% INCLUDE 'js-patron-get-age.inc' %] |
167 |
[% INCLUDE 'js-patron-format.inc' %] |
203 |
[% INCLUDE 'js-patron-format.inc' %] |
168 |
[% INCLUDE 'js-patron-format-address.inc' %] |
204 |
[% INCLUDE 'js-patron-format-address.inc' %] |
|
|
205 |
[% IF sticky_header %] |
206 |
[% Asset.js("lib/hc-sticky.js") | $raw %] |
207 |
[% END %] |
169 |
|
208 |
|
170 |
<script> |
209 |
<script> |
171 |
var first_draw = 0; |
210 |
var first_draw = 0; |
172 |
let patrons_table; |
211 |
let patrons_table; |
|
|
212 |
var Sticky; |
213 |
var singleBranchMode = '[% singleBranchMode | html %]'; |
214 |
let logged_in_library_id = "[% Branches.GetLoggedInBranchcode | html %]"; |
173 |
|
215 |
|
174 |
$(document).ready(function(){ |
216 |
/* popstate event triggered by forward and back button. Need to refresh search */ |
|
|
217 |
window.addEventListener('popstate', (event) => { |
218 |
getSearchByLocation( false ); |
219 |
}); |
175 |
|
220 |
|
|
|
221 |
$(document).ready(function(){ |
176 |
|
222 |
|
177 |
$("#info").hide(); |
223 |
$("#info").hide(); |
178 |
$("#error").hide(); |
224 |
$("#error").hide(); |
179 |
|
225 |
|
|
|
226 |
// Build the aLengthMenu |
227 |
var aLengthMenu = [ |
228 |
[% Koha.Preference('PatronsPerPage') | html %], 10, 20, 50, 100, -1 |
229 |
]; |
230 |
jQuery.unique(aLengthMenu); |
231 |
aLengthMenu.sort(function( a, b ){ |
232 |
// Put "All" at the end |
233 |
if ( a == -1 ) { |
234 |
return 1; |
235 |
} else if ( b == -1 ) { |
236 |
return -1; |
237 |
} |
238 |
return parseInt(a) < parseInt(b) ? -1 : 1;} |
239 |
); |
240 |
var aLengthMenuLabel = []; |
241 |
$(aLengthMenu).each(function(){ |
242 |
if ( this == -1 ) { |
243 |
// Label for -1 is "All" |
244 |
aLengthMenuLabel.push(_("All")); |
245 |
} else { |
246 |
aLengthMenuLabel.push(this); |
247 |
} |
248 |
}); |
249 |
|
180 |
let additional_filters = { |
250 |
let additional_filters = { |
181 |
surname: function(){ |
251 |
surname: function(){ |
182 |
let start_with = $("#firstletter_filter").val() |
252 |
let start_with = $("#firstletter_filter").val() |
Lines 186-203
Link Here
|
186 |
"-and": function(){ |
256 |
"-and": function(){ |
187 |
let filter = $("#search_patron_filter").val(); |
257 |
let filter = $("#search_patron_filter").val(); |
188 |
if (!filter) return ""; |
258 |
if (!filter) return ""; |
189 |
[% SET search_fields = Koha.Preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid' %] |
259 |
|
190 |
return [ |
260 |
let filters = []; |
191 |
[% FOR search_field IN search_fields.split(',') %] |
261 |
let search_type = $("#searchtype_filter").val() || "contain"; |
192 |
{"me.[% search_field | html %]":{"like":"%"+filter+"%"}}, |
262 |
let search_fields = $("#searchfieldstype_filter").val(); |
193 |
[% END %] |
263 |
if ( !search_fields ) { |
194 |
[% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %] |
264 |
search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid' | html %]"; |
195 |
{ |
265 |
} |
196 |
"extended_attributes.value": { "like": "%" + filter + "%" }, |
266 |
search_fields.split(',').forEach(function(e,i){ |
|
|
267 |
filters.push({["me."+e]:{"like":"%"+filter+(search_type == "contain" ? "%" : "" )}}); |
268 |
}); |
269 |
[% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %] |
270 |
filters.push({ |
271 |
"extended_attributes.value": { "like": "%" + filter + (search_type == "contain" ? "%" : "" )}, |
197 |
"extended_attributes.code": extended_attribute_types |
272 |
"extended_attributes.code": extended_attribute_types |
198 |
} |
273 |
}); |
199 |
[% END %] |
274 |
[% END %] |
200 |
]; |
275 |
return filters; |
201 |
} |
276 |
} |
202 |
}; |
277 |
}; |
203 |
[% UNLESS default_sort_column %] |
278 |
[% UNLESS default_sort_column %] |
Lines 223-229
Link Here
|
223 |
[% IF redirect_if_one_result %] |
298 |
[% IF redirect_if_one_result %] |
224 |
// redirect if there is only 1 result. |
299 |
// redirect if there is only 1 result. |
225 |
if ( first_draw && json.recordsFiltered == 1 ) { |
300 |
if ( first_draw && json.recordsFiltered == 1 ) { |
226 |
document.location.href = '[% redirect_url | url %]&borrowernumber=' + json.data[0].patron_id; |
301 |
let url = '[% redirect_url | url %]'.indexOf("?") != -1 |
|
|
302 |
? '[% redirect_url | url %]&borrowernumber=' + json.data[0].patron_id |
303 |
: '[% redirect_url | url %]?borrowernumber=' + json.data[0].patron_id; |
304 |
document.location.href = url; |
227 |
return false; |
305 |
return false; |
228 |
} |
306 |
} |
229 |
first_draw = 0; |
307 |
first_draw = 0; |
Lines 231-236
Link Here
|
231 |
return json.data; |
309 |
return json.data; |
232 |
} |
310 |
} |
233 |
}, |
311 |
}, |
|
|
312 |
[% IF open_on_row_click OR preview_on_name_click %] |
234 |
"drawCallback": function( settings ) { |
313 |
"drawCallback": function( settings ) { |
235 |
var api = this.api(); |
314 |
var api = this.api(); |
236 |
var data = api.data(); |
315 |
var data = api.data(); |
Lines 244-255
Link Here
|
244 |
}).addClass('clickable'); |
323 |
}).addClass('clickable'); |
245 |
$(tr).find("a.patron_name").attr('href', url); |
324 |
$(tr).find("a.patron_name").attr('href', url); |
246 |
}); |
325 |
}); |
247 |
[% ELSE %] |
326 |
[% END %] |
|
|
327 |
[% IF preview_on_name_click %] |
248 |
$.each($(this).find("tbody tr"), function(index, tr) { |
328 |
$.each($(this).find("tbody tr"), function(index, tr) { |
249 |
$(tr).find("a.patron_name").addClass("patron_preview"); |
329 |
$(tr).find("a.patron_name").addClass("patron_preview"); |
250 |
}); |
330 |
}); |
251 |
[% END %] |
331 |
[% END %] |
252 |
}, |
332 |
}, |
|
|
333 |
[% END %] |
253 |
"iDeferLoading": 0, |
334 |
"iDeferLoading": 0, |
254 |
"columns": [ |
335 |
"columns": [ |
255 |
[% FOR column IN columns %] |
336 |
[% FOR column IN columns %] |
Lines 259-278
Link Here
|
259 |
[% SWITCH column %] |
340 |
[% SWITCH column %] |
260 |
[% CASE 'checkbox' %] |
341 |
[% CASE 'checkbox' %] |
261 |
{ |
342 |
{ |
262 |
"data": "borrowernumber", |
343 |
"data": "patron_id", |
263 |
"searchable": true, |
344 |
"searchable": false, |
264 |
"orderable": true, |
345 |
"orderable": false, |
265 |
"render": function( data, type, row, meta ) { |
346 |
"render": function( data, type, row, meta ) { |
266 |
return "<input type=\"checkbox\" name="data ? escape_str($date(data) + " (" + _("%s years").format($get_age(data)) + ")") : ""; |
347 |
return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />"; |
267 |
|
|
|
268 |
return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />", |
269 |
} |
348 |
} |
270 |
} |
349 |
} |
271 |
[% CASE 'cardnumber' %] |
350 |
[% CASE 'cardnumber' %] |
272 |
{ |
351 |
{ |
273 |
"data": "cardnumber", |
352 |
"data": "cardnumber", |
274 |
"searchable": true, |
353 |
"searchable": true, |
275 |
"orderable": true |
354 |
"orderable": true, |
|
|
355 |
"render": function( data, type, row, meta ) { |
356 |
let patron_id = encodeURIComponent(row.patron_id); |
357 |
[% IF !open_on_row_click AND CAN_user_circulate_circulate_remaining_permissions %] |
358 |
return "<a href=\"/cgi-bin/koha/circ/circulation.pl?borrowernumber=" + patron_id + "\" title=\"[% I18N.t("Check out") | html %]\" class=\"patron_name\" data-borrowernumber=\"" + patron_id + "\" style=\"white-space:nowrap\">" + escape_str(data) + "</a>"; |
359 |
[% ELSE %] |
360 |
return escape_str(data); |
361 |
[% END %] |
362 |
} |
363 |
|
276 |
} |
364 |
} |
277 |
[% CASE 'dateofbirth' %] |
365 |
[% CASE 'dateofbirth' %] |
278 |
{ |
366 |
{ |
Lines 340-346
Link Here
|
340 |
"orderable": true, |
428 |
"orderable": true, |
341 |
"render": function( data, type, row, meta ) { |
429 |
"render": function( data, type, row, meta ) { |
342 |
let patron_id = encodeURIComponent(row.patron_id); |
430 |
let patron_id = encodeURIComponent(row.patron_id); |
|
|
431 |
[% IF ! open_on_row_click %] |
343 |
return "<a href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=" + patron_id + "\" class=\"patron_name\" data-borrowernumber=\"" + patron_id + "\" style=\"white-space:nowrap\">" + $patron_to_html(row, { invert_name: 1 }) + "</a>"; |
432 |
return "<a href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=" + patron_id + "\" class=\"patron_name\" data-borrowernumber=\"" + patron_id + "\" style=\"white-space:nowrap\">" + $patron_to_html(row, { invert_name: 1 }) + "</a>"; |
|
|
433 |
[% ELSE %] |
434 |
return $patron_to_html(row, { invert_name: 1 }); |
435 |
[% END %] |
344 |
} |
436 |
} |
345 |
} |
437 |
} |
346 |
[% CASE 'branch' %] |
438 |
[% CASE 'branch' %] |
Lines 349-355
Link Here
|
349 |
"searchable": true, |
441 |
"searchable": true, |
350 |
"orderable": true, |
442 |
"orderable": true, |
351 |
"render": function( data, type, row, meta ) { |
443 |
"render": function( data, type, row, meta ) { |
352 |
return escape_str(libraries_map[data].branchname); |
444 |
let library_name = libraries_map[data].branchname |
|
|
445 |
if( !singleBranchMode && data == logged_in_library_id ) { |
446 |
return "<span class=\"currentlibrary\">" + escape_str(library_name) + "</span>"; |
447 |
} else { |
448 |
return escape_str(library_name); |
449 |
} |
353 |
} |
450 |
} |
354 |
} |
451 |
} |
355 |
[% CASE 'category' %] |
452 |
[% CASE 'category' %] |
Lines 426-436
Link Here
|
426 |
"data": function( row, type, val, meta ) { |
523 |
"data": function( row, type, val, meta ) { |
427 |
|
524 |
|
428 |
let patron_id = encodeURIComponent(row.patron_id); |
525 |
let patron_id = encodeURIComponent(row.patron_id); |
429 |
[% IF selection_type == 'select' %] |
526 |
let action_node = ""; |
430 |
return '<a href="#" class="btn btn-default btn-xs select_user" data-borrowernumber="' + patron_id + '">Select</a><input type="hidden" id="borrower_data' + patron_id + '" name="borrower_data'+ patron_id + '" value=\''+JSON.stringify(row)+'\' />'; |
527 |
[% FOR action IN actions %] |
431 |
[% ELSE %] |
528 |
[% SWITCH action %] |
432 |
return '<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 + '" />'; |
529 |
[% CASE 'select' %] |
|
|
530 |
action_node += '<a href="#" class="btn btn-default btn-xs select_user" data-borrowernumber="' + patron_id + '">Select</a><input type="hidden" id="borrower_data' + patron_id + '" name="borrower_data'+ patron_id + '" value=\''+JSON.stringify(row)+'\' />'; |
531 |
[% CASE 'add' %] |
532 |
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 + '" />'; |
533 |
[% CASE 'edit' %] |
534 |
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 fa-pencil"></i> Edit</a>'; |
535 |
[% CASE 'checkout' %] |
536 |
[% IF CAN_user_circulate_circulate_remaining_permissions %] |
537 |
action_node += '<a class="btn btn-default btn-xs" href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=' + patron_id + '"><i class="fa fa-barcode"></i> ' + _("Check out") + '</a>'; |
538 |
[% END %] |
539 |
[% END %] |
433 |
[% END %] |
540 |
[% END %] |
|
|
541 |
return action_node; |
434 |
}, |
542 |
}, |
435 |
"searchable": false, |
543 |
"searchable": false, |
436 |
"orderable": false |
544 |
"orderable": false |
Lines 442-455
Link Here
|
442 |
'embed': [% To.json(embed) | $raw %], |
550 |
'embed': [% To.json(embed) | $raw %], |
443 |
"order": [[ [% order_column_index | html %], "asc" ]], |
551 |
"order": [[ [% order_column_index | html %], "asc" ]], |
444 |
'bAutoWidth': false, |
552 |
'bAutoWidth': false, |
|
|
553 |
'lengthMenu': [aLengthMenu, aLengthMenuLabel], |
445 |
'sPaginationType': 'full_numbers', |
554 |
'sPaginationType': 'full_numbers', |
446 |
"iDisplayLength": [% Koha.Preference('PatronsPerPage') | html %], |
555 |
"pageLength": [% Koha.Preference('PatronsPerPage') | html %], |
|
|
556 |
[% IF sticky_header %] |
557 |
"initComplete": function(settings, json) { |
558 |
Sticky = $("#[% sticky_header | html %]"); |
559 |
Sticky.hcSticky({ |
560 |
stickTo: "#[% sticky_to | html %]", |
561 |
stickyClass: "floating" |
562 |
}); |
563 |
}, |
564 |
[% END %] |
447 |
}, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters); |
565 |
}, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters); |
448 |
|
566 |
|
449 |
$("#patron_search_form").on('submit', filter); |
567 |
$("#patron_search_form").on('submit', filter); |
450 |
$(".filterByLetter").on("click",function(e){ |
568 |
$(".filterByLetter").on("click",function(e){ |
451 |
e.preventDefault(); |
569 |
e.preventDefault(); |
452 |
filterByFirstLetterSurname($(this).text()); |
570 |
filterByFirstLetterSurname($(this).text(), true); |
453 |
}); |
571 |
}); |
454 |
$("body").on("click",".add_user",function(e){ |
572 |
$("body").on("click",".add_user",function(e){ |
455 |
e.preventDefault(); |
573 |
e.preventDefault(); |
Lines 478-485
Link Here
|
478 |
$("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading"); |
596 |
$("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading"); |
479 |
}); |
597 |
}); |
480 |
|
598 |
|
|
|
599 |
$("#clear_search").on("click",function(e){ |
600 |
e.preventDefault(); |
601 |
clearFilters(); |
602 |
$("#searchpattern").parent().hide(); |
603 |
}); |
604 |
|
605 |
if ( $("#search_patron_filter").val().length > 0 ) { |
606 |
$("#patron_search_form").submit(); |
607 |
} |
608 |
|
609 |
/* Initial page load does not trigger the popstate event, so we explicitly call this */ |
610 |
getSearchByLocation( false ); |
611 |
|
481 |
}); |
612 |
}); |
482 |
|
613 |
|
|
|
614 |
function getSearchByLocation( setstate ){ |
615 |
/* Check to see if the URL contains a search parameter */ |
616 |
if( location.search != ""){ |
617 |
var params = new URLSearchParams( location.search ); |
618 |
var firstletter = params.get("firstletter"); |
619 |
/* Check to see if search is a first letter param */ |
620 |
if( firstletter ){ |
621 |
/* Trigger function to return search results by letter */ |
622 |
filterByFirstLetterSurname( firstletter, setstate ); |
623 |
} |
624 |
} |
625 |
} |
626 |
|
627 |
function update_search_description(){ |
628 |
var searched = $("#searchfieldstype_filter").find("option:selected").text(); |
629 |
if ( $("#search_patron_filter").val() ) { |
630 |
if ( $("#searchtype_filter").val() == 'start_with' ) { |
631 |
searched += _(" starting with "); |
632 |
} else { |
633 |
searched += _(" containing "); |
634 |
} |
635 |
searched += "'" + $("#search_patron_filter").val() + "'"; |
636 |
} |
637 |
if ( $("#firstletter_filter").val() ) { |
638 |
searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'"; |
639 |
} |
640 |
if ( $("#categorycode_filter").val() ) { |
641 |
searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'"; |
642 |
} |
643 |
if ( $("#branchcode_filter").val() ) { |
644 |
searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text(); |
645 |
} |
646 |
$("#searchpattern").text(searched); |
647 |
$("#searchpattern").parent().show(); |
648 |
} |
649 |
|
483 |
function filter() { |
650 |
function filter() { |
484 |
$("#firstletter_filter").val(''); |
651 |
$("#firstletter_filter").val(''); |
485 |
$("#[% table_id | html %]_search_results").show(); |
652 |
$("#[% table_id | html %]_search_results").show(); |
Lines 500-549
Link Here
|
500 |
table_dt.search(""); |
667 |
table_dt.search(""); |
501 |
first_draw = 1; // Only redirect if we are coming from here |
668 |
first_draw = 1; // Only redirect if we are coming from here |
502 |
table_dt.draw(); |
669 |
table_dt.draw(); |
|
|
670 |
update_search_description(); |
503 |
return false; |
671 |
return false; |
504 |
} |
672 |
} |
505 |
|
673 |
|
|
|
674 |
function clearFilters() { |
675 |
$("#searchfieldstype_filter option:first").prop("selected", true); |
676 |
$("#searchtype_filter option[value='contain']").prop("selected", true); |
677 |
$("#categorycode_filter option:first").prop("selected", true); |
678 |
$("#branchcode_filter option:first").prop("selected", true); |
679 |
$("#firstletter_filter").val(''); |
680 |
$("#search_patron_filter").val(''); |
681 |
/* remove any search string added by firstletter search */ |
682 |
history.pushState( {}, null, window.location.href.split("?" )[0]); |
683 |
$("#[% table_id | html %]_search_results").hide(); |
684 |
update_search_description(); |
685 |
} |
686 |
|
506 |
// User has clicked on a letter |
687 |
// User has clicked on a letter |
507 |
function filterByFirstLetterSurname(letter) { |
688 |
function filterByFirstLetterSurname(letter, setstate ) { |
508 |
$("#firstletter_filter").val(letter); |
689 |
$("#firstletter_filter").val(letter); |
|
|
690 |
|
509 |
$("#[% table_id | html %]_search_results").show(); |
691 |
$("#[% table_id | html %]_search_results").show(); |
|
|
692 |
|
693 |
if ( setstate ) { |
694 |
history.pushState( null, null, "?firstletter=" + letter ); |
695 |
} |
696 |
|
510 |
patrons_table.DataTable().draw(); |
697 |
patrons_table.DataTable().draw(); |
|
|
698 |
update_search_description(); |
511 |
} |
699 |
} |
512 |
|
700 |
|
513 |
// modify parent window owner element |
701 |
// modify parent window owner element |
514 |
[% IF selection_type == 'add' %] |
702 |
function add_user(borrowernumber, borrowername) { |
515 |
function add_user(borrowernumber, borrowername) { |
703 |
var p = window.opener; |
516 |
var p = window.opener; |
704 |
// In one place (serials/routing.tt), the page is reload on every add |
517 |
// In one place (serials/routing.tt), the page is reload on every add |
705 |
// We have to wait for the page to be there |
518 |
// We have to wait for the page to be there |
706 |
function wait_for_opener () { |
519 |
function wait_for_opener () { |
707 |
if ( ! $(opener.document).find('body').size() ) { |
520 |
if ( ! $(opener.document).find('body').size() ) { |
708 |
setTimeout(wait_for_opener, 500); |
521 |
setTimeout(wait_for_opener, 500); |
709 |
} else { |
|
|
710 |
[%# Note that add_user could sent data instead of borrowername too %] |
711 |
$("#info").hide(); |
712 |
$("#error").hide(); |
713 |
if ( p.add_user(borrowernumber, borrowername) < 0 ) { |
714 |
$("#error").html(_("Patron '%s' is already in the list.").format(borrowername)); |
715 |
$("#error").show(); |
522 |
} else { |
716 |
} else { |
523 |
[%# Note that add_user could sent data instead of borrowername too %] |
717 |
$("#info").html(_("Patron '%s' added.").format(borrowername)); |
524 |
$("#info").hide(); |
718 |
$("#info").show(); |
525 |
$("#error").hide(); |
|
|
526 |
if ( p.add_user(borrowernumber, borrowername) < 0 ) { |
527 |
$("#error").html(_("Patron '%s' is already in the list.").format(borrowername)); |
528 |
$("#error").show(); |
529 |
} else { |
530 |
$("#info").html(_("Patron '%s' added.").format(borrowername)); |
531 |
$("#info").show(); |
532 |
} |
533 |
} |
719 |
} |
534 |
} |
720 |
} |
535 |
wait_for_opener(); |
|
|
536 |
} |
721 |
} |
537 |
[% ELSIF selection_type == 'select' %] |
722 |
wait_for_opener(); |
538 |
function select_user(borrowernumber, data) { |
723 |
} |
539 |
var p = window.opener; |
724 |
function select_user(borrowernumber, data) { |
540 |
[% IF callback %] |
725 |
var p = window.opener; |
541 |
p.[% callback | html %](borrowernumber, data); |
726 |
[% IF callback %] |
542 |
[% ELSE %] |
727 |
p.[% callback | html %](borrowernumber, data); |
543 |
p.select_user(borrowernumber, data); |
728 |
[% ELSE %] |
544 |
[% END %] |
729 |
p.select_user(borrowernumber, data); |
545 |
window.close(); |
730 |
[% END %] |
546 |
} |
731 |
window.close(); |
547 |
[% END %] |
732 |
} |
548 |
</script> |
733 |
</script> |
549 |
[% END %] |
734 |
[% END %] |