8bfc06d61ac77aa100ff591c1ff4a36892333503
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / library_groups.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaSpan %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Administration &rsaquo; Library groups</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 [% Asset.css("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") | $raw %]
9 </head>
10
11 <body id="admin_library_groups" class="admin">
12 [% INCLUDE 'header.inc' %]
13 [% INCLUDE 'cat-search.inc' %]
14
15 <div id="breadcrumbs">
16     <a href="/cgi-bin/koha/mainpage.pl">Home</a>
17     &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
18     &rsaquo; <a href="/cgi-bin/koha/admin/library_groups.pl">Library groups</a>
19 </div>
20
21 [% FOR m IN messages %]
22     <div class="dialog [% m.type | html %]">
23         [% SWITCH m.code %]
24         [% CASE 'error_on_insert' %]
25             An error occurred when adding this library. The library id might already exist in this group.
26         [% CASE %]
27             [% m.code | html %]
28         [% END %]
29     </div>
30 [% END %]
31
32 [% IF added %]
33     <div class="dialog message group-added">
34         [% IF added.branchcode %]
35             [% added.library.branchname | $KohaSpan class = 'name' | $raw %] added to group.
36         [% ELSE %]
37             Group [% added.title | $KohaSpan class = 'name' | $raw %] created.
38         [% END %]
39     </div>
40 [% ELSIF deleted %]
41     <div class="dialog message group-deleted">
42         [% IF deleted.title %]
43             Group [% deleted.title | $KohaSpan class = 'name' | $raw %] has been deleted.
44         [% ELSE %]
45             [% deleted.library | $KohaSpan class = 'name' | $raw %] has been removed from group.
46         [% END %]
47     </div>
48 [% ELSIF error_duplicate_title %]
49     <div class="dialog alert error-duplicate-group-title">
50             A group with the title [% error_duplicate_title | $KohaSpan class = 'name' | $raw %] already exists.
51     </div>
52 [% END %]
53
54 <div class="main container-fluid">
55     <div class="row">
56         <div class="col-sm-10 col-sm-push-2">
57             <main>
58
59                     <div id="toolbar" class="btn-toolbar">
60                         <div class="btn-group">
61                             <a id="add-group-root" class="btn btn-default add-group" href="#">
62                                 <i class="fa fa-plus"></i> Add group
63                             </a>
64                         </div>
65                     </div>
66
67                 <h2>Library groups</h2>
68
69                 [% FOREACH root_group IN root_groups %]
70                     <table class="library-groups">
71                         <tr>
72                             <th>&nbsp;</th>
73                             <th>Description</th>
74                             <th>Features enabled</th>
75                             <th>&nbsp;</th>
76                         </tr>
77                         [% PROCESS tree group=root_group %]
78                     </table>
79                 [% END %]
80
81             </main>
82         </div> <!-- /.col-sm-10.col-sm-push-2 -->
83
84         <div class="col-sm-2 col-sm-pull-10">
85             <aside>
86                 [% INCLUDE 'admin-menu.inc' %]
87             </aside>
88         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
89     </div> <!-- /.row -->
90
91     <div id="add-group-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="add-group-modal-label" aria-hidden="true">
92         <form id="add-group-form" action="/cgi-bin/koha/admin/library_groups.pl" class="form-horizontal">
93             <div class="modal-dialog">
94                 <div class="modal-content">
95                     <div class="modal-header">
96                         <h3 id="add-group-modal-label">Add group</h3>
97                     </div>
98                     <div class="modal-body">
99                         <fieldset class="rows">
100                             <input type="hidden" id="add-group-modal-parent-id" name="parent_id" value="" />
101                             <input type="hidden" id="add-group-modal-action" name="action" value="add">
102                             <ol>
103                                 <li>
104                                     <label for="add-group-modal-title">Title: </label>
105                                     <input type="text" size="40" maxlength="100" name="title" id="add-group-modal-title" required="required" />
106                                     <span class="required">Required</span>
107                                 </li>
108                                 <li>
109                                     <label for="add-group-modal-description">Description: </label>
110                                     <input type="text" size="40" name="description" id="add-group-modal-description" />
111                                 </li>
112                             </ol>
113                         </fieldset>
114                         <div id="root-group-features-add">
115                             <h3>Features</h3>
116                             <div class="checkbox">
117                                 <p>
118                                     <label>
119                                         <input type="checkbox" name="ft_hide_patron_info" id="add-group-modal-ft_hide_patron_info" value="1" />
120                                         Limit patron data access by group
121                                     </label>
122                                 </p>
123                                 <p>
124                                     <label>
125                                         <input type="checkbox" name="ft_search_groups_opac" id="add-group-modal-ft_search_groups_opac" value="1" />
126                                         Use for OPAC search groups
127                                     </label>
128                                 </p>
129                                 <p>
130                                     <label>
131                                         <input type="checkbox" name="ft_search_groups_staff" id="add-group-modal-ft_search_groups_staff" value="1" />
132                                         Use for staff search groups
133                                     </label>
134                                 </p>
135                                 <p>
136                                     <label>
137                                         <input type="checkbox" name="ft_local_hold_group" id="add-group-modal-ft_local_hold_group" value="1" />
138                                         Is local hold group
139                                     </label>
140                                 </p>
141                             </div>
142                         </div>
143                     </div>
144                     <div class="modal-footer">
145                         <button type="submit" class="btn btn-default">Save</button>
146                         <a href="#" class="cancel" data-dismiss="modal" aria-hidden="true">Cancel</a>
147                     </div>
148                 </div>
149             </div>
150         </form>
151     </div>
152
153     <div id="edit-group-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="edit-group-modal-label" aria-hidden="true">
154         <form id="edit-group-form" action="/cgi-bin/koha/admin/library_groups.pl" class="form-horizontal">
155             <div class="modal-dialog">
156                 <div class="modal-content">
157                     <div class="modal-header">
158                         <h3 id="edit-group-modal-label">Edit group</h3>
159                     </div>
160                     <div class="modal-body">
161                         <input type="hidden" id="edit-group-modal-id" name="id" value="" />
162                         <input type="hidden" id="edit-group-modal-action" name="action" value="edit" />
163                         <fieldset class="rows">
164                             <ol>
165                                 <li>
166                                     <label for="edit-group-modal-title">Title: </label>
167                                     <input type="text" size="40" maxlength="100" id="edit-group-modal-title" name="title" value="" required="required" />
168                                     <span class="required">Required</span>
169                                 </li>
170
171                                 <li>
172                                     <label for="edit-group-modal-description">Description: </label>
173                                     <input type="text" size="40" id="edit-group-modal-description" name="description" value="" />
174                                 </li>
175                             </ol>
176                         </fieldset>
177                         <div id="root-group-features-edit">
178                             <h3>Features</h3>
179                             <div class="checkbox">
180                                 <p>
181                                     <label>
182                                         <input type="checkbox" id="edit-group-modal-ft_hide_patron_info" name="ft_hide_patron_info" value="1" />
183                                         Limit patron data access by group
184                                     </label>
185                                 </p>
186                                 <p>
187                                     <label>
188                                         <input type="checkbox" id="edit-group-modal-ft_search_groups_opac" name="ft_search_groups_opac" value="1" />
189                                         Use for OPAC search groups
190                                     </label>
191                                 </p>
192                                 <p>
193                                     <label>
194                                         <input type="checkbox" id="edit-group-modal-ft_search_groups_staff" name="ft_search_groups_staff" value="1" />
195                                         Use for staff search groups
196                                     </label>
197                                 </p>
198                                 <p>
199                                     <label>
200                                         <input type="checkbox" id="edit-group-modal-ft_local_hold_group" name="ft_local_hold_group" value="1" />
201                                         Is local hold group
202                                     </label>
203                                 </p>
204                             </div>
205                         </div>
206                     </div>
207                     <div class="modal-footer">
208                         <button type="submit" class="btn btn-default">Update</button>
209                         <a href="#" class="cancel" data-dismiss="modal" aria-hidden="true">Cancel</a>
210                     </div>
211                 </div>
212             </div>
213         </form>
214     </div>
215
216     <div id="delete-group-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete-group-modal-label" aria-hidden="true">
217         <form action="/cgi-bin/koha/admin/library_groups.pl">
218             <div class="modal-dialog">
219                 <div class="modal-content">
220                     <input id="delete-group-modal-action" type="hidden" name="action" value="delete" />
221                     <input id="delete-group-modal-id" type="hidden" name="id" value="" />
222                     <div class="modal-header">
223                         <h3 id="delete-group-modal-label">Delete group</h3>
224                     </div>
225                     <div class="modal-body">
226                         Are you sure you want to delete <span id="delete-group-modal-title" class="name"></span>?
227                     </div>
228                     <div class="modal-footer">
229                         <button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i> Delete</button>
230                         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
231                     </div>
232                 </div>
233             </div>
234         </form>
235     </div>
236
237     <div id="remove-library-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="remove-library-modal-label" aria-hidden="true">
238         <form action="/cgi-bin/koha/admin/library_groups.pl">
239             <div class="modal-dialog">
240                 <div class="modal-content">
241                     <input id="remove-library-modal-action" type="hidden" name="action" value="delete" />
242                     <input id="remove-library-modal-id" type="hidden" name="id" value="" />
243                     <div class="modal-header">
244                         <h3 id="remove-library-modal-label">Remove library from group</h3>
245                     </div>
246                     <div class="modal-body">
247                         Are you sure you want to remove <span id="remove-library-modal-library" class="name"></span> from <span id="remove-library-modal-group" class="name"></span>?
248                     </div>
249                     <div class="modal-footer">
250                         <button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i> Remove</button>
251                         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
252                     </div>
253                 </div>
254             </div>
255         </form>
256     </div>
257
258 [% MACRO jsinclude BLOCK %]
259     [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
260     <script>
261         $(document).ready(function() {
262             $('.library-groups').treetable({
263                 expandable: true,
264                 initialState: 'expanded',
265                 clickableNodeNames: true,
266             });
267
268             $('.add-group').on('click', function(e) {
269                 e.preventDefault();
270                 var id = $(this).data('groupId');
271                 add_group( id );
272             });
273
274             $('.edit-group').on('click', function(e) {
275                 e.preventDefault();
276                 var id = $(this).data('groupId');
277                 var parent_id = $(this).data('groupParentId');
278                 var title = $(this).data('groupTitle');
279                 var description = $(this).data('groupDescription');
280                 var ft_hide_patron_info = $(this).data('groupFt_hide_patron_info');
281                 var ft_search_groups_opac = $(this).data('groupFt_search_groups_opac');
282                 var ft_search_groups_staff = $(this).data('groupFt_search_groups_staff');
283                 var ft_local_hold_group = $(this).data('groupFt_local_hold_group');
284                 edit_group( id, parent_id, title, description, ft_hide_patron_info, ft_search_groups_opac, ft_search_groups_staff, ft_local_hold_group );
285             });
286
287             $('.delete-group').on('click', function(e) {
288                 e.preventDefault();
289                 var id = $(this).data('groupId');
290                 var title = $(this).data('groupTitle');
291                 delete_group( id, title );
292             });
293
294             $('.remove-library').on('click', function(e) {
295                 e.preventDefault();
296                 var id = $(this).data('groupId');
297                 var library = $(this).data('groupLibrary');
298                 var parent_title = $(this).data('groupParentTitle');
299                 remove_library( id, library, parent_title );
300             });
301             $('#add-group-modal').on('shown.bs.modal', function() {
302                 $('#add-group-modal-title').focus();
303             });
304             $('#edit-group-modal').on('shown.bs.modal', function() {
305                 $('#edit-group-modal-title').focus();
306             });
307         });
308
309         function add_group( parent_id ) {
310             $('#add-group-modal-parent-id').val( parent_id );
311
312             $('#add-group-modal-description').val("");
313             $('#add-group-modal-title').val("");
314
315
316             $('#add-group-modal-ft_hide_patron_info').prop('checked', false);
317             $('#add-group-modal-ft_search_groups_opac').prop('checked', false);
318             $('#add-group-modal-ft_search_groups_staff').prop('checked', false);
319             $('#add-group-modal-ft_local_hold_group').prop('checked', false);
320             if ( parent_id ) {
321                 $('#root-group-features-add').hide();
322             } else {
323                 $('#root-group-features-add').show();
324             }
325             $('#add-group-modal').modal('show');
326
327         }
328
329         function edit_group( id, parent_id, title, description, ft_hide_patron_info, ft_search_groups_opac, ft_search_groups_staff, ft_local_hold_group ) {
330             $('#edit-group-modal-id').val( id );
331             $('#edit-group-modal-title').val( title );
332             $('#edit-group-modal-description').val( description );
333
334             if ( parent_id ) {
335                 $('#edit-group-modal-ft_hide_patron_info').prop('checked', false);
336                 $('#edit-group-modal-ft_search_groups_opac').prop('checked', false);
337                 $('#edit-group-modal-ft_search_groups_staff').prop('checked', false);
338                 $('#edit-group-modal-ft_local_hold_group').prop('checked', false);
339                 $('#root-group-features-edit').hide();
340             } else {
341                 $('#edit-group-modal-ft_hide_patron_info').prop('checked', ft_hide_patron_info ? true : false );
342                 $('#edit-group-modal-ft_search_groups_opac').prop('checked', ft_search_groups_opac ? true : false );
343                 $('#edit-group-modal-ft_search_groups_staff').prop('checked', ft_search_groups_staff ? true : false );
344                 $('#edit-group-modal-ft_local_hold_group').prop('checked', ft_local_hold_group ? true : false );
345                 $('#root-group-features-edit').show();
346             }
347
348             $('#edit-group-modal').modal('show');
349         }
350
351         function delete_group( id, title ) {
352             $('#delete-group-modal-title').html(title);
353             $('#delete-group-modal-id').val( id );
354             $('#delete-group-modal').modal('show');
355         }
356
357         function remove_library( id, library, parent_title ) {
358             $('#remove-library-modal-library').html( library );
359             $('#remove-library-modal-group').html(parent_title);
360             $('#remove-library-modal-id').val( id );
361             $('#remove-library-modal').modal('show');
362         }
363
364     </script>
365 [% END %]
366
367 [% INCLUDE 'intranet-bottom.inc' %]
368
369 [% BLOCK tree %]
370     <tr data-tt-id="[% group.id | html %]" data-tt-parent-id="[% group.parent_id | html %]">
371         <td>
372             [% IF group.branchcode %]
373                 [% group.branchcode | html %]
374             [% ELSE %]
375                 [% group.title | html %]
376             [% END %]
377         </td>
378         <td>
379             [% IF group.branchcode %]
380                 [% group.library.branchname | html %]
381             [% ELSE %]
382                 [% group.description | html %]
383             [% END %]
384         </td>
385         <td>
386             [% UNLESS group.branchcode %]
387               <ul>
388                 [% IF group.ft_hide_patron_info %]
389                     <li>Hide patron's info for librarians outside of this group.</li>
390                 [% END %]
391                 [% IF group.ft_search_groups_opac %]
392                     <li>Use for OPAC search groups</li>
393                 [% END %]
394                 [% IF group.ft_search_groups_staff %]
395                     <li>Use for staff search groups</li>
396                 [% END %]
397                 [% IF group.ft_local_hold_group %]
398                     <li>Is local hold group</li>
399                 [% END %]
400               </ul>
401             [% END %]
402         </td>
403         <td>
404             [% IF group.branchcode %]
405                 <button class="btn btn-default btn-xs remove-library" data-group-id="[% group.id | html %]" data-group-library="[% group.library.branchname | html %]" data-group-parent-title="[% group.parent.title | html %]" ><i class="fa fa-trash"></i> Remove from group</button>
406             [% ELSE %]
407                 <div class="btn-group">
408                     <button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown"><i class="fa fa-wrench"></i> Actions <span class="caret"></span></button>
409                     <ul class="dropdown-menu">
410                         <li>
411                             <a id="add-group-[% group.id | html %]" href="#" class="add-group" data-group-id="[% group.id | html %]">
412                                 <i class="fa fa-plus"></i> Add sub-group
413                             </a>
414                        </li>
415
416                         <li>
417                             <a class="edit-group" id="edit-group-[% group.id | html %]" href="#" data-group-id="[% group.id | html %]" data-group-parent-id="[% group.parent_id | html %]" data-group-title="[% group.title | html %]" data-group-description="[% group.description | html %]" data-group-ft_hide_patron_info="[% group.ft_hide_patron_info | html %]" data-group-ft_search_groups_opac="[% group.ft_search_groups_opac | html %]" data-group-ft_search_groups_staff="[% group.ft_search_groups_staff | html %]" data-group-ft_local_hold_group="[% group.ft_local_hold_group | html %]" >
418                                 <i class="fa fa-pencil"></i> Edit
419                             </a>
420                        </li>
421
422                         <li>
423                             <a class="delete-group" id="delete-group-[% group.id | html %]" href="#" data-group-id="[% group.id | html %]" data-group-title="[% group.title | html %]">
424                                 <i class="fa fa-trash"></i> Delete
425                             </a>
426                        </li>
427                     </ul>
428                 </div>
429
430                 <div class="btn-group">
431                     <button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> Add library <span class="caret"></span></button>
432                     <ul class="dropdown-menu">
433                         [% FOREACH library IN group.libraries_not_direct_children %]
434                             <li>
435                                 <a class="add-library" id="add-library[% library.id | html %]-[% group.id | html %]" href="/cgi-bin/koha/admin/library_groups.pl?action=add&parent_id=[% group.id | html %]&branchcode=[% library.id | html %]">
436                                     [% library.branchname | html %]
437                                 </a>
438                            </li>
439                         [% END %]
440                     </ul>
441                 </div>
442             [% END %]
443         </td>
444     </tr>
445
446     [% FOREACH g IN group.children %]
447         [% PROCESS tree group=g %]
448     [% END %]
449 [% END %]