[freeside-commits] freeside/httemplate/edit/process cust_main.cgi, 1.41, 1.42

Ivan,,, ivan at wavetail.420.am
Fri Aug 7 16:08:05 PDT 2009


Update of /home/cvs/cvsroot/freeside/httemplate/edit/process
In directory wavetail.420.am:/tmp/cvs-serv7772/httemplate/edit/process

Modified Files:
	cust_main.cgi 
Log Message:
add ability to edit signup dates (turn on cust_main-edit_signupdate config), RT#4644

Index: cust_main.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/cust_main.cgi,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- cust_main.cgi	22 Jun 2009 07:50:18 -0000	1.41
+++ cust_main.cgi	7 Aug 2009 23:08:03 -0000	1.42
@@ -73,20 +73,41 @@
   );
 }
 
-if ( $cgi->param('birthdate') && $cgi->param('birthdate') =~ /^([ 0-9\-\/]{0,10})$/) {
-  my $format = $conf->config('date_format') || "%m/%d/%Y";
-  my $parser = DateTime::Format::Strptime->new(pattern => $format,
-                                               time_zone => 'floating',
-                                              );
-  my $dt =  $parser->parse_datetime($1);
-  if ($dt) {
-    $new->setfield('birthdate', $dt->epoch);
-    $cgi->param('birthdate', $dt->epoch);
-  } else {
-#    $error ||= $cgi->param('birthdate') . " is an invalid birthdate:" . $parser->errmsg;
-    $error ||= "Invalid birthdate: " . $cgi->param('birthdate') . ".";
-    $cgi->param('birthdate', '');
+my %usedatetime = ( 'birthdate' => 1 );
+
+foreach my $dfield (qw( birthdate signupdate )) {
+
+  if ( $cgi->param($dfield) && $cgi->param($dfield) =~ /^([ 0-9\-\/]{0,10})$/) {
+
+    my $value = $1;
+    my $parsed = '';
+
+    if ( exists $usedatetime{$dfield} && $usedatetime{$dfield} ) {
+
+      my $format = $conf->config('date_format') || "%m/%d/%Y";
+      my $parser = DateTime::Format::Strptime->new( pattern   => $format,
+                                                    time_zone => 'floating',
+                                                  );
+      my $dt = $parser->parse_datetime($value);
+      if ( $dt ) {
+        $parsed = $dt->epoch;
+      } else {
+    #    $error ||= $cgi->param('birthdate') . " is an invalid birthdate:" . $parser->errmsg;
+        $error ||= "Invalid $dfield: $value";
+      }
+
+    } else {
+
+      $parsed = str2time($value)
+        or $error ||= "Invalid $dfield: $value";
+
+    }
+
+    $new->setfield( $dfield, $parsed );
+    $cgi->param(    $dfield, $parsed );
+
   }
+
 }
 
 $new->setfield('paid', $cgi->param('paid') )



More information about the freeside-commits mailing list