Bug 11853: Allow to clear the date of birth at the OPAC

A patron is not able to clear their date of birth.

When cleared tt is set to NULL in DB which means, for the patron's
modifications feature, that nothing has been changed.

Test plan:
0/ Do not apply the patch
1/ Edit your personal details at the OPAC
2/ Add a date of birth
3/ On the staff interface, approve the modification request
=> OK it is updated
4/ Edit your personal details and clear the date of birth
5/ On the staff interface
=> KO the table display is wrong, nothing is marked has changed
6/ Approve the modification requiest
=> KO it has not been cleared
7/ Apply the patch and repeat 1 to 6 and confirm that the behaviors are
now correct.

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 6692800794)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2019-05-08 16:37:50 -05:00 committed by Martin Renvoize
parent b95682f735
commit c6ca2dfcd3
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 14 additions and 6 deletions

View File

@ -92,14 +92,18 @@ sub approve {
delete $data->{verification_token};
delete $data->{extended_attributes};
foreach my $key ( keys %$data ) {
delete $data->{$key} unless ( defined( $data->{$key} ) );
}
my $patron = Koha::Patrons->find( $self->borrowernumber );
return unless $patron;
foreach my $key ( keys %$data ) {
next # Unset it!
if $key eq 'dateofbirth'
&& $patron->dateofbirth
&& not defined $data->{$key};
delete $data->{$key} unless defined $data->{$key};
}
$patron->set($data);
# Take care of extended attributes

View File

@ -132,7 +132,11 @@ sub pending {
$row->{$key} = \@pending_attributes;
}
delete $row->{$key} unless defined $row->{$key};
if ( $key eq 'dateofbirth' and not defined $row->{$key}) {
$row->{$key} = '';
} else {
delete $row->{$key} unless defined $row->{$key};
}
}
push( @m, $row );