Bug 23838: Use $datetime formater
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / member.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE TablesSettings %]
5 [% USE Branches %]
6 [% USE Categories %]
7 [% SET footerjs = 1 %]
8 [% PROCESS 'patronfields.inc' %]
9 [% SET libraries = Branches.all %]
10 [% SET categories = Categories.all.unblessed %]
11 [% SET columns = ['cardnumber', 'name-address', 'dateofbirth', 'branch', 'category', 'dateexpiry', 'checkouts', 'account_balance', 'borrowernotes', 'action'] %]
12 [% PROCESS 'patron-search.inc' %]
13 [% INCLUDE 'doc-head-open.inc' %]
14 <title>Patrons[% IF ( searching ) %] &rsaquo; Search results[% END %] &rsaquo; Koha</title>
15 [% INCLUDE 'doc-head-close.inc' %]
16 </head>
17
18 <body id="pat_member" class="pat">
19 [% INCLUDE 'header.inc' %]
20 [% INCLUDE 'patron-search-header.inc' %]
21
22 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
23     <ol>
24         <li>
25             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
26         </li>
27         [% IF ( searching ) %]
28             <li>
29                 <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
30             </li>
31             <li>
32                 <a href="#" aria-current="page">
33                     Search results
34                 </a>
35             </li>
36         [% ELSE %]
37             <li>
38                 <a href="#" aria-current="page">
39                     Patrons
40                 </a>
41             </li>
42         [% END %]
43     </ol>
44 </nav>
45
46 <div class="main container-fluid">
47     <div class="row">
48         <div class="col-sm-10 col-sm-push-2">
49             <main>
50
51           [% IF CAN_user_tools_manage_patron_lists %]
52             <div id="patron_list_dialog" class="dialog message">
53               Added <span class="patrons-length"></span> patrons to <a></a>.
54             </div>
55           [% END %]
56
57           [% INCLUDE 'patron-toolbar.inc' %]
58           [% INCLUDE 'noadd-warnings.inc' %]
59
60           [% IF CAN_user_borrowers_edit_borrowers && pending_borrower_modifications %]
61             <div class="pending-info" id="patron_updates_pending">
62               <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
63               <span class="number_box"><a href="/cgi-bin/koha/members/members-update.pl">[% pending_borrower_modifications | html %]</a></span>
64             </div>
65           [% END %]
66
67           <div id="searchresults">
68             [% IF CAN_user_tools_manage_patron_lists || CAN_user_borrowers_edit_borrowers %]
69               <div class="searchheader fh-fixedHeader" id="searchheader" style="display:none;">
70                   <div>
71                       <a href="#" class="btn btn-link" id="select_all"><i class="fa fa-check"></i> Select all</a>
72                       |
73                       <a href="#" class="btn btn-link" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
74                     [% IF CAN_user_tools_manage_patron_lists %]
75
76                     [% END %]
77
78                     [% IF CAN_user_tools_manage_patron_lists %]
79                         <div id="patronlist-dropdown" class="btn-group">
80                             <button id="patronlist-menu" type="button" class="btn btn-sm btn-default dropdown-toggle patron-edits disabled" disabled="disabled" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
81                                 Add to patron list <span class="caret"></span>
82                             </button>
83                             <ul class="dropdown-menu">
84                                 [% IF patron_lists %]
85                                     [% FOREACH pl IN patron_lists %]
86                                         <li><a href="#" class="patron-list-add" data-listid="[% pl.patron_list_id | html %]">[% pl.name | html %]</a></li>
87                                     [% END %]
88                                 [% END %]
89                                 <li role="separator" class="divider"></li>
90                                 <li><a href="#" class="patron-list-add" data-listid="new">New list</a></li>
91                             </ul>
92                         </div>
93                     [% END %]
94
95                     [% IF CAN_user_borrowers_edit_borrowers %]
96                           <button id="merge-patrons" class="btn btn-sm btn-default disabled" disabled="disabled" type="submit"><i class="fa fa-compress" aria-hidden="true"></i> Merge selected patrons</button>
97                     [% END %]
98                   </div>
99                 </div>
100             [% END %]
101
102             [% IF CAN_user_borrowers_edit_borrowers || CAN_user_tools_manage_patron_lists %]
103                 [% columns.unshift('checkbox') | html %]
104             [% END %]
105             [% PROCESS patron_search_table table_id => 'memberresultst' columns => columns %]
106           </div>
107
108             </main>
109         </div> <!-- /.col-sm-10.col-sm-push-2 -->
110
111         <div class="col-sm-2 col-sm-pull-10">
112             <aside>
113                 [% PROCESS patron_search_filters categories => categories, libraries => libraries, filters => ['search_field', 'search_type', 'category', 'branch'], search_filter => searchmember %]
114             </aside>
115         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
116     </div> <!-- /.row -->
117
118     <!-- New Patron List Modal -->
119     <div class="modal" id="new-patron-list" tabindex="-1" role="dialog" aria-labelledby="new-patron-listLabel">
120         <div class="modal-dialog" role="document">
121             <div class="modal-content">
122                 <div class="modal-header">
123                     <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
124                     <h4 class="modal-title" id="new-patron-listLabel">Add patrons to a new patron list</h4>
125                 </div>
126                 <form id="new-patron-list_form">
127                     <div class="modal-body">
128                         <div class="form-group">
129                             <label for="new_patron_list" class="required">Patron list name: </label>
130                             <input class="form-control required" type="text" name="new_patron_list" id="new_patron_list" required="required" />
131                             <input type="hidden" name="add_to_patron_list" id="add_to_patron_list" />
132                             <span class="required">Required</span>
133                         </div>
134                     </div> <!-- /.modal-body -->
135                     <div class="modal-footer">
136                         <button type="submit" id="add_to_patron_list_submit" class="btn btn-default approve">Submit</button>
137                         <button type="button" class="btn btn-default deny" data-dismiss="modal">Cancel</button>
138                     </div> <!-- /.modal-footer -->
139                 </form> <!-- /#new-patron-list_form -->
140             </div> <!-- /.modal-content -->
141         </div> <!-- /.modal-dialog -->
142     </div> <!-- /#new-patron-list -->
143
144 [% MACRO jsinclude BLOCK %]
145     [% INCLUDE 'datatables.inc' %]
146     [% INCLUDE 'columns_settings.inc' %]
147     [% INCLUDE 'str/members-menu.inc' %]
148     [% Asset.js("js/members-menu.js") | $raw %]
149     <script>
150
151         $(document).ready(function() {
152             $('#merge-patrons').prop('disabled', true);
153             $('#memberresultst').on('change', 'input.selection', function() {
154                 if ( $('.selection:checked').length > 1 ) {
155                     /* More than one checkbox has been checked */
156                     $('#merge-patrons').prop('disabled', false).removeClass("disabled");
157                     $("#patronlist-menu").removeClass("disabled").prop("disabled", false);
158                 } else if ( $('.selection:checked').length == 1 ) {
159                     /* At least one checkbox has been checked */
160                     $('#merge-patrons').prop('disabled', true).addClass("disabled");
161                     $("#patronlist-menu").removeClass("disabled").prop("disabled", false);
162                 } else {
163                     /* No checkbox has been checked */
164                     $('#merge-patrons').prop('disabled', true).addClass("disabled");
165                     $("#patronlist-menu").addClass("disabled").prop("disabled", true);
166                 }
167             });
168
169             $('#merge-patrons').on('click', function() {
170                 var merge_patrons_url = 'merge-patrons.pl?' + $('.selection:checked')
171                     .map(function() {
172                        return "id=" + $(this).val()
173                     }).get().join('&');
174                 window.location.href = merge_patrons_url;
175             });
176
177             $("#patronlist-dropdown").on("click", ".patron-list-add", function(e){
178                 e.preventDefault();
179
180                 if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
181                     alert( _("You have not selected any patrons to add to a list!") );
182                     $(".btn-group").removeClass("open"); /* Close button menu */
183                     return false;
184                 }
185
186                 var listid = $(this).data("listid");
187                 $("#add_to_patron_list").val( listid );
188                 if( listid == "new" ){
189                     /* #add_to_patron_list value "new" in the modal form will tell API to create a new list */
190                     $("#new-patron-list").modal("show");
191                 } else {
192                     /* Ajax submit the patrons to list */
193
194                     patronListAdd();
195                 }
196             })
197
198             /* Submit selected patrons to a list via AJAX */
199             $("#new-patron-list_form").on('submit', function(e){
200                 e.preventDefault();
201                 /* Upon submitting modal patron list add form... */
202                 if ( $('#new_patron_list').val() ) {
203                     $(".patron-list-add").each(function() {
204                         /* Check each list name in the menu of patron lists */
205                         /* If submitted list name matches... */
206                         if ( $(this).text() == $('#new_patron_list').val() ) {
207                             alert( _("You already have a list with that name!") );
208                             return false;
209                         }
210                     });
211                 } else {
212                     alert( _("You must give your new patron list a name!") );
213                     return false;
214                 }
215                 $("#new-patron-list").modal("hide");
216                 patronListAdd();
217             });
218
219             $("#select_all").on("click",function(e){
220                 e.preventDefault();
221                 $(".selection").prop("checked", true).change();
222             });
223             $("#clear_all").on("click",function(e){
224                 e.preventDefault();
225                 $(".selection").prop("checked", false).change();
226             });
227
228             [% IF searchmember %]
229                 $("#searchmember_filter").val("[% searchmember | html %]");
230             [% END %]
231             [% IF searchfieldstype %]
232                 $("searchfieldstype_filter").val("[% searchfieldstype | html %]");
233             [% END %]
234             [% IF searchtype %]
235                 $("#searchtype_filter").val("[% searchtype | html %]");
236             [% END %]
237             [% IF categorycode %]
238                 $("#categorycode_filter").val("[% categorycode_filter | html %]");
239             [% END %]
240             [% IF branchcode %]
241                 $("#branchcode_filter").val("[% branchcode_filter | html %]");
242             [% END %]
243
244             $("#searchheader").hide();
245             $("#patron_search_form").on('submit', function(){$("#searchheader").show();});
246             $("#clear_search").on("click",function(e){$("#searchheader").hide();});
247         });
248
249         function patronListAdd(){
250             var borrowernumbers = [];
251             $("#memberresultst").find("input:checkbox:checked").each(function(){
252                 borrowernumbers.push($(this).val());
253             });
254             var data = {
255                 add_to_patron_list: $("#add_to_patron_list").val(),
256                 new_patron_list: $("#new_patron_list").val(),
257                 borrowernumbers: borrowernumbers
258             };
259             $.ajax({
260                 data: data,
261                 type: 'POST',
262                 url: '/cgi-bin/koha/svc/members/add_to_list',
263                 success: function(data) {
264                     $("#patron_list_dialog").show();
265                     $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
266                     $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
267                     $("#patron_list_dialog > a").html(data.patron_list.name);
268
269                     if ( $('#add_to_patron_list').val() == 'new' ) {
270                         /* Add a new entry to the menu */
271                         $("#patronlist-dropdown .divider").before('<li><a class="patron-list-add" href="#" data-listid="' + data.patron_list.patron_list_id + '">' + data.patron_list.name + '</li>');
272                     }
273                 },
274                 error: function() {
275                     alert( _("An error occurred. Patron list could not be updated.") );
276                 }
277             });
278             return true;
279         }
280
281         $('#memberresultst tbody').on('click','td',function(e){
282             var $checkbox = $(this).find("input[type=checkbox]");
283             if (e.target.type != "checkbox") {
284                 $checkbox.prop('checked', !$checkbox.prop("checked"));
285                 $checkbox.change();
286             }
287         });
288
289     </script>
290
291     <script>
292         // Apply DataTables on the results table
293         var table_settings = [% TablesSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) | $raw %];
294         [% UNLESS CAN_user_borrowers_edit_borrowers OR CAN_user_tools_manage_patron_lists %]
295             [%# Remove the first column if we do not display the checkbox %]
296             table_settings['columns'].splice(0, 1);
297         [% END %]
298     </script>
299
300     [% IF circsearch == 1 %]
301         [% SET redirect_url = '/cgi-bin/koha/circ/circulation.pl' %]
302     [% ELSE %]
303         [% SET redirect_url = '/cgi-bin/koha/members/moremember.pl' %]
304     [% END %]
305     [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns,actions => ['edit', 'checkout'], redirect_if_one_result => 1, redirect_url => redirect_url, sticky_header => "searchheader", sticky_to => "searchresults", default_sort_column => 'name-address', display_search_description => 1 %]
306
307 [% END %]
308
309 [% INCLUDE 'intranet-bottom.inc' %]