Lines 78-84
Link Here
|
78 |
[% END %] |
78 |
[% END %] |
79 |
</div> |
79 |
</div> |
80 |
|
80 |
|
81 |
<div id="[% table_id %]_search_results" style="display:none;"> |
81 |
<div id="[% table_id | html %]_search_results" style="display:none;"> |
82 |
|
82 |
|
83 |
<div id="info" class="dialog message" style="display: none;"></div> |
83 |
<div id="info" class="dialog message" style="display: none;"></div> |
84 |
<div id="error" class="dialog alert" style="dispay: none;"></div> |
84 |
<div id="error" class="dialog alert" style="dispay: none;"></div> |
Lines 86-94
Link Here
|
86 |
|
86 |
|
87 |
<input type="hidden" id="firstletter_filter" value="" /> |
87 |
<input type="hidden" id="firstletter_filter" value="" /> |
88 |
[% IF open_on_row_click %] |
88 |
[% IF open_on_row_click %] |
89 |
<table id="[% table_id %]" class="selections-table"> |
89 |
<table id="[% table_id | html %]" class="selections-table"> |
90 |
[% ELSE %] |
90 |
[% ELSE %] |
91 |
<table id="[% table_id %]"> |
91 |
<table id="[% table_id | html %]"> |
92 |
[% END %] |
92 |
[% END %] |
93 |
<thead> |
93 |
<thead> |
94 |
<tr> |
94 |
<tr> |
Lines 105-110
Link Here
|
105 |
[% CASE 'dateexpiry' %]<th>Expires on</td> |
105 |
[% CASE 'dateexpiry' %]<th>Expires on</td> |
106 |
[% CASE 'borrowernotes' %]<th>Notes</th> |
106 |
[% CASE 'borrowernotes' %]<th>Notes</th> |
107 |
[% CASE 'phone' %]<th>Phone</th> |
107 |
[% CASE 'phone' %]<th>Phone</th> |
|
|
108 |
[% CASE 'checkouts' %]<th>Checkouts</th> |
108 |
[% CASE 'action' %]<th> </th> |
109 |
[% CASE 'action' %]<th> </th> |
109 |
[% END %] |
110 |
[% END %] |
110 |
[% END %] |
111 |
[% END %] |
Lines 153-160
Link Here
|
153 |
return map; |
154 |
return map; |
154 |
}, {}); |
155 |
}, {}); |
155 |
|
156 |
|
156 |
[% IF Koha.Preference('ExtendedPatronAttributes') %] |
157 |
[% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %] |
157 |
let extended_attribute_types = [% To.json(attribute_type_codes || []) | $raw %]; |
158 |
let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; |
158 |
[% END %] |
159 |
[% END %] |
159 |
|
160 |
|
160 |
</script> |
161 |
</script> |
Lines 187-195
Link Here
|
187 |
[% SET search_fields = Koha.Preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid' %] |
188 |
[% SET search_fields = Koha.Preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid' %] |
188 |
return [ |
189 |
return [ |
189 |
[% FOR search_field IN search_fields.split(',') %] |
190 |
[% FOR search_field IN search_fields.split(',') %] |
190 |
{"me.[% search_field %]":{"like":"%"+filter+"%"}}, |
191 |
{"me.[% search_field | html %]":{"like":"%"+filter+"%"}}, |
191 |
[% END %] |
192 |
[% END %] |
192 |
[% IF Koha.Preference('ExtendedPatronAttributes') %] |
193 |
[% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %] |
193 |
{ |
194 |
{ |
194 |
"extended_attributes.value": { "like": "%" + filter + "%" }, |
195 |
"extended_attributes.value": { "like": "%" + filter + "%" }, |
195 |
"extended_attributes.code": extended_attribute_types |
196 |
"extended_attributes.code": extended_attribute_types |
Lines 198-204
Link Here
|
198 |
]; |
199 |
]; |
199 |
} |
200 |
} |
200 |
}; |
201 |
}; |
201 |
patrons_table = $("#[% table_id %]").kohaTable({ |
202 |
patrons_table = $("#[% table_id | html %]").kohaTable({ |
202 |
"ajax": { |
203 |
"ajax": { |
203 |
[% SWITCH filter %] |
204 |
[% SWITCH filter %] |
204 |
[% CASE 'suggestions_managers' %] |
205 |
[% CASE 'suggestions_managers' %] |
Lines 216-222
Link Here
|
216 |
[% IF redirect_if_one_result %] |
217 |
[% IF redirect_if_one_result %] |
217 |
// redirect if there is only 1 result. |
218 |
// redirect if there is only 1 result. |
218 |
if ( first_draw && json.recordsFiltered == 1 ) { |
219 |
if ( first_draw && json.recordsFiltered == 1 ) { |
219 |
document.location.href = '[% redirect_url %]&borrowernumber=' + json.data[0].patron_id; |
220 |
document.location.href = '[% redirect_url | html %]&borrowernumber=' + json.data[0].patron_id; |
220 |
return false; |
221 |
return false; |
221 |
} |
222 |
} |
222 |
first_draw = 0; |
223 |
first_draw = 0; |
Lines 224-230
Link Here
|
224 |
return json.data; |
225 |
return json.data; |
225 |
} |
226 |
} |
226 |
}, |
227 |
}, |
227 |
embed: ['extended_attributes'], |
228 |
embed: ['extended_attributes', 'checkouts+count'], |
228 |
"drawCallback": function( settings ) { |
229 |
"drawCallback": function( settings ) { |
229 |
var api = this.api(); |
230 |
var api = this.api(); |
230 |
var data = api.data(); |
231 |
var data = api.data(); |
Lines 232-238
Link Here
|
232 |
|
233 |
|
233 |
[% IF open_on_row_click %] |
234 |
[% IF open_on_row_click %] |
234 |
$.each($(this).find("tbody tr"), function(index, tr) { |
235 |
$.each($(this).find("tbody tr"), function(index, tr) { |
235 |
let url = "[% on_click_url %]&borrowernumber=" + data[index].patron_id; |
236 |
let url = "[% on_click_url | html %]&borrowernumber=" + data[index].patron_id; |
236 |
$(tr).off('click').on('click', function() { |
237 |
$(tr).off('click').on('click', function() { |
237 |
document.location.href = url; |
238 |
document.location.href = url; |
238 |
}).addClass('clickable'); |
239 |
}).addClass('clickable'); |
Lines 249-254
Link Here
|
249 |
"columns": [ |
250 |
"columns": [ |
250 |
[% FOR column IN columns %] |
251 |
[% FOR column IN columns %] |
251 |
[% SWITCH column %] |
252 |
[% SWITCH column %] |
|
|
253 |
[% CASE 'checkbox' %] |
254 |
{ |
255 |
"data": "borrowernumber", |
256 |
"searchable": true, |
257 |
"orderable": true, |
258 |
"render": function( data, type, row, meta ) { |
259 |
return "<input type=\"checkbox\" name="data ? escape_str($date(data) + " (" + _("%s years").format($get_age(data)) + ")") : ""; |
260 |
|
261 |
return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />", |
262 |
} |
263 |
} |
252 |
[% CASE 'cardnumber' %] |
264 |
[% CASE 'cardnumber' %] |
253 |
{ |
265 |
{ |
254 |
"data": "cardnumber", |
266 |
"data": "cardnumber", |
Lines 367-372
Link Here
|
367 |
return escape_str(data); |
379 |
return escape_str(data); |
368 |
} |
380 |
} |
369 |
} |
381 |
} |
|
|
382 |
[% CASE 'checkouts' %] |
383 |
{ |
384 |
"data": "", |
385 |
"searchable": false, |
386 |
"orderable": false, |
387 |
"render": function( data, type, row, meta ) { |
388 |
return escape_str(row.checkouts_count); |
389 |
} |
390 |
} |
370 |
[% CASE 'action' %] |
391 |
[% CASE 'action' %] |
371 |
{ |
392 |
{ |
372 |
"data": function( row, type, val, meta ) { |
393 |
"data": function( row, type, val, meta ) { |
Lines 426-432
Link Here
|
426 |
|
447 |
|
427 |
function filter() { |
448 |
function filter() { |
428 |
$("#firstletter_filter").val(''); |
449 |
$("#firstletter_filter").val(''); |
429 |
$("#[% table_id %]_search_results").show(); |
450 |
$("#[% table_id | html %]_search_results").show(); |
430 |
|
451 |
|
431 |
let table_dt = patrons_table.DataTable(); |
452 |
let table_dt = patrons_table.DataTable(); |
432 |
[% FOR c IN columns %] |
453 |
[% FOR c IN columns %] |
Lines 450-456
Link Here
|
450 |
// User has clicked on a letter |
471 |
// User has clicked on a letter |
451 |
function filterByFirstLetterSurname(letter) { |
472 |
function filterByFirstLetterSurname(letter) { |
452 |
$("#firstletter_filter").val(letter); |
473 |
$("#firstletter_filter").val(letter); |
453 |
$("#[% table_id %]_search_results").show(); |
474 |
$("#[% table_id | html %]_search_results").show(); |
454 |
patrons_table.DataTable().draw(); |
475 |
patrons_table.DataTable().draw(); |
455 |
} |
476 |
} |
456 |
|
477 |
|