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);
81 alert("an error occurred");
90 $(document).ready(function() {
92 $("#searchmember_filter").val("[% searchmember %]");
94 [% IF searchfieldstype %]
95 $("searchfieldstype_filter").val("[% searchfieldstype %]");
98 $("#searchtype_filter").val("[% searchtype %]");
100 [% IF categorycode %]
101 $("#categorycode_filter").val("[% categorycode %]");
104 $("#branchcode_filter").val("[% branchcode %]");
107 [% IF view != "show_results" %]
108 $("#searchresults").hide();
112 // Build the aLengthMenu
114 [%PatronsPerPage %], 10, 20, 50, 100, -1
116 jQuery.unique(aLengthMenu);
117 aLengthMenu.sort(function( a, b ){
118 // Put "All" at the end
121 } else if ( b == -1 ) {
124 return parseInt(a) < parseInt(b) ? -1 : 1;}
126 var aLengthMenuLabel = [];
127 $(aLengthMenu).each(function(){
129 // Label for -1 is "All"
130 aLengthMenuLabel.push("All");
132 aLengthMenuLabel.push(this);
136 // Apply DataTables on the results table
137 var columns_settings = [% ColumnsSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) %];
138 dtMemberResults = KohaTable("#memberresultst", {
140 'sAjaxSource': "/cgi-bin/koha/svc/members/search",
141 'fnServerData': function(sSource, aoData, fnCallback) {
146 'name': 'searchmember',
147 'value': $("#searchmember_filter").val()
149 'name': 'firstletter',
150 'value': $("#firstletter_filter").val()
152 'name': 'searchfieldstype',
153 'value': $("#searchfieldstype_filter").val()
155 'name': 'searchtype',
156 'value': $("#searchtype_filter").val()
158 'name': 'categorycode',
159 'value': $("#categorycode_filter").val()
161 'name': 'branchcode',
162 'value': $("#branchcode_filter").val()
164 'name': 'name_sorton',
165 'value': 'borrowers.surname borrowers.firstname'
167 'name': 'category_sorton',
168 'value': 'categories.description',
170 'name': 'branch_sorton',
171 'value': 'branches.branchname'
173 'name': 'template_path',
174 'value': 'members/tables/members_results.tt',
181 'success': function(json){
182 // redirect if there is only 1 result.
183 if ( json.aaData.length == 1 ) {
184 var borrowernumber = json.aaData[0].borrowernumber;
185 document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
193 [% IF CAN_user_tools_manage_patron_lists %]
194 { 'mDataProp': 'dt_borrowernumber', 'bSortable': false },
196 { 'mDataProp': 'dt_cardnumber' },
197 { 'mDataProp': 'dt_name' },
198 { 'mDataProp': 'dt_category' },
199 { 'mDataProp': 'dt_branch' },
200 { 'mDataProp': 'dt_dateexpiry' },
201 { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
202 { 'mDataProp': 'dt_fines', 'bSortable': false },
203 { 'mDataProp': 'dt_borrowernotes' },
204 { 'mDataProp': 'dt_action', 'bSortable': false }
206 'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
207 /* Center text for 6th column */
208 $("td:eq(5)", nRow).css("text-align", "center");
214 [% IF CAN_user_tools_manage_patron_lists %]
215 'aaSorting': [[1, 'asc']],
217 'aaSorting': [[0, 'asc']],
219 "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
220 'sPaginationType': 'full_numbers',
221 "iDisplayLength": [% PatronsPerPage %],
223 }, columns_settings);
227 // Update the string "Results found ..."
228 function update_searched(){
229 var searched = $("#searchfieldstype_filter").find("option:selected").text();
230 if ( $("#searchmember_filter").val() ) {
231 if ( $("#searchtype_filter").val() == 'start_with' ) {
232 searched += _(" starting with ");
234 searched += _(" containing ");
236 searched += "'" + $("#searchmember_filter").val() + "'";
238 if ( $("#firstletter_filter").val() ) {
239 searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
241 if ( $("#categorycode_filter").val() ) {
242 searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
244 if ( $("#branchcode_filter").val() ) {
245 searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
247 $("#searchpattern").text(searched);
252 $("#firstletter_filter").val('');
255 $("#searchresults").show();
256 dtMemberResults.fnDraw();
260 // User has clicked on the Clear button
261 function clearFilters(redraw) {
262 $("#searchform select").val('');
263 $("#firstletter_filter").val('');
264 $("#searchmember_filter").val('');
267 $("#searchresults").show();
268 dtMemberResults.fnDraw();
272 // User has clicked on a letter
273 function filterByFirstLetterSurname(letter) {
275 $("#firstletter_filter").val(letter);
278 $("#searchresults").show();
279 dtMemberResults.fnDraw();
284 <body id="pat_member" class="pat">
285 [% INCLUDE 'header.inc' %]
286 [% INCLUDE 'patron-search.inc' %]
288 <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>
290 <div id="doc3" class="yui-t2">
295 [% IF CAN_user_tools_manage_patron_lists %]
296 <div id="patron_list_dialog" class="dialog alert">
297 Added <span class="patrons-length"></span> patrons to <a></a>.
301 [% IF Koha.Preference( 'NorwegianPatronDBEnable' ) == 1 %]
302 [% SET nl_search_form_title='Search the Norwegian national patron database' %]
303 [% INCLUDE 'nl-search-form.tt' %]
306 [% INCLUDE 'patron-toolbar.inc' %]
308 <div class="dialog alert">
309 <h3>Cannot add patron</h3>
310 [% IF ( no_branches ) %]
311 <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>
313 [% IF ( no_categories ) %]
314 <p>There are <strong>no patron categories defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/categorie.pl">add a patron category</a>.[% ELSE %]An administrator must define at least one patron category.[% END %]</p>
320 [% FOREACH letter IN alphabet.split(' ') %]
321 <a style="cursor:pointer" onclick="filterByFirstLetterSurname('[% letter %]');">[% letter %]</a>
325 [% IF ( CAN_user_borrowers && pending_borrower_modifications ) %]
326 <div class="pending-info" id="patron_updates_pending">
327 <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
328 <span class="holdcount"><a href="/cgi-bin/koha/members/members-update.pl">[% pending_borrower_modifications %]</a></span>
332 <div id="searchresults">
333 <div id="searchheader">
334 <h3>Patrons found for: <span id="searchpattern">[% IF searchmember %] for '[% searchmember %]'[% END %]</span></h3>
336 [% IF CAN_user_tools_manage_patron_lists %]
337 <div id="searchheader">
339 <a href="javascript:void(0)" onclick="$('.selection').prop('checked', true)">Select all</a>
341 <a href="javascript:void(0)" onclick="$('.selection').prop('checked', false)">Clear all</a>
344 <label for="add_to_patron_list">Add selected patrons to:</label>
345 <select id="add_to_patron_list" name="add_to_patron_list">
346 <option value=""></option>
347 [% IF patron_lists %]
348 <optgroup label="Patron lists:">
349 [% FOREACH pl IN patron_lists %]
350 <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
355 <option value="new">[ New list ]</option>
358 <input type="text" id="new_patron_list" name="new_patron_list" id="new_patron_list" />
360 <input id="add_to_patron_list_submit" type="submit" class="submit" value="Save">
366 <table id="memberresultst">
369 [% IF CAN_user_tools_manage_patron_lists %]
377 <th>OD/Checkouts</th>
390 <form onsubmit="return filter();" id="searchform">
391 <input type="hidden" id="firstletter_filter" value="" />
392 <fieldset class="brief">
396 <label for="searchmember_filter">Search:</label>
397 <input type="text" id="searchmember_filter" value="[% searchmember %]"/>
400 <label for="searchfieldstype_filter">Search fields:</label>
401 <select name="searchfieldstype" id="searchfieldstype_filter">
402 [% IF searchfieldstype == "standard" %]
403 <option selected="selected" value='standard'>Standard</option>
405 <option value='standard'>Standard</option>
407 [% IF searchfieldstype == "email" %]
408 <option selected="selected" value='email'>Email</option>
410 <option value='email'>Email</option>
412 [% IF searchfieldstype == "borrowernumber" %]
413 <option selected="selected" value='borrowernumber'>Borrower number</option>
415 <option value='borrowernumber'>Borrower number</option>
417 [% IF searchfieldstype == "phone" %]
418 <option selected="selected" value='phone'>Phone number</option>
420 <option value='phone'>Phone number</option>
422 [% IF searchfieldstype == "address" %]
423 <option selected="selected" value='address'>Street address</option>
425 <option value='address'>Street address</option>
427 [% IF searchfieldstype == "dateofbirth" %]
428 <option selected="selected" value='dateofbirth'>Date of birth</option>
430 <option value='dateofbirth'>Date of birth</option>
432 [% IF searchfieldstype == "sort1" %]
433 <option selected="selected" value='sort1'>Sort field 1</option>
435 <option value='sort1'>Sort field 1</option>
437 [% IF searchfieldstype == "sort2" %]
438 <option selected="selected" value='sort2'>Sort field 2</option>
440 <option value='sort2'>Sort field 2</option>
445 <label for="searchtype_filter">Search type:</label>
446 <select name="searchtype" id="searchtype_filter">
447 <option value='start_with'>Starts with</option>
448 [% IF searchtype == "contain" %]
449 <option value="contain" selected="selected">Contains</option>
451 <option value="contain" selected="selected">Contains</option>
456 <label for="categorycode_filter">Category:</label>
457 [% SET categories = Categories.all( selected => categorycode ) %]
458 <select id="categorycode_filter">
459 <option value="">Any</option>
460 [% FOREACH cat IN categories %]
461 [% IF cat.selected %]
462 <option selected="selected" value="[% cat.categorycode %]">[% cat.description %]</option>
464 <option value="[% cat.categorycode %]">[% cat.description %]</option>
470 <label for="branchcode_filter">Library:</label>
471 [% SET branches = Branches.all( selected => branchcode ) %]
472 <select id="branchcode_filter">
473 [% IF branches.size != 1 %]
474 <option value="">Any</option>
476 [% FOREACH b IN branches %]
478 <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
480 <option value="[% b.branchcode %]">[% b.branchname %]</option>
486 <fieldset class="action">
487 <input type="submit" value="Search" />
488 <input type="button" value="Clear" onclick="clearFilters(true);" />
495 [% INCLUDE 'members-menu.inc' %]
498 [% INCLUDE 'intranet-bottom.inc' %]