4 [% PROCESS 'i18n.inc' %]
6 [% PROCESS 'permissions.inc' %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>[% FILTER collapse %]
9 [% t("Set permissions for") | html %] [% INCLUDE 'patron-title.inc' no_html = 1 %] ›
10 [% t("Patrons") | html %] ›
11 [% t("Koha") | html %]
13 [% INCLUDE 'doc-head-close.inc' %]
16 <body id="pat_member-flags" class="pat">
17 [% WRAPPER 'header.inc' %]
18 [% INCLUDE 'patron-search-header.inc' %]
21 [% WRAPPER 'sub-header.inc' %]
22 [% WRAPPER breadcrumbs %]
23 [% WRAPPER breadcrumb_item %]
24 <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
26 [% WRAPPER breadcrumb_item %]
27 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% INCLUDE 'patron-title.inc' %]</a>
29 [% WRAPPER breadcrumb_item bc_active= 1 %]
30 <span>Set permissions</span>
32 [% END #/ WRAPPER breadcrumbs %]
33 [% END #/ WRAPPER sub-header.inc %]
35 <div class="main container-fluid">
37 <div class="col-sm-10 col-sm-push-2">
40 [% INCLUDE 'members-toolbar.inc' %]
42 <form id="flag_form" method="post" action="/cgi-bin/koha/members/member-flags.pl">
43 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
44 <input type="hidden" name="member" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
45 <input type="hidden" name="newflags" value="1" />
46 <h1>Set permissions for [% INCLUDE 'patron-title.inc' no_html = 1 %]</h1>
48 <div id="permissionstree">
49 <div id="permissions_toolbar" class="btn-toolbar">
50 <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Save</button>
51 <a class="btn btn-default" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-times"></i> Cancel</a>
52 <a class="toggleall toggleall_on btn btn-link" href="#"><i class="fa-solid fa-square-plus"></i> Show all</a>
53 <a class="toggleall toggleall_off btn btn-link" href="#"><i class="fa-solid fa-square-minus"></i> Hide all</a>
54 <a id="CheckAllFlags" class="btn btn-link" href="#">
55 <i class="fa fa-check"></i> Select all
57 <a id="UncheckAllFlags" class="btn btn-link" href="#">
58 <i class="fa fa-times"></i> Clear all
60 <div class="btn-group pull-right">
61 Filter: <input type="text" name="permissions_filter" id="permissions_filter" size="20" />
62 <a href="#" id="clear_filter" style="display:none"><i class="fa fa-times"></i></a>
65 <div class="permissions">
66 [% FOREACH loo IN loop %]
67 [% IF ( loo.expand ) %]
68 <div id="parent-flag-[% loo.flag | html %]" class="open parent">
70 <div id="parent-flag-[% loo.flag | html %]" class="parent">
72 [% IF ( loo.checked ) %]
73 [% IF disable_superlibrarian_privs && loo.bit == 0 %]
74 <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" />
75 <input type="hidden" id="flag-0" name="flag" value="[% loo.flag | html %]" >
77 <input type="checkbox" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]" class="parent flag" name="flag" value="[% loo.flag | html %]" checked="checked" />
80 [% IF disable_superlibrarian_privs && loo.bit == 0 %]
81 <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" />
83 <input type="checkbox" class="flag parent" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" />
85 [% END # /IF loo.checked %]
86 <label class="permissiondesc" for="flag-[% loo.bit | html %]">
87 [% PROCESS main_permissions name=loo.flag %]
89 [% 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 %]
90 [% IF ( loo.sub_perm_loop ) %]
91 <a class="toggle-[% loo.bit | html %] togglechildren_off" href="#" data-bit="[% loo.bit | html %]"><i class="fa-solid fa-square-minus"></i> Hide details</a>
92 <a class="toggle-[% loo.bit | html %] togglechildren_on" href="#" data-bit="[% loo.bit | html %]"><i class="fa-solid fa-square-plus"></i> Show details</a>
93 <div class="children" id="flag-[% loo.bit | html %]-children">
94 [% FOREACH sub_perm_loo IN loo.sub_perm_loop %]
95 <div class="child-flags">
96 [% IF ( sub_perm_loo.checked ) %]
97 <input type="checkbox" id="[% sub_perm_loo.id | html %]" class="child flag" name="flag" value="[% sub_perm_loo.perm | html %]" checked="checked" />
99 <input type="checkbox" id="[% sub_perm_loo.id | html %]" class="child flag" name="flag" value="[% sub_perm_loo.perm | html %]" />
101 <label class="permissiondesc" for="[% sub_perm_loo.id | html %]">
102 [% PROCESS sub_permissions name=sub_perm_loo.code %]
106 </div> <!-- /#flag-[% loo.bit | html %]-children -->
107 [% END # /IF loo.sub_perm_loop %]
108 </div> <!-- /.parent -->
109 [% END # /FOREACH loo %]
111 </div> <!-- /#permissionstree -->
115 </div> <!-- /.col-sm-10.col-sm-push-2 -->
117 <div class="col-sm-2 col-sm-pull-10">
119 [% INCLUDE 'circ-menu.inc' %]
121 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
122 </div> <!-- /.row -->
124 [% MACRO jsinclude BLOCK %]
125 [% INCLUDE 'str/members-menu.inc' %]
126 [% Asset.js("js/members-menu.js") | $raw %]
127 [% Asset.js("lib/hc-sticky.js") | $raw %]
130 $(document).ready(function() {
132 [% IF disable_superlibrarian_privs && patron.is_superlibrarian %]
133 $("#CheckAllFlags,#UncheckAllFlags")
134 .attr("disabled", true)
135 .attr("title", _("The system preference ProtectSuperlibrarian is enabled"))
136 .on("click", function(e){e.preventDefault()});
138 $("#CheckAllFlags").on("click",function(){
139 $(".flag").attr("disabled", false);
140 $(".flag").prop("checked", true);
141 $("#flag-0").prop("checked", false);
142 [% IF disable_superlibrarian_privs %]
143 $("#flag-0").prop("disabled", true);
147 $("#UncheckAllFlags").on("click",function(){
148 $(".flag").attr("disabled", false);
149 [% IF disable_superlibrarian_privs %]
150 $("#flag-0").prop("disabled", true);
152 $(".flag").prop("checked", false);
155 $(".flag").change(function(){
156 if(!$(this).is(':checked')){
157 $("input#flag-0").prop("checked", false);
162 Sticky = $("#permissions_toolbar");
164 stickTo: "#permissionstree",
165 stickyClass: "floating"
168 $(".open div").show();
170 $("#permissions_filter").on("keyup", function(){
171 $("#clear_filter").css("display","inline-block");
172 $("a[class^=toggle-]").hide();
173 var string = $(this).val();
174 var divs = $("div[id!='parent-flag-superlibrarian']", ".permissions");
175 if( string != "" && string.length > 3 ){
176 divs.each(function(){
177 if ( $(this).text().search(new RegExp( string, "i")) < 0 ) {
188 $("#clear_filter").on("click", function(){
189 $(".togglechildren_off").show();
190 $("#permissions_filter").val("");
191 $("div", "#permissionstree").show();
192 $(this).css("display","none");
195 // Enforce Superlibrarian Privilege Mutual Exclusivity
196 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
197 if ($('input[name="flag"]:checked').length > 1){
198 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."));
204 $('input#flag-0').click(function() {
205 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
206 $('input[name="flag"]').each(function() {
207 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
208 $(this).prop('disabled', true);
209 $(this).prop('checked', false);
214 $('input[name="flag"]').each(function() {
215 $(this).prop('disabled', false);
221 $(".toggleall_off, .toggleall_on").on('click', function(e) {
223 if( $(this).hasClass("toggleall_on")){
224 $(".children,.togglechildren_off").show();
225 $(".togglechildren_on").hide();
227 $(".children,.togglechildren_off").hide();
228 $(".togglechildren_on").show();
232 $(".togglechildren_off, .togglechildren_on").on('click', function(e) {
234 var bit = $(this).data("bit");
235 $("#flag-" + bit + "-children").toggle();
236 $(".toggle-" + bit).toggle();
239 $(".togglechildren_off, .togglechildren_on").hover( function(){
240 $(this).parent().addClass("permission-highlight");
242 $(this).parent().removeClass("permission-highlight");
245 $(".flag").on("change",function(e){
247 if( $(this).hasClass("child") ){
248 if( $(this).prop("checked") ){
249 // If this is the last of all the child boxes to be checked the parent should be checked too
251 $(this).closest(".children").find(".child").each(function(){
252 if( !$(this).prop("checked") ){
253 // There are still unchecked checkboxes in this group
257 if( unchecked === 0 ){
258 $(this).closest(".parent").find(".flag.parent").prop("checked", true);
261 $(this).closest(".parent").find(".flag.parent").prop("checked", false);
264 var bit = $(this).data("bit");
265 if( $(this).is(":checked") ){
266 $("#flag-" + bit + "-children").show().find(".flag").prop("checked", true);
267 $(".toggle-" + bit + ".togglechildren_on").hide();
268 $(".toggle-" + bit + ".togglechildren_off").show();
270 $("#flag-" + bit + "-children").show().find(".flag").prop("checked", false);
276 function setLibrarian(){
277 $('input[name="flag"]').each(function() {
278 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
279 $(this).prop('disabled', true);
280 $(this).prop('checked', false);
288 [% INCLUDE 'intranet-bottom.inc' %]