2 [% USE ColumnsSettings %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha › Patrons [% IF ( searching ) %]› Search results[% END %]</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
9 [% INCLUDE 'datatables.inc' %]
10 [% INCLUDE 'columns_settings.inc' %]
11 <script type="text/javascript">
13 $(document).ready(function() {
14 $('#add_to_patron_list_submit').prop('disabled', true);
15 $('#new_patron_list').hide();
17 $('#add_to_patron_list').change(function() {
18 var value = $('#add_to_patron_list').val();
19 if ( value == 'new' ) {
20 $('#new_patron_list').val('')
21 $('#new_patron_list').show();
22 $('#new_patron_list').focus();
24 $('#new_patron_list').hide();
25 $('#add_to_patron_list_submit').prop('disabled', false);
27 $('#new_patron_list').hide();
28 $('#add_to_patron_list_submit').prop('disabled', true);
32 $('#new_patron_list').on('input', function() {
33 if ( $('#new_patron_list').val() ) {
34 $('#add_to_patron_list_submit').prop('disabled', false);
36 $('#add_to_patron_list_submit').prop('disabled', true);
40 $("#add_to_patron_list_submit").on('click', function(e){
41 if ( $('#add_to_patron_list').val() == 'new' ) {
42 if ( $('#new_patron_list').val() ) {
43 $("#add_to_patron_list option").each(function() {
44 if ( $(this).text() == $('#new_patron_list').val() ) {
45 alert( _("You already have a list with that name!") );
50 alert( _("You must give your new patron list a name!") );
55 if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
56 alert( _("You have not selected any patrons to add to a list!") );
60 var borrowernumbers = [];
61 $("#memberresultst").find("input:checkbox:checked").each(function(){
62 borrowernumbers.push($(this).val());
65 add_to_patron_list: $("#add_to_patron_list").val(),
66 new_patron_list: $("#new_patron_list").val(),
67 borrowernumbers: borrowernumbers
72 url: '/cgi-bin/koha/svc/members/add_to_list',
73 success: function(data) {
74 $("#patron_list_dialog").show();
75 $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
76 $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
77 $("#patron_list_dialog > a").html(data.patron_list.name);
78 if ( $('#add_to_patron_list').val() == 'new' ) {
79 var new_patron_list_added = $("<option>", {
80 value: data.patron_list.patron_list_id,
81 text: data.patron_list.name
83 $("#add_to_patron_list optgroup").append(new_patron_list_added);
84 $("#add_to_patron_list").val(data.patron_list.patron_list_id);
85 $("#new_patron_list").val('');
86 $('#add_to_patron_list').change();
90 alert("an error occurred");
95 $(".filterByLetter").on("click",function(e){
97 filterByFirstLetterSurname($(this).text());
99 $("#select_all").on("click",function(e){
101 $(".selection").prop("checked", true);
103 $("#clear_all").on("click",function(e){
105 $(".selection").prop("checked", false);
107 $("#clear_search").on("click",function(e){
111 $("#searchform").on("submit", filter);
116 $(document).ready(function() {
117 [% IF searchmember %]
118 $("#searchmember_filter").val("[% searchmember %]");
120 [% IF searchfieldstype %]
121 $("searchfieldstype_filter").val("[% searchfieldstype %]");
124 $("#searchtype_filter").val("[% searchtype %]");
126 [% IF categorycode %]
127 $("#categorycode_filter").val("[% categorycode_filter %]");
130 $("#branchcode_filter").val("[% branchcode_filter %]");
133 [% IF view != "show_results" %]
136 $("#searchresults").show();
139 // Build the aLengthMenu
141 [%PatronsPerPage %], 10, 20, 50, 100, -1
143 jQuery.unique(aLengthMenu);
144 aLengthMenu.sort(function( a, b ){
145 // Put "All" at the end
148 } else if ( b == -1 ) {
151 return parseInt(a) < parseInt(b) ? -1 : 1;}
153 var aLengthMenuLabel = [];
154 $(aLengthMenu).each(function(){
156 // Label for -1 is "All"
157 aLengthMenuLabel.push("All");
159 aLengthMenuLabel.push(this);
163 // Apply DataTables on the results table
164 var columns_settings = [% ColumnsSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) %];
165 [% UNLESS CAN_user_tools_manage_patron_lists %]
166 [%# Remove the first column if we do not display the checkbox %]
167 columns_settings.splice(0, 1);
169 dtMemberResults = KohaTable("#memberresultst", {
171 'sAjaxSource': "/cgi-bin/koha/svc/members/search",
172 'fnServerData': function(sSource, aoData, fnCallback) {
177 'name': 'searchmember',
178 'value': $("#searchmember_filter").val()
180 'name': 'firstletter',
181 'value': $("#firstletter_filter").val()
183 'name': 'searchfieldstype',
184 'value': $("#searchfieldstype_filter").val()
186 'name': 'searchtype',
187 'value': $("#searchtype_filter").val()
189 'name': 'categorycode',
190 'value': $("#categorycode_filter").val()
192 'name': 'branchcode',
193 'value': $("#branchcode_filter").val()
195 'name': 'name_sorton',
196 'value': 'borrowers.surname borrowers.firstname'
198 'name': 'dateofbirth',
199 'value': 'borrowers.dateofbirth',
201 'name': 'category_sorton',
202 'value': 'categories.description',
204 'name': 'branch_sorton',
205 'value': 'branches.branchname'
207 'name': 'template_path',
208 'value': 'members/tables/members_results.tt',
215 'success': function(json){
216 // redirect if there is only 1 result.
217 if ( json.aaData.length == 1 ) {
218 var borrowernumber = json.aaData[0].borrowernumber;
219 document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
227 [% IF CAN_user_tools_manage_patron_lists %]
228 { 'mDataProp': 'dt_borrowernumber', 'bSortable': false },
230 { 'mDataProp': 'dt_cardnumber' },
231 { 'mDataProp': 'dt_name' },
232 { 'mDataProp': 'dt_dateofbirth' },
233 { 'mDataProp': 'dt_category' },
234 { 'mDataProp': 'dt_branch' },
235 { 'mDataProp': 'dt_dateexpiry' },
236 { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
237 { 'mDataProp': 'dt_fines', 'bSortable': false },
238 { 'mDataProp': 'dt_borrowernotes' },
239 { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
241 'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
242 /* Center text for 6th column */
243 $("td:eq(5)", nRow).css("text-align", "center");
249 [% IF CAN_user_tools_manage_patron_lists %]
250 'aaSorting': [[2, 'asc']],
252 'aaSorting': [[1, 'asc']],
254 "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
255 'sPaginationType': 'full_numbers',
256 "iDisplayLength": [% PatronsPerPage %],
258 }, columns_settings);
262 // Update the string "Results found ..."
263 function update_searched(){
264 var searched = $("#searchfieldstype_filter").find("option:selected").text();
265 if ( $("#searchmember_filter").val() ) {
266 if ( $("#searchtype_filter").val() == 'start_with' ) {
267 searched += _(" starting with ");
269 searched += _(" containing ");
271 searched += "'" + $("#searchmember_filter").val() + "'";
273 if ( $("#firstletter_filter").val() ) {
274 searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
276 if ( $("#categorycode_filter").val() ) {
277 searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
279 if ( $("#branchcode_filter").val() ) {
280 searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
282 $("#searchpattern").text(searched);
287 $("#firstletter_filter").val('');
290 $("#searchresults").show();
291 dtMemberResults.fnDraw();
295 // User has clicked on the Clear button
296 function clearFilters(redraw) {
297 $("#searchform select").val('');
298 $("#firstletter_filter").val('');
299 $("#searchmember_filter").val('');
302 $("#searchresults").show();
303 dtMemberResults.fnDraw();
307 // User has clicked on a letter
308 function filterByFirstLetterSurname(letter) {
310 $("#firstletter_filter").val(letter);
313 $("#searchresults").show();
314 dtMemberResults.fnDraw();
319 <body id="pat_member" class="pat">
320 [% INCLUDE 'header.inc' %]
321 [% INCLUDE 'patron-search.inc' %]
323 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › [% IF ( searching ) %]<a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › Search results[% ELSE %]Patrons[% END %]</div>
325 <div id="doc3" class="yui-t2">
330 [% IF CAN_user_tools_manage_patron_lists %]
331 <div id="patron_list_dialog" class="dialog alert">
332 Added <span class="patrons-length"></span> patrons to <a></a>.
336 [% IF Koha.Preference( 'NorwegianPatronDBEnable' ) == 1 %]
337 [% SET nl_search_form_title='Search the Norwegian national patron database' %]
338 [% INCLUDE 'nl-search-form.tt' %]
341 [% INCLUDE 'patron-toolbar.inc' %]
342 [% INCLUDE 'noadd-warnings.inc' %]
346 [% FOREACH letter IN alphabet.split(' ') %]
347 <a href="#" class="filterByLetter">[% letter %]</a>
351 [% IF ( CAN_user_borrowers && pending_borrower_modifications ) %]
352 <div class="pending-info" id="patron_updates_pending">
353 <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
354 <span class="number_box"><a href="/cgi-bin/koha/members/members-update.pl">[% pending_borrower_modifications %]</a></span>
358 <div id="searchresults">
359 <div id="searchheader">
360 <h3>Patrons found for: <span id="searchpattern">[% IF searchmember %] for '[% searchmember %]'[% END %]</span></h3>
362 [% IF CAN_user_tools_manage_patron_lists %]
363 <div id="searchheader">
365 <a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a>
367 <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
370 <label for="add_to_patron_list">Add selected patrons to:</label>
371 <select id="add_to_patron_list" name="add_to_patron_list">
372 <option value=""></option>
373 [% IF patron_lists %]
374 <optgroup label="Patron lists:">
375 [% FOREACH pl IN patron_lists %]
376 <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
381 <option value="new">[ New list ]</option>
384 <input type="text" id="new_patron_list" name="new_patron_list" id="new_patron_list" />
386 <input id="add_to_patron_list_submit" type="submit" class="submit" value="Save">
392 <table id="memberresultst">
395 [% IF CAN_user_tools_manage_patron_lists %]
400 <th>Date of birth</th>
404 <th>OD/Checkouts</th>
417 <form method="get" id="searchform">
418 <input type="hidden" id="firstletter_filter" value="" />
419 <fieldset class="brief">
423 <label for="searchmember_filter">Search:</label>
424 <input type="text" id="searchmember_filter" value="[% searchmember %]"/>
427 <label for="searchfieldstype_filter">Search fields:</label>
428 <select name="searchfieldstype" id="searchfieldstype_filter">
429 [% IF searchfieldstype == "standard" %]
430 <option selected="selected" value='standard'>Standard</option>
432 <option value='standard'>Standard</option>
434 [% IF searchfieldstype == "surname" %]
435 <option selected="selected" value='surname'>Surname</option>
437 <option value='surname'>Surname</option>
439 [% IF searchfieldstype == "email" %]
440 <option selected="selected" value='email'>Email</option>
442 <option value='email'>Email</option>
444 [% IF searchfieldstype == "borrowernumber" %]
445 <option selected="selected" value='borrowernumber'>Borrower number</option>
447 <option value='borrowernumber'>Borrower number</option>
449 [% IF searchfieldstype == "userid" %]
450 <option selected="selected" value='userid'>Username</option>
452 <option value='userid'>Username</option>
454 [% IF searchfieldstype == "phone" %]
455 <option selected="selected" value='phone'>Phone number</option>
457 <option value='phone'>Phone number</option>
459 [% IF searchfieldstype == "address" %]
460 <option selected="selected" value='address'>Street address</option>
462 <option value='address'>Street address</option>
464 [% IF searchfieldstype == "dateofbirth" %]
465 <option selected="selected" value='dateofbirth'>Date of birth</option>
467 <option value='dateofbirth'>Date of birth</option>
469 [% IF searchfieldstype == "sort1" %]
470 <option selected="selected" value='sort1'>Sort field 1</option>
472 <option value='sort1'>Sort field 1</option>
474 [% IF searchfieldstype == "sort2" %]
475 <option selected="selected" value='sort2'>Sort field 2</option>
477 <option value='sort2'>Sort field 2</option>
482 <label for="searchtype_filter">Search type:</label>
483 <select name="searchtype" id="searchtype_filter">
484 [% IF searchtype == "start_with" %]
485 <option value='start_with' selected="selected">Starts with</option>
486 <option value="contain">Contains</option>
488 <option value='start_with'>Starts with</option>
489 <option value="contain" selected="selected">Contains</option>
494 <label for="categorycode_filter">Category:</label>
495 [% SET categories = Categories.all() %]
496 <select id="categorycode_filter">
497 <option value="">Any</option>
498 [% FOREACH cat IN categories %]
499 [% IF cat.categorycode == categorycode_filter %]
500 <option selected="selected" value="[% cat.categorycode %]">[% cat.description %]</option>
502 <option value="[% cat.categorycode %]">[% cat.description %]</option>
508 <label for="branchcode_filter">Library:</label>
509 [% SET branches = Branches.all( selected => branchcode_filter ) %]
510 <select id="branchcode_filter">
511 [% IF branches.size != 1 %]
512 <option value="">Any</option>
514 [% PROCESS options_for_libraries libraries => branches %]
518 <fieldset class="action">
519 <input type="submit" value="Search" />
520 <input type="button" value="Clear" id="clear_search" />
527 [% INCLUDE 'members-menu.inc' %]
530 [% INCLUDE 'intranet-bottom.inc' %]