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