Bug 21578: Terminology changes in patron's account section (staff)
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / member-flags.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Branches %]
4 [% SET footerjs = 1 %]
5 [% PROCESS 'permissions.inc' %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Patrons &rsaquo; Set permissions for [% patron.surname | html %], [% patron.firstname | html %]</title>
8 [% Asset.css("css/treeview/jquery.treeview.css") | $raw %]
9 [% INCLUDE 'doc-head-close.inc' %]
10 </head>
11
12 <body id="pat_member-flags" class="pat">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'patron-search.inc' %]
15
16 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Set permissions for [% patron.surname | html %], [% patron.firstname | html %]</div>
17
18 <div id="doc3" class="yui-t2">
19    
20    <div id="bd">
21         <div id="yui-main">
22         <div class="yui-b">
23 [% INCLUDE 'members-toolbar.inc' %]
24
25 <form method="post" action="/cgi-bin/koha/members/member-flags.pl">
26     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
27     <input type="hidden" name="member" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
28     <input type="hidden" name="newflags" value="1" />
29     <h1>Set permissions for [% patron.surname | html %], [% patron.firstname | html %]</h1>
30     <!-- <ul id="permissionstree"><li class="root">All privileges<ul> -->
31     <ul id="permissionstree" class="treeview-grey">
32         <!-- <li class="folder-close">One level down<ul> -->
33     [% FOREACH loo IN loop %]
34         [% IF ( loo.expand ) %]
35         <li class="open">
36         [% ELSE %]
37         <li>
38         [% END %]
39                         [% IF ( loo.checked ) %]
40           [% IF disable_superlibrarian_privs && loo.bit == 0 %]
41               <input type="checkbox" disabled="disabled" class="flag parent superlib" id="flag-[% loo.bit | html %]_disabled" name="flag" value="[% loo.flag | html %]" checked="checked" title="The system preference ProtectSuperlibrarianPrivileges is enabled" />
42               <input type="hidden" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" >
43           [% ELSE %]
44               <input type="checkbox" class="flag parent" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" checked="checked" />
45           [% END %]
46                         [% ELSE %]
47           [% IF disable_superlibrarian_privs && loo.bit == 0 %]
48               <input type="checkbox" disabled="disabled" class="flag parent" id="flag-[% loo.bit | html %]_disabled" name="flag" value="[% loo.flag | html %]" title="The system preference ProtectSuperlibrarianPrivileges is enabled" />
49           [% ELSE %]
50               <input type="checkbox" class="flag parent" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" />
51           [% END %]
52                         [% END %]
53                 <label class="permissioncode" for="flag-[% loo.bit | html %]">[% loo.flag | html %]</label>
54                 <span class="permissiondesc">[% PROCESS main_permissions name=loo.flag %]</span>
55             [% IF ( loo.sub_perm_loop ) %]
56                 <ul id="flag-[% loo.bit | html %]-children">
57                     [% FOREACH sub_perm_loo IN loo.sub_perm_loop %]
58                         <li>
59                                     [% IF ( sub_perm_loo.checked ) %]
60                             <input type="checkbox" class="flag child" id="[% sub_perm_loo.id | html %]" name="flag" value="[% sub_perm_loo.perm | html %]" checked="checked" />
61                                     [% ELSE %]
62                             <input type="checkbox" class="flag child" id="[% sub_perm_loo.id | html %]" name="flag" value="[% sub_perm_loo.perm | html %]" />
63                                     [% END %]
64                     <label class="permissioncode" for="[% sub_perm_loo.id | html %]">[% sub_perm_loo.code | html %]</label>
65                              <span class="permissiondesc">[% PROCESS sub_permissions name=sub_perm_loo.code %]</span>
66                         </li>
67                     [% END %]
68                 </ul>
69                 </li>
70             [% ELSE %]
71                 </li>
72                         [% END %]
73     [% END %]
74         <!-- </ul></li> -->
75     <!-- </ul></li></ul> -->
76     </ul>
77
78 <fieldset class="action"><input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a></fieldset>
79
80 </form>
81 </div>
82 </div>
83
84 <div class="yui-b">
85 [% INCLUDE 'circ-menu.inc' %]
86 </div>
87 </div>
88
89 [% MACRO jsinclude BLOCK %]
90     [% INCLUDE 'str/members-menu.inc' %]
91     [% Asset.js("js/members-menu.js") | $raw %]
92     [% Asset.js("lib/jquery/plugins/jquery.treeview.pack.js") | $raw %]
93     <!-- set up tree -->
94     <script type="text/javascript">
95         $(document).ready(function() {
96             $("#permissionstree").treeview({animated: "fast", collapsed: true});
97
98             // Enforce Superlibrarian Privilege Mutual Exclusivity
99             if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
100                 if ($('input[name="flag"]:checked').length > 1){
101                     alert(_("Inconsistency detected! The superlibrarian privilege is mutually exclusive of other privileges, as it includes them all. This patron's privileges will now be reset to include only superlibrarian."));
102                 }
103
104                 $('input[name="flag"]').each(function() {
105                     if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
106                         $(this).prop('disabled', true);
107                         $(this).prop('checked', false);
108                     }
109                 });
110             }
111
112             $('input#flag-0').click(function() {
113                 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
114                     $('input[name="flag"]').each(function() {
115                         if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
116                             $(this).prop('disabled', true);
117                             $(this).prop('checked', false);
118                         }
119                     });
120                 }
121                 else {
122                     $('input[name="flag"]').each(function() {
123                         $(this).prop('disabled', false);
124                     });
125                 }
126             });
127
128             $(".flag").on("change",function(){
129                 if( $(this).hasClass("parent") ){
130                     toggleChildren(this);
131                 } else {
132                     toggleParent(this);
133                 }
134             });
135
136         });
137
138         // manage checking/unchecking parent permissions
139         var originalChildStates = {}; /* keep track of subpermission checkbox values
140                                          so that user can recover from accidentally
141                                          toggling a parent/module permission */
142         function selectChildren(parentInput) {
143             var childListId = parentInput.id + '-children';
144             var list = document.getElementById(childListId);
145             var children = [];
146             if (list) {
147                 var inputs = list.getElementsByTagName('input');
148                 for (var i = 0; i < inputs.length; i++) {
149                     if (inputs[i].type == 'checkbox') {
150                         children.push(inputs[i]);
151                     }
152                 }
153             }
154             return children;
155         }
156
157         function toggleChildren(parentInput) {
158             var children = selectChildren(parentInput);
159             if (children.length == 0) {
160                 return;
161             }
162             var checked = parentInput.checked;
163             if (checked && parentInput.parentNode.className == 'expandable') {
164                 /* expand the tree */
165                 $(".hitarea", parentInput.parentNode).click();
166             }
167             for (var i = 0; i < children.length; i++) {
168                 if (checked) {
169                     originalChildStates[children[i].id] = children[i].checked;
170                     children[i].checked = checked;
171                 } else {
172                     if (children[i].id in originalChildStates) {
173                         children[i].checked = originalChildStates[children[i].id];
174                     } else {
175                         children[i].checked = checked;
176                     }
177                 }
178             }
179         }
180
181         function toggleParent(childInput) {
182             originalChildStates[childInput.id] = childInput.checked;
183             if (childInput.checked) {
184                 return;
185             }
186             var parentId = childInput.parentNode.parentNode.id.replace(/-children$/, '');;
187             var parentInput = document.getElementById(parentId);
188             if (parentInput) {
189                 parentInput.checked = false;
190             }
191         }
192
193     </script>
194 [% END %]
195
196 [% INCLUDE 'intranet-bottom.inc' %]