wtf?
[freeside.git] / httemplate / edit / process / cust_main.cgi
index d5d127b..b27e722 100755 (executable)
@@ -1,5 +1,3 @@
-%
-%
 %my $error = '';
 %
 %#unmunge stuff
@@ -46,6 +44,9 @@
 %  } fields('cust_main')
 %} );
 %
+% delete( $new->hashref->{'agent_custid'} )
+%   unless $new->hashref->{'agent_custid'};
+%
 %if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) {
 %  $new->setfield("ship_$_", '') foreach qw(
 %    last first company address1 address2 city county state zip
 %  );
 %}
 %
-%if ( $cgi->param('birthdate') && $cgi->param('birthdate') =~ /^([ 0-9\-\/]{0,10})$/ ) {
-%  eval "use DateTime::Format::Strptime;";
-%  die $@ if $@;
+%if ( $cgi->param('birthdate') && $cgi->param('birthdate') =~ /^([ 0-9\-\/]{0,10})$/) {
 %  my $conf = new FS::Conf;
 %  my $format = $conf->config('date_format') || "%m/%d/%Y";
 %  my $parser = DateTime::Format::Strptime->new(pattern => $format,
 %                                               time_zone => 'floating',
 %                                              );
-%  $new->setfield('birthdate', $parser->parse_datetime($1)->epoch);
+%  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', '');
+%  }
 %}
 %
 %$new->setfield('paid', $cgi->param('paid') )
 %
 %    #$error ||= $cust_svc->check;
 %
-%    $svc_acct = new FS::svc_acct ( {
-%                                     'svcpart'   => $svcpart,
-%                                     'username'  => $cgi->param('username'),
-%                                     '_password' => $cgi->param('_password'),
-%                                     'popnum'    => $cgi->param('popnum'),
-%                                   } );
+%    my %svc_acct = (
+%                     'svcpart'   => $svcpart,
+%                     'username'  => $cgi->param('username'),
+%                     '_password' => $cgi->param('_password'),
+%                     'popnum'    => $cgi->param('popnum'),
+%                   );
+%    $svc_acct{'domsvc'} = $cgi->param('domsvc')
+%      if $cgi->param('domsvc');
+%
+%    $svc_acct = new FS::svc_acct \%svc_acct;
 %
 %    #and just in case you were silly
 %    $svc_acct->svcpart($svcpart);
 %  my $conf = new FS::Conf;
 %  if ( $conf->exists('backend-realtime') && ! $error ) {
 %
-%    my $berror = $new->bill;
-%    $new->apply_payments;
-%    $new->apply_credits;
-%    $berror ||= $new->collect( 'realtime' => 1 );
+%    my $berror =    $new->bill
+%                 || $new->apply_payments_and_credits
+%                 || $new->collect( 'realtime' => 1 );
 %    warn "Warning, error billing during backend-realtime: $berror" if $berror;
 %
 %  }
 %       && $new->paycvv =~ /^\s*\*+\s*$/ ) {
 %    $new->paycvv($old->paycvv);
 %  }
+%  if ($new->ss =~ /xx/) {
+%    $new->ss($old->ss);
+%  }
+%  if ($new->stateid =~ /^xxx/) {
+%    $new->stateid($old->stateid);
+%  }
+%  if ($new->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ && $new->payinfo =~ /xx/) {
+%    $new->payinfo($old->payinfo);
+%  }
 %  $error ||= $new->replace($old, \@invoicing_list);
 %  
 %}
 %} else { 
 %  print $cgi->redirect(popurl(3). "view/cust_main.cgi?". $new->custnum);
 %} 
-%
-
-