View | Details | Raw Unified | Return to bug 14924
Collapse All | Expand All

(-)a/members/memberentry.pl (-18 / +9 lines)
Lines 35-41 use C4::Members; Link Here
35
use C4::Members::Attributes;
35
use C4::Members::Attributes;
36
use C4::Members::AttributeTypes;
36
use C4::Members::AttributeTypes;
37
use C4::Koha;
37
use C4::Koha;
38
use C4::Dates qw/format_date format_date_in_iso/;
39
use C4::Log;
38
use C4::Log;
40
use C4::Letters;
39
use C4::Letters;
41
use C4::Branch; # GetBranches
40
use C4::Branch; # GetBranches
Lines 168-187 if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) Link Here
168
        }
167
        }
169
    }
168
    }
170
169
171
    my $dateobject = C4::Dates->new();
172
    my $syspref = $dateobject->regexp();		# same syspref format for all 3 dates
173
    my $iso     = $dateobject->regexp('iso');	#
174
    foreach (qw(dateenrolled dateexpiry dateofbirth)) {
170
    foreach (qw(dateenrolled dateexpiry dateofbirth)) {
175
        next unless exists $newdata{$_};
171
        next unless exists $newdata{$_};
176
        my $userdate = $newdata{$_} or next;
172
        my $userdate = $newdata{$_} or next;
177
        if ($userdate =~ /$syspref/) {
173
        if ( $userdate ) {
178
            $newdata{$_} = format_date_in_iso($userdate);	# if they match syspref format, then convert to ISO
174
            $newdata{$_} = output_pref({ dt => dt_from_string( $userdate ), dateformat => 'iso', dateonly => 1 });
179
        } elsif ($userdate =~ /$iso/) {
180
            warn "Date $_ ($userdate) is already in ISO format";
181
        } else {
182
            ($userdate eq '0000-00-00') and warn "Data error: $_ is '0000-00-00'";
183
            $template->param( "ERROR_$_" => 1 );	# else ERROR!
184
            push(@errors,"ERROR_$_");
185
        }
175
        }
186
    }
176
    }
187
  # check permission to modify login info.
177
  # check permission to modify login info.
Lines 361-367 if ($op eq 'save' || $op eq 'insert'){ Link Here
361
351
362
if ( ($op eq 'modify' || $op eq 'insert' || $op eq 'save'|| $op eq 'duplicate') and ($step == 0 or $step == 3 )){
352
if ( ($op eq 'modify' || $op eq 'insert' || $op eq 'save'|| $op eq 'duplicate') and ($step == 0 or $step == 3 )){
363
    unless ($newdata{'dateexpiry'}){
353
    unless ($newdata{'dateexpiry'}){
364
        my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso');
354
        my $arg2 = $newdata{'dateenrolled'} || output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
365
        $newdata{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2);
355
        $newdata{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2);
366
    }
356
    }
367
}
357
}
Lines 657-666 if ($nok) { Link Here
657
  #Formatting data for display    
647
  #Formatting data for display    
658
  
648
  
659
if (!defined($data{'dateenrolled'}) or $data{'dateenrolled'} eq ''){
649
if (!defined($data{'dateenrolled'}) or $data{'dateenrolled'} eq ''){
660
  $data{'dateenrolled'}=C4::Dates->today('iso');
650
  $data{'dateenrolled'} = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
661
}
651
}
662
if ( $op eq 'duplicate' ) {
652
if ( $op eq 'duplicate' ) {
663
    $data{'dateenrolled'} = C4::Dates->today('iso');
653
    $data{'dateenrolled'} = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
664
    $data{'dateexpiry'} = GetExpiryDate( $data{'categorycode'}, $data{'dateenrolled'} );
654
    $data{'dateexpiry'} = GetExpiryDate( $data{'categorycode'}, $data{'dateenrolled'} );
665
}
655
}
666
if (C4::Context->preference('uppercasesurnames')) {
656
if (C4::Context->preference('uppercasesurnames')) {
Lines 669-676 if (C4::Context->preference('uppercasesurnames')) { Link Here
669
}
659
}
670
660
671
foreach (qw(dateenrolled dateexpiry dateofbirth)) {
661
foreach (qw(dateenrolled dateexpiry dateofbirth)) {
672
	$data{$_} = format_date($data{$_});	# back to syspref for display
662
    if ( $data{$_} ) {
673
	$template->param( $_ => $data{$_});
663
        $data{$_} = output_pref({ dt => dt_from_string( $data{$_} ), dateonly => 1 }); # back to syspref for display
664
    }
665
    $template->param( $_ => $data{$_});
674
}
666
}
675
667
676
if (C4::Context->preference('ExtendedPatronAttributes')) {
668
if (C4::Context->preference('ExtendedPatronAttributes')) {
677
- 

Return to bug 14924