MT3212 : members modification wipeout dateexpiry
authorHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 7 Apr 2010 13:01:22 +0000 (15:01 +0200)
committerGalen Charlton <gmcharlt@gmail.com>
Fri, 30 Apr 2010 01:33:51 +0000 (21:33 -0400)
Members modification when not in Library information mode would wipe out dateexpiry information

Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
members/memberentry.pl

index 8aff67a..c99dcb9 100755 (executable)
@@ -130,6 +130,7 @@ if ($op eq 'insert' || $op eq 'modify' || $op eq 'save') {
     my $syspref = $dateobject->regexp();               # same syspref format for all 3 dates
     my $iso     = $dateobject->regexp('iso');  #
     foreach (qw(dateenrolled dateexpiry dateofbirth)) {
+        next unless exists $newdata{$_};
         my $userdate = $newdata{$_} or next;
         if ($userdate =~ /$syspref/) {
             $newdata{$_} = format_date_in_iso($userdate);      # if they match syspref format, then convert to ISO
@@ -274,7 +275,7 @@ if ($op eq 'save' || $op eq 'insert'){
 }
 
 if ($op eq 'modify' || $op eq 'insert' || $op eq 'save' ){
-    unless ($newdata{'dateexpiry'}){
+    if (exists ($newdata{'dateexpiry'}) && !($newdata{'dateexpiry'})){
         my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso');
         $newdata{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2);
     }
@@ -373,8 +374,6 @@ if (C4::Context->preference("IndependantBranches")) {
     }
 }
 if ($op eq 'add'){
-    my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso');
-    $data{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2);
     $template->param( updtype => 'I', step_1=>1, step_2=>1, step_3=>1, step_4=>1, step_5 => 1, step_6 => 1);
 }
 if ($op eq "modify")  {