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