+$new->invoice_noemail( ($cgi->param('invoice_email') eq 'Y') ? '' : 'Y' );
+
+if ( $duplicate_of ) {
+ # then negate all changes to the customer; the only change we should
+ # make is to order a package, if requested
+ $new = qsearchs('cust_main', { 'custnum' => $duplicate_of })
+ # this should never happen
+ or die "nonexistent existing customer (custnum $duplicate_of)";
+}
+
+for my $pre (qw(bill ship)) {
+ $new->set($pre.'_location', $locations{$pre});
+ $new->set($pre.'_locationnum', $locations{$pre}->locationnum);
+}
+
+if ( $cgi->param('no_credit_limit') ) {
+ $new->setfield('credit_limit', '');
+}
+
+$new->tagnum( [ $cgi->param('tagnum') ] );
+
+$error ||= $new->set_national_id_from_cgi( $cgi );
+
+my %usedatetime = ( 'birthdate' => 1,
+ 'spouse_birthdate' => 1,
+ 'anniversary_date' => 1,
+ );
+
+foreach my $dfield (qw(
+ signupdate birthdate spouse_birthdate anniversary_date
+)) {
+
+ 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 ||= "Invalid $dfield: $value";
+ }
+
+ } else {
+
+ $parsed = parse_datetime($value)
+ or $error ||= "Invalid $dfield: $value";
+
+ }
+
+ $new->setfield( $dfield, $parsed );
+ $cgi->param( $dfield, $parsed );
+
+ }
+