From b9c74fb24c3c484352841bc38201faf4b5f3b7e6 Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Tue, 18 Dec 2007 13:06:36 -0600 Subject: [PATCH] memberentry.pl - dates validation, error passing to template Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- members/memberentry.pl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/members/memberentry.pl b/members/memberentry.pl index 253e6e45af..17a84e82aa 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -108,9 +108,18 @@ if ($op eq 'insert' || $op eq 'modify' || $op eq 'save') { $newdata{$key} = $input->param($key) if (defined $input->param($key)); $newdata{$key} =~ s/\"/"/gg unless $key eq 'borrowernotes' or $key eq 'opacnote'; } -# $newdata{'dateenrolled'}=format_date_in_iso($newdata{'dateenrolled'}) if ($newdata{dateenrolled}); -# $newdata{'dateexpiry'} =format_date_in_iso($newdata{'dateexpiry'} ) if ($newdata{dateexpiry}); -# $newdata{'dateofbirth'} =format_date_in_iso($newdata{'dateofbirth'} ) if ($newdata{dateofbirth}); + my $dateobject = C4::Dates->new(); + my $regexp = $dateobject->regexp(); # same format for all 3 dates + foreach (qw(dateenrolled dateexpiry dateofbirth)) { + my $userdate = $newdata{$_} or next; + if ($userdate =~ /$regexp/) { + $newdata{$_} = format_date_in_iso($userdate); + } else { + $template->param( "ERROR_$_" => $userdate ); + push(@errors,"ERROR_$_"); + $nok++; + } + } # check permission to modify login info. if (ref($borrower_data) && ($borrower_data->{'category_type'} eq 'S') && ! (C4::Auth::haspermission($dbh,$userenv->{'id'},{'staffaccess'=>1})) ) { $NoUpdateLogin =1; @@ -207,7 +216,7 @@ if ($op eq 'insert'){ add_member_orgs($borrowernumber,\@orgs); } if ($destination eq "circ") { - print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$data{'cardnumber'}"); + print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$data{'cardnumber'}"); } else { if ($loginexist == 0) { print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber"); -- 2.39.5