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