use Koha::List::Patron qw( GetPatronLists );
use Koha::Libraries;
use Koha::Patron::Categories;
-use Koha::Patron::Debarments qw( AddDebarment DelDebarment GetDebarments );
+use Koha::Patron::Debarments qw( AddDebarment DelDebarment );
use Koha::Patrons;
use List::MoreUtils qw(uniq);
my $logged_in_user = Koha::Patrons->find( $loggedinuser );
+$template->param( CanUpdatePasswordExpiration => 1 ) if $logged_in_user->is_superlibrarian;
+
my $dbh = C4::Context->dbh;
# Show borrower informations
},
);
+ push @fields, { name => "password_expiration_date", type => "date" } if $logged_in_user->is_superlibrarian;
+
$template->param('patron_attributes_codes', \@patron_attributes_codes);
$template->param('patron_attributes_values', \@patron_attributes_values);
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 sort1 sort2 dateenrolled dateexpiry borrowernotes opacnote debarred debarredcomment/ ) {
+ for my $field ( qw/surname firstname branchcode categorycode streetnumber address address2 city state zipcode country email phone mobile sort1 sort2 dateenrolled dateexpiry password_expiration_date borrowernotes opacnote debarred debarredcomment/ ) {
my $value = $input->param($field);
$infos->{$field} = $value if $value;
$infos->{$field} = "" if grep { $_ eq $field } @disabled;
}
- for my $field ( qw( dateenrolled dateexpiry debarred ) ) {
+ for my $field ( qw( dateenrolled dateexpiry debarred password_expiration_date ) ) {
$infos->{$field} = dt_from_string($infos->{$field}) if $infos->{$field};
}
+ delete $infos->{password_expiration_date} unless $logged_in_user->is_superlibrarian;
+
my @attributes = $input->multi_param('patron_attributes');
my @attr_values = $input->multi_param('patron_attributes_value');
my @borrowernumbers = $input->multi_param('borrowernumber');
# For each borrower selected
for my $borrowernumber ( @borrowernumbers ) {
+
# If at least one field are filled, we want to modify the borrower
if ( defined $infos ) {
# If a debarred date or debarred comment has been submitted make a new debarment
}
# If debarment date or debarment comment are disabled then remove all debarrments
+ my $patron = Koha::Patrons->find( $borrowernumber );
if ( grep { /debarred/ } @disabled ) {
eval {
- my $debarrments = GetDebarments( { borrowernumber => $borrowernumber } );
- foreach my $debarment (@$debarrments) {
- DelDebarment( $debarment->{'borrower_debarment_id'} );
+ my $debarrments = $patron->restrictions;
+ while( my $debarment = $debarrments->next ) {
+ DelDebarment( $debarment->borrower_debarment_id );
}
};
}
$infos->{borrowernumber} = $borrowernumber;
- eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; };
+ eval { $patron->set($infos)->store; };
if ( $@ ) { # FIXME We could provide better error handling here
- my $patron = Koha::Patrons->find( $borrowernumber );
$infos->{cardnumber} = $patron ? $patron->cardnumber || '' : '';
push @errors, { error => "can_not_update", borrowernumber => $infos->{borrowernumber}, cardnumber => $infos->{cardnumber} };
}