Bug 9586 - Remove $ENV{DEBUG} info from Member Template
[koha.git] / members / memberentry.pl
index 58f5cf1..7fc27c0 100755 (executable)
@@ -101,6 +101,8 @@ my @field_check=split(/\|/,$check_BorrowerMandatoryField);
 foreach (@field_check) {
        $template->param( "mandatory$_" => 1);    
 }
+# we'll need this, later.
+my $dateofbirthmandatory = (scalar grep {$_ eq "dateofbirth"} @field_check) ? 1 : 0;
 # function to designate unwanted fields
 my $check_BorrowerUnwantedField=C4::Context->preference("BorrowerUnwantedField");
 @field_check=split(/\|/,$check_BorrowerUnwantedField);
@@ -264,14 +266,14 @@ if ($op eq 'save' || $op eq 'insert'){
     if (checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ 
         push @errors, 'ERROR_cardnumber';
     } 
-    my $dateofbirthmandatory = (scalar grep {$_ eq "dateofbirth"} @field_check) ? 1 : 0;
     if ($newdata{dateofbirth} && $dateofbirthmandatory) {
         my $age = GetAge($newdata{dateofbirth});
         my $borrowercategory=GetBorrowercategory($newdata{'categorycode'});   
         my ($low,$high) = ($borrowercategory->{'dateofbirthrequired'}, $borrowercategory->{'upperagelimit'});
         if (($high && ($age > $high)) or ($age < $low)) {
             push @errors, 'ERROR_age_limitations';
-            $template->param('ERROR_age_limitations' => "$low to $high");
+            $template->param( age_low => $low);
+            $template->param( age_high => $high);
         }
     }
   
@@ -431,9 +433,10 @@ if ($op eq "modify")  {
 if ( $op eq "duplicate" ) {
     $template->param( updtype => 'I' );
     $template->param( step_1 => 1, step_2 => 1, step_3 => 1, step_4 => 1, step_5 => 1, step_6 => 1 ) unless $step;
+    $data{'cardnumber'} = "";
 }
 
-$data{'cardnumber'}=fixup_cardnumber($data{'cardnumber'}) if $op eq 'add';
+$data{'cardnumber'}=fixup_cardnumber($data{'cardnumber'}) if ( ( $op eq 'add' ) or ( $op eq 'duplicate' ) );
 if(!defined($data{'sex'})){
     $template->param( none => 1);
 } elsif($data{'sex'} eq 'F'){
@@ -521,8 +524,8 @@ my $roadpopup = CGI::popup_menu(-name=>'streettype',
         -default=>$default_roadtype
         );  
 
-my $default_borrowertitle;
-$default_borrowertitle=$data{'title'} ;
+my $default_borrowertitle = '';
+unless ( $op eq 'duplicate' ) { $default_borrowertitle=$data{'title'} }
 my($borrowertitle)=GetTitles();
 $template->param( title_cgipopup => 1) if ($borrowertitle);
 my $borrotitlepopup = CGI::popup_menu(-name=>'title',
@@ -696,12 +699,10 @@ $debug and warn "memberentry step: $step";
 $template->param(%data);
 $template->param( "step_$step"  => 1) if $step;        # associate with step to know where u are
 $template->param(  step  => $step   ) if $step;        # associate with step to know where u are
-$template->param( debug  => $debug  ) if $debug;
 
 $template->param(
   BorrowerMandatoryField => C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript
   category_type => $category_type,#to know the category type of the borrower
-  DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
   select_city => $select_city,
   "$category_type"  => 1,# associate with step to know where u are
   destination   => $destination,#to know wher u come from and wher u must go in redirect