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 $("#patron_list_dialog").hide();
41 $("#add_to_patron_list_submit").on('click', function(e){
42 if ( $('#add_to_patron_list').val() == 'new' ) {
43 if ( $('#new_patron_list').val() ) {
44 $("#add_to_patron_list option").each(function() {
45 if ( $(this).text() == $('#new_patron_list').val() ) {
46 alert( _("You already have a list with that name!") );
51 alert( _("You must give your new patron list a name!") );
56 if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
57 alert( _("You have not selected any patrons to add to a list!") );
61 var borrowernumbers = [];
62 $("#memberresultst").find("input:checkbox:checked").each(function(){
63 borrowernumbers.push($(this).val());
66 add_to_patron_list: $("#add_to_patron_list").val(),
67 new_patron_list: $("#new_patron_list").val(),
68 borrowernumbers: borrowernumbers
73 url: '/cgi-bin/koha/svc/members/add_to_list',
74 success: function(data) {
75 $("#patron_list_dialog").show();
76 $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
77 $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
78 $("#patron_list_dialog > a").html(data.patron_list.name);
79 if ( $('#add_to_patron_list').val() == 'new' ) {
80 var new_patron_list_added = $("<option>", {
81 value: data.patron_list.patron_list_id,
82 text: data.patron_list.name
84 $("#add_to_patron_list optgroup").append(new_patron_list_added);
85 $("#add_to_patron_list").val(data.patron_list.patron_list_id);
86 $("#new_patron_list").val('');
87 $('#add_to_patron_list').change();
91 alert("an error occurred");
96 $(".filterByLetter").on("click",function(e){
98 filterByFirstLetterSurname($(this).text());
100 $("#select_all").on("click",function(e){
102 $(".selection").prop("checked", true);
104 $("#clear_all").on("click",function(e){
106 $(".selection").prop("checked", false);
108 $("#clear_search").on("click",function(e){
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" %]
134 $("#searchresults").hide();
138 // Build the aLengthMenu
140 [%PatronsPerPage %], 10, 20, 50, 100, -1
142 jQuery.unique(aLengthMenu);
143 aLengthMenu.sort(function( a, b ){
144 // Put "All" at the end
147 } else if ( b == -1 ) {
150 return parseInt(a) < parseInt(b) ? -1 : 1;}
152 var aLengthMenuLabel = [];
153 $(aLengthMenu).each(function(){
155 // Label for -1 is "All"
156 aLengthMenuLabel.push("All");
158 aLengthMenuLabel.push(this);
162 // Apply DataTables on the results table
163 var columns_settings = [% ColumnsSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) %];
164 dtMemberResults = KohaTable("#memberresultst", {
166 'sAjaxSource': "/cgi-bin/koha/svc/members/search",
167 'fnServerData': function(sSource, aoData, fnCallback) {
172 'name': 'searchmember',
173 'value': $("#searchmember_filter").val()
175 'name': 'firstletter',
176 'value': $("#firstletter_filter").val()
178 'name': 'searchfieldstype',
179 'value': $("#searchfieldstype_filter").val()
181 'name': 'searchtype',
182 'value': $("#searchtype_filter").val()
184 'name': 'categorycode',
185 'value': $("#categorycode_filter").val()
187 'name': 'branchcode',
188 'value': $("#branchcode_filter").val()
190 'name': 'name_sorton',
191 'value': 'borrowers.surname borrowers.firstname'
193 'name': 'dateofbirth',
194 'value': 'borrowers.dateofbirth',
196 'name': 'category_sorton',
197 'value': 'categories.description',
199 'name': 'branch_sorton',
200 'value': 'branches.branchname'
202 'name': 'template_path',
203 'value': 'members/tables/members_results.tt',
210 'success': function(json){
211 // redirect if there is only 1 result.
212 if ( json.aaData.length == 1 ) {
213 var borrowernumber = json.aaData[0].borrowernumber;
214 document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
222 [% IF CAN_user_tools_manage_patron_lists %]
223 { 'mDataProp': 'dt_borrowernumber', 'bSortable': false },
225 { 'mDataProp': 'dt_cardnumber' },
226 { 'mDataProp': 'dt_name' },
227 { 'mDataProp': 'dt_dateofbirth' },
228 { 'mDataProp': 'dt_category' },
229 { 'mDataProp': 'dt_branch' },
230 { 'mDataProp': 'dt_dateexpiry' },
231 { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
232 { 'mDataProp': 'dt_fines', 'bSortable': false },
233 { 'mDataProp': 'dt_borrowernotes' },
234 { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
236 'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
237 /* Center text for 6th column */
238 $("td:eq(5)", nRow).css("text-align", "center");
244 [% IF CAN_user_tools_manage_patron_lists %]
245 'aaSorting': [[2, 'asc']],
247 'aaSorting': [[1, 'asc']],
249 "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
250 'sPaginationType': 'full_numbers',
251 "iDisplayLength": [% PatronsPerPage %],
253 }, columns_settings);
257 // Update the string "Results found ..."
258 function update_searched(){
259 var searched = $("#searchfieldstype_filter").find("option:selected").text();
260 if ( $("#searchmember_filter").val() ) {
261 if ( $("#searchtype_filter").val() == 'start_with' ) {
262 searched += _(" starting with ");
264 searched += _(" containing ");
266 searched += "'" + $("#searchmember_filter").val() + "'";
268 if ( $("#firstletter_filter").val() ) {
269 searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
271 if ( $("#categorycode_filter").val() ) {
272 searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
274 if ( $("#branchcode_filter").val() ) {
275 searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
277 $("#searchpattern").text(searched);
282 $("#firstletter_filter").val('');
285 $("#searchresults").show();
286 dtMemberResults.fnDraw();
290 // User has clicked on the Clear button
291 function clearFilters(redraw) {
292 $("#searchform select").val('');
293 $("#firstletter_filter").val('');
294 $("#searchmember_filter").val('');
297 $("#searchresults").show();
298 dtMemberResults.fnDraw();
302 // User has clicked on a letter
303 function filterByFirstLetterSurname(letter) {
305 $("#firstletter_filter").val(letter);
308 $("#searchresults").show();
309 dtMemberResults.fnDraw();
314 <body id="pat_member" class="pat">
315 [% INCLUDE 'header.inc' %]
316 [% INCLUDE 'patron-search.inc' %]
318 <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>
320 <div id="doc3" class="yui-t2">
325 [% IF CAN_user_tools_manage_patron_lists %]
326 <div id="patron_list_dialog" class="dialog alert">
327 Added <span class="patrons-length"></span> patrons to <a></a>.
331 [% IF Koha.Preference( 'NorwegianPatronDBEnable' ) == 1 %]
332 [% SET nl_search_form_title='Search the Norwegian national patron database' %]
333 [% INCLUDE 'nl-search-form.tt' %]
336 [% INCLUDE 'patron-toolbar.inc' %]
337 [% INCLUDE 'noadd-warnings.inc' %]
341 [% FOREACH letter IN alphabet.split(' ') %]
342 <a href="#" class="filterByLetter">[% letter %]</a>
346 [% IF ( CAN_user_borrowers && pending_borrower_modifications ) %]
347 <div class="pending-info" id="patron_updates_pending">
348 <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
349 <span class="holdcount"><a href="/cgi-bin/koha/members/members-update.pl">[% pending_borrower_modifications %]</a></span>
353 <div id="searchresults">
354 <div id="searchheader">
355 <h3>Patrons found for: <span id="searchpattern">[% IF searchmember %] for '[% searchmember %]'[% END %]</span></h3>
357 [% IF CAN_user_tools_manage_patron_lists %]
358 <div id="searchheader">
360 <a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a>
362 <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
365 <label for="add_to_patron_list">Add selected patrons to:</label>
366 <select id="add_to_patron_list" name="add_to_patron_list">
367 <option value=""></option>
368 [% IF patron_lists %]
369 <optgroup label="Patron lists:">
370 [% FOREACH pl IN patron_lists %]
371 <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
376 <option value="new">[ New list ]</option>
379 <input type="text" id="new_patron_list" name="new_patron_list" id="new_patron_list" />
381 <input id="add_to_patron_list_submit" type="submit" class="submit" value="Save">
387 <table id="memberresultst">
390 [% IF CAN_user_tools_manage_patron_lists %]
395 <th>Date of birth</th>
399 <th>OD/Checkouts</th>
412 <form onsubmit="return filter();" id="searchform">
413 <input type="hidden" id="firstletter_filter" value="" />
414 <fieldset class="brief">
418 <label for="searchmember_filter">Search:</label>
419 <input type="text" id="searchmember_filter" value="[% searchmember %]"/>
422 <label for="searchfieldstype_filter">Search fields:</label>
423 <select name="searchfieldstype" id="searchfieldstype_filter">
424 [% IF searchfieldstype == "standard" %]
425 <option selected="selected" value='standard'>Standard</option>
427 <option value='standard'>Standard</option>
429 [% IF searchfieldstype == "surname" %]
430 <option selected="selected" value='surname'>Surname</option>
432 <option value='surname'>Surname</option>
434 [% IF searchfieldstype == "email" %]
435 <option selected="selected" value='email'>Email</option>
437 <option value='email'>Email</option>
439 [% IF searchfieldstype == "borrowernumber" %]
440 <option selected="selected" value='borrowernumber'>Borrower number</option>
442 <option value='borrowernumber'>Borrower number</option>
444 [% IF searchfieldstype == "userid" %]
445 <option selected="selected" value='userid'>Username</option>
447 <option value='userid'>Username</option>
449 [% IF searchfieldstype == "phone" %]
450 <option selected="selected" value='phone'>Phone number</option>
452 <option value='phone'>Phone number</option>
454 [% IF searchfieldstype == "address" %]
455 <option selected="selected" value='address'>Street address</option>
457 <option value='address'>Street address</option>
459 [% IF searchfieldstype == "dateofbirth" %]
460 <option selected="selected" value='dateofbirth'>Date of birth</option>
462 <option value='dateofbirth'>Date of birth</option>
464 [% IF searchfieldstype == "sort1" %]
465 <option selected="selected" value='sort1'>Sort field 1</option>
467 <option value='sort1'>Sort field 1</option>
469 [% IF searchfieldstype == "sort2" %]
470 <option selected="selected" value='sort2'>Sort field 2</option>
472 <option value='sort2'>Sort field 2</option>
477 <label for="searchtype_filter">Search type:</label>
478 <select name="searchtype" id="searchtype_filter">
479 [% IF searchtype == "start_with" %]
480 <option value='start_with' selected="selected">Starts with</option>
481 <option value="contain">Contains</option>
483 <option value='start_with'>Starts with</option>
484 <option value="contain" selected="selected">Contains</option>
489 <label for="categorycode_filter">Category:</label>
490 [% SET categories = Categories.all() %]
491 <select id="categorycode_filter">
492 <option value="">Any</option>
493 [% FOREACH cat IN categories %]
494 [% IF cat.categorycode == categorycode_filter %]
495 <option selected="selected" value="[% cat.categorycode %]">[% cat.description %]</option>
497 <option value="[% cat.categorycode %]">[% cat.description %]</option>
503 <label for="branchcode_filter">Library:</label>
504 [% SET branches = Branches.all( selected => branchcode_filter ) %]
505 <select id="branchcode_filter">
506 [% IF branches.size != 1 %]
507 <option value="">Any</option>
509 [% PROCESS options_for_libraries libraries => branches %]
513 <fieldset class="action">
514 <input type="submit" value="Search" />
515 <input type="button" value="Clear" id="clear_search" />
522 [% INCLUDE 'members-menu.inc' %]
525 [% INCLUDE 'intranet-bottom.inc' %]