From 084378a086119bc0648b77300547e227e22ccd80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Tue, 29 Sep 2015 17:32:56 +0200 Subject: [PATCH] Bug 14924 - Remove C4::Dates from members/memberentry.pl This patch removes C4::Dates from members/memberentry.pl To test: - Apply patch - Add and edit patrons with and without birthdate as mandatory field (syspref BorrowerMandatoryField) - Verify that dates (birtdate, registration, expiration) display and are stored correctly --- members/memberentry.pl | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/members/memberentry.pl b/members/memberentry.pl index 5841022..1a0f83b 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -35,7 +35,6 @@ use C4::Members; use C4::Members::Attributes; use C4::Members::AttributeTypes; use C4::Koha; -use C4::Dates qw/format_date format_date_in_iso/; use C4::Log; use C4::Letters; use C4::Branch; # GetBranches @@ -168,20 +167,11 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) } } - my $dateobject = C4::Dates->new(); - 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 - } elsif ($userdate =~ /$iso/) { - warn "Date $_ ($userdate) is already in ISO format"; - } else { - ($userdate eq '0000-00-00') and warn "Data error: $_ is '0000-00-00'"; - $template->param( "ERROR_$_" => 1 ); # else ERROR! - push(@errors,"ERROR_$_"); + if ( $userdate ) { + $newdata{$_} = output_pref({ dt => dt_from_string( $userdate ), dateformat => 'iso', dateonly => 1 }); } } # check permission to modify login info. @@ -361,7 +351,7 @@ if ($op eq 'save' || $op eq 'insert'){ if ( ($op eq 'modify' || $op eq 'insert' || $op eq 'save'|| $op eq 'duplicate') and ($step == 0 or $step == 3 )){ unless ($newdata{'dateexpiry'}){ - my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso'); + my $arg2 = $newdata{'dateenrolled'} || output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); $newdata{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2); } } @@ -657,10 +647,10 @@ if ($nok) { #Formatting data for display if (!defined($data{'dateenrolled'}) or $data{'dateenrolled'} eq ''){ - $data{'dateenrolled'}=C4::Dates->today('iso'); + $data{'dateenrolled'} = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); } if ( $op eq 'duplicate' ) { - $data{'dateenrolled'} = C4::Dates->today('iso'); + $data{'dateenrolled'} = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); $data{'dateexpiry'} = GetExpiryDate( $data{'categorycode'}, $data{'dateenrolled'} ); } if (C4::Context->preference('uppercasesurnames')) { @@ -669,8 +659,10 @@ if (C4::Context->preference('uppercasesurnames')) { } foreach (qw(dateenrolled dateexpiry dateofbirth)) { - $data{$_} = format_date($data{$_}); # back to syspref for display - $template->param( $_ => $data{$_}); + if ( $data{$_} ) { + $data{$_} = output_pref({ dt => dt_from_string( $data{$_} ), dateonly => 1 }); # back to syspref for display + } + $template->param( $_ => $data{$_}); } if (C4::Context->preference('ExtendedPatronAttributes')) { -- 1.7.10.4