From 6aa4566a38f2ef9a9580b976138bfa83e1a7d69d Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Thu, 28 Feb 2013 23:21:19 -0800 Subject: enforce agent-ship_address in backend interface, #21327 --- httemplate/edit/process/cust_main.cgi | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'httemplate/edit/process') diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index c6c8ea1aa..29805beeb 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -78,6 +78,23 @@ if ( $duplicate_of ) { 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', ''); + } +} + if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) { $new->setfield("ship_$_", '') foreach qw( last first company address1 address2 city county state zip -- cgit v1.2.1