6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha › Patron search</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 <style> .modal-body .close { display: none; } </style>
12 <body id="common_patron_search" class="common">
13 <div id="patron_search" class="yui-t7">
14 <div class="container-fluid">
16 <form id="searchform">
17 <fieldset class="brief">
18 <h3>Search for patron</h3>
21 <label for="searchmember_filter">Search:</label>
22 <input type="text" id="searchmember_filter" value="[% searchmember | html %]"/>
25 <label for="categorycode_filter">Category:</label>
26 <select id="categorycode_filter">
27 <option value="">Any</option>
28 [% FOREACH category IN categories %]
29 <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
34 <label for="branchcode_filter">Library:</label>
35 <select id="branchcode_filter">
36 [% SET libraries = Branches.all( only_from_group => 1 ) %]
37 [% IF libraries.size != 1 %]
38 <option value="">Any</option>
40 [% FOREACH l IN libraries %]
41 <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
46 <fieldset class="action">
47 <input type="submit" value="Search" />
52 [% IF patrons_with_acq_perm_only %]
53 <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>
56 [% IF patrons_with_suggestion_perm_only %]
57 <div class="hint">Only staff with superlibrarian or suggestions_manage permissions are returned in the search results</div>
62 [% FOREACH letter IN alphabet.split(' ') %]
63 <a href="#" class="filterByLetter">[% letter | html %]</a>
67 <div id="info" class="dialog message"></div>
68 <div id="error" class="dialog alert"></div>
70 <input type="hidden" id="firstletter_filter" value="" />
71 <div id="searchresults">
72 <table id="memberresultst">
75 [% FOR column IN columns %]
77 [% CASE 'cardnumber' %]<th>Card</th>
78 [% CASE 'dateofbirth' %]<th>Date of birth</th>
79 [% CASE 'address' %]<th>Address</th>
80 [% CASE 'name' %]<th>Name</th>
81 [% CASE 'branch' %]<th>Library</th>
82 [% CASE 'category' %]<th>Category</th>
83 [% CASE 'dateexpiry' %]<th>Expires on</td>
84 [% CASE 'borrowernotes' %]<th>Notes</th>
85 [% CASE 'action' %]<th> </th>
94 <div id="closewindow"><a href="#" class="btn btn-default btn-default close">Close</a></div>
96 <!-- Patron preview modal -->
97 <div class="modal" id="patronPreview" tabindex="-1" role="dialog" aria-labelledby="patronPreviewLabel">
98 <div class="modal-dialog" role="document">
99 <div class="modal-content">
100 <div class="modal-header">
101 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
102 <h4 class="modal-title" id="patronPreviewLabel"></h4>
104 <div class="modal-body">
106 <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading
109 <div class="modal-footer">
110 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
119 [% MACRO jsinclude BLOCK %]
120 [% INCLUDE 'datatables.inc' %]
122 <script type="text/javascript">
124 $(document).ready(function(){
128 [% IF view != "show_results" %]
129 $("#searchresults").hide();
133 // Apply DataTables on the results table
134 dtMemberResults = $("#memberresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
136 'sAjaxSource': "/cgi-bin/koha/svc/members/search",
137 'fnServerData': function(sSource, aoData, fnCallback) {
142 'name': 'searchmember',
143 'value': $("#searchmember_filter").val()
145 'name': 'firstletter',
146 'value': $("#firstletter_filter").val()
148 'name': 'categorycode',
149 'value': $("#categorycode_filter").val()
151 'name': 'branchcode',
152 'value': $("#branchcode_filter").val()
154 'name': 'name_sorton',
155 'value': 'borrowers.surname borrowers.firstname'
157 'name': 'category_sorton',
158 'value': 'categories.description',
160 'name': 'branch_sorton',
161 'value': 'branches.branchname'
163 'name': 'template_path',
164 'value': '[% json_template | html %]',
166 'name': 'selection_type',
167 'value': '[% selection_type | html %]',
169 [% IF patrons_with_acq_perm_only %]
171 'name': 'has_permission',
172 'value': 'acquisition.order_manage',
174 [% ELSIF patrons_with_suggestion_perm_only %]
176 'name': 'has_permission',
177 'value': 'acquisition.suggestions_manage',
186 'success': function(json){
192 [% FOR column IN columns %]
193 [% IF column == 'action' %]
194 { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
195 [% ELSIF column == 'address' %]
196 { 'mDataProp': 'dt_address', 'bSortable': false }
198 { 'mDataProp': 'dt_[% column | html %]' }
200 [% UNLESS loop.last %],[% END %]
204 [% IF patrons_with_acq_perm_only %]
207 'sPaginationType': 'full_numbers',
208 "iDisplayLength": [% Koha.Preference('PatronsPerPage') | html %],
210 'aaSorting': [[[% aaSorting || 0 | html %], 'asc']],
215 $("#searchform").on('submit', filter);
216 $(".filterByLetter").on("click",function(e){
218 filterByFirstLetterSurname($(this).text());
220 $("body").on("click",".add_user",function(e){
222 var borrowernumber = $(this).data("borrowernumber");
223 var firstname = $(this).data("firstname");
224 var surname = $(this).data("surname");
225 add_user( borrowernumber, firstname + " " + surname );
228 $("body").on("click",".select_user",function(e){
230 var borrowernumber = $(this).data("borrowernumber");
231 var borrower_data = $("#borrower_data"+borrowernumber).val();
232 select_user( borrowernumber, JSON.parse(borrower_data) );
235 $("body").on("click",".patron_preview", function( e ){
237 var borrowernumber = $(this).data("borrowernumber");
238 var page = "/cgi-bin/koha/members/moremember.pl?print=brief&borrowernumber=" + borrowernumber;
239 $("#patronPreview .modal-body").load( page + " div.container-fluid" );
240 $('#patronPreview').modal({show:true});
243 $("#patronPreview").on('hidden.bs.modal', function (e) {
244 $("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading");
251 $("#firstletter_filter").val('');
252 $("#searchresults").show();
253 dtMemberResults.fnDraw();
257 // User has clicked on a letter
258 function filterByFirstLetterSurname(letter) {
259 $("#firstletter_filter").val(letter);
261 $("#searchresults").show();
262 dtMemberResults.fnDraw();
265 // modify parent window owner element
266 [% IF selection_type == 'add' %]
267 function add_user(borrowernumber, borrowername) {
268 var p = window.opener;
269 // In one place (serials/routing.tt), the page is reload on every add
270 // We have to wait for the page to be there
271 function wait_for_opener () {
272 if ( ! $(opener.document).find('body').size() ) {
273 setTimeout(wait_for_opener, 500);
275 [%# Note that add_user could sent data instead of borrowername too %]
278 if ( p.add_user(borrowernumber, borrowername) < 0 ) {
279 $("#error").html(_("Patron '%s' is already in the list.").format(borrowername));
282 $("#info").html(_("Patron '%s' added.").format(borrowername));
289 [% ELSIF selection_type == 'select' %]
290 function select_user(borrowernumber, data) {
291 var p = window.opener;
292 p.select_user(borrowernumber, data);
299 [% SET popup_window = 1 %]
300 [% INCLUDE 'intranet-bottom.inc' %]