5 [% PROCESS 'permissions.inc' %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha › Patrons › 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' %]
12 <body id="pat_member-flags" class="pat">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'patron-search.inc' %]
16 <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 | html %], [% patron.firstname | html %]</div>
18 <div class="main container-fluid">
20 <div class="col-sm-10 col-sm-push-2">
23 [% INCLUDE 'members-toolbar.inc' %]
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 ) %]
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 %]" >
44 <input type="checkbox" class="flag parent" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" checked="checked" />
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" />
50 <input type="checkbox" class="flag parent" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" />
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 %]
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" />
62 <input type="checkbox" class="flag child" id="[% sub_perm_loo.id | html %]" name="flag" value="[% sub_perm_loo.perm | html %]" />
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>
75 <!-- </ul></li></ul> -->
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>
83 </div> <!-- /.col-sm-10.col-sm-push-2 -->
85 <div class="col-sm-2 col-sm-pull-10">
87 [% INCLUDE 'circ-menu.inc' %]
89 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
92 [% MACRO jsinclude BLOCK %]
93 [% INCLUDE 'str/members-menu.inc' %]
94 [% Asset.js("js/members-menu.js") | $raw %]
95 [% Asset.js("lib/jquery/plugins/jquery.treeview.pack.js") | $raw %]
98 $(document).ready(function() {
99 $("#permissionstree").treeview({animated: "fast", collapsed: true});
101 // Enforce Superlibrarian Privilege Mutual Exclusivity
102 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
103 if ($('input[name="flag"]:checked').length > 1){
104 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."));
107 $('input[name="flag"]').each(function() {
108 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
109 $(this).prop('disabled', true);
110 $(this).prop('checked', false);
115 $('input#flag-0').click(function() {
116 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
117 $('input[name="flag"]').each(function() {
118 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
119 $(this).prop('disabled', true);
120 $(this).prop('checked', false);
125 $('input[name="flag"]').each(function() {
126 $(this).prop('disabled', false);
131 $(".flag").on("change",function(){
132 if( $(this).hasClass("parent") ){
133 toggleChildren(this);
141 // manage checking/unchecking parent permissions
142 var originalChildStates = {}; /* keep track of subpermission checkbox values
143 so that user can recover from accidentally
144 toggling a parent/module permission */
145 function selectChildren(parentInput) {
146 var childListId = parentInput.id + '-children';
147 var list = document.getElementById(childListId);
150 var inputs = list.getElementsByTagName('input');
151 for (var i = 0; i < inputs.length; i++) {
152 if (inputs[i].type == 'checkbox') {
153 children.push(inputs[i]);
160 function toggleChildren(parentInput) {
161 var children = selectChildren(parentInput);
162 if (children.length == 0) {
165 var checked = parentInput.checked;
166 if (checked && parentInput.parentNode.className == 'expandable') {
167 /* expand the tree */
168 $(".hitarea", parentInput.parentNode).click();
170 for (var i = 0; i < children.length; i++) {
172 originalChildStates[children[i].id] = children[i].checked;
173 children[i].checked = checked;
175 if (children[i].id in originalChildStates) {
176 children[i].checked = originalChildStates[children[i].id];
178 children[i].checked = checked;
184 function toggleParent(childInput) {
185 originalChildStates[childInput.id] = childInput.checked;
186 if (childInput.checked) {
189 var parentId = childInput.parentNode.parentNode.id.replace(/-children$/, '');;
190 var parentInput = document.getElementById(parentId);
192 parentInput.checked = false;
199 [% INCLUDE 'intranet-bottom.inc' %]