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 <catrina@bywatersolutions.com>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jake Deery 2024-08-30 11:10:35 +00:00 committed by Katrin Fischer
parent 480bb45281
commit ea156c99b8
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 30 additions and 7 deletions

View File

@ -261,6 +261,9 @@
[% IF CanUpdatePasswordExpiration %]
<th>Password expiration date</th>
[% END %]
[% IF CanUpdateProtectPatron %]
<th>Protected</th>
[% END %]
<th>Circulation note</th>
<th>OPAC note</th>
<th>Message</th>
@ -308,6 +311,15 @@
<td data-order="9999-99-99">Never</td>
[% END %]
[% END %]
[% IF CanUpdateProtectPatron %]
<td>
[% IF borrower.protected %]
Yes
[% ELSE %]
No
[% END %]
</td>
[% END %]
<td>[% borrower.borrowernotes | $raw | html_line_break %]</td>
<td>[% borrower.opacnote | html %]</td>
<td>
@ -378,6 +390,7 @@
[% CASE 'debarred' %]<span>Restriction expiration:</span>
[% CASE 'debarredcomment' %]<span>Restriction comment:</span>
[% CASE 'password_expiration_date' %]<span>Password expiration date:</span>
[% CASE 'protected' %]<span>Protected:</span>
[% END %]
</label>
[% IF ( field.type == 'text' ) %]

View File

@ -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;
@ -54,8 +54,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
@ -194,6 +196,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;
@ -334,7 +340,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 );
@ -349,11 +358,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;
}
@ -362,6 +371,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');