+$new->invoice_noemail( ($cgi->param('invoice_email') eq 'Y') ? '' : 'Y' );
+
+$cgi->param('duplicate_of_custnum') =~ /^(\d+)$/;
+my $duplicate_of = $1;
+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)";
+}
+
+# if this is enabled, enforce it
+if ( $conf->exists('agent-ship_address', $cgi->param('agentnum')) ) {
+ my $agent = FS::agent->by_key($cgi->param('agentnum'));
+ my $agent_cust_main = $agent->agent_cust_main;
+ if ( $agent_cust_main ) {
+ my $pre = '';
+ $pre = 'ship_' if $agent_cust_main->has_ship_address;
+ foreach (qw(address1 city state zip country latitude longitude)) {
+ $new->set("ship_$_", $agent_cust_main->get($pre.$_));
+ }
+ foreach (qw(first last company)) {
+ $new->set("ship_$_", $cgi->param($_));
+ }
+ $cgi->param('same', '');
+ }
+}
+