From 28068ce124475769c26419dbc0799cfac04a39dd Mon Sep 17 00:00:00 2001 From: Jake Deery Date: Fri, 30 Aug 2024 11:10:35 +0000 Subject: [PATCH] Bug 37360: Add protected as a borrower mod option This patch adds protected status as a batch borrower modification option, if the user performing the modification is a superlibrarian. TO TEST: a) login as a superlibrarian b) attempt to batch modify these k.t.d user barcodes: 1) 23529000035676 2) 23529001000463 3) 23529000050113 c) notice that there is no protected option d) APPLY PATCH e) repeat step b f) notice that protected is now an option g) set all borrowers to protected (yes) 1) notice that the status has changed, in each individual user record h) set all borrowers to unprotected (no) 1) notice that the status has changed, in each individual user record i) set the proctedted status back to yes, but also set some other random options (e.g. city to Cork) 1) notice that the city and protected status are both updated j) use the disabled checkbox next to protected 1) notice that this always sets the protected status to zero k) SIGN OFF Signed-off-by: Catrina Signed-off-by: Brendan Lawlor --- .../prog/en/modules/tools/modborrowers.tt | 13 ++++++++++ tools/modborrowers.pl | 24 +++++++++++++------ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt index e398e1241b..431cf9ea41 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt @@ -260,6 +260,9 @@ [% IF CanUpdatePasswordExpiration %] Password expiration date [% END %] + [% IF CanUpdateProtectPatron %] + Protected + [% END %] Circulation note OPAC note Restriction expiration @@ -306,6 +309,15 @@ Never [% END %] [% END %] + [% IF CanUpdateProtectPatron %] + + [% IF borrower.protected %] + Yes + [% ELSE %] + No + [% END %] + + [% END %] [% borrower.borrowernotes | $raw | html_line_break %] [% borrower.opacnote | html %] [% borrower.debarred | $KohaDates %] @@ -363,6 +375,7 @@ [% CASE 'debarred' %]Restriction expiration: [% CASE 'debarredcomment' %]Restriction comment: [% CASE 'password_expiration_date' %]Password expiration date: + [% CASE 'protected' %]Protected: [% END %] [% IF ( field.type == 'text' ) %] diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl index 6492d2f07b..99f33f788c 100755 --- a/tools/modborrowers.pl +++ b/tools/modborrowers.pl @@ -22,7 +22,7 @@ # Batch Edit Patrons # Modification for patron's fields: # surname firstname branchcode categorycode city state zipcode country sort1 -# sort2 dateenrolled dateexpiry borrowernotes +# sort2 dateenrolled dateexpiry borrowernotes protected # And for patron attributes. use Modern::Perl; @@ -51,8 +51,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $logged_in_user = Koha::Patrons->find( $loggedinuser ); -$template->param( CanUpdatePasswordExpiration => 1 ) if $logged_in_user->is_superlibrarian; - +if ($logged_in_user->is_superlibrarian) { + $template->param( CanUpdatePasswordExpiration => 1 ); + $template->param( CanUpdateProtectPatron => 1 ); +} my $dbh = C4::Context->dbh; # Show borrower informations @@ -178,6 +180,10 @@ if ( $op eq 'cud-show' || $op eq 'show' ) { my @categories_option; push @categories_option, { value => $_->categorycode, lib => $_->description } for @patron_categories; unshift @categories_option, { value => "", lib => "" }; + my @protected_option; + push @protected_option, { value => 1, lib => "Yes" }; + push @protected_option, { value => 0, lib => "No" }; + unshift @protected_option, { value => "", lib => "" }; my $bsort1 = GetAuthorisedValues("Bsort1"); my @sort1_option; push @sort1_option, { value => $_->{authorised_value}, lib => $_->{lib} } for @$bsort1; @@ -335,7 +341,10 @@ if ( $op eq 'cud-show' || $op eq 'show' ) { }, ); - push @fields, { name => "password_expiration_date", type => "date" } if $logged_in_user->is_superlibrarian; + if ($logged_in_user->is_superlibrarian) { + push @fields, { name => "password_expiration_date", type => "date" } ; + push @fields, { name => "protected", type => "select", option => \@protected_option }; + } $template->param('patron_attributes_codes', \@patron_attributes_codes); $template->param('patron_attributes_values', \@patron_attributes_values); @@ -350,11 +359,11 @@ if ( $op eq 'cud-do' ) { my @disabled = $input->multi_param('disable_input'); my $infos; for my $field ( - qw/surname firstname branchcode categorycode streetnumber address address2 city state zipcode country email phone mobile fax sort1 sort2 dateenrolled dateexpiry password_expiration_date borrowernotes opacnote debarred debarredcomment/ + qw/surname firstname branchcode categorycode streetnumber address address2 city state zipcode country email phone mobile fax sort1 sort2 dateenrolled dateexpiry password_expiration_date borrowernotes opacnote debarred debarredcomment protected/ ) { - my $value = $input->param($field); - $infos->{$field} = $value if $value; + my $value = $input->param($field) if $input->param($field) ne ''; + $infos->{$field} = $value if defined $value; $infos->{$field} = "" if grep { $_ eq $field } @disabled; } @@ -363,6 +372,7 @@ if ( $op eq 'cud-do' ) { } delete $infos->{password_expiration_date} unless $logged_in_user->is_superlibrarian; + delete $infos->{protected} unless $logged_in_user->is_superlibrarian; my @errors; my @borrowernumbers = $input->multi_param('borrowernumber'); -- 2.39.5