Bug 14915: (QA followup) Replace fa-remove-sign with fa-times-circle
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / member.tt
1 [% USE Koha %]
2 [% USE ColumnsSettings %]
3 [% USE Branches %]
4 [% USE Categories %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; 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">
12 //<![CDATA[
13 $(document).ready(function() {
14     $('#add_to_patron_list_submit').attr('disabled', 'disabled');
15     $('#new_patron_list').hide();
16
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();
23         } else if ( value ) {
24             $('#new_patron_list').hide();
25             $('#add_to_patron_list_submit').removeAttr('disabled');
26         } else {
27             $('#new_patron_list').hide();
28             $('#add_to_patron_list_submit').attr('disabled', 'disabled');
29         }
30     });
31
32     $('#new_patron_list').on('input', function() {
33         if ( $('#new_patron_list').val() ) {
34             $('#add_to_patron_list_submit').removeAttr('disabled');
35         } else {
36             $('#add_to_patron_list_submit').attr('disabled', 'disabled');
37         }
38     });
39
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!") );
47                         return false;
48                     }
49                 });
50             } else {
51                 alert( _("You must give your new patron list a name!") );
52                 return false;
53             }
54         }
55
56         if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
57             alert( _("You have not selected any patrons to add to a list!") );
58             return false;
59         }
60
61         var borrowernumbers = [];
62         $("#memberresultst").find("input:checkbox:checked").each(function(){
63             borrowernumbers.push($(this).val());
64         });
65         var data = {
66             add_to_patron_list: $("#add_to_patron_list").val(),
67             new_patron_list: $("#new_patron_list").val(),
68             borrowernumbers: borrowernumbers
69         };
70         $.ajax({
71             data: data,
72             type: 'POST',
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
83                     });
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();
88                 }
89             },
90             error: function() {
91                 alert("an error occurred");
92             }
93         });
94         return true;
95     });
96 });
97
98 var dtMemberResults;
99 var search = 1;
100 $(document).ready(function() {
101     [% IF searchmember %]
102         $("#searchmember_filter").val("[% searchmember %]");
103     [% END %]
104     [% IF searchfieldstype %]
105         $("searchfieldstype_filter").val("[% searchfieldstype %]");
106     [% END %]
107     [% IF searchtype %]
108         $("#searchtype_filter").val("[% searchtype %]");
109     [% END %]
110     [% IF categorycode %]
111         $("#categorycode_filter").val("[% categorycode_filter %]");
112     [% END %]
113     [% IF branchcode %]
114         $("#branchcode_filter").val("[% branchcode_filter %]");
115     [% END %]
116
117     [% IF view != "show_results" %]
118         $("#searchresults").hide();
119         search = 0;
120     [% END %]
121
122     // Build the aLengthMenu
123     var aLengthMenu = [
124         [%PatronsPerPage %], 10, 20, 50, 100, -1
125     ];
126     jQuery.unique(aLengthMenu);
127     aLengthMenu.sort(function( a, b ){
128         // Put "All" at the end
129         if ( a == -1 ) {
130             return 1;
131         } else if ( b == -1 ) {
132             return -1;
133         }
134         return parseInt(a) < parseInt(b) ? -1 : 1;}
135     );
136     var aLengthMenuLabel = [];
137     $(aLengthMenu).each(function(){
138         if ( this == -1 ) {
139             // Label for -1 is "All"
140             aLengthMenuLabel.push("All");
141         } else {
142             aLengthMenuLabel.push(this);
143         }
144     });
145
146     // Apply DataTables on the results table
147     var columns_settings = [% ColumnsSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) %];
148     dtMemberResults = KohaTable("#memberresultst", {
149         'bServerSide': true,
150         'sAjaxSource': "/cgi-bin/koha/svc/members/search",
151         'fnServerData': function(sSource, aoData, fnCallback) {
152             if ( ! search ) {
153                 return;
154             }
155             aoData.push({
156                 'name': 'searchmember',
157                 'value': $("#searchmember_filter").val()
158             },{
159                 'name': 'firstletter',
160                 'value': $("#firstletter_filter").val()
161             },{
162                 'name': 'searchfieldstype',
163                 'value': $("#searchfieldstype_filter").val()
164             },{
165                 'name': 'searchtype',
166                 'value': $("#searchtype_filter").val()
167             },{
168                 'name': 'categorycode',
169                 'value': $("#categorycode_filter").val()
170             },{
171                 'name': 'branchcode',
172                 'value': $("#branchcode_filter").val()
173             },{
174                 'name': 'name_sorton',
175                 'value': 'borrowers.surname borrowers.firstname'
176             },{
177                 'name': 'category_sorton',
178                 'value': 'categories.description',
179             },{
180                 'name': 'branch_sorton',
181                 'value': 'branches.branchname'
182             },{
183                 'name': 'template_path',
184                 'value': 'members/tables/members_results.tt',
185             });
186             $.ajax({
187                 'dataType': 'json',
188                 'type': 'POST',
189                 'url': sSource,
190                 'data': aoData,
191                 'success': function(json){
192                     // redirect if there is only 1 result.
193                     if ( json.aaData.length == 1 ) {
194                         var borrowernumber = json.aaData[0].borrowernumber;
195                         document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
196                         return false;
197                     }
198                     fnCallback(json);
199                 }
200             });
201         },
202         'aoColumns':[
203             [% IF CAN_user_tools_manage_patron_lists %]
204               { 'mDataProp': 'dt_borrowernumber', 'bSortable': false },
205             [% END %]
206             { 'mDataProp': 'dt_cardnumber' },
207             { 'mDataProp': 'dt_name' },
208             { 'mDataProp': 'dt_category' },
209             { 'mDataProp': 'dt_branch' },
210             { 'mDataProp': 'dt_dateexpiry' },
211             { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
212             { 'mDataProp': 'dt_fines', 'bSortable': false },
213             { 'mDataProp': 'dt_borrowernotes' },
214             { 'mDataProp': 'dt_action', 'bSortable': false }
215         ],
216         'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
217             /* Center text for 6th column */
218             $("td:eq(5)", nRow).css("text-align", "center");
219
220             return nRow;
221         },
222         'bFilter': false,
223         'bAutoWidth': false,
224         [% IF CAN_user_tools_manage_patron_lists %]
225             'aaSorting': [[1, 'asc']],
226         [% ELSE %]
227             'aaSorting': [[0, 'asc']],
228         [% END %]
229         "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
230         'sPaginationType': 'full_numbers',
231         "iDisplayLength": [% PatronsPerPage %],
232         "bProcessing": true,
233     }, columns_settings);
234     update_searched();
235 });
236
237 // Update the string "Results found ..."
238 function update_searched(){
239     var searched = $("#searchfieldstype_filter").find("option:selected").text();
240     if ( $("#searchmember_filter").val() ) {
241         if ( $("#searchtype_filter").val() == 'start_with' ) {
242             searched += _(" starting with ");
243         } else {
244             searched += _(" containing ");
245         }
246         searched += "'" + $("#searchmember_filter").val() + "'";
247     }
248     if ( $("#firstletter_filter").val() ) {
249         searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
250     }
251     if ( $("#categorycode_filter").val() ) {
252         searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
253     }
254     if ( $("#branchcode_filter").val() ) {
255         searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
256     }
257     $("#searchpattern").text(searched);
258 }
259
260 // Redraw the table
261 function filter() {
262     $("#firstletter_filter").val('');
263     update_searched();
264     search = 1;
265     $("#searchresults").show();
266     dtMemberResults.fnDraw();
267     return false;
268 }
269
270 // User has clicked on the Clear button
271 function clearFilters(redraw) {
272     $("#searchform select").val('');
273     $("#firstletter_filter").val('');
274     $("#searchmember_filter").val('');
275     if(redraw) {
276         search = 1;
277         $("#searchresults").show();
278         dtMemberResults.fnDraw();
279     }
280 }
281
282 // User has clicked on a letter
283 function filterByFirstLetterSurname(letter) {
284     clearFilters(false);
285     $("#firstletter_filter").val(letter);
286     update_searched();
287     search = 1;
288     $("#searchresults").show();
289     dtMemberResults.fnDraw();
290 }
291 //]]>
292 </script>
293 </head>
294 <body id="pat_member" class="pat">
295 [% INCLUDE 'header.inc' %]
296 [% INCLUDE 'patron-search.inc' %]
297
298 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; [% IF ( searching ) %]<a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Search results[% ELSE %]Patrons[% END %]</div>
299
300 <div id="doc3" class="yui-t2">
301   <div id="bd">
302     <div id="yui-main">
303       <div class="yui-b">
304         <div class="yui-g">
305           [% IF CAN_user_tools_manage_patron_lists %]
306             <div id="patron_list_dialog" class="dialog alert">
307               Added <span class="patrons-length"></span> patrons to <a></a>.
308             </div>
309           [% END %]
310
311           [% IF Koha.Preference( 'NorwegianPatronDBEnable' ) == 1 %]
312             [% SET nl_search_form_title='Search the Norwegian national patron database' %]
313             [% INCLUDE 'nl-search-form.tt' %]
314           [% END %]
315
316           [% INCLUDE 'patron-toolbar.inc' %]
317           [% IF ( no_add ) %]
318             <div class="dialog alert">
319               <h3>Cannot add patron</h3>
320               [% IF ( no_branches ) %]
321                 <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>
322               [% END %]
323               [% IF ( no_categories ) %]
324                 <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>
325               [% END %]
326             </div>
327           [% END %]
328           <div class="browse">
329             Browse by last name:
330             [% FOREACH letter IN alphabet.split(' ') %]
331               <a style="cursor:pointer" onclick="filterByFirstLetterSurname('[% letter %]');">[% letter %]</a>
332             [% END %]
333           </div>
334
335           [% IF ( CAN_user_borrowers && pending_borrower_modifications ) %]
336             <div class="pending-info" id="patron_updates_pending">
337               <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
338               <span class="holdcount"><a href="/cgi-bin/koha/members/members-update.pl">[% pending_borrower_modifications %]</a></span>
339             </div>
340           [% END %]
341
342           <div id="searchresults">
343             <div id="searchheader">
344               <h3>Patrons found for: <span id="searchpattern">[% IF searchmember %] for '[% searchmember %]'[% END %]</span></h3>
345             </div>
346             [% IF CAN_user_tools_manage_patron_lists %]
347               <div id="searchheader">
348                   <div>
349                       <a href="javascript:void(0)" onclick="$('.selection').prop('checked', true)">Select all</a>
350                       |
351                       <a href="javascript:void(0)" onclick="$('.selection').prop('checked', false)">Clear all</a>
352                       |
353                       <span>
354                           <label for="add_to_patron_list">Add selected patrons to:</label>
355                           <select id="add_to_patron_list" name="add_to_patron_list">
356                               <option value=""></option>
357                               [% IF patron_lists %]
358                                   <optgroup label="Patron lists:">
359                                       [% FOREACH pl IN patron_lists %]
360                                           <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
361                                       [% END %]
362                                   </optgroup>
363                               [% END %]
364
365                               <option value="new">[ New list ]</option>
366                           </select>
367
368                           <input type="text" id="new_patron_list" name="new_patron_list" id="new_patron_list" />
369
370                           <input id="add_to_patron_list_submit" type="submit" class="submit" value="Save">
371                       </span>
372                   </div>
373               </div>
374             [% END %]
375
376             <table id="memberresultst">
377               <thead>
378                 <tr>
379                 [% IF CAN_user_tools_manage_patron_lists %]
380                   <th>&nbsp;</th>
381                 [% END %]
382                   <th>Card</th>
383                   <th>Name</th>
384                   <th>Category</th>
385                   <th>Library</th>
386                   <th>Expires on</th>
387                   <th>OD/Checkouts</th>
388                   <th>Fines</th>
389                   <th>Circ note</th>
390                   <th>&nbsp;</th>
391                 </tr>
392               </thead>
393               <tbody></tbody>
394             </table>
395           </div>
396         </div>
397       </div>
398     </div>
399     <div class="yui-b">
400       <form onsubmit="return filter();" id="searchform">
401         <input type="hidden" id="firstletter_filter" value="" />
402         <fieldset class="brief">
403           <h3>Filters</h3>
404           <ol>
405             <li>
406               <label for="searchmember_filter">Search:</label>
407               <input type="text" id="searchmember_filter" value="[% searchmember %]"/>
408             </li>
409             <li>
410               <label for="searchfieldstype_filter">Search fields:</label>
411               <select name="searchfieldstype" id="searchfieldstype_filter">
412                 [% IF searchfieldstype == "standard" %]
413                   <option selected="selected" value='standard'>Standard</option>
414                 [% ELSE %]
415                   <option value='standard'>Standard</option>
416                 [% END %]
417                 [% IF searchfieldstype == "email" %]
418                   <option selected="selected" value='email'>Email</option>
419                 [% ELSE %]
420                   <option value='email'>Email</option>
421                 [% END %]
422                 [% IF searchfieldstype == "borrowernumber" %]
423                   <option selected="selected" value='borrowernumber'>Borrower number</option>
424                 [% ELSE %]
425                   <option value='borrowernumber'>Borrower number</option>
426                 [% END %]
427                 [% IF searchfieldstype == "userid" %]
428                   <option selected="selected" value='userid'>Username</option>
429                 [% ELSE %]
430                   <option value='userid'>Username</option>
431                 [% END %]
432                 [% IF searchfieldstype == "phone" %]
433                   <option selected="selected" value='phone'>Phone number</option>
434                 [% ELSE %]
435                   <option value='phone'>Phone number</option>
436                 [% END %]
437                 [% IF searchfieldstype == "address" %]
438                   <option selected="selected" value='address'>Street address</option>
439                 [% ELSE %]
440                   <option value='address'>Street address</option>
441                 [% END %]
442                 [% IF searchfieldstype == "dateofbirth" %]
443                   <option selected="selected" value='dateofbirth'>Date of birth</option>
444                 [% ELSE %]
445                   <option value='dateofbirth'>Date of birth</option>
446                 [% END %]
447                 [% IF searchfieldstype == "sort1" %]
448                   <option selected="selected" value='sort1'>Sort field 1</option>
449                 [% ELSE %]
450                   <option value='sort1'>Sort field 1</option>
451                 [% END %]
452                 [% IF searchfieldstype == "sort2" %]
453                   <option selected="selected" value='sort2'>Sort field 2</option>
454                 [% ELSE %]
455                   <option value='sort2'>Sort field 2</option>
456                 [% END %]
457               </select>
458             </li>
459             <li>
460               <label for="searchtype_filter">Search type:</label>
461               <select name="searchtype" id="searchtype_filter">
462                 <option value='start_with'>Starts with</option>
463                 [% IF searchtype == "contain" %]
464                   <option value="contain" selected="selected">Contains</option>
465                 [% ELSE %]
466                   <option value="contain" selected="selected">Contains</option>
467                 [% END %]
468               </select>
469             </li>
470             <li>
471               <label for="categorycode_filter">Category:</label>
472               [% SET categories = Categories.all( selected => categorycode_filter ) %]
473               <select id="categorycode_filter">
474                 <option value="">Any</option>
475                 [% FOREACH cat IN categories %]
476                   [% IF cat.selected %]
477                     <option selected="selected" value="[% cat.categorycode %]">[% cat.description %]</option>
478                   [% ELSE %]
479                     <option value="[% cat.categorycode %]">[% cat.description %]</option>
480                   [% END %]
481                 [% END %]
482               </select>
483             </li>
484             <li>
485               <label for="branchcode_filter">Library:</label>
486               [% SET branches = Branches.all( selected => branchcode_filter ) %]
487               <select id="branchcode_filter">
488                 [% IF branches.size != 1 %]
489                   <option value="">Any</option>
490                 [% END %]
491                 [% FOREACH b IN branches %]
492                   [% IF b.selected %]
493                     <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
494                   [% ELSE %]
495                     <option value="[% b.branchcode %]">[% b.branchname %]</option>
496                   [% END %]
497                 [% END %]
498               </select>
499             </li>
500           </ol>
501           <fieldset class="action">
502             <input type="submit" value="Search" />
503             <input type="button" value="Clear" onclick="clearFilters(true);" />
504           </fieldset>
505         </fieldset>
506       </form>
507     </div>
508   </div>
509   <div class="yui-g">
510     [% INCLUDE 'members-menu.inc' %]
511   </div>
512 </div>
513 [% INCLUDE 'intranet-bottom.inc' %]