4 [% PROCESS 'permissions.inc' %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha › Patrons › Set permissions for [% patron.surname %], [% patron.firstname %]</title>
7 [% Asset.css("css/treeview/jquery.treeview.css") %]
8 [% INCLUDE 'doc-head-close.inc' %]
11 <body id="pat_member-flags" class="pat">
12 [% INCLUDE 'header.inc' %]
13 [% INCLUDE 'patron-search.inc' %]
15 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › Set permissions for [% patron.surname %], [% patron.firstname %]</div>
17 <div id="doc3" class="yui-t2">
22 [% INCLUDE 'members-toolbar.inc' %]
24 <form method="post" action="/cgi-bin/koha/members/member-flags.pl">
25 <input type="hidden" name="csrf_token" value="[% csrf_token %]" />
26 <input type="hidden" name="member" id="borrowernumber" value="[% patron.borrowernumber %]" />
27 <input type="hidden" name="newflags" value="1" />
28 <h1>Set permissions for [% patron.surname %], [% patron.firstname %]</h1>
29 <!-- <ul id="permissionstree"><li class="root">All privileges<ul> -->
30 <ul id="permissionstree" class="treeview-grey">
31 <!-- <li class="folder-close">One level down<ul> -->
32 [% FOREACH loo IN loop %]
33 [% IF ( loo.expand ) %]
38 [% IF ( loo.checked ) %]
39 <input type="checkbox" class="flag parent" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]" checked="checked" />
41 <input type="checkbox" class="flag parent" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]" />
43 <label class="permissioncode" for="flag-[% loo.bit %]">[% loo.flag %]</label>
44 <span class="permissiondesc">[% PROCESS main_permissions name=loo.flag %]</span>
45 [% IF ( loo.sub_perm_loop ) %]
46 <ul id="flag-[% loo.bit %]-children">
47 [% FOREACH sub_perm_loo IN loo.sub_perm_loop %]
49 [% IF ( sub_perm_loo.checked ) %]
50 <input type="checkbox" class="flag child" id="[% sub_perm_loo.id %]" name="flag" value="[% sub_perm_loo.perm %]" checked="checked" />
52 <input type="checkbox" class="flag child" id="[% sub_perm_loo.id %]" name="flag" value="[% sub_perm_loo.perm %]" />
54 <label class="permissioncode" for="[% sub_perm_loo.id %]">[% sub_perm_loo.code %]</label>
55 <span class="permissiondesc">[% PROCESS sub_permissions name=sub_perm_loo.code %]</span>
65 <!-- </ul></li></ul> -->
68 <fieldset class="action"><input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></fieldset>
75 [% INCLUDE 'circ-menu.inc' %]
79 [% MACRO jsinclude BLOCK %]
80 [% Asset.js("js/members-menu.js") %]
81 [% Asset.js("lib/jquery/plugins/jquery.treeview.pack.js") %]
83 <script type="text/javascript">
84 $(document).ready(function() {
85 $("#permissionstree").treeview({animated: "fast", collapsed: true});
87 // Enforce Superlibrarian Privilege Mutual Exclusivity
88 if($('input[id="flag-0"]:checked').length){
89 if ($('input[name="flag"]:checked').length > 1){
90 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."));
93 $('input[name="flag"]').each(function() {
94 if($(this).attr('id') != "flag-0"){
95 $(this).prop('disabled', true);
96 $(this).prop('checked', false);
101 $('input#flag-0').click(function() {
102 if($('input[id="flag-0"]:checked').length){
103 $('input[name="flag"]').each(function() {
104 if($(this).attr('id') != "flag-0"){
105 $(this).prop('disabled', true);
106 $(this).prop('checked', false);
111 $('input[name="flag"]').each(function() {
112 $(this).prop('disabled', false);
117 $(".flag").on("change",function(){
118 if( $(this).hasClass("parent") ){
119 toggleChildren(this);
127 // manage checking/unchecking parent permissions
128 var originalChildStates = {}; /* keep track of subpermission checkbox values
129 so that user can recover from accidentally
130 toggling a parent/module permission */
131 function selectChildren(parentInput) {
132 var childListId = parentInput.id + '-children';
133 var list = document.getElementById(childListId);
136 var inputs = list.getElementsByTagName('input');
137 for (var i = 0; i < inputs.length; i++) {
138 if (inputs[i].type == 'checkbox') {
139 children.push(inputs[i]);
146 function toggleChildren(parentInput) {
147 var children = selectChildren(parentInput);
148 if (children.length == 0) {
151 var checked = parentInput.checked;
152 if (checked && parentInput.parentNode.className == 'expandable') {
153 /* expand the tree */
154 $(".hitarea", parentInput.parentNode).click();
156 for (var i = 0; i < children.length; i++) {
158 originalChildStates[children[i].id] = children[i].checked;
159 children[i].checked = checked;
161 if (children[i].id in originalChildStates) {
162 children[i].checked = originalChildStates[children[i].id];
164 children[i].checked = checked;
170 function toggleParent(childInput) {
171 originalChildStates[childInput.id] = childInput.checked;
172 if (childInput.checked) {
175 var parentId = childInput.parentNode.parentNode.id.replace(/-children$/, '');;
176 var parentInput = document.getElementById(parentId);
178 parentInput.checked = false;
185 [% INCLUDE 'intranet-bottom.inc' %]