Bug 11853: Allow to clear the date of birth at the OPAC
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 8 May 2019 21:37:50 +0000 (16:37 -0500)
committerNick Clemens <nick@bywatersolutions.com>
Tue, 14 May 2019 18:20:31 +0000 (18:20 +0000)
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>

Koha/Patron/Modification.pm
Koha/Patron/Modifications.pm

index b0e01b7..b5d5ade 100644 (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
index 5b424cd..646d112 100644 (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 );