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="[% themelang %]/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').attr('disabled', 'disabled');
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').removeAttr('disabled');
27 $('#new_patron_list').hide();
28 $('#add_to_patron_list_submit').attr('disabled', 'disabled');
32 $('#new_patron_list').on('input', function() {
33 if ( $('#new_patron_list').val() ) {
34 $('#add_to_patron_list_submit').removeAttr('disabled');
36 $('#add_to_patron_list_submit').attr('disabled', 'disabled');
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());
104 $(document).ready(function() {
105 [% IF searchmember %]
106 $("#searchmember_filter").val("[% searchmember %]");
108 [% IF searchfieldstype %]
109 $("searchfieldstype_filter").val("[% searchfieldstype %]");
112 $("#searchtype_filter").val("[% searchtype %]");
114 [% IF categorycode %]
115 $("#categorycode_filter").val("[% categorycode_filter %]");
118 $("#branchcode_filter").val("[% branchcode_filter %]");
121 [% IF view != "show_results" %]
122 $("#searchresults").hide();
126 // Build the aLengthMenu
128 [%PatronsPerPage %], 10, 20, 50, 100, -1
130 jQuery.unique(aLengthMenu);
131 aLengthMenu.sort(function( a, b ){
132 // Put "All" at the end
135 } else if ( b == -1 ) {
138 return parseInt(a) < parseInt(b) ? -1 : 1;}
140 var aLengthMenuLabel = [];
141 $(aLengthMenu).each(function(){
143 // Label for -1 is "All"
144 aLengthMenuLabel.push("All");
146 aLengthMenuLabel.push(this);
150 // Apply DataTables on the results table
151 var columns_settings = [% ColumnsSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) %];
152 dtMemberResults = KohaTable("#memberresultst", {
154 'sAjaxSource': "/cgi-bin/koha/svc/members/search",
155 'fnServerData': function(sSource, aoData, fnCallback) {
160 'name': 'searchmember',
161 'value': $("#searchmember_filter").val()
163 'name': 'firstletter',
164 'value': $("#firstletter_filter").val()
166 'name': 'searchfieldstype',
167 'value': $("#searchfieldstype_filter").val()
169 'name': 'searchtype',
170 'value': $("#searchtype_filter").val()
172 'name': 'categorycode',
173 'value': $("#categorycode_filter").val()
175 'name': 'branchcode',
176 'value': $("#branchcode_filter").val()
178 'name': 'name_sorton',
179 'value': 'borrowers.surname borrowers.firstname'
181 'name': 'dateofbirth',
182 'value': 'borrowers.dateofbirth',
184 'name': 'category_sorton',
185 'value': 'categories.description',
187 'name': 'branch_sorton',
188 'value': 'branches.branchname'
190 'name': 'template_path',
191 'value': 'members/tables/members_results.tt',
198 'success': function(json){
199 // redirect if there is only 1 result.
200 if ( json.aaData.length == 1 ) {
201 var borrowernumber = json.aaData[0].borrowernumber;
202 document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
210 [% IF CAN_user_tools_manage_patron_lists %]
211 { 'mDataProp': 'dt_borrowernumber', 'bSortable': false },
213 { 'mDataProp': 'dt_cardnumber' },
214 { 'mDataProp': 'dt_name' },
215 { 'mDataProp': 'dt_dateofbirth' },
216 { 'mDataProp': 'dt_category' },
217 { 'mDataProp': 'dt_branch' },
218 { 'mDataProp': 'dt_dateexpiry' },
219 { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
220 { 'mDataProp': 'dt_fines', 'bSortable': false },
221 { 'mDataProp': 'dt_borrowernotes' },
222 { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
224 'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
225 /* Center text for 6th column */
226 $("td:eq(5)", nRow).css("text-align", "center");
232 [% IF CAN_user_tools_manage_patron_lists %]
233 'aaSorting': [[2, 'asc']],
235 'aaSorting': [[1, 'asc']],
237 "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
238 'sPaginationType': 'full_numbers',
239 "iDisplayLength": [% PatronsPerPage %],
241 }, columns_settings);
245 // Update the string "Results found ..."
246 function update_searched(){
247 var searched = $("#searchfieldstype_filter").find("option:selected").text();
248 if ( $("#searchmember_filter").val() ) {
249 if ( $("#searchtype_filter").val() == 'start_with' ) {
250 searched += _(" starting with ");
252 searched += _(" containing ");
254 searched += "'" + $("#searchmember_filter").val() + "'";
256 if ( $("#firstletter_filter").val() ) {
257 searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
259 if ( $("#categorycode_filter").val() ) {
260 searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
262 if ( $("#branchcode_filter").val() ) {
263 searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
265 $("#searchpattern").text(searched);
270 $("#firstletter_filter").val('');
273 $("#searchresults").show();
274 dtMemberResults.fnDraw();
278 // User has clicked on the Clear button
279 function clearFilters(redraw) {
280 $("#searchform select").val('');
281 $("#firstletter_filter").val('');
282 $("#searchmember_filter").val('');
285 $("#searchresults").show();
286 dtMemberResults.fnDraw();
290 // User has clicked on a letter
291 function filterByFirstLetterSurname(letter) {
293 $("#firstletter_filter").val(letter);
296 $("#searchresults").show();
297 dtMemberResults.fnDraw();
302 <body id="pat_member" class="pat">
303 [% INCLUDE 'header.inc' %]
304 [% INCLUDE 'patron-search.inc' %]
306 <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>
308 <div id="doc3" class="yui-t2">
313 [% IF CAN_user_tools_manage_patron_lists %]
314 <div id="patron_list_dialog" class="dialog alert">
315 Added <span class="patrons-length"></span> patrons to <a></a>.
319 [% IF Koha.Preference( 'NorwegianPatronDBEnable' ) == 1 %]
320 [% SET nl_search_form_title='Search the Norwegian national patron database' %]
321 [% INCLUDE 'nl-search-form.tt' %]
324 [% INCLUDE 'patron-toolbar.inc' %]
326 <div class="dialog alert">
327 <h3>Cannot add patron</h3>
328 [% IF ( no_branches ) %]
329 <p>There are <strong>no libraries defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/branches.pl">add a library</a>.[% ELSE %]An administrator must define at least one library.[% END %]</p>
331 [% IF ( no_categories ) %]
332 <p>There are <strong>no patron categories defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/categories.pl">add a patron category</a>.[% ELSE %]An administrator must define at least one patron category.[% END %]</p>
338 [% FOREACH letter IN alphabet.split(' ') %]
339 <a href="#" class="filterByLetter">[% letter %]</a>
343 [% IF ( CAN_user_borrowers && pending_borrower_modifications ) %]
344 <div class="pending-info" id="patron_updates_pending">
345 <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
346 <span class="holdcount"><a href="/cgi-bin/koha/members/members-update.pl">[% pending_borrower_modifications %]</a></span>
350 <div id="searchresults">
351 <div id="searchheader">
352 <h3>Patrons found for: <span id="searchpattern">[% IF searchmember %] for '[% searchmember %]'[% END %]</span></h3>
354 [% IF CAN_user_tools_manage_patron_lists %]
355 <div id="searchheader">
357 <a href="javascript:void(0)" onclick="$('.selection').prop('checked', true)">Select all</a>
359 <a href="javascript:void(0)" onclick="$('.selection').prop('checked', false)">Clear all</a>
362 <label for="add_to_patron_list">Add selected patrons to:</label>
363 <select id="add_to_patron_list" name="add_to_patron_list">
364 <option value=""></option>
365 [% IF patron_lists %]
366 <optgroup label="Patron lists:">
367 [% FOREACH pl IN patron_lists %]
368 <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
373 <option value="new">[ New list ]</option>
376 <input type="text" id="new_patron_list" name="new_patron_list" id="new_patron_list" />
378 <input id="add_to_patron_list_submit" type="submit" class="submit" value="Save">
384 <table id="memberresultst">
387 [% IF CAN_user_tools_manage_patron_lists %]
396 <th>OD/Checkouts</th>
409 <form onsubmit="return filter();" id="searchform">
410 <input type="hidden" id="firstletter_filter" value="" />
411 <fieldset class="brief">
415 <label for="searchmember_filter">Search:</label>
416 <input type="text" id="searchmember_filter" value="[% searchmember %]"/>
419 <label for="searchfieldstype_filter">Search fields:</label>
420 <select name="searchfieldstype" id="searchfieldstype_filter">
421 [% IF searchfieldstype == "standard" %]
422 <option selected="selected" value='standard'>Standard</option>
424 <option value='standard'>Standard</option>
426 [% IF searchfieldstype == "email" %]
427 <option selected="selected" value='email'>Email</option>
429 <option value='email'>Email</option>
431 [% IF searchfieldstype == "borrowernumber" %]
432 <option selected="selected" value='borrowernumber'>Borrower number</option>
434 <option value='borrowernumber'>Borrower number</option>
436 [% IF searchfieldstype == "userid" %]
437 <option selected="selected" value='userid'>Username</option>
439 <option value='userid'>Username</option>
441 [% IF searchfieldstype == "phone" %]
442 <option selected="selected" value='phone'>Phone number</option>
444 <option value='phone'>Phone number</option>
446 [% IF searchfieldstype == "address" %]
447 <option selected="selected" value='address'>Street address</option>
449 <option value='address'>Street address</option>
451 [% IF searchfieldstype == "dateofbirth" %]
452 <option selected="selected" value='dateofbirth'>Date of birth</option>
454 <option value='dateofbirth'>Date of birth</option>
456 [% IF searchfieldstype == "sort1" %]
457 <option selected="selected" value='sort1'>Sort field 1</option>
459 <option value='sort1'>Sort field 1</option>
461 [% IF searchfieldstype == "sort2" %]
462 <option selected="selected" value='sort2'>Sort field 2</option>
464 <option value='sort2'>Sort field 2</option>
469 <label for="searchtype_filter">Search type:</label>
470 <select name="searchtype" id="searchtype_filter">
471 [% IF searchtype == "start_with" %]
472 <option value='start_with' selected="selected">Starts with</option>
473 <option value="contain">Contains</option>
475 <option value='start_with'>Starts with</option>
476 <option value="contain" selected="selected">Contains</option>
481 <label for="categorycode_filter">Category:</label>
482 [% SET categories = Categories.all( selected => categorycode_filter ) %]
483 <select id="categorycode_filter">
484 <option value="">Any</option>
485 [% FOREACH cat IN categories %]
486 [% IF cat.selected %]
487 <option selected="selected" value="[% cat.categorycode %]">[% cat.description %]</option>
489 <option value="[% cat.categorycode %]">[% cat.description %]</option>
495 <label for="branchcode_filter">Library:</label>
496 [% SET branches = Branches.all( selected => branchcode_filter ) %]
497 <select id="branchcode_filter">
498 [% IF branches.size != 1 %]
499 <option value="">Any</option>
501 [% FOREACH b IN branches %]
503 <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
505 <option value="[% b.branchcode %]">[% b.branchname %]</option>
511 <fieldset class="action">
512 <input type="submit" value="Search" />
513 <input type="button" value="Clear" onclick="clearFilters(true);" />
520 [% INCLUDE 'members-menu.inc' %]
523 [% INCLUDE 'intranet-bottom.inc' %]