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