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