6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha › Patron search</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 [% Asset.css("css/datatables.css") | $raw %]
10 <style> .modal-body .close { display: none; } </style>
13 <body id="common_patron_search" class="common">
14 <div id="patron_search" class="yui-t7">
15 <div class="container-fluid">
17 <form id="searchform">
18 <fieldset class="brief">
19 <h3>Search for patron</h3>
22 <label for="searchmember_filter">Search:</label>
23 <input type="text" id="searchmember_filter" value="[% searchmember | html %]"/>
26 <label for="categorycode_filter">Category:</label>
27 <select id="categorycode_filter">
28 <option value="">Any</option>
29 [% FOREACH category IN categories %]
30 <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
35 <label for="branchcode_filter">Library:</label>
36 <select id="branchcode_filter">
37 [% SET libraries = Branches.all( only_from_group => 1 ) %]
38 [% IF libraries.size != 1 %]
39 <option value="">Any</option>
41 [% FOREACH l IN libraries %]
42 <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
47 <fieldset class="action">
48 <input type="submit" value="Search" />
53 [% IF patrons_with_acq_perm_only %]
54 <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>
59 [% FOREACH letter IN alphabet.split(' ') %]
60 <a href="#" class="filterByLetter">[% letter | html %]</a>
64 <div id="info" class="dialog message"></div>
65 <div id="error" class="dialog alert"></div>
67 <input type="hidden" id="firstletter_filter" value="" />
68 <div id="searchresults">
69 <table id="memberresultst">
72 [% FOR column IN columns %]
74 [% CASE 'cardnumber' %]<th>Card</th>
75 [% CASE 'dateofbirth' %]<th>Date of birth</th>
76 [% CASE 'address' %]<th>Address</th>
77 [% CASE 'name' %]<th>Name</th>
78 [% CASE 'branch' %]<th>Library</th>
79 [% CASE 'category' %]<th>Category</th>
80 [% CASE 'dateexpiry' %]<th>Expires on</td>
81 [% CASE 'borrowernotes' %]<th>Notes</th>
82 [% CASE 'action' %]<th> </th>
91 <div id="closewindow"><a href="#" class="btn btn-default btn-default close">Close</a></div>
93 <!-- Patron preview modal -->
94 <div class="modal" id="patronPreview" tabindex="-1" role="dialog" aria-labelledby="patronPreviewLabel">
95 <div class="modal-dialog" role="document">
96 <div class="modal-content">
97 <div class="modal-header">
98 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
99 <h4 class="modal-title" id="patronPreviewLabel"></h4>
101 <div class="modal-body">
103 <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading
106 <div class="modal-footer">
107 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
116 [% MACRO jsinclude BLOCK %]
117 [% INCLUDE 'datatables.inc' %]
119 <script type="text/javascript">
121 $(document).ready(function(){
125 [% IF view != "show_results" %]
126 $("#searchresults").hide();
130 // Apply DataTables on the results table
131 dtMemberResults = $("#memberresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
133 'sAjaxSource': "/cgi-bin/koha/svc/members/search",
134 'fnServerData': function(sSource, aoData, fnCallback) {
139 'name': 'searchmember',
140 'value': $("#searchmember_filter").val()
142 'name': 'firstletter',
143 'value': $("#firstletter_filter").val()
145 'name': 'categorycode',
146 'value': $("#categorycode_filter").val()
148 'name': 'branchcode',
149 'value': $("#branchcode_filter").val()
151 'name': 'name_sorton',
152 'value': 'borrowers.surname borrowers.firstname'
154 'name': 'category_sorton',
155 'value': 'categories.description',
157 'name': 'branch_sorton',
158 'value': 'branches.branchname'
160 'name': 'template_path',
161 'value': '[% json_template | html %]',
163 'name': 'selection_type',
164 'value': '[% selection_type | html %]',
166 [% IF patrons_with_acq_perm_only %]
168 'name': 'has_permission',
169 'value': 'acquisition.order_manage',
178 'success': function(json){
184 [% FOR column IN columns %]
185 [% IF column == 'action' %]
186 { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
187 [% ELSIF column == 'address' %]
188 { 'mDataProp': 'dt_address', 'bSortable': false }
190 { 'mDataProp': 'dt_[% column | html %]' }
192 [% UNLESS loop.last %],[% END %]
196 [% IF patrons_with_acq_perm_only %]
199 'sPaginationType': 'full_numbers',
200 "iDisplayLength": [% Koha.Preference('PatronsPerPage') | html %],
202 'aaSorting': [[[% aaSorting || 0 | html %], 'asc']],
207 $("#searchform").on('submit', filter);
208 $(".filterByLetter").on("click",function(e){
210 filterByFirstLetterSurname($(this).text());
212 $("body").on("click",".add_user",function(e){
214 var borrowernumber = $(this).data("borrowernumber");
215 var firstname = $(this).data("firstname");
216 var surname = $(this).data("surname");
217 add_user( borrowernumber, firstname + " " + surname );
220 $("body").on("click",".select_user",function(e){
222 var borrowernumber = $(this).data("borrowernumber");
223 var borrower_data = $("#borrower_data"+borrowernumber).val();
224 select_user( borrowernumber, JSON.parse(borrower_data) );
227 $("body").on("click",".patron_preview", function( e ){
229 var borrowernumber = $(this).data("borrowernumber");
230 var page = "/cgi-bin/koha/members/moremember.pl?print=brief&borrowernumber=" + borrowernumber;
231 $("#patronPreview .modal-body").load( page + " div.container-fluid" );
232 $('#patronPreview').modal({show:true});
235 $("#patronPreview").on('hidden.bs.modal', function (e) {
236 $("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading");
243 $("#firstletter_filter").val('');
244 $("#searchresults").show();
245 dtMemberResults.fnDraw();
249 // User has clicked on a letter
250 function filterByFirstLetterSurname(letter) {
251 $("#firstletter_filter").val(letter);
253 $("#searchresults").show();
254 dtMemberResults.fnDraw();
257 // modify parent window owner element
258 [% IF selection_type == 'add' %]
259 function add_user(borrowernumber, borrowername) {
260 var p = window.opener;
261 // In one place (serials/routing.tt), the page is reload on every add
262 // We have to wait for the page to be there
263 function wait_for_opener () {
264 if ( ! $(opener.document).find('body').size() ) {
265 setTimeout(wait_for_opener, 500);
267 [%# Note that add_user could sent data instead of borrowername too %]
270 if ( p.add_user(borrowernumber, borrowername) < 0 ) {
271 $("#error").html(_("Patron '%s' is already in the list.").format(borrowername));
274 $("#info").html(_("Patron '%s' added.").format(borrowername));
281 [% ELSIF selection_type == 'select' %]
282 function select_user(borrowernumber, data) {
283 var p = window.opener;
284 p.select_user(borrowernumber, data);
291 [% SET popup_window = 1 %]
292 [% INCLUDE 'intranet-bottom.inc' %]