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