3 [% USE ColumnsSettings %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha › Patrons [% IF ( searching ) %]› Search results[% END %]</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% Asset.css("css/datatables.css") %]
13 <body id="pat_member" class="pat">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'patron-search.inc' %]
17 <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>
19 <div id="doc3" class="yui-t2">
24 [% IF CAN_user_tools_manage_patron_lists %]
25 <div id="patron_list_dialog" class="dialog alert">
26 Added <span class="patrons-length"></span> patrons to <a></a>.
30 [% IF Koha.Preference( 'NorwegianPatronDBEnable' ) == 1 %]
31 [% SET nl_search_form_title='Search the Norwegian national patron database' %]
32 [% INCLUDE 'nl-search-form.tt' %]
35 [% INCLUDE 'patron-toolbar.inc' %]
36 [% INCLUDE 'noadd-warnings.inc' %]
40 [% FOREACH letter IN alphabet.split(' ') %]
41 <a href="#" class="filterByLetter">[% letter %]</a>
45 [% IF CAN_user_borrowers_edit_borrowers && pending_borrower_modifications %]
46 <div class="pending-info" id="patron_updates_pending">
47 <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
48 <span class="number_box"><a href="/cgi-bin/koha/members/members-update.pl">[% pending_borrower_modifications %]</a></span>
52 <div id="searchresults">
53 <div id="searchheader">
54 <h3>Patrons found for: <span id="searchpattern">[% IF searchmember %] for '[% searchmember | html %]'[% END %]</span></h3>
56 [% IF CAN_user_tools_manage_patron_lists || CAN_user_borrowers_edit_borrowers %]
57 <div id="searchheader">
59 [% IF CAN_user_tools_manage_patron_lists %]
60 <a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a>
62 <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
65 <label for="add_to_patron_list">Add selected patrons to:</label>
66 <select id="add_to_patron_list" name="add_to_patron_list">
67 <option value=""></option>
69 <optgroup label="Patron lists:">
70 [% FOREACH pl IN patron_lists %]
71 <option value="[% pl.patron_list_id %]">[% pl.name |html %]</option>
76 <option value="new">[ New list ]</option>
79 <input type="text" id="new_patron_list" name="new_patron_list" id="new_patron_list" />
81 <input id="add_to_patron_list_submit" type="submit" class="submit" value="Save">
85 [% IF CAN_user_tools_manage_patron_lists && CAN_user_borrowers_edit_borrowers %]
89 [% IF CAN_user_borrowers_edit_borrowers %]
90 <button id="merge-patrons" type="submit">Merge selected patrons</button>
96 <table id="memberresultst">
99 [% IF CAN_user_tools_manage_patron_lists %]
104 <th>Date of birth</th>
108 <th>OD/Checkouts</th>
121 <form method="get" id="searchform">
122 <input type="hidden" id="firstletter_filter" value="" />
123 <fieldset class="brief">
127 <label for="searchmember_filter">Search:</label>
128 <input type="text" id="searchmember_filter" value="[% searchmember %]"/>
131 <label for="searchfieldstype_filter">Search fields:</label>
132 <select name="searchfieldstype" id="searchfieldstype_filter">
133 [% IF searchfieldstype == "standard" %]
134 <option selected="selected" value='standard'>Standard</option>
136 <option value='standard'>Standard</option>
138 [% IF searchfieldstype == "surname" %]
139 <option selected="selected" value='surname'>Surname</option>
141 <option value='surname'>Surname</option>
143 [% IF searchfieldstype == "email" %]
144 <option selected="selected" value='email'>Email</option>
146 <option value='email'>Email</option>
148 [% IF searchfieldstype == "borrowernumber" %]
149 <option selected="selected" value='borrowernumber'>Borrower number</option>
151 <option value='borrowernumber'>Borrower number</option>
153 [% IF searchfieldstype == "userid" %]
154 <option selected="selected" value='userid'>Username</option>
156 <option value='userid'>Username</option>
158 [% IF searchfieldstype == "phone" %]
159 <option selected="selected" value='phone'>Phone number</option>
161 <option value='phone'>Phone number</option>
163 [% IF searchfieldstype == "address" %]
164 <option selected="selected" value='address'>Street address</option>
166 <option value='address'>Street address</option>
168 [% IF searchfieldstype == "dateofbirth" %]
169 <option selected="selected" value='dateofbirth'>Date of birth</option>
171 <option value='dateofbirth'>Date of birth</option>
173 [% IF searchfieldstype == "sort1" %]
174 <option selected="selected" value='sort1'>Sort field 1</option>
176 <option value='sort1'>Sort field 1</option>
178 [% IF searchfieldstype == "sort2" %]
179 <option selected="selected" value='sort2'>Sort field 2</option>
181 <option value='sort2'>Sort field 2</option>
186 <label for="searchtype_filter">Search type:</label>
187 <select name="searchtype" id="searchtype_filter">
188 [% IF searchtype == "start_with" %]
189 <option value='start_with' selected="selected">Starts with</option>
190 <option value="contain">Contains</option>
192 <option value='start_with'>Starts with</option>
193 <option value="contain" selected="selected">Contains</option>
198 <label for="categorycode_filter">Category:</label>
199 [% SET categories = Categories.all() %]
200 <select id="categorycode_filter">
201 <option value="">Any</option>
202 [% FOREACH cat IN categories %]
203 [% IF cat.categorycode == categorycode_filter %]
204 <option selected="selected" value="[% cat.categorycode %]">[% cat.description |html %]</option>
206 <option value="[% cat.categorycode %]">[% cat.description |html %]</option>
212 <label for="branchcode_filter">Library:</label>
213 [% SET branches = Branches.all( selected => branchcode_filter, only_from_group => 1 ) %]
214 <select id="branchcode_filter">
215 [% IF branches.size != 1 %]
216 <option value="">Any</option>
218 [% PROCESS options_for_libraries libraries => branches %]
222 <fieldset class="action">
223 <input type="submit" value="Search" />
224 <input type="button" value="Clear" id="clear_search" />
231 [% INCLUDE 'members-menu.inc' %]
235 [% MACRO jsinclude BLOCK %]
236 [% INCLUDE 'datatables.inc' %]
237 [% INCLUDE 'columns_settings.inc' %]
238 [% Asset.js("js/members-menu.js") %]
239 <script type="text/javascript">
240 $(document).ready(function() {
241 $('#merge-patrons').prop('disabled', true);
242 $('#memberresultst').on('change', 'input.selection', function() {
243 if ( $('.selection:checked').length > 1 ) {
244 $('#merge-patrons').prop('disabled', false);
246 $('#merge-patrons').prop('disabled', true);
249 $('#merge-patrons').on('click', function() {
250 var merge_patrons_url = 'merge-patrons.pl?' + $('.selection:checked')
252 return "id=" + $(this).val()
255 window.location.href = merge_patrons_url;
258 $('#add_to_patron_list_submit').prop('disabled', true);
259 $('#new_patron_list').hide();
261 $('#add_to_patron_list').change(function() {
262 var value = $('#add_to_patron_list').val();
263 if ( value == 'new' ) {
264 $('#new_patron_list').val('')
265 $('#new_patron_list').show();
266 $('#new_patron_list').focus();
267 } else if ( value ) {
268 $('#new_patron_list').hide();
269 $('#add_to_patron_list_submit').prop('disabled', false);
271 $('#new_patron_list').hide();
272 $('#add_to_patron_list_submit').prop('disabled', true);
276 $('#new_patron_list').on('input', function() {
277 if ( $('#new_patron_list').val() ) {
278 $('#add_to_patron_list_submit').prop('disabled', false);
280 $('#add_to_patron_list_submit').prop('disabled', true);
284 $("#add_to_patron_list_submit").on('click', function(e){
285 if ( $('#add_to_patron_list').val() == 'new' ) {
286 if ( $('#new_patron_list').val() ) {
287 $("#add_to_patron_list option").each(function() {
288 if ( $(this).text() == $('#new_patron_list').val() ) {
289 alert( _("You already have a list with that name!") );
294 alert( _("You must give your new patron list a name!") );
299 if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
300 alert( _("You have not selected any patrons to add to a list!") );
304 var borrowernumbers = [];
305 $("#memberresultst").find("input:checkbox:checked").each(function(){
306 borrowernumbers.push($(this).val());
309 add_to_patron_list: $("#add_to_patron_list").val(),
310 new_patron_list: $("#new_patron_list").val(),
311 borrowernumbers: borrowernumbers
316 url: '/cgi-bin/koha/svc/members/add_to_list',
317 success: function(data) {
318 $("#patron_list_dialog").show();
319 $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
320 $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
321 $("#patron_list_dialog > a").html(data.patron_list.name);
322 if ( $('#add_to_patron_list').val() == 'new' ) {
323 var new_patron_list_added = $("<option>", {
324 value: data.patron_list.patron_list_id,
325 text: data.patron_list.name
327 $("#add_to_patron_list optgroup").append(new_patron_list_added);
328 $("#add_to_patron_list").val(data.patron_list.patron_list_id);
329 $("#new_patron_list").val('');
330 $('#add_to_patron_list').change();
334 alert("an error occurred");
339 $(".filterByLetter").on("click",function(e){
341 filterByFirstLetterSurname($(this).text());
343 $("#select_all").on("click",function(e){
345 $(".selection").prop("checked", true).change();
347 $("#clear_all").on("click",function(e){
349 $(".selection").prop("checked", false).change();
351 $("#clear_search").on("click",function(e){
355 $("#searchform").on("submit", filter);
360 $(document).ready(function() {
361 [% IF searchmember %]
362 $("#searchmember_filter").val("[% searchmember | html %]");
364 [% IF searchfieldstype %]
365 $("searchfieldstype_filter").val("[% searchfieldstype %]");
368 $("#searchtype_filter").val("[% searchtype %]");
370 [% IF categorycode %]
371 $("#categorycode_filter").val("[% categorycode_filter %]");
374 $("#branchcode_filter").val("[% branchcode_filter %]");
377 [% IF view != "show_results" %]
380 $("#searchresults").show();
383 // Build the aLengthMenu
385 [%PatronsPerPage %], 10, 20, 50, 100, -1
387 jQuery.unique(aLengthMenu);
388 aLengthMenu.sort(function( a, b ){
389 // Put "All" at the end
392 } else if ( b == -1 ) {
395 return parseInt(a) < parseInt(b) ? -1 : 1;}
397 var aLengthMenuLabel = [];
398 $(aLengthMenu).each(function(){
400 // Label for -1 is "All"
401 aLengthMenuLabel.push(_("All"));
403 aLengthMenuLabel.push(this);
407 // Apply DataTables on the results table
408 var columns_settings = [% ColumnsSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) %];
409 [% UNLESS CAN_user_tools_manage_patron_lists %]
410 [%# Remove the first column if we do not display the checkbox %]
411 columns_settings.splice(0, 1);
413 dtMemberResults = KohaTable("memberresultst", {
415 'sAjaxSource': "/cgi-bin/koha/svc/members/search",
416 'fnServerData': function(sSource, aoData, fnCallback) {
421 'name': 'searchmember',
422 'value': $("#searchmember_filter").val()
424 'name': 'firstletter',
425 'value': $("#firstletter_filter").val()
427 'name': 'searchfieldstype',
428 'value': $("#searchfieldstype_filter").val()
430 'name': 'searchtype',
431 'value': $("#searchtype_filter").val()
433 'name': 'categorycode',
434 'value': $("#categorycode_filter").val()
436 'name': 'branchcode',
437 'value': $("#branchcode_filter").val()
439 'name': 'name_sorton',
440 'value': 'borrowers.surname borrowers.firstname'
442 'name': 'dateofbirth',
443 'value': 'borrowers.dateofbirth',
445 'name': 'category_sorton',
446 'value': 'categories.description',
448 'name': 'branch_sorton',
449 'value': 'branches.branchname'
451 'name': 'template_path',
452 'value': 'members/tables/members_results.tt',
459 'success': function(json){
460 // redirect if there is only 1 result.
461 if ( json.aaData.length == 1 ) {
462 var borrowernumber = json.aaData[0].borrowernumber;
463 document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
471 [% IF CAN_user_tools_manage_patron_lists %]
472 { 'mDataProp': 'dt_borrowernumber', 'bSortable': false },
474 { 'mDataProp': 'dt_cardnumber' },
475 { 'mDataProp': 'dt_name' },
476 { 'mDataProp': 'dt_dateofbirth' },
477 { 'mDataProp': 'dt_category' },
478 { 'mDataProp': 'dt_branch' },
479 { 'mDataProp': 'dt_dateexpiry' },
480 { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
481 { 'mDataProp': 'dt_fines', 'bSortable': false },
482 { 'mDataProp': 'dt_borrowernotes' },
483 { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
485 'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
486 /* Center text for 6th column */
487 $("td:eq(5)", nRow).css("text-align", "center");
493 [% IF CAN_user_tools_manage_patron_lists %]
494 'aaSorting': [[2, 'asc']],
496 'aaSorting': [[1, 'asc']],
498 "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
499 'sPaginationType': 'full_numbers',
500 "iDisplayLength": [% PatronsPerPage %],
502 }, columns_settings);
506 // Update the string "Results found ..."
507 function update_searched(){
508 var searched = $("#searchfieldstype_filter").find("option:selected").text();
509 if ( $("#searchmember_filter").val() ) {
510 if ( $("#searchtype_filter").val() == 'start_with' ) {
511 searched += _(" starting with ");
513 searched += _(" containing ");
515 searched += "'" + $("#searchmember_filter").val() + "'";
517 if ( $("#firstletter_filter").val() ) {
518 searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
520 if ( $("#categorycode_filter").val() ) {
521 searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
523 if ( $("#branchcode_filter").val() ) {
524 searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
526 $("#searchpattern").text(searched);
531 $("#firstletter_filter").val('');
534 $("#searchresults").show();
535 dtMemberResults.fnDraw();
539 // User has clicked on the Clear button
540 function clearFilters(redraw) {
541 $("#searchform select").val('');
542 $("#firstletter_filter").val('');
543 $("#searchmember_filter").val('');
546 $("#searchresults").show();
547 dtMemberResults.fnDraw();
551 // User has clicked on a letter
552 function filterByFirstLetterSurname(letter) {
554 $("#firstletter_filter").val(letter);
557 $("#searchresults").show();
558 dtMemberResults.fnDraw();
563 [% INCLUDE 'intranet-bottom.inc' %]