Lines 195-200
Link Here
|
195 |
[%# Get the following parameters: %] |
195 |
[%# Get the following parameters: %] |
196 |
[%# - redirect_if_one_result: Redirect to the patron if the search returns only one result, note that it will not redirect if filters of the DT are used (this is a feature) %] |
196 |
[%# - redirect_if_one_result: Redirect to the patron if the search returns only one result, note that it will not redirect if filters of the DT are used (this is a feature) %] |
197 |
[%# - redirect_url: The URL to use, the borrowernumber parameter will be added %] |
197 |
[%# - redirect_url: The URL to use, the borrowernumber parameter will be added %] |
|
|
198 |
[%# - redirect_if_attribute_equal: Name of the attribute to use for the redirect. Query using this attribute, before the normal search %] |
198 |
[%# filter: Same as patron_search_table %] |
199 |
[%# filter: Same as patron_search_table %] |
199 |
[%# open_on_row_click: boolean, default off. Will allow to select a patron by clicking on the whole tr element %] |
200 |
[%# open_on_row_click: boolean, default off. Will allow to select a patron by clicking on the whole tr element %] |
200 |
[%# columns: list of columns that will be displayed. Possible values are: 'checkbox', 'cardnumber', 'dateofbirth', 'address', 'name', 'name-address', 'branch', 'category', 'dateexpiry', 'borrowernotes, 'phone', 'checkouts', 'account_balance', 'action' %] |
201 |
[%# columns: list of columns that will be displayed. Possible values are: 'checkbox', 'cardnumber', 'dateofbirth', 'address', 'name', 'name-address', 'branch', 'category', 'dateexpiry', 'borrowernotes, 'phone', 'checkouts', 'account_balance', 'action' %] |
Lines 260-265
Link Here
|
260 |
getSearchByLocation( false ); |
261 |
getSearchByLocation( false ); |
261 |
}); |
262 |
}); |
262 |
|
263 |
|
|
|
264 |
[% SWITCH filter %] |
265 |
[% CASE 'suggestions_managers' %] |
266 |
let patron_search_url = '/api/v1/suggestions/managers'; |
267 |
[% CASE 'baskets_managers' %] |
268 |
let patron_search_url = '/api/v1/acquisitions/baskets/managers'; |
269 |
[% CASE 'funds_owners' %] |
270 |
let patron_search_url = '/api/v1/acquisitions/funds/owners'; |
271 |
[% CASE 'funds_users' %] |
272 |
let patron_search_url = '/api/v1/acquisitions/funds/users'; |
273 |
[% CASE %] |
274 |
let patron_search_url = '/api/v1/patrons'; |
275 |
[% END %] |
263 |
$(document).ready(function(){ |
276 |
$(document).ready(function(){ |
264 |
|
277 |
|
265 |
$("#info").hide(); |
278 |
$("#info").hide(); |
Lines 317-322
Link Here
|
317 |
return filters; |
330 |
return filters; |
318 |
} |
331 |
} |
319 |
}; |
332 |
}; |
|
|
333 |
|
320 |
[% UNLESS default_sort_column %] |
334 |
[% UNLESS default_sort_column %] |
321 |
[% default_sort_column = "name" %] |
335 |
[% default_sort_column = "name" %] |
322 |
[% END %] |
336 |
[% END %] |
Lines 324-341
Link Here
|
324 |
[% SET embed = ['extended_attributes'] %] |
338 |
[% SET embed = ['extended_attributes'] %] |
325 |
patrons_table = $("#[% table_id | html %]").kohaTable({ |
339 |
patrons_table = $("#[% table_id | html %]").kohaTable({ |
326 |
"ajax": { |
340 |
"ajax": { |
327 |
[% SWITCH filter %] |
341 |
"url": patron_search_url, |
328 |
[% CASE 'suggestions_managers' %] |
|
|
329 |
"url": '/api/v1/suggestions/managers', |
330 |
[% CASE 'baskets_managers' %] |
331 |
"url": '/api/v1/acquisitions/baskets/managers', |
332 |
[% CASE 'funds_owners' %] |
333 |
"url": '/api/v1/acquisitions/funds/owners', |
334 |
[% CASE 'funds_users' %] |
335 |
"url": '/api/v1/acquisitions/funds/users', |
336 |
[% CASE %] |
337 |
"url": '/api/v1/patrons', |
338 |
[% END %] |
339 |
"dataSrc": function ( json ) { |
342 |
"dataSrc": function ( json ) { |
340 |
[% IF redirect_if_one_result %] |
343 |
[% IF redirect_if_one_result %] |
341 |
// redirect if there is only 1 result. |
344 |
// redirect if there is only 1 result. |
Lines 716-721
Link Here
|
716 |
} |
719 |
} |
717 |
|
720 |
|
718 |
function filter() { |
721 |
function filter() { |
|
|
722 |
[% IF redirect_if_attribute_equal %] |
723 |
let filter = $("#search_patron_filter").val(); |
724 |
if ( filter ) { |
725 |
$.ajax({ |
726 |
data: { cardnumber: filter, _match: 'exact' }, |
727 |
type: 'GET', |
728 |
url: patron_search_url, |
729 |
success: function(data) { |
730 |
if ( data.length == 1 ) { |
731 |
let url = '[% redirect_url | url %]'.indexOf("?") != -1 |
732 |
? '[% redirect_url | url %]&borrowernumber=' + data[0].patron_id |
733 |
: '[% redirect_url | url %]?borrowernumber=' + data[0].patron_id; |
734 |
document.location.href = url; |
735 |
return false; |
736 |
} |
737 |
}, |
738 |
error: function() { |
739 |
alert( _("An error occurred. Check the logs") ); |
740 |
} |
741 |
}); |
742 |
} |
743 |
[% END %] |
719 |
$("#firstletter_filter").val(''); |
744 |
$("#firstletter_filter").val(''); |
720 |
$("#[% table_id | html %]_search_results").show(); |
745 |
$("#[% table_id | html %]_search_results").show(); |
721 |
|
746 |
|