8 [%# Display a simple form %]
9 [% BLOCK patron_search_filters_simple %]
10 <form id="patron_search_form">
11 <div class="hint">Enter patron card number or partial name:</div>
12 <input type="text" size="40" id="search_patron_filter" class="focus" autocomplete="off" />
13 <input type="submit" value="Search" />
17 [%# Display a complex patron search form %]
18 [%# - Search: <input> %]
19 [%# You can then pass a list of filters %]
20 [%# - branch: <select library list> %]
21 [%# - category: <select patron category list> %]
22 [%# - search_field: <select patron field list> %]
23 [%# - search_type: <select "contain" or "start with"> %]
24 [% BLOCK patron_search_filters %]
25 <form id="patron_search_form">
26 <fieldset class="brief">
27 <h3>Search for patron</h3>
30 <label for="search_patron_filter">Search:</label>
31 <input type="text" id="search_patron_filter" value="[% search_filter | html %]" class="focus" />
34 [% FOR f IN filters %]
38 <label for="branchcode_filter">Library:</label>
39 <select id="branchcode_filter">
40 [% SET libraries = Branches.all( only_from_group => 1 ) %]
41 [% IF libraries.size != 1 %]
42 <option value="">Any</option>
44 [% FOREACH l IN libraries %]
45 <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
51 <label for="categorycode_filter">Category:</label>
52 <select id="categorycode_filter">
53 <option value="">Any</option>
54 [% FOREACH category IN categories %]
55 <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
59 [% CASE 'search_field' %]
61 <label for="searchfieldstype_filter">Search field:</label>
62 <select name="searchfieldstype" id="searchfieldstype_filter">
63 [% SET standard = Koha.Preference('DefaultPatronSearchFields') || 'firstname,surname,othernames,cardnumber,userid' %]
64 [% SET search_options = [ standard, 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %]
65 [% FOREACH s_o IN search_options %]
66 [% display_name = PROCESS patron_fields name=s_o %]
67 [% NEXT IF !display_name %]
68 [% IF searchfieldstype == s_o %]
69 <option selected="selected" value=[% s_o | html %]>[% display_name | $raw %]</option>
71 <option value=[% s_o | html %]>[% display_name | $raw %]</option>
76 [% CASE 'search_type' %]
78 <label for="searchtype_filter">Search type:</label>
79 <select name="searchtype" id="searchtype_filter">
80 [% IF searchtype == "start_with" %]
81 <option value='start_with' selected="selected">Starts with</option>
82 <option value="contain">Contains</option>
84 <option value='start_with'>Starts with</option>
85 <option value="contain" selected="selected">Contains</option>
92 <fieldset class="action">
93 <input type="submit" value="Search" />
94 <input type="button" value="Clear" id="clear_search" />
100 [%# Display the table with: %]
101 [%# - At the top a hint about a possible filter %]
102 [%# - Browse by last name %]
104 [%# Get the following parameters: %]
105 [%# - filter: can be 'suggestions_managers', 'orders_managers', 'funds_owners' or 'funds_users' to filter patrons on their permissions %]
106 [%# - table_id: the ID of the table %]
107 [%# open_on_row_click: See patron_search_js %]
108 [%# columns: See patron_search_js %]
109 [% BLOCK patron_search_table %]
111 [% IF filter == 'suggestions_managers' %]
112 <div class="hint">Only staff with superlibrarian or suggestions_manage permissions are returned in the search results</div>
113 [% ELSIF filter == 'orders_managers' %]
114 <div class="hint">Only staff with superlibrarian or acquisitions permissions (or order_manage permission if granular permissions are enabled) are returned in the search results</div>
115 [% ELSIF filter == 'funds_owners' OR filter == 'funds_users' %]
116 <div class="hint">Only staff with superlibrarian or acquisitions permissions (or budget_modify permission if granular permissions are enabled) are returned in the search results</div>
121 [% SET alphabet = Koha.Preference('alphabet').split(' ') %]
122 [% UNLESS alphabet.size %]
123 [% alphabet = ['A' .. 'Z'] %]
125 [% FOREACH letter IN alphabet %]
126 <a href="#" class="filterByLetter">[% letter | html %]</a>
131 <h3 style="display: none;">Patrons found for: <span id="searchpattern"></span></h3>
133 <div id="[% table_id | html %]_search_results" style="display:none;">
135 <div id="info" class="dialog message" style="display: none;"></div>
136 <div id="error" class="dialog alert" style="display: none;"></div>
138 <input type="hidden" id="firstletter_filter" value="" />
139 [% IF open_on_row_click %]
140 <table id="[% table_id | html %]" class="selections-table">
142 <table id="[% table_id | html %]">
146 [% FOR column IN columns %]
148 [% CASE 'checkbox' %]<th class="noExport"></th>
149 [% CASE 'cardnumber' %]<th>Card</th>
150 [% CASE 'dateofbirth' %]<th>Date of birth</th>
151 [% CASE 'name' %]<th>Name</th>
152 [% CASE 'name-address' %]<th>Name</th>
153 [% CASE 'address' %]<th>Address</th>
154 [% CASE 'address-library' %]<th>Address</th>
155 [% CASE 'branch' %]<th data-filter="libraries">Library</th>
156 [% CASE 'category' %]<th data-filter="categories">Category</th>
157 [% CASE 'dateexpiry' %]<th>Expires on</td>
158 [% CASE 'borrowernotes' %]<th>Notes</th>
159 [% CASE 'phone' %]<th>Phone</th>
160 [% CASE 'checkouts' %]<th>Checkouts</th>
161 [% CASE 'account_balance' %]<th>Fines</th>
162 [% CASE 'action' %]<th> </th>
171 <!-- Patron preview modal -->
172 <div class="modal" id="patronPreview" tabindex="-1" role="dialog" aria-labelledby="patronPreviewLabel">
173 <div class="modal-dialog" role="document">
174 <div class="modal-content">
175 <div class="modal-header">
176 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
177 <h4 class="modal-title" id="patronPreviewLabel"></h4>
179 <div class="modal-body">
181 <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading
184 <div class="modal-footer">
185 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
193 [%# Integrate all the JS code, outside of a script tag %]
194 [%# Get the following parameters: %]
195 [%# - 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_url: The URL to use, the borrowernumber parameter will be added %]
197 [%# filter: Same as patron_search_table %]
198 [%# open_on_row_click: boolean, default off. Will allow to select a patron by clicking on the whole tr element %]
199 [%# 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' %]
200 [%# preview_on_name_click: Open a modal window with patron's info when the name is clicked %]
201 [%# actions: list of buttons to display in the action column. Possible values are: 'select', 'add', 'edit', 'checkout' %]
202 [%# sticky_header and sticky_to: If we need a sticky header %]
203 [%# callback: name of the JS function that will be called when a patron is selected. Only work with action=select %]
204 [%# display_search_description: boolean, default off. Display the description of the search %]
205 [% BLOCK patron_search_js %]
207 [% IF redirect_if_one_result && !redirect_url %]
208 <script>console.log("Wrong call of patron_searh_js - missing redirect_url");</script>
211 let categories = [% To.json(categories) | $raw %].map(e => {
212 e['_id'] = e.categorycode;
213 e['_str'] = e.description;
216 let categories_map = categories.reduce((map, e) => {
220 let libraries = [% To.json(libraries) | $raw %].map(e => {
221 e['_id'] = e.branchcode;
222 e['_str'] = e.branchname;
225 let libraries_map = libraries.reduce((map, e) => {
230 [% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %]
231 let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %];
236 [% INCLUDE 'datatables.inc' %]
237 [% INCLUDE 'js-date-format.inc' %]
238 [% INCLUDE 'js-patron-get-age.inc' %]
239 [% INCLUDE 'js-patron-format.inc' %]
240 [% INCLUDE 'js-patron-format-address.inc' %]
241 [% IF sticky_header %]
242 [% Asset.js("lib/hc-sticky.js") | $raw %]
249 var singleBranchMode = '[% singleBranchMode | html %]';
250 let logged_in_library_id = "[% Branches.GetLoggedInBranchcode | html %]";
251 [% IF do_not_defer_loading %]
252 let defer_loading = 0;
254 let defer_loading = 1;
257 /* popstate event triggered by forward and back button. Need to refresh search */
258 window.addEventListener('popstate', (event) => {
259 getSearchByLocation( false );
262 $(document).ready(function(){
267 // Build the aLengthMenu
269 [% Koha.Preference('PatronsPerPage') | html %], 10, 20, 50, 100, -1
271 jQuery.unique(aLengthMenu);
272 aLengthMenu.sort(function( a, b ){
273 // Put "All" at the end
276 } else if ( b == -1 ) {
279 return parseInt(a) < parseInt(b) ? -1 : 1;}
281 var aLengthMenuLabel = [];
282 $(aLengthMenu).each(function(){
284 // Label for -1 is "All"
285 aLengthMenuLabel.push(_("All"));
287 aLengthMenuLabel.push(this);
291 let additional_filters = {
293 let start_with = $("#firstletter_filter").val()
294 if (!start_with) return "";
295 return { "like": start_with + "%" }
298 let filter = $("#search_patron_filter").val();
299 if (!filter) return "";
302 let search_type = $("#searchtype_filter").val() || "contain";
303 let search_fields = $("#searchfieldstype_filter").val();
304 if ( !search_fields ) {
305 search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,surname,othernames,cardnumber,userid' | html %]";
307 search_fields.split(',').forEach(function(e,i){
308 filters.push({["me."+e]:{"like":(search_type == "contain" ? "%" : "" ) + filter + "%"}});
310 [% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %]
312 "extended_attributes.value": { "like": "%" + filter + (search_type == "contain" ? "%" : "" )},
313 "extended_attributes.code": extended_attribute_types
319 [% UNLESS default_sort_column %]
320 [% default_sort_column = "name" %]
322 [% SET order_column_index = 0 %]
323 [% SET embed = ['extended_attributes'] %]
324 patrons_table = $("#[% table_id | html %]").kohaTable({
327 [% CASE 'suggestions_managers' %]
328 "url": '/api/v1/suggestions/managers',
329 [% CASE 'baskets_managers' %]
330 "url": '/api/v1/acquisitions/baskets/managers',
331 [% CASE 'funds_owners' %]
332 "url": '/api/v1/acquisitions/funds/owners',
333 [% CASE 'funds_users' %]
334 "url": '/api/v1/acquisitions/funds/users',
336 "url": '/api/v1/patrons',
338 "dataSrc": function ( json ) {
339 [% IF redirect_if_one_result %]
340 // redirect if there is only 1 result.
341 if ( first_draw && json.recordsFiltered == 1 ) {
342 let url = '[% redirect_url | url %]'.indexOf("?") != -1
343 ? '[% redirect_url | url %]&borrowernumber=' + json.data[0].patron_id
344 : '[% redirect_url | url %]?borrowernumber=' + json.data[0].patron_id;
345 document.location.href = url;
353 [% IF open_on_row_click OR preview_on_name_click %]
354 "drawCallback": function( settings ) {
355 var api = this.api();
356 var data = api.data();
357 if ( data.length == 0 ) return;
359 [% IF open_on_row_click %]
360 $.each($(this).find("tbody tr"), function(index, tr) {
361 let url = "[% on_click_url | url %]&borrowernumber=" + data[index].patron_id;
362 $(tr).off('click').on('click', function() {
363 document.location.href = url;
364 }).addClass('clickable');
365 $(tr).find("a.patron_name").attr('href', url);
368 [% IF preview_on_name_click %]
369 $.each($(this).find("tbody tr"), function(index, tr) {
370 $(tr).find("a.patron_name").addClass("patron_preview");
375 "iDeferLoading": defer_loading,
377 [% FOR column IN columns %]
378 [% IF default_sort_column == column %]
379 [% order_column_index = loop.count - 1%]
382 [% CASE 'checkbox' %]
387 "render": function( data, type, row, meta ) {
388 return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />";
391 [% CASE 'cardnumber' %]
393 "data": "cardnumber",
396 "render": function( data, type, row, meta ) {
397 let patron_id = encodeURIComponent(row.patron_id);
398 [% IF !open_on_row_click AND CAN_user_circulate_circulate_remaining_permissions %]
399 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>";
401 return escape_str(data);
406 [% CASE 'dateofbirth' %]
408 "data": "date_of_birth",
411 "render": function( data, type, row, meta ) {
412 return data ? escape_str($date(data) + " (" + _("%s years").format($get_age(data)) + ")") : "";
417 "data": "me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country",
420 "render": function( data, type, row, meta ) {
421 let r = '<div class="address"><ul>';
422 r += $format_address(row, { no_line_break: 1 });
427 [% CASE 'address-library' %]
429 "data": "me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country",
432 "render": function( data, type, row, meta ) {
433 let r = '<div class="address"><ul>';
434 r += $format_address(row, { no_line_break: 1 });
436 r += " " + escape_str(libraries_map[row.library_id].branchname);
440 [% CASE 'name-address' %]
442 "data": "me.surname:me.firstname:me.othernames:me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country",
445 "render": function( data, type, row, meta ) {
446 let patron_id = encodeURIComponent(row.patron_id);
448 [% IF ! open_on_row_click %]
449 r += "<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>";
451 r += $patron_to_html(row, { invert_name: 1 });
454 r += '<div class="address"><ul>';
455 r += $format_address(row, { no_line_break: 1 });
458 r += "<li>" + _("Email: ") + "<a href='mailto:" + encodeURIComponent(row.email) + "'>" + escape_str(row.email) + "</a></li>";
465 [% CASE 'name-address' %]
467 "data": "me.surname:me.firstname:me.othernames:me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country",
470 "render": function( data, type, row, meta ) {
471 let patron_id = encodeURIComponent(row.patron_id);
473 [% IF ! open_on_row_click %]
474 r += "<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>";
476 r += $patron_to_html(row, { invert_name: 1 });
479 r += '<div class="address"><ul>';
480 r += $format_address(row, { no_line_break: 1 });
483 r += "<li>" + _("Email: ") + "<a href='mailto:" + encodeURIComponent(row.email) + "'>" + escape_str(row.email) + "</a></li>";
492 "data": "me.surname:me.firstname:me.othernames",
495 "render": function( data, type, row, meta ) {
496 let patron_id = encodeURIComponent(row.patron_id);
497 [% IF ! open_on_row_click %]
498 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>";
500 return $patron_to_html(row, { invert_name: 1 });
506 "data": "library_id",
509 "render": function( data, type, row, meta ) {
510 let library_name = libraries_map[data].branchname
511 if( !singleBranchMode && data == logged_in_library_id ) {
512 return "<span class=\"currentlibrary\">" + escape_str(library_name) + "</span>";
514 return escape_str(library_name);
518 [% CASE 'category' %]
520 "data": "category_id",
523 "render": function( data, type, row, meta ) {
524 return escape_str(categories_map[data].description);
527 [% CASE 'dateexpiry' %]
529 "data": "expiry_date",
532 "render": function( data, type, row, meta ) {
533 return data ? escape_str($date(data)) : "";
536 [% CASE 'borrowernotes' %]
538 "data": "staff_notes",
541 [%# We don't escape here, we allow html tag in staff notes %]
548 "render": function( data, type, row, meta ) {
549 return escape_str(data);
552 [% CASE 'checkouts' %][% embed.push('checkouts+count', 'overdues+count') %]
557 "render": function( data, type, row, meta ) {
558 if ( row.overdues_count ) {
559 return "<span class='overdue'><strong>"+row.overdues_count + "</strong></span>";
561 return "0 / " + row.checkouts_count;
565 [% CASE 'account_balance' %][% embed.push('account_balance') %]
570 "render": function( data, type, row, meta ) {
571 let r = "<span style='text-align: right; display: block;'><a href=\"/cgi-bin/koha/members/boraccount.pl?borrowernumber="+row.patron_id+"\">";
572 let balance_str = row.account_balance || 0;
573 balance_str = balance_str.escapeHtml().format_price();
574 if ( row.account_balance < 0 ) {
575 // FIXME Format price here
576 r += "<span class='credit'>" + balance_str + "</span>";
577 } else if ( row.account_balance > 0 ) {
578 r += "<span class='debit'><strong>" + balance_str + "</strong></span>"
589 "data": function( row, type, val, meta ) {
591 let patron_id = encodeURIComponent(row.patron_id);
592 let action_node = "";
593 [% FOR action IN actions %]
596 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)+'\' />';
598 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 + '" />';
600 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>';
601 [% CASE 'checkout' %]
602 [% IF CAN_user_circulate_circulate_remaining_permissions %]
603 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>';
613 [% UNLESS loop.last %],[% END %]
616 'embed': [% To.json(embed) | $raw %],
617 "order": [[ [% order_column_index | html %], "asc" ]],
619 'lengthMenu': [aLengthMenu, aLengthMenuLabel],
620 'sPaginationType': 'full_numbers',
621 "pageLength": [% Koha.Preference('PatronsPerPage') | html %],
622 [% IF sticky_header %]
623 "initComplete": function(settings, json) {
624 $("#[% sticky_header | html %]").show();
625 Sticky = $("#[% sticky_header | html %]");
627 stickTo: "#[% sticky_to | html %]",
628 stickyClass: "floating"
632 }, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters);
634 $("#patron_search_form").on('submit', filter);
635 $(".filterByLetter").on("click",function(e){
637 filterByFirstLetterSurname($(this).text(), true);
639 $("body").on("click",".add_user",function(e){
641 var borrowernumber = $(this).data("borrowernumber");
642 var firstname = $(this).data("firstname");
643 var surname = $(this).data("surname");
644 add_user( borrowernumber, firstname + " " + surname );
647 $("body").on("click",".select_user",function(e){
649 var borrowernumber = $(this).data("borrowernumber");
650 var borrower_data = $("#borrower_data"+borrowernumber).val();
651 select_user( borrowernumber, JSON.parse(borrower_data) );
654 $("body").on("click",".patron_preview", function( e ){
656 var borrowernumber = $(this).data("borrowernumber");
657 var page = "/cgi-bin/koha/members/moremember.pl?print=brief&borrowernumber=" + borrowernumber;
658 $("#patronPreview .modal-body").load( page + " div.container-fluid" );
659 $('#patronPreview').modal({show:true});
662 $("#patronPreview").on('hidden.bs.modal', function (e) {
663 $("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading");
666 $("#clear_search").on("click",function(e){
669 $("#searchpattern").parent().hide();
672 if ( !defer_loading ) {
673 $("#patron_search_form").submit();
676 /* Initial page load does not trigger the popstate event, so we explicitly call this */
677 getSearchByLocation( false );
681 function getSearchByLocation( setstate ){
682 /* Check to see if the URL contains a search parameter */
683 if( location.search != ""){
684 var params = new URLSearchParams( location.search );
685 var firstletter = params.get("firstletter");
686 /* Check to see if search is a first letter param */
688 /* Trigger function to return search results by letter */
689 filterByFirstLetterSurname( firstletter, setstate );
694 function update_search_description(){
695 var searched = $("#searchfieldstype_filter").find("option:selected").text();
696 if ( $("#search_patron_filter").val() ) {
697 if ( $("#searchtype_filter").val() == 'start_with' ) {
698 searched += _(" starting with ");
700 searched += _(" containing ");
702 searched += "'" + $("#search_patron_filter").val() + "'";
704 if ( $("#firstletter_filter").val() ) {
705 searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
707 if ( $("#categorycode_filter").val() ) {
708 searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
710 if ( $("#branchcode_filter").val() ) {
711 searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
713 $("#searchpattern").text(searched);
714 $("#searchpattern").parent().show();
718 $("#firstletter_filter").val('');
719 $("#[% table_id | html %]_search_results").show();
721 let table_dt = patrons_table.DataTable();
722 [% FOR c IN columns %]
725 library_id = $("#branchcode_filter").val() || "";
726 patrons_table.find('thead tr:eq(1) th[data-filter="libraries"] select').val(library_id);
727 table_dt.column([% loop.count - 1 %]).search(library_id ? '^'+library_id+'$' : '');
728 [% CASE 'category' %]
729 let category_id = $("#categorycode_filter").val() || "";
730 patrons_table.find('thead tr:eq(1) th[data-filter="categories"] select').val(category_id);
731 table_dt.column([% loop.count - 1 %]).search(category_id ? '^'+category_id+'$' : '');
735 first_draw = 1; // Only redirect if we are coming from here
737 [% IF display_search_description %]
738 update_search_description();
743 function clearFilters() {
744 $("#searchfieldstype_filter option:first").prop("selected", true);
745 $("#searchtype_filter option[value='contain']").prop("selected", true);
746 $("#categorycode_filter option:first").prop("selected", true);
747 $("#branchcode_filter option:first").prop("selected", true);
748 $("#firstletter_filter").val('');
749 $("#search_patron_filter").val('');
750 /* remove any search string added by firstletter search */
751 history.pushState( {}, null, window.location.href.split("?" )[0]);
752 $("#[% table_id | html %]_search_results").hide();
753 [% IF display_search_description %]
754 update_search_description();
758 // User has clicked on a letter
759 function filterByFirstLetterSurname(letter, setstate ) {
760 $("#firstletter_filter").val(letter);
762 $("#[% table_id | html %]_search_results").show();
765 history.pushState( null, null, "?firstletter=" + letter );
768 patrons_table.DataTable().draw();
769 [% IF display_search_description %]
770 update_search_description();
774 // modify parent window owner element
775 function add_user(borrowernumber, borrowername) {
776 var p = window.opener;
777 // In one place (serials/routing.tt), the page is reload on every add
778 // We have to wait for the page to be there
779 function wait_for_opener () {
780 if ( ! $(opener.document).find('body').size() ) {
781 setTimeout(wait_for_opener, 500);
783 [%# Note that add_user could sent data instead of borrowername too %]
786 if ( p.add_user(borrowernumber, borrowername) < 0 ) {
787 $("#error").html(_("Patron '%s' is already in the list.").format(borrowername));
790 $("#info").html(_("Patron '%s' added.").format(borrowername));
797 function select_user(borrowernumber, data) {
798 var p = window.opener;
800 p.[% callback | html %](borrowernumber, data);
802 p.select_user(borrowernumber, data);