5 [% PROCESS 'permissions.inc' %]
6 [% INCLUDE 'doc-head-open.inc' %]
8 Set permissions for [% patron.surname | html %], [% patron.firstname | html %] › Patrons › Koha
10 [% INCLUDE 'doc-head-close.inc' %]
13 <body id="pat_member-flags" class="pat">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'patron-search-header.inc' %]
17 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
20 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
23 <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
26 <a href="#" aria-current="page">
27 Set permissions for [% patron.surname | html %], [% patron.firstname | html %]
33 <div class="main container-fluid">
35 <div class="col-sm-10 col-sm-push-2">
38 [% INCLUDE 'members-toolbar.inc' %]
40 <form id="flag_form" method="post" action="/cgi-bin/koha/members/member-flags.pl">
41 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
42 <input type="hidden" name="member" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
43 <input type="hidden" name="newflags" value="1" />
44 <h1>Set permissions for [% patron.surname | html %], [% patron.firstname | html %]</h1>
46 <div id="permissionstree">
47 <div id="permissions_toolbar" class="btn-toolbar">
48 <button type="submit" class="btn btn-default"><i class="fa fa-save"></i> Save</button>
49 <a class="btn btn-default" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-remove"></i> Cancel</a>
50 <a class="toggleall toggleall_on btn btn-link" href="#"><i class="fa fa-plus-square-o"></i> Show all</a>
51 <a class="toggleall toggleall_off btn btn-link" href="#"><i class="fa fa-minus-square-o"></i> Hide all</a>
52 <a id="CheckAllFlags" class="btn btn-link" href="#">
53 <i class="fa fa-check"></i> Select all
55 <a id="UncheckAllFlags" class="btn btn-link" href="#">
56 <i class="fa fa-remove"></i> Clear all
58 <div class="btn-group pull-right">
59 Filter: <input type="text" name="permissions_filter" id="permissions_filter" size="20" />
60 <a href="#" id="clear_filter" style="display:none"><i class="fa fa-remove"></i></a>
63 <div class="permissions">
64 [% FOREACH loo IN loop %]
65 [% IF ( loo.expand ) %]
66 <div id="parent-flag-[% loo.flag | html %]" class="open parent">
68 <div id="parent-flag-[% loo.flag | html %]" class="parent">
70 [% IF ( loo.checked ) %]
71 [% IF disable_superlibrarian_privs && loo.bit == 0 %]
72 <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" />
73 <input type="hidden" id="flag-0" name="flag" value="[% loo.flag | html %]" >
75 <input type="checkbox" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]" class="parent flag" name="flag" value="[% loo.flag | html %]" checked="checked" />
78 [% IF disable_superlibrarian_privs && loo.bit == 0 %]
79 <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" />
81 <input type="checkbox" class="flag parent" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" />
83 [% END # /IF loo.checked %]
84 <label class="permissiondesc" for="flag-[% loo.bit | html %]">
85 [% PROCESS main_permissions name=loo.flag %]
87 [% 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 %]
88 [% IF ( loo.sub_perm_loop ) %]
89 <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>
90 <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>
91 <div class="children" id="flag-[% loo.bit | html %]-children">
92 [% FOREACH sub_perm_loo IN loo.sub_perm_loop %]
93 <div class="child-flags">
94 [% IF ( sub_perm_loo.checked ) %]
95 <input type="checkbox" id="[% sub_perm_loo.id | html %]" class="child flag" name="flag" value="[% sub_perm_loo.perm | html %]" checked="checked" />
97 <input type="checkbox" id="[% sub_perm_loo.id | html %]" class="child flag" name="flag" value="[% sub_perm_loo.perm | html %]" />
99 <label class="permissiondesc" for="[% sub_perm_loo.id | html %]">
100 [% PROCESS sub_permissions name=sub_perm_loo.code %]
104 </div> <!-- /#flag-[% loo.bit | html %]-children -->
105 [% END # /IF loo.sub_perm_loop %]
106 </div> <!-- /.parent -->
107 [% END # /FOREACH loo %]
109 </div> <!-- /#permissionstree -->
113 </div> <!-- /.col-sm-10.col-sm-push-2 -->
115 <div class="col-sm-2 col-sm-pull-10">
117 [% INCLUDE 'circ-menu.inc' %]
119 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
120 </div> <!-- /.row -->
122 [% MACRO jsinclude BLOCK %]
123 [% INCLUDE 'str/members-menu.inc' %]
124 [% Asset.js("js/members-menu.js") | $raw %]
125 [% Asset.js("lib/hc-sticky.js") | $raw %]
128 $(document).ready(function() {
130 [% IF disable_superlibrarian_privs && patron.is_superlibrarian %]
131 $("#CheckAllFlags,#UncheckAllFlags")
132 .attr("disabled", true)
133 .attr("title", _("The system preference ProtectSuperlibrarian is enabled"))
134 .on("click", function(e){e.preventDefault()});
136 $("#CheckAllFlags").on("click",function(){
137 $(".flag").attr("disabled", false);
138 $(".flag").prop("checked", true);
139 $("#flag-0").prop("checked", false);
140 [% IF disable_superlibrarian_privs %]
141 $("#flag-0").prop("disabled", true);
145 $("#UncheckAllFlags").on("click",function(){
146 $(".flag").attr("disabled", false);
147 [% IF disable_superlibrarian_privs %]
148 $("#flag-0").prop("disabled", true);
150 $(".flag").prop("checked", false);
153 $(".flag").change(function(){
154 if(!$(this).is(':checked')){
155 $("input#flag-0").prop("checked", false);
160 Sticky = $("#permissions_toolbar");
162 stickTo: "#permissionstree",
163 stickyClass: "floating"
166 $(".open div").show();
168 $("#permissions_filter").on("keyup", function(){
169 $("#clear_filter").css("display","inline-block");
170 $("a[class^=toggle-]").hide();
171 var string = $(this).val();
172 var divs = $("div[id!='parent-flag-superlibrarian']", ".permissions");
173 if( string != "" && string.length > 3 ){
174 divs.each(function(){
175 if ( $(this).text().search(new RegExp( string, "i")) < 0 ) {
186 $("#clear_filter").on("click", function(){
187 $(".togglechildren_off").show();
188 $("#permissions_filter").val("");
189 $("div", "#permissionstree").show();
190 $(this).css("display","none");
193 // Enforce Superlibrarian Privilege Mutual Exclusivity
194 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
195 if ($('input[name="flag"]:checked').length > 1){
196 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."));
202 $('input#flag-0').click(function() {
203 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
204 $('input[name="flag"]').each(function() {
205 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
206 $(this).prop('disabled', true);
207 $(this).prop('checked', false);
212 $('input[name="flag"]').each(function() {
213 $(this).prop('disabled', false);
219 $(".toggleall_off, .toggleall_on").on('click', function(e) {
221 if( $(this).hasClass("toggleall_on")){
222 $(".children,.togglechildren_off").show();
223 $(".togglechildren_on").hide();
225 $(".children,.togglechildren_off").hide();
226 $(".togglechildren_on").show();
230 $(".togglechildren_off, .togglechildren_on").on('click', function(e) {
232 var bit = $(this).data("bit");
233 $("#flag-" + bit + "-children").toggle();
234 $(".toggle-" + bit).toggle();
237 $(".togglechildren_off, .togglechildren_on").hover( function(){
238 $(this).parent().addClass("permission-highlight");
240 $(this).parent().removeClass("permission-highlight");
243 $(".flag").on("change",function(e){
245 if( $(this).hasClass("child") ){
246 if( $(this).prop("checked") ){
247 // If this is the last of all the child boxes to be checked the parent should be checked too
249 $(this).closest(".children").find(".child").each(function(){
250 if( !$(this).prop("checked") ){
251 // There are still unchecked checkboxes in this group
255 if( unchecked === 0 ){
256 $(this).closest(".parent").find(".flag.parent").prop("checked", true);
259 $(this).closest(".parent").find(".flag.parent").prop("checked", false);
262 var bit = $(this).data("bit");
263 if( $(this).is(":checked") ){
264 $("#flag-" + bit + "-children").show().find(".flag").prop("checked", true);
265 $(".toggle-" + bit + ".togglechildren_on").hide();
266 $(".toggle-" + bit + ".togglechildren_off").show();
268 $("#flag-" + bit + "-children").show().find(".flag").prop("checked", false);
274 function setLibrarian(){
275 $('input[name="flag"]').each(function() {
276 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
277 $(this).prop('disabled', true);
278 $(this).prop('checked', false);
286 [% INCLUDE 'intranet-bottom.inc' %]