4 [% USE ColumnsSettings %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Koha › Patrons [% IF ( searching ) %]› Search results[% END %]</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 [% Asset.css("css/datatables.css") | $raw %]
14 <body id="pat_member" class="pat">
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'patron-search.inc' %]
18 <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>
20 <div id="doc3" class="yui-t2">
25 [% IF CAN_user_tools_manage_patron_lists %]
26 <div id="patron_list_dialog" class="dialog alert">
27 Added <span class="patrons-length"></span> patrons to <a></a>.
31 [% IF Koha.Preference( 'NorwegianPatronDBEnable' ) == 1 %]
32 [% SET nl_search_form_title='Search the Norwegian national patron database' %]
33 [% INCLUDE 'nl-search-form.tt' %]
36 [% INCLUDE 'patron-toolbar.inc' %]
37 [% INCLUDE 'noadd-warnings.inc' %]
41 [% FOREACH letter IN alphabet.split(' ') %]
42 <a href="#" class="filterByLetter">[% letter | html %]</a>
46 [% IF CAN_user_borrowers_edit_borrowers && pending_borrower_modifications %]
47 <div class="pending-info" id="patron_updates_pending">
48 <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
49 <span class="number_box"><a href="/cgi-bin/koha/members/members-update.pl">[% pending_borrower_modifications | html %]</a></span>
53 <div id="searchresults">
54 <div id="searchheader">
55 <h3>Patrons found for: <span id="searchpattern">[% IF searchmember %] for '[% searchmember | html %]'[% END %]</span></h3>
57 [% IF CAN_user_tools_manage_patron_lists || CAN_user_borrowers_edit_borrowers %]
58 <div id="searchheader">
60 [% IF CAN_user_tools_manage_patron_lists %]
61 <a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a>
63 <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
66 <label for="add_to_patron_list">Add selected patrons to:</label>
67 <select id="add_to_patron_list" name="add_to_patron_list">
68 <option value=""></option>
70 <optgroup label="Patron lists:">
71 [% FOREACH pl IN patron_lists %]
72 <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
77 <option value="new">[ New list ]</option>
80 <input type="text" id="new_patron_list" name="new_patron_list" id="new_patron_list" />
82 <input id="add_to_patron_list_submit" type="submit" class="submit" value="Save">
86 [% IF CAN_user_tools_manage_patron_lists && CAN_user_borrowers_edit_borrowers %]
90 [% IF CAN_user_borrowers_edit_borrowers %]
91 <button id="merge-patrons" type="submit">Merge selected patrons</button>
97 <table id="memberresultst">
100 [% IF CAN_user_tools_manage_patron_lists %]
105 <th>Date of birth</th>
109 <th>OD/Checkouts</th>
122 <form method="get" id="searchform">
123 <input type="hidden" id="firstletter_filter" value="" />
124 <fieldset class="brief">
128 <label for="searchmember_filter">Search:</label>
129 <input type="text" id="searchmember_filter" value="[% searchmember | html %]"/>
132 <label for="searchfieldstype_filter">Search fields:</label>
133 <select name="searchfieldstype" id="searchfieldstype_filter">
134 [% IF searchfieldstype == "standard" %]
135 <option selected="selected" value='standard'>Standard</option>
137 <option value='standard'>Standard</option>
139 [% IF searchfieldstype == "surname" %]
140 <option selected="selected" value='surname'>Surname</option>
142 <option value='surname'>Surname</option>
144 [% IF searchfieldstype == "email" %]
145 <option selected="selected" value='email'>Email</option>
147 <option value='email'>Email</option>
149 [% IF searchfieldstype == "borrowernumber" %]
150 <option selected="selected" value='borrowernumber'>Borrower number</option>
152 <option value='borrowernumber'>Borrower number</option>
154 [% IF searchfieldstype == "userid" %]
155 <option selected="selected" value='userid'>Username</option>
157 <option value='userid'>Username</option>
159 [% IF searchfieldstype == "phone" %]
160 <option selected="selected" value='phone'>Phone number</option>
162 <option value='phone'>Phone number</option>
164 [% IF searchfieldstype == "address" %]
165 <option selected="selected" value='address'>Street address</option>
167 <option value='address'>Street address</option>
169 [% IF searchfieldstype == "dateofbirth" %]
170 <option selected="selected" value='dateofbirth'>Date of birth</option>
172 <option value='dateofbirth'>Date of birth</option>
174 [% IF searchfieldstype == "sort1" %]
175 <option selected="selected" value='sort1'>Sort field 1</option>
177 <option value='sort1'>Sort field 1</option>
179 [% IF searchfieldstype == "sort2" %]
180 <option selected="selected" value='sort2'>Sort field 2</option>
182 <option value='sort2'>Sort field 2</option>
187 <label for="searchtype_filter">Search type:</label>
188 <select name="searchtype" id="searchtype_filter">
189 [% IF searchtype == "start_with" %]
190 <option value='start_with' selected="selected">Starts with</option>
191 <option value="contain">Contains</option>
193 <option value='start_with'>Starts with</option>
194 <option value="contain" selected="selected">Contains</option>
199 <label for="categorycode_filter">Category:</label>
200 [% SET categories = Categories.all() %]
201 <select id="categorycode_filter">
202 <option value="">Any</option>
203 [% FOREACH cat IN categories %]
204 [% IF cat.categorycode == categorycode_filter %]
205 <option selected="selected" value="[% cat.categorycode | html %]">[% cat.description | html %]</option>
207 <option value="[% cat.categorycode | html %]">[% cat.description | html %]</option>
213 <label for="branchcode_filter">Library:</label>
214 [% SET branches = Branches.all( selected => branchcode_filter, only_from_group => 1 ) %]
215 <select id="branchcode_filter">
216 [% IF branches.size != 1 %]
217 <option value="">Any</option>
219 [% PROCESS options_for_libraries libraries => branches %]
223 <fieldset class="action">
224 <input type="submit" value="Search" />
225 <input type="button" value="Clear" id="clear_search" />
232 [% INCLUDE 'members-menu.inc' %]
236 [% MACRO jsinclude BLOCK %]
237 [% INCLUDE 'datatables.inc' %]
238 [% INCLUDE 'columns_settings.inc' %]
239 [% INCLUDE 'str/members-menu.inc' %]
240 [% Asset.js("js/members-menu.js") | $raw %]
241 <script type="text/javascript">
242 $(document).ready(function() {
243 $('#merge-patrons').prop('disabled', true);
244 $('#memberresultst').on('change', 'input.selection', function() {
245 if ( $('.selection:checked').length > 1 ) {
246 $('#merge-patrons').prop('disabled', false);
248 $('#merge-patrons').prop('disabled', true);
251 $('#merge-patrons').on('click', function() {
252 var merge_patrons_url = 'merge-patrons.pl?' + $('.selection:checked')
254 return "id=" + $(this).val()
257 window.location.href = merge_patrons_url;
260 $('#add_to_patron_list_submit').prop('disabled', true);
261 $('#new_patron_list').hide();
263 $('#add_to_patron_list').change(function() {
264 var value = $('#add_to_patron_list').val();
265 if ( value == 'new' ) {
266 $('#new_patron_list').val('')
267 $('#new_patron_list').show();
268 $('#new_patron_list').focus();
269 } else if ( value ) {
270 $('#new_patron_list').hide();
271 $('#add_to_patron_list_submit').prop('disabled', false);
273 $('#new_patron_list').hide();
274 $('#add_to_patron_list_submit').prop('disabled', true);
278 $('#new_patron_list').on('input', function() {
279 if ( $('#new_patron_list').val() ) {
280 $('#add_to_patron_list_submit').prop('disabled', false);
282 $('#add_to_patron_list_submit').prop('disabled', true);
286 $("#add_to_patron_list_submit").on('click', function(e){
287 if ( $('#add_to_patron_list').val() == 'new' ) {
288 if ( $('#new_patron_list').val() ) {
289 $("#add_to_patron_list option").each(function() {
290 if ( $(this).text() == $('#new_patron_list').val() ) {
291 alert( _("You already have a list with that name!") );
296 alert( _("You must give your new patron list a name!") );
301 if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
302 alert( _("You have not selected any patrons to add to a list!") );
306 var borrowernumbers = [];
307 $("#memberresultst").find("input:checkbox:checked").each(function(){
308 borrowernumbers.push($(this).val());
311 add_to_patron_list: $("#add_to_patron_list").val(),
312 new_patron_list: $("#new_patron_list").val(),
313 borrowernumbers: borrowernumbers
318 url: '/cgi-bin/koha/svc/members/add_to_list',
319 success: function(data) {
320 $("#patron_list_dialog").show();
321 $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
322 $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
323 $("#patron_list_dialog > a").html(data.patron_list.name);
324 if ( $('#add_to_patron_list').val() == 'new' ) {
325 var new_patron_list_added = $("<option>", {
326 value: data.patron_list.patron_list_id,
327 text: data.patron_list.name
329 $("#add_to_patron_list optgroup").append(new_patron_list_added);
330 $("#add_to_patron_list").val(data.patron_list.patron_list_id);
331 $("#new_patron_list").val('');
332 $('#add_to_patron_list').change();
336 alert("an error occurred");
341 $(".filterByLetter").on("click",function(e){
343 filterByFirstLetterSurname($(this).text());
345 $("#select_all").on("click",function(e){
347 $(".selection").prop("checked", true).change();
349 $("#clear_all").on("click",function(e){
351 $(".selection").prop("checked", false).change();
353 $("#clear_search").on("click",function(e){
357 $("#searchform").on("submit", filter);
362 $(document).ready(function() {
363 [% IF searchmember %]
364 $("#searchmember_filter").val("[% searchmember | html %]");
366 [% IF searchfieldstype %]
367 $("searchfieldstype_filter").val("[% searchfieldstype | html %]");
370 $("#searchtype_filter").val("[% searchtype | html %]");
372 [% IF categorycode %]
373 $("#categorycode_filter").val("[% categorycode_filter | html %]");
376 $("#branchcode_filter").val("[% branchcode_filter | html %]");
379 [% IF view != "show_results" %]
382 $("#searchresults").show();
385 // Build the aLengthMenu
387 [% PatronsPerPage | html %], 10, 20, 50, 100, -1
389 jQuery.unique(aLengthMenu);
390 aLengthMenu.sort(function( a, b ){
391 // Put "All" at the end
394 } else if ( b == -1 ) {
397 return parseInt(a) < parseInt(b) ? -1 : 1;}
399 var aLengthMenuLabel = [];
400 $(aLengthMenu).each(function(){
402 // Label for -1 is "All"
403 aLengthMenuLabel.push(_("All"));
405 aLengthMenuLabel.push(this);
409 // Apply DataTables on the results table
410 var columns_settings = [% ColumnsSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) | $raw %];
411 [% UNLESS CAN_user_tools_manage_patron_lists %]
412 [%# Remove the first column if we do not display the checkbox %]
413 columns_settings.splice(0, 1);
415 dtMemberResults = KohaTable("memberresultst", {
417 'sAjaxSource': "/cgi-bin/koha/svc/members/search",
418 'fnServerData': function(sSource, aoData, fnCallback) {
423 'name': 'searchmember',
424 'value': $("#searchmember_filter").val()
426 'name': 'firstletter',
427 'value': $("#firstletter_filter").val()
429 'name': 'searchfieldstype',
430 'value': $("#searchfieldstype_filter").val()
432 'name': 'searchtype',
433 'value': $("#searchtype_filter").val()
435 'name': 'categorycode',
436 'value': $("#categorycode_filter").val()
438 'name': 'branchcode',
439 'value': $("#branchcode_filter").val()
441 'name': 'name_sorton',
442 'value': 'borrowers.surname borrowers.firstname'
444 'name': 'dateofbirth',
445 'value': 'borrowers.dateofbirth',
447 'name': 'category_sorton',
448 'value': 'categories.description',
450 'name': 'branch_sorton',
451 'value': 'branches.branchname'
453 'name': 'template_path',
454 'value': 'members/tables/members_results.tt',
461 'success': function(json){
462 // redirect if there is only 1 result.
463 if ( json.aaData.length == 1 ) {
464 var borrowernumber = json.aaData[0].borrowernumber;
465 document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
473 [% IF CAN_user_tools_manage_patron_lists %]
474 { 'mDataProp': 'dt_borrowernumber', 'bSortable': false },
476 { 'mDataProp': 'dt_cardnumber' },
477 { 'mDataProp': 'dt_name' },
478 { 'mDataProp': 'dt_dateofbirth' },
479 { 'mDataProp': 'dt_category' },
480 { 'mDataProp': 'dt_branch' },
481 { 'mDataProp': 'dt_dateexpiry' },
482 { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
483 { 'mDataProp': 'dt_fines', 'bSortable': false },
484 { 'mDataProp': 'dt_borrowernotes' },
485 { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
487 'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
488 /* Center text for 6th column */
489 $("td:eq(5)", nRow).css("text-align", "center");
495 [% IF CAN_user_tools_manage_patron_lists %]
496 'aaSorting': [[2, 'asc']],
498 'aaSorting': [[1, 'asc']],
500 "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
501 'sPaginationType': 'full_numbers',
502 "iDisplayLength": [% PatronsPerPage | html %],
504 }, columns_settings);
508 // Update the string "Results found ..."
509 function update_searched(){
510 var searched = $("#searchfieldstype_filter").find("option:selected").text();
511 if ( $("#searchmember_filter").val() ) {
512 if ( $("#searchtype_filter").val() == 'start_with' ) {
513 searched += _(" starting with ");
515 searched += _(" containing ");
517 searched += "'" + $("#searchmember_filter").val() + "'";
519 if ( $("#firstletter_filter").val() ) {
520 searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
522 if ( $("#categorycode_filter").val() ) {
523 searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
525 if ( $("#branchcode_filter").val() ) {
526 searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
528 $("#searchpattern").text(searched);
533 $("#firstletter_filter").val('');
536 $("#searchresults").show();
537 dtMemberResults.fnDraw();
541 // User has clicked on the Clear button
542 function clearFilters(redraw) {
543 $("#searchform select").val('');
544 $("#firstletter_filter").val('');
545 $("#searchmember_filter").val('');
548 $("#searchresults").show();
549 dtMemberResults.fnDraw();
553 // User has clicked on a letter
554 function filterByFirstLetterSurname(letter) {
556 $("#firstletter_filter").val(letter);
559 $("#searchresults").show();
560 dtMemberResults.fnDraw();
565 [% INCLUDE 'intranet-bottom.inc' %]