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 [% WRAPPER breadcrumbs %]
20 [% WRAPPER breadcrumb_item %]
21 <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
23 [% WRAPPER breadcrumb_item %]
24 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% INCLUDE 'patron-title.inc' %]</a>
26 [% WRAPPER breadcrumb_item bc_active= 1 %]
27 <span>Set permissions</span>
29 [% END #/ WRAPPER breadcrumbs %]
30 [% END #/ WRAPPER sub-header.inc %]
32 <div class="main container-fluid">
34 <div class="col-sm-10 col-sm-push-2">
37 [% INCLUDE 'members-toolbar.inc' %]
39 <form id="flag_form" method="post" action="/cgi-bin/koha/members/member-flags.pl">
40 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
41 <input type="hidden" name="member" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
42 <input type="hidden" name="newflags" value="1" />
43 <h1>Set permissions for [% INCLUDE 'patron-title.inc' no_html = 1 %]</h1>
45 <div id="permissionstree">
46 <div id="permissions_toolbar" class="btn-toolbar">
47 <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Save</button>
48 <a class="btn btn-default" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-remove"></i> Cancel</a>
49 <a class="toggleall toggleall_on btn btn-link" href="#"><i class="fa fa-plus-square-o"></i> Show all</a>
50 <a class="toggleall toggleall_off btn btn-link" href="#"><i class="fa fa-minus-square-o"></i> Hide all</a>
51 <a id="CheckAllFlags" class="btn btn-link" href="#">
52 <i class="fa fa-check"></i> Select all
54 <a id="UncheckAllFlags" class="btn btn-link" href="#">
55 <i class="fa fa-remove"></i> Clear all
57 <div class="btn-group pull-right">
58 Filter: <input type="text" name="permissions_filter" id="permissions_filter" size="20" />
59 <a href="#" id="clear_filter" style="display:none"><i class="fa fa-remove"></i></a>
62 <div class="permissions">
63 [% FOREACH loo IN loop %]
64 [% IF ( loo.expand ) %]
65 <div id="parent-flag-[% loo.flag | html %]" class="open parent">
67 <div id="parent-flag-[% loo.flag | html %]" class="parent">
69 [% IF ( loo.checked ) %]
70 [% IF disable_superlibrarian_privs && loo.bit == 0 %]
71 <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" />
72 <input type="hidden" id="flag-0" name="flag" value="[% loo.flag | html %]" >
74 <input type="checkbox" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]" class="parent flag" name="flag" value="[% loo.flag | html %]" checked="checked" />
77 [% IF disable_superlibrarian_privs && loo.bit == 0 %]
78 <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" />
80 <input type="checkbox" class="flag parent" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" />
82 [% END # /IF loo.checked %]
83 <label class="permissiondesc" for="flag-[% loo.bit | html %]">
84 [% PROCESS main_permissions name=loo.flag %]
86 [% 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 %]
87 [% IF ( loo.sub_perm_loop ) %]
88 <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>
89 <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>
90 <div class="children" id="flag-[% loo.bit | html %]-children">
91 [% FOREACH sub_perm_loo IN loo.sub_perm_loop %]
92 <div class="child-flags">
93 [% IF ( sub_perm_loo.checked ) %]
94 <input type="checkbox" id="[% sub_perm_loo.id | html %]" class="child flag" name="flag" value="[% sub_perm_loo.perm | html %]" checked="checked" />
96 <input type="checkbox" id="[% sub_perm_loo.id | html %]" class="child flag" name="flag" value="[% sub_perm_loo.perm | html %]" />
98 <label class="permissiondesc" for="[% sub_perm_loo.id | html %]">
99 [% PROCESS sub_permissions name=sub_perm_loo.code %]
103 </div> <!-- /#flag-[% loo.bit | html %]-children -->
104 [% END # /IF loo.sub_perm_loop %]
105 </div> <!-- /.parent -->
106 [% END # /FOREACH loo %]
108 </div> <!-- /#permissionstree -->
112 </div> <!-- /.col-sm-10.col-sm-push-2 -->
114 <div class="col-sm-2 col-sm-pull-10">
116 [% INCLUDE 'circ-menu.inc' %]
118 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
119 </div> <!-- /.row -->
121 [% MACRO jsinclude BLOCK %]
122 [% INCLUDE 'str/members-menu.inc' %]
123 [% Asset.js("js/members-menu.js") | $raw %]
124 [% Asset.js("lib/hc-sticky.js") | $raw %]
127 $(document).ready(function() {
129 [% IF disable_superlibrarian_privs && patron.is_superlibrarian %]
130 $("#CheckAllFlags,#UncheckAllFlags")
131 .attr("disabled", true)
132 .attr("title", _("The system preference ProtectSuperlibrarian is enabled"))
133 .on("click", function(e){e.preventDefault()});
135 $("#CheckAllFlags").on("click",function(){
136 $(".flag").attr("disabled", false);
137 $(".flag").prop("checked", true);
138 $("#flag-0").prop("checked", false);
139 [% IF disable_superlibrarian_privs %]
140 $("#flag-0").prop("disabled", true);
144 $("#UncheckAllFlags").on("click",function(){
145 $(".flag").attr("disabled", false);
146 [% IF disable_superlibrarian_privs %]
147 $("#flag-0").prop("disabled", true);
149 $(".flag").prop("checked", false);
152 $(".flag").change(function(){
153 if(!$(this).is(':checked')){
154 $("input#flag-0").prop("checked", false);
159 Sticky = $("#permissions_toolbar");
161 stickTo: "#permissionstree",
162 stickyClass: "floating"
165 $(".open div").show();
167 $("#permissions_filter").on("keyup", function(){
168 $("#clear_filter").css("display","inline-block");
169 $("a[class^=toggle-]").hide();
170 var string = $(this).val();
171 var divs = $("div[id!='parent-flag-superlibrarian']", ".permissions");
172 if( string != "" && string.length > 3 ){
173 divs.each(function(){
174 if ( $(this).text().search(new RegExp( string, "i")) < 0 ) {
185 $("#clear_filter").on("click", function(){
186 $(".togglechildren_off").show();
187 $("#permissions_filter").val("");
188 $("div", "#permissionstree").show();
189 $(this).css("display","none");
192 // Enforce Superlibrarian Privilege Mutual Exclusivity
193 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
194 if ($('input[name="flag"]:checked').length > 1){
195 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."));
201 $('input#flag-0').click(function() {
202 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
203 $('input[name="flag"]').each(function() {
204 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
205 $(this).prop('disabled', true);
206 $(this).prop('checked', false);
211 $('input[name="flag"]').each(function() {
212 $(this).prop('disabled', false);
218 $(".toggleall_off, .toggleall_on").on('click', function(e) {
220 if( $(this).hasClass("toggleall_on")){
221 $(".children,.togglechildren_off").show();
222 $(".togglechildren_on").hide();
224 $(".children,.togglechildren_off").hide();
225 $(".togglechildren_on").show();
229 $(".togglechildren_off, .togglechildren_on").on('click', function(e) {
231 var bit = $(this).data("bit");
232 $("#flag-" + bit + "-children").toggle();
233 $(".toggle-" + bit).toggle();
236 $(".togglechildren_off, .togglechildren_on").hover( function(){
237 $(this).parent().addClass("permission-highlight");
239 $(this).parent().removeClass("permission-highlight");
242 $(".flag").on("change",function(e){
244 if( $(this).hasClass("child") ){
245 if( $(this).prop("checked") ){
246 // If this is the last of all the child boxes to be checked the parent should be checked too
248 $(this).closest(".children").find(".child").each(function(){
249 if( !$(this).prop("checked") ){
250 // There are still unchecked checkboxes in this group
254 if( unchecked === 0 ){
255 $(this).closest(".parent").find(".flag.parent").prop("checked", true);
258 $(this).closest(".parent").find(".flag.parent").prop("checked", false);
261 var bit = $(this).data("bit");
262 if( $(this).is(":checked") ){
263 $("#flag-" + bit + "-children").show().find(".flag").prop("checked", true);
264 $(".toggle-" + bit + ".togglechildren_on").hide();
265 $(".toggle-" + bit + ".togglechildren_off").show();
267 $("#flag-" + bit + "-children").show().find(".flag").prop("checked", false);
273 function setLibrarian(){
274 $('input[name="flag"]').each(function() {
275 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
276 $(this).prop('disabled', true);
277 $(this).prop('checked', false);
285 [% INCLUDE 'intranet-bottom.inc' %]