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 [% INCLUDE 'patron-toolbar.inc' %]
32 [% INCLUDE 'noadd-warnings.inc' %]
36 [% FOREACH letter IN alphabet.split(' ') %]
37 <a href="#" class="filterByLetter">[% letter | html %]</a>
41 [% IF CAN_user_borrowers_edit_borrowers && pending_borrower_modifications %]
42 <div class="pending-info" id="patron_updates_pending">
43 <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
44 <span class="number_box"><a href="/cgi-bin/koha/members/members-update.pl">[% pending_borrower_modifications | html %]</a></span>
48 <div id="searchresults">
49 <div id="searchheader">
50 <h3>Patrons found for: <span id="searchpattern">[% IF searchmember %] for '[% searchmember | html %]'[% END %]</span></h3>
52 [% IF CAN_user_tools_manage_patron_lists || CAN_user_borrowers_edit_borrowers %]
53 <div id="searchheader">
55 <a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a>
57 <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
58 [% IF CAN_user_tools_manage_patron_lists %]
61 <label for="add_to_patron_list">Add selected patrons to:</label>
62 <select id="add_to_patron_list" name="add_to_patron_list">
63 <option value=""></option>
65 <optgroup label="Patron lists:">
66 [% FOREACH pl IN patron_lists %]
67 <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
72 <option value="new">[ New list ]</option>
75 <input type="text" id="new_patron_list" name="new_patron_list" id="new_patron_list" />
77 <input id="add_to_patron_list_submit" type="submit" class="submit" value="Save">
81 [% IF CAN_user_tools_manage_patron_lists && CAN_user_borrowers_edit_borrowers %]
85 [% IF CAN_user_borrowers_edit_borrowers %]
86 <button id="merge-patrons" type="submit">Merge selected patrons</button>
92 <table id="memberresultst">
95 [% IF CAN_user_borrowers_edit_borrowers || CAN_user_tools_manage_patron_lists %]
100 <th>Date of birth</th>
104 <th>OD/Checkouts</th>
117 <form method="get" id="searchform">
118 <input type="hidden" id="firstletter_filter" value="" />
119 <fieldset class="brief">
123 <label for="searchmember_filter">Search:</label>
124 <input type="text" id="searchmember_filter" value="[% searchmember | html %]"/>
127 <label for="searchfieldstype_filter">Search fields:</label>
128 <select name="searchfieldstype" id="searchfieldstype_filter">
129 [% IF searchfieldstype == "standard" %]
130 <option selected="selected" value='standard'>Standard</option>
132 <option value='standard'>Standard</option>
134 [% IF searchfieldstype == "surname" %]
135 <option selected="selected" value='surname'>Surname</option>
137 <option value='surname'>Surname</option>
139 [% IF searchfieldstype == "email" %]
140 <option selected="selected" value='email'>Email</option>
142 <option value='email'>Email</option>
144 [% IF searchfieldstype == "borrowernumber" %]
145 <option selected="selected" value='borrowernumber'>Borrower number</option>
147 <option value='borrowernumber'>Borrower number</option>
149 [% IF searchfieldstype == "userid" %]
150 <option selected="selected" value='userid'>Username</option>
152 <option value='userid'>Username</option>
154 [% IF searchfieldstype == "phone" %]
155 <option selected="selected" value='phone'>Phone number</option>
157 <option value='phone'>Phone number</option>
159 [% IF searchfieldstype == "address" %]
160 <option selected="selected" value='address'>Street address</option>
162 <option value='address'>Street address</option>
164 [% IF searchfieldstype == "dateofbirth" %]
165 <option selected="selected" value='dateofbirth'>Date of birth</option>
167 <option value='dateofbirth'>Date of birth</option>
169 [% IF searchfieldstype == "sort1" %]
170 <option selected="selected" value='sort1'>Sort field 1</option>
172 <option value='sort1'>Sort field 1</option>
174 [% IF searchfieldstype == "sort2" %]
175 <option selected="selected" value='sort2'>Sort field 2</option>
177 <option value='sort2'>Sort field 2</option>
182 <label for="searchtype_filter">Search type:</label>
183 <select name="searchtype" id="searchtype_filter">
184 [% IF searchtype == "start_with" %]
185 <option value='start_with' selected="selected">Starts with</option>
186 <option value="contain">Contains</option>
188 <option value='start_with'>Starts with</option>
189 <option value="contain" selected="selected">Contains</option>
194 <label for="categorycode_filter">Category:</label>
195 [% SET categories = Categories.all() %]
196 <select id="categorycode_filter">
197 <option value="">Any</option>
198 [% FOREACH cat IN categories %]
199 [% IF cat.categorycode == categorycode_filter %]
200 <option selected="selected" value="[% cat.categorycode | html %]">[% cat.description | html %]</option>
202 <option value="[% cat.categorycode | html %]">[% cat.description | html %]</option>
208 <label for="branchcode_filter">Library:</label>
209 [% SET branches = Branches.all( selected => branchcode_filter, only_from_group => 1 ) %]
210 <select id="branchcode_filter">
211 [% IF branches.size != 1 %]
212 <option value="">Any</option>
214 [% PROCESS options_for_libraries libraries => branches %]
218 <fieldset class="action">
219 <input type="submit" value="Search" />
220 <input type="button" value="Clear" id="clear_search" />
228 [% MACRO jsinclude BLOCK %]
229 [% INCLUDE 'datatables.inc' %]
230 [% INCLUDE 'columns_settings.inc' %]
231 [% INCLUDE 'str/members-menu.inc' %]
232 [% Asset.js("js/members-menu.js") | $raw %]
233 <script type="text/javascript">
234 $(document).ready(function() {
235 $('#merge-patrons').prop('disabled', true);
236 $('#memberresultst').on('change', 'input.selection', function() {
237 if ( $('.selection:checked').length > 1 ) {
238 $('#merge-patrons').prop('disabled', false);
240 $('#merge-patrons').prop('disabled', true);
243 $('#merge-patrons').on('click', function() {
244 var merge_patrons_url = 'merge-patrons.pl?' + $('.selection:checked')
246 return "id=" + $(this).val()
249 window.location.href = merge_patrons_url;
252 $('#add_to_patron_list_submit').prop('disabled', true);
253 $('#new_patron_list').hide();
255 $('#add_to_patron_list').change(function() {
256 var value = $('#add_to_patron_list').val();
257 if ( value == 'new' ) {
258 $('#new_patron_list').val('')
259 $('#new_patron_list').show();
260 $('#new_patron_list').focus();
261 } else if ( value ) {
262 $('#new_patron_list').hide();
263 $('#add_to_patron_list_submit').prop('disabled', false);
265 $('#new_patron_list').hide();
266 $('#add_to_patron_list_submit').prop('disabled', true);
270 $('#new_patron_list').on('input', function() {
271 if ( $('#new_patron_list').val() ) {
272 $('#add_to_patron_list_submit').prop('disabled', false);
274 $('#add_to_patron_list_submit').prop('disabled', true);
278 $("#add_to_patron_list_submit").on('click', function(e){
279 if ( $('#add_to_patron_list').val() == 'new' ) {
280 if ( $('#new_patron_list').val() ) {
281 $("#add_to_patron_list option").each(function() {
282 if ( $(this).text() == $('#new_patron_list').val() ) {
283 alert( _("You already have a list with that name!") );
288 alert( _("You must give your new patron list a name!") );
293 if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
294 alert( _("You have not selected any patrons to add to a list!") );
298 var borrowernumbers = [];
299 $("#memberresultst").find("input:checkbox:checked").each(function(){
300 borrowernumbers.push($(this).val());
303 add_to_patron_list: $("#add_to_patron_list").val(),
304 new_patron_list: $("#new_patron_list").val(),
305 borrowernumbers: borrowernumbers
310 url: '/cgi-bin/koha/svc/members/add_to_list',
311 success: function(data) {
312 $("#patron_list_dialog").show();
313 $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
314 $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
315 $("#patron_list_dialog > a").html(data.patron_list.name);
316 if ( $('#add_to_patron_list').val() == 'new' ) {
317 var new_patron_list_added = $("<option>", {
318 value: data.patron_list.patron_list_id,
319 text: data.patron_list.name
321 $("#add_to_patron_list optgroup").append(new_patron_list_added);
322 $("#add_to_patron_list").val(data.patron_list.patron_list_id);
323 $("#new_patron_list").val('');
324 $('#add_to_patron_list').change();
328 alert("an error occurred");
333 $(".filterByLetter").on("click",function(e){
335 filterByFirstLetterSurname($(this).text());
337 $("#select_all").on("click",function(e){
339 $(".selection").prop("checked", true).change();
341 $("#clear_all").on("click",function(e){
343 $(".selection").prop("checked", false).change();
345 $("#clear_search").on("click",function(e){
349 $("#searchform").on("submit", filter);
354 $(document).ready(function() {
355 [% IF searchmember %]
356 $("#searchmember_filter").val("[% searchmember | html %]");
358 [% IF searchfieldstype %]
359 $("searchfieldstype_filter").val("[% searchfieldstype | html %]");
362 $("#searchtype_filter").val("[% searchtype | html %]");
364 [% IF categorycode %]
365 $("#categorycode_filter").val("[% categorycode_filter | html %]");
368 $("#branchcode_filter").val("[% branchcode_filter | html %]");
371 [% IF view != "show_results" %]
374 $("#searchresults").show();
377 // Build the aLengthMenu
379 [% PatronsPerPage | html %], 10, 20, 50, 100, -1
381 jQuery.unique(aLengthMenu);
382 aLengthMenu.sort(function( a, b ){
383 // Put "All" at the end
386 } else if ( b == -1 ) {
389 return parseInt(a) < parseInt(b) ? -1 : 1;}
391 var aLengthMenuLabel = [];
392 $(aLengthMenu).each(function(){
394 // Label for -1 is "All"
395 aLengthMenuLabel.push(_("All"));
397 aLengthMenuLabel.push(this);
401 // Apply DataTables on the results table
402 var columns_settings = [% ColumnsSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) | $raw %];
403 [% UNLESS CAN_user_borrowers_edit_borrowers OR CAN_user_tools_manage_patron_lists %]
404 [%# Remove the first column if we do not display the checkbox %]
405 columns_settings.splice(0, 1);
407 dtMemberResults = KohaTable("memberresultst", {
409 'sAjaxSource': "/cgi-bin/koha/svc/members/search",
410 'fnServerData': function(sSource, aoData, fnCallback) {
415 'name': 'searchmember',
416 'value': $("#searchmember_filter").val()
418 'name': 'firstletter',
419 'value': $("#firstletter_filter").val()
421 'name': 'searchfieldstype',
422 'value': $("#searchfieldstype_filter").val()
424 'name': 'searchtype',
425 'value': $("#searchtype_filter").val()
427 'name': 'categorycode',
428 'value': $("#categorycode_filter").val()
430 'name': 'branchcode',
431 'value': $("#branchcode_filter").val()
433 'name': 'name_sorton',
434 'value': 'borrowers.surname borrowers.firstname'
436 'name': 'dateofbirth',
437 'value': 'borrowers.dateofbirth',
439 'name': 'category_sorton',
440 'value': 'categories.description',
442 'name': 'branch_sorton',
443 'value': 'branches.branchname'
445 'name': 'template_path',
446 'value': 'members/tables/members_results.tt',
453 'success': function(json){
454 // redirect if there is only 1 result.
455 if ( json.aaData.length == 1 ) {
456 var borrowernumber = json.aaData[0].borrowernumber;
457 document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
465 [% IF CAN_user_borrowers_edit_borrowers || CAN_user_tools_manage_patron_lists %]
466 { 'mDataProp': 'dt_borrowernumber', 'bSortable': false },
468 { 'mDataProp': 'dt_cardnumber' },
469 { 'mDataProp': 'dt_name' },
470 { 'mDataProp': 'dt_dateofbirth' },
471 { 'mDataProp': 'dt_category' },
472 { 'mDataProp': 'dt_branch' },
473 { 'mDataProp': 'dt_dateexpiry' },
474 { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
475 { 'mDataProp': 'dt_fines', 'bSortable': false },
476 { 'mDataProp': 'dt_borrowernotes' },
477 { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
479 'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
480 /* Center text for 6th column */
481 $("td:eq(5)", nRow).css("text-align", "center");
487 [% IF CAN_user_borrowers_edit_borrowers || CAN_user_tools_manage_patron_lists %]
488 'aaSorting': [[2, 'asc']],
490 'aaSorting': [[1, 'asc']],
492 "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
493 'sPaginationType': 'full_numbers',
494 "iDisplayLength": [% PatronsPerPage | html %],
496 }, columns_settings);
500 // Update the string "Results found ..."
501 function update_searched(){
502 var searched = $("#searchfieldstype_filter").find("option:selected").text();
503 if ( $("#searchmember_filter").val() ) {
504 if ( $("#searchtype_filter").val() == 'start_with' ) {
505 searched += _(" starting with ");
507 searched += _(" containing ");
509 searched += "'" + $("#searchmember_filter").val() + "'";
511 if ( $("#firstletter_filter").val() ) {
512 searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
514 if ( $("#categorycode_filter").val() ) {
515 searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
517 if ( $("#branchcode_filter").val() ) {
518 searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
520 $("#searchpattern").text(searched);
525 $("#firstletter_filter").val('');
528 $("#searchresults").show();
529 dtMemberResults.fnDraw();
533 // User has clicked on the Clear button
534 function clearFilters(redraw) {
535 $("#searchform select").val('');
536 $("#firstletter_filter").val('');
537 $("#searchmember_filter").val('');
540 $("#searchresults").show();
541 dtMemberResults.fnDraw();
545 // User has clicked on a letter
546 function filterByFirstLetterSurname(letter) {
548 $("#firstletter_filter").val(letter);
551 $("#searchresults").show();
552 dtMemberResults.fnDraw();
557 [% INCLUDE 'intranet-bottom.inc' %]