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