2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha › Patron search</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
6 [% INCLUDE 'datatables.inc' %]
8 <script type="text/javascript">
12 $(document).ready(function(){
16 [% IF view != "show_results" %]
17 $("#searchresults").hide();
21 // Apply DataTables on the results table
22 dtMemberResults = $("#memberresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
24 'sAjaxSource': "/cgi-bin/koha/svc/members/search",
25 'fnServerData': function(sSource, aoData, fnCallback) {
30 'name': 'searchmember',
31 'value': $("#searchmember_filter").val()
33 'name': 'firstletter',
34 'value': $("#firstletter_filter").val()
36 'name': 'categorycode',
37 'value': $("#categorycode_filter").val()
40 'value': $("#branchcode_filter").val()
42 'name': 'name_sorton',
43 'value': 'borrowers.surname borrowers.firstname'
45 'name': 'category_sorton',
46 'value': 'categories.description',
48 'name': 'branch_sorton',
49 'value': 'branches.branchname'
51 'name': 'template_path',
52 'value': '[% json_template %]',
54 'name': 'selection_type',
55 'value': '[% selection_type %]',
57 [% IF patrons_with_acq_perm_only %]
59 'name': 'has_permission',
60 'value': 'acquisition.order_manage',
69 'success': function(json){
75 [% FOR column IN columns %]
76 [% IF column == 'action' %]
77 { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
78 [% ELSIF column == 'address' %]
79 { 'mDataProp': 'dt_address', 'bSortable': false }
81 { 'mDataProp': 'dt_[% column %]' }
83 [% UNLESS loop.last %],[% END %]
87 [% IF patrons_with_acq_perm_only %]
90 'sPaginationType': 'full_numbers',
91 "iDisplayLength": [% Koha.Preference('PatronsPerPage') %],
93 'aaSorting': [[[% aaSorting || 0 %], 'asc']],
98 $("#searchform").on('submit', filter);
99 $(".filterByLetter").on("click",function(e){
101 filterByFirstLetterSurname($(this).text());
103 $("body").on("click",".add_user",function(e){
105 var borrowernumber = $(this).data("borrowernumber");
106 var firstname = $(this).data("firstname");
107 var surname = $(this).data("surname");
108 add_user( borrowernumber, firstname + " " + surname );
114 $("#firstletter_filter").val('');
115 $("#searchresults").show();
116 dtMemberResults.fnDraw();
120 // User has clicked on a letter
121 function filterByFirstLetterSurname(letter) {
122 $("#firstletter_filter").val(letter);
124 $("#searchresults").show();
125 dtMemberResults.fnDraw();
129 // modify parent window owner element
130 [% IF selection_type == 'add' %]
131 function add_user(borrowernumber, borrowername) {
132 var p = window.opener;
133 // In one place (serials/routing.tt), the page is reload on every add
134 // We have to wait for the page to be there
135 function wait_for_opener () {
136 if ( ! $(opener.document).find('body').size() ) {
137 setTimeout(wait_for_opener, 500);
139 [%# Note that add_user could sent data instead of borrowername too %]
142 if ( p.add_user(borrowernumber, borrowername) < 0 ) {
143 $("#error").html(_("Patron '%s' is already in the list.").format(borrowername));
146 $("#info").html(_("Patron '%s' added.").format(borrowername));
153 [% ELSIF selection_type == 'select' %]
154 function select_user(borrowernumber, data) {
155 var p = window.opener;
156 p.select_user(borrowernumber, data);
164 <body id="common_patron_search" class="common">
165 <div id="patron_search" class="yui-t7">
169 <form id="searchform">
170 <fieldset class="brief">
171 <h3>Search for patron</h3>
174 <label for="searchmember_filter">Search:</label>
175 <input type="text" id="searchmember_filter" value="[% searchmember %]"/>
178 <label for="categorycode_filter">Category:</label>
179 <select id="categorycode_filter">
180 <option value="">Any</option>
181 [% FOREACH category IN categories %]
182 <option value="[% category.categorycode %]">[% category.description %]</option>
187 <label for="branchcode_filter">Library:</label>
188 <select id="branchcode_filter">
189 [% IF branches.size != 1 %]
190 <option value="">Any</option>
192 [% FOREACH branch IN branches %]
193 <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
198 <fieldset class="action">
199 <input type="submit" value="Search" />
204 [% IF patrons_with_acq_perm_only %]
205 <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>
210 [% FOREACH letter IN alphabet.split(' ') %]
211 <a href="#" class="filterByLetter">[% letter %]</a>
215 <div id="info" class="dialog message"></div>
216 <div id="error" class="dialog alert"></div>
218 <input type="hidden" id="firstletter_filter" value="" />
219 <div id="searchresults">
220 <table id="memberresultst">
223 [% FOR column IN columns %]
225 [% CASE 'cardnumber' %]<th>Card</th>
226 [% CASE 'dateofbirth' %]<th>Date of birth</th>
227 [% CASE 'address' %]<th>Address</th>
228 [% CASE 'name' %]<th>Name</th>
229 [% CASE 'branch' %]<th>Library</th>
230 [% CASE 'category' %]<th>Category</th>
231 [% CASE 'dateexpiry' %]<th>Expires on</td>
232 [% CASE 'borrowernotes' %]<th>Notes</th>
233 [% CASE 'action' %]<th> </th>
242 <div id="closewindow"><a href="#" class="btn btn-default close">Close</a></div>
245 [% INCLUDE 'intranet-bottom.inc' %]