5 [% PROCESS 'permissions.inc' %]
6 [% INCLUDE 'doc-head-open.inc' %]
8 Set permissions for [% INCLUDE 'patron-title.inc' no_html = 1 %] › Patrons › Koha
10 [% INCLUDE 'doc-head-close.inc' %]
13 <body id="pat_member-flags" class="pat">
14 [% WRAPPER 'header.inc' %]
15 [% INCLUDE 'patron-search-header.inc' %]
18 [% WRAPPER 'sub-header.inc' %]
19 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
22 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
25 <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
28 <a href="#" aria-current="page">
29 Set permissions for [% INCLUDE 'patron-title.inc' %]
36 <div class="main container-fluid">
38 <div class="col-sm-10 col-sm-push-2">
41 [% INCLUDE 'members-toolbar.inc' %]
43 <form id="flag_form" method="post" action="/cgi-bin/koha/members/member-flags.pl">
44 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
45 <input type="hidden" name="member" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
46 <input type="hidden" name="newflags" value="1" />
47 <h1>Set permissions for [% INCLUDE 'patron-title.inc' no_html = 1 %]</h1>
49 <div id="permissionstree">
50 <div id="permissions_toolbar" class="btn-toolbar">
51 <button type="submit" class="btn btn-default"><i class="fa fa-save"></i> Save</button>
52 <a class="btn btn-default" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-remove"></i> Cancel</a>
53 <a class="toggleall toggleall_on btn btn-link" href="#"><i class="fa fa-plus-square-o"></i> Show all</a>
54 <a class="toggleall toggleall_off btn btn-link" href="#"><i class="fa fa-minus-square-o"></i> Hide all</a>
55 <a id="CheckAllFlags" class="btn btn-link" href="#">
56 <i class="fa fa-check"></i> Select all
58 <a id="UncheckAllFlags" class="btn btn-link" href="#">
59 <i class="fa fa-remove"></i> Clear all
61 <div class="btn-group pull-right">
62 Filter: <input type="text" name="permissions_filter" id="permissions_filter" size="20" />
63 <a href="#" id="clear_filter" style="display:none"><i class="fa fa-remove"></i></a>
66 <div class="permissions">
67 [% FOREACH loo IN loop %]
68 [% IF ( loo.expand ) %]
69 <div id="parent-flag-[% loo.flag | html %]" class="open parent">
71 <div id="parent-flag-[% loo.flag | html %]" class="parent">
73 [% IF ( loo.checked ) %]
74 [% IF disable_superlibrarian_privs && loo.bit == 0 %]
75 <input type="checkbox" disabled="disabled" data-bit="0" id="flag-0" class="parent flag superlib" name="flag" value="[% loo.flag | html %]" checked="checked" title="The system preference ProtectSuperlibrarianPrivileges is enabled" />
76 <input type="hidden" id="flag-0" name="flag" value="[% loo.flag | html %]" >
78 <input type="checkbox" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]" class="parent flag" name="flag" value="[% loo.flag | html %]" checked="checked" />
81 [% IF disable_superlibrarian_privs && loo.bit == 0 %]
82 <input type="checkbox" disabled="disabled" class="flag parent" data-bit="0" id="flag-0" name="flag" value="[% loo.flag | html %]" title="The system preference ProtectSuperlibrarianPrivileges is enabled" />
84 <input type="checkbox" class="flag parent" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" />
86 [% END # /IF loo.checked %]
87 <label class="permissiondesc" for="flag-[% loo.bit | html %]">
88 [% PROCESS main_permissions name=loo.flag %]
90 [% IF ( loo.flag == "superlibrarian" ) %]<div class="hint superlibrarian-hint">This permission grants access to all areas. If selected, specific sub-permissions cannot be selected.</div>[% END %]
91 [% IF ( loo.sub_perm_loop ) %]
92 <a class="toggle-[% loo.bit | html %] togglechildren_off" href="#" data-bit="[% loo.bit | html %]"><i class="fa fa-minus-square-o"></i> Hide details</a>
93 <a class="toggle-[% loo.bit | html %] togglechildren_on" href="#" data-bit="[% loo.bit | html %]"><i class="fa fa-plus-square-o"></i> Show details</a>
94 <div class="children" id="flag-[% loo.bit | html %]-children">
95 [% FOREACH sub_perm_loo IN loo.sub_perm_loop %]
96 <div class="child-flags">
97 [% IF ( sub_perm_loo.checked ) %]
98 <input type="checkbox" id="[% sub_perm_loo.id | html %]" class="child flag" name="flag" value="[% sub_perm_loo.perm | html %]" checked="checked" />
100 <input type="checkbox" id="[% sub_perm_loo.id | html %]" class="child flag" name="flag" value="[% sub_perm_loo.perm | html %]" />
102 <label class="permissiondesc" for="[% sub_perm_loo.id | html %]">
103 [% PROCESS sub_permissions name=sub_perm_loo.code %]
107 </div> <!-- /#flag-[% loo.bit | html %]-children -->
108 [% END # /IF loo.sub_perm_loop %]
109 </div> <!-- /.parent -->
110 [% END # /FOREACH loo %]
112 </div> <!-- /#permissionstree -->
116 </div> <!-- /.col-sm-10.col-sm-push-2 -->
118 <div class="col-sm-2 col-sm-pull-10">
120 [% INCLUDE 'circ-menu.inc' %]
122 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
123 </div> <!-- /.row -->
125 [% MACRO jsinclude BLOCK %]
126 [% INCLUDE 'str/members-menu.inc' %]
127 [% Asset.js("js/members-menu.js") | $raw %]
128 [% Asset.js("lib/hc-sticky.js") | $raw %]
131 $(document).ready(function() {
133 [% IF disable_superlibrarian_privs && patron.is_superlibrarian %]
134 $("#CheckAllFlags,#UncheckAllFlags")
135 .attr("disabled", true)
136 .attr("title", _("The system preference ProtectSuperlibrarian is enabled"))
137 .on("click", function(e){e.preventDefault()});
139 $("#CheckAllFlags").on("click",function(){
140 $(".flag").attr("disabled", false);
141 $(".flag").prop("checked", true);
142 $("#flag-0").prop("checked", false);
143 [% IF disable_superlibrarian_privs %]
144 $("#flag-0").prop("disabled", true);
148 $("#UncheckAllFlags").on("click",function(){
149 $(".flag").attr("disabled", false);
150 [% IF disable_superlibrarian_privs %]
151 $("#flag-0").prop("disabled", true);
153 $(".flag").prop("checked", false);
156 $(".flag").change(function(){
157 if(!$(this).is(':checked')){
158 $("input#flag-0").prop("checked", false);
163 Sticky = $("#permissions_toolbar");
165 stickTo: "#permissionstree",
166 stickyClass: "floating"
169 $(".open div").show();
171 $("#permissions_filter").on("keyup", function(){
172 $("#clear_filter").css("display","inline-block");
173 $("a[class^=toggle-]").hide();
174 var string = $(this).val();
175 var divs = $("div[id!='parent-flag-superlibrarian']", ".permissions");
176 if( string != "" && string.length > 3 ){
177 divs.each(function(){
178 if ( $(this).text().search(new RegExp( string, "i")) < 0 ) {
189 $("#clear_filter").on("click", function(){
190 $(".togglechildren_off").show();
191 $("#permissions_filter").val("");
192 $("div", "#permissionstree").show();
193 $(this).css("display","none");
196 // Enforce Superlibrarian Privilege Mutual Exclusivity
197 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
198 if ($('input[name="flag"]:checked').length > 1){
199 alert(_("Inconsistency detected!") + "\n\n" + _("The superlibrarian privilege is mutually exclusive of other privileges, as it includes them all.") + "\n\n" + _("This patron's privileges will now be reset to include only superlibrarian."));
205 $('input#flag-0').click(function() {
206 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
207 $('input[name="flag"]').each(function() {
208 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
209 $(this).prop('disabled', true);
210 $(this).prop('checked', false);
215 $('input[name="flag"]').each(function() {
216 $(this).prop('disabled', false);
222 $(".toggleall_off, .toggleall_on").on('click', function(e) {
224 if( $(this).hasClass("toggleall_on")){
225 $(".children,.togglechildren_off").show();
226 $(".togglechildren_on").hide();
228 $(".children,.togglechildren_off").hide();
229 $(".togglechildren_on").show();
233 $(".togglechildren_off, .togglechildren_on").on('click', function(e) {
235 var bit = $(this).data("bit");
236 $("#flag-" + bit + "-children").toggle();
237 $(".toggle-" + bit).toggle();
240 $(".togglechildren_off, .togglechildren_on").hover( function(){
241 $(this).parent().addClass("permission-highlight");
243 $(this).parent().removeClass("permission-highlight");
246 $(".flag").on("change",function(e){
248 if( $(this).hasClass("child") ){
249 if( $(this).prop("checked") ){
250 // If this is the last of all the child boxes to be checked the parent should be checked too
252 $(this).closest(".children").find(".child").each(function(){
253 if( !$(this).prop("checked") ){
254 // There are still unchecked checkboxes in this group
258 if( unchecked === 0 ){
259 $(this).closest(".parent").find(".flag.parent").prop("checked", true);
262 $(this).closest(".parent").find(".flag.parent").prop("checked", false);
265 var bit = $(this).data("bit");
266 if( $(this).is(":checked") ){
267 $("#flag-" + bit + "-children").show().find(".flag").prop("checked", true);
268 $(".toggle-" + bit + ".togglechildren_on").hide();
269 $(".toggle-" + bit + ".togglechildren_off").show();
271 $("#flag-" + bit + "-children").show().find(".flag").prop("checked", false);
277 function setLibrarian(){
278 $('input[name="flag"]').each(function() {
279 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
280 $(this).prop('disabled', true);
281 $(this).prop('checked', false);
289 [% INCLUDE 'intranet-bottom.inc' %]