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 filter IN filters %] |
26 |
[% SWITCH column %] |
27 |
[% SWITCH filter %] |
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-88
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="dispay: none;"></div> |
120 |
<div id="error" class="dialog alert" style="display: none;"></div> |
85 |
|
|
|
86 |
|
121 |
|
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 %] |
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></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 184-203
Link Here
|
184 |
return { "like": start_with + "%" } |
254 |
return { "like": start_with + "%" } |
185 |
}, |
255 |
}, |
186 |
"-and": function(){ |
256 |
"-and": function(){ |
187 |
let filter = $("#searchmember_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 |
patrons_table = $("#[% table_id | html %]").kohaTable({ |
278 |
patrons_table = $("#[% table_id | html %]").kohaTable({ |
Lines 218-224
Link Here
|
218 |
[% IF redirect_if_one_result %] |
293 |
[% IF redirect_if_one_result %] |
219 |
// redirect if there is only 1 result. |
294 |
// redirect if there is only 1 result. |
220 |
if ( first_draw && json.recordsFiltered == 1 ) { |
295 |
if ( first_draw && json.recordsFiltered == 1 ) { |
221 |
document.location.href = '[% redirect_url | html %]&borrowernumber=' + json.data[0].patron_id; |
296 |
let url = '[% redirect_url | html %]'.indexOf("?") != -1 |
|
|
297 |
? '[% redirect_url | html %]&borrowernumber=' + json.data[0].patron_id |
298 |
: '[% redirect_url | html %]?borrowernumber=' + json.data[0].patron_id; |
299 |
document.location.href = url; |
222 |
return false; |
300 |
return false; |
223 |
} |
301 |
} |
224 |
first_draw = 0; |
302 |
first_draw = 0; |
Lines 227-232
Link Here
|
227 |
} |
305 |
} |
228 |
}, |
306 |
}, |
229 |
embed: ['extended_attributes', 'checkouts+count', 'overdues+count', 'account_balance'], |
307 |
embed: ['extended_attributes', 'checkouts+count', 'overdues+count', 'account_balance'], |
|
|
308 |
[% IF open_on_row_click OR preview_on_name_click %] |
230 |
"drawCallback": function( settings ) { |
309 |
"drawCallback": function( settings ) { |
231 |
var api = this.api(); |
310 |
var api = this.api(); |
232 |
var data = api.data(); |
311 |
var data = api.data(); |
Lines 240-251
Link Here
|
240 |
}).addClass('clickable'); |
319 |
}).addClass('clickable'); |
241 |
$(tr).find("a.patron_name").attr('href', url); |
320 |
$(tr).find("a.patron_name").attr('href', url); |
242 |
}); |
321 |
}); |
243 |
[% ELSE %] |
322 |
[% END %] |
|
|
323 |
[% IF preview_on_name_click %] |
244 |
$.each($(this).find("tbody tr"), function(index, tr) { |
324 |
$.each($(this).find("tbody tr"), function(index, tr) { |
245 |
$(tr).find("a.patron_name").addClass("patron_preview"); |
325 |
$(tr).find("a.patron_name").addClass("patron_preview"); |
246 |
}); |
326 |
}); |
247 |
[% END %] |
327 |
[% END %] |
248 |
}, |
328 |
}, |
|
|
329 |
[% END %] |
249 |
"order": [[ 1, "asc" ]], |
330 |
"order": [[ 1, "asc" ]], |
250 |
"iDeferLoading": 0, |
331 |
"iDeferLoading": 0, |
251 |
"columns": [ |
332 |
"columns": [ |
Lines 253-272
Link Here
|
253 |
[% SWITCH column %] |
334 |
[% SWITCH column %] |
254 |
[% CASE 'checkbox' %] |
335 |
[% CASE 'checkbox' %] |
255 |
{ |
336 |
{ |
256 |
"data": "borrowernumber", |
337 |
"data": "patron_id", |
257 |
"searchable": true, |
338 |
"searchable": false, |
258 |
"orderable": true, |
339 |
"orderable": false, |
259 |
"render": function( data, type, row, meta ) { |
340 |
"render": function( data, type, row, meta ) { |
260 |
return "<input type=\"checkbox\" name="data ? escape_str($date(data) + " (" + _("%s years").format($get_age(data)) + ")") : ""; |
341 |
return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />"; |
261 |
|
|
|
262 |
return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />", |
263 |
} |
342 |
} |
264 |
} |
343 |
} |
265 |
[% CASE 'cardnumber' %] |
344 |
[% CASE 'cardnumber' %] |
266 |
{ |
345 |
{ |
267 |
"data": "cardnumber", |
346 |
"data": "cardnumber", |
268 |
"searchable": true, |
347 |
"searchable": true, |
269 |
"orderable": true |
348 |
"orderable": true, |
|
|
349 |
"render": function( data, type, row, meta ) { |
350 |
let patron_id = encodeURIComponent(row.patron_id); |
351 |
[% IF !open_on_row_click AND CAN_user_circulate_circulate_remaining_permissions %] |
352 |
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>"; |
353 |
[% ELSE %] |
354 |
return escape_str(data); |
355 |
[% END %] |
356 |
} |
357 |
|
270 |
} |
358 |
} |
271 |
[% CASE 'dateofbirth' %] |
359 |
[% CASE 'dateofbirth' %] |
272 |
{ |
360 |
{ |
Lines 334-340
Link Here
|
334 |
"orderable": true, |
422 |
"orderable": true, |
335 |
"render": function( data, type, row, meta ) { |
423 |
"render": function( data, type, row, meta ) { |
336 |
let patron_id = encodeURIComponent(row.patron_id); |
424 |
let patron_id = encodeURIComponent(row.patron_id); |
|
|
425 |
[% IF ! open_on_row_click %] |
337 |
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>"; |
426 |
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>"; |
|
|
427 |
[% ELSE %] |
428 |
return $patron_to_html(row, { invert_name: 1 }); |
429 |
[% END %] |
338 |
} |
430 |
} |
339 |
} |
431 |
} |
340 |
[% CASE 'branch' %] |
432 |
[% CASE 'branch' %] |
Lines 343-349
Link Here
|
343 |
"searchable": true, |
435 |
"searchable": true, |
344 |
"orderable": true, |
436 |
"orderable": true, |
345 |
"render": function( data, type, row, meta ) { |
437 |
"render": function( data, type, row, meta ) { |
346 |
return escape_str(libraries_map[data].branchname); |
438 |
let library_name = libraries_map[data].branchname |
|
|
439 |
if( !singleBranchMode && data == logged_in_library_id ) { |
440 |
return "<span class=\"currentlibrary\">" + escape_str(library_name) + "</span>"; |
441 |
} else { |
442 |
return escape_str(library_name); |
443 |
} |
347 |
} |
444 |
} |
348 |
} |
445 |
} |
349 |
[% CASE 'category' %] |
446 |
[% CASE 'category' %] |
Lines 420-430
Link Here
|
420 |
"data": function( row, type, val, meta ) { |
517 |
"data": function( row, type, val, meta ) { |
421 |
|
518 |
|
422 |
let patron_id = encodeURIComponent(row.patron_id); |
519 |
let patron_id = encodeURIComponent(row.patron_id); |
423 |
[% IF selection_type == 'select' %] |
520 |
let action_node = ""; |
424 |
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)+'\' />'; |
521 |
[% FOR action IN actions %] |
425 |
[% ELSE %] |
522 |
[% SWITCH action %] |
426 |
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 + '" />'; |
523 |
[% CASE 'select' %] |
|
|
524 |
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)+'\' />'; |
525 |
[% CASE 'add' %] |
526 |
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 + '" />'; |
527 |
[% CASE 'edit' %] |
528 |
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>'; |
529 |
[% CASE 'checkout' %] |
530 |
[% IF CAN_user_circulate_circulate_remaining_permissions %] |
531 |
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>'; |
532 |
[% END %] |
533 |
[% END %] |
427 |
[% END %] |
534 |
[% END %] |
|
|
535 |
return action_node; |
428 |
}, |
536 |
}, |
429 |
"searchable": false, |
537 |
"searchable": false, |
430 |
"orderable": false |
538 |
"orderable": false |
Lines 434-447
Link Here
|
434 |
[% END %] |
542 |
[% END %] |
435 |
], |
543 |
], |
436 |
'bAutoWidth': false, |
544 |
'bAutoWidth': false, |
|
|
545 |
'lengthMenu': [aLengthMenu, aLengthMenuLabel], |
437 |
'sPaginationType': 'full_numbers', |
546 |
'sPaginationType': 'full_numbers', |
438 |
"iDisplayLength": [% Koha.Preference('PatronsPerPage') | html %], |
547 |
"pageLength": [% Koha.Preference('PatronsPerPage') | html %], |
|
|
548 |
[% IF sticky_header %] |
549 |
"initComplete": function(settings, json) { |
550 |
Sticky = $("#[% sticky_header | html %]x"); |
551 |
Sticky.hcSticky({ |
552 |
stickTo: "#[% sticky_to | html %]", |
553 |
stickyClass: "floating" |
554 |
}); |
555 |
}, |
556 |
[% END %] |
439 |
}, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters); |
557 |
}, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters); |
440 |
|
558 |
|
441 |
$("#patron_search_form").on('submit', filter); |
559 |
$("#patron_search_form").on('submit', filter); |
442 |
$(".filterByLetter").on("click",function(e){ |
560 |
$(".filterByLetter").on("click",function(e){ |
443 |
e.preventDefault(); |
561 |
e.preventDefault(); |
444 |
filterByFirstLetterSurname($(this).text()); |
562 |
filterByFirstLetterSurname($(this).text(), true); |
445 |
}); |
563 |
}); |
446 |
$("body").on("click",".add_user",function(e){ |
564 |
$("body").on("click",".add_user",function(e){ |
447 |
e.preventDefault(); |
565 |
e.preventDefault(); |
Lines 470-477
Link Here
|
470 |
$("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading"); |
588 |
$("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading"); |
471 |
}); |
589 |
}); |
472 |
|
590 |
|
|
|
591 |
$("#clear_search").on("click",function(e){ |
592 |
e.preventDefault(); |
593 |
clearFilters(); |
594 |
$("#searchpattern").parent().hide(); |
595 |
}); |
596 |
|
597 |
if ( $("#search_patron_filter").val().length > 0 ) { |
598 |
$("#patron_search_form").submit(); |
599 |
} |
600 |
|
601 |
/* Initial page load does not trigger the popstate event, so we explicitly call this */ |
602 |
getSearchByLocation( false ); |
603 |
|
473 |
}); |
604 |
}); |
474 |
|
605 |
|
|
|
606 |
function getSearchByLocation( setstate ){ |
607 |
/* Check to see if the URL contains a search parameter */ |
608 |
if( location.search != ""){ |
609 |
var params = new URLSearchParams( location.search ); |
610 |
var firstletter = params.get("firstletter"); |
611 |
/* Check to see if search is a first letter param */ |
612 |
if( firstletter ){ |
613 |
/* Trigger function to return search results by letter */ |
614 |
filterByFirstLetterSurname( firstletter, setstate ); |
615 |
} |
616 |
} |
617 |
} |
618 |
|
619 |
function update_search_description(){ |
620 |
var searched = $("#searchfieldstype_filter").find("option:selected").text(); |
621 |
if ( $("#search_patron_filter").val() ) { |
622 |
if ( $("#searchtype_filter").val() == 'start_with' ) { |
623 |
searched += _(" starting with "); |
624 |
} else { |
625 |
searched += _(" containing "); |
626 |
} |
627 |
searched += "'" + $("#search_patron_filter").val() + "'"; |
628 |
} |
629 |
if ( $("#firstletter_filter").val() ) { |
630 |
searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'"; |
631 |
} |
632 |
if ( $("#categorycode_filter").val() ) { |
633 |
searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'"; |
634 |
} |
635 |
if ( $("#branchcode_filter").val() ) { |
636 |
searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text(); |
637 |
} |
638 |
$("#searchpattern").text(searched); |
639 |
$("#searchpattern").parent().show(); |
640 |
} |
641 |
|
475 |
function filter() { |
642 |
function filter() { |
476 |
$("#firstletter_filter").val(''); |
643 |
$("#firstletter_filter").val(''); |
477 |
$("#[% table_id | html %]_search_results").show(); |
644 |
$("#[% table_id | html %]_search_results").show(); |
Lines 492-541
Link Here
|
492 |
table_dt.search(""); |
659 |
table_dt.search(""); |
493 |
first_draw = 1; // Only redirect if we are coming from here |
660 |
first_draw = 1; // Only redirect if we are coming from here |
494 |
table_dt.draw(); |
661 |
table_dt.draw(); |
|
|
662 |
update_search_description(); |
495 |
return false; |
663 |
return false; |
496 |
} |
664 |
} |
497 |
|
665 |
|
|
|
666 |
function clearFilters() { |
667 |
$("#searchfieldstype_filter option:first").prop("selected", true); |
668 |
$("#searchtype_filter option[value='contain']").prop("selected", true); |
669 |
$("#categorycode_filter option:first").prop("selected", true); |
670 |
$("#branchcode_filter option:first").prop("selected", true); |
671 |
$("#firstletter_filter").val(''); |
672 |
$("#search_patron_filter").val(''); |
673 |
/* remove any search string added by firstletter search */ |
674 |
history.pushState( {}, null, window.location.href.split("?" )[0]); |
675 |
$("#[% table_id | html %]_search_results").hide(); |
676 |
update_search_description(); |
677 |
} |
678 |
|
498 |
// User has clicked on a letter |
679 |
// User has clicked on a letter |
499 |
function filterByFirstLetterSurname(letter) { |
680 |
function filterByFirstLetterSurname(letter, setstate ) { |
500 |
$("#firstletter_filter").val(letter); |
681 |
$("#firstletter_filter").val(letter); |
|
|
682 |
|
501 |
$("#[% table_id | html %]_search_results").show(); |
683 |
$("#[% table_id | html %]_search_results").show(); |
|
|
684 |
|
685 |
if ( setstate ) { |
686 |
history.pushState( null, null, "?firstletter=" + letter ); |
687 |
} |
688 |
|
502 |
patrons_table.DataTable().draw(); |
689 |
patrons_table.DataTable().draw(); |
|
|
690 |
update_search_description(); |
503 |
} |
691 |
} |
504 |
|
692 |
|
505 |
// modify parent window owner element |
693 |
// modify parent window owner element |
506 |
[% IF selection_type == 'add' %] |
694 |
function add_user(borrowernumber, borrowername) { |
507 |
function add_user(borrowernumber, borrowername) { |
695 |
var p = window.opener; |
508 |
var p = window.opener; |
696 |
// In one place (serials/routing.tt), the page is reload on every add |
509 |
// In one place (serials/routing.tt), the page is reload on every add |
697 |
// We have to wait for the page to be there |
510 |
// We have to wait for the page to be there |
698 |
function wait_for_opener () { |
511 |
function wait_for_opener () { |
699 |
if ( ! $(opener.document).find('body').size() ) { |
512 |
if ( ! $(opener.document).find('body').size() ) { |
700 |
setTimeout(wait_for_opener, 500); |
513 |
setTimeout(wait_for_opener, 500); |
701 |
} else { |
|
|
702 |
[%# Note that add_user could sent data instead of borrowername too %] |
703 |
$("#info").hide(); |
704 |
$("#error").hide(); |
705 |
if ( p.add_user(borrowernumber, borrowername) < 0 ) { |
706 |
$("#error").html(_("Patron '%s' is already in the list.").format(borrowername)); |
707 |
$("#error").show(); |
514 |
} else { |
708 |
} else { |
515 |
[%# Note that add_user could sent data instead of borrowername too %] |
709 |
$("#info").html(_("Patron '%s' added.").format(borrowername)); |
516 |
$("#info").hide(); |
710 |
$("#info").show(); |
517 |
$("#error").hide(); |
|
|
518 |
if ( p.add_user(borrowernumber, borrowername) < 0 ) { |
519 |
$("#error").html(_("Patron '%s' is already in the list.").format(borrowername)); |
520 |
$("#error").show(); |
521 |
} else { |
522 |
$("#info").html(_("Patron '%s' added.").format(borrowername)); |
523 |
$("#info").show(); |
524 |
} |
525 |
} |
711 |
} |
526 |
} |
712 |
} |
527 |
wait_for_opener(); |
|
|
528 |
} |
713 |
} |
529 |
[% ELSIF selection_type == 'select' %] |
714 |
wait_for_opener(); |
530 |
function select_user(borrowernumber, data) { |
715 |
} |
531 |
var p = window.opener; |
716 |
function select_user(borrowernumber, data) { |
532 |
[% IF callback %] |
717 |
var p = window.opener; |
533 |
p.[% callback | html %](borrowernumber, data); |
718 |
[% IF callback %] |
534 |
[% ELSE %] |
719 |
p.[% callback | html %](borrowernumber, data); |
535 |
p.select_user(borrowernumber, data); |
720 |
[% ELSE %] |
536 |
[% END %] |
721 |
p.select_user(borrowernumber, data); |
537 |
window.close(); |
722 |
[% END %] |
538 |
} |
723 |
window.close(); |
539 |
[% END %] |
724 |
} |
540 |
</script> |
725 |
</script> |
541 |
[% END %] |
726 |
[% END %] |