summaryrefslogtreecommitdiff
path: root/httemplate/edit/process
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-02-28 23:21:19 -0800
committerMark Wells <mark@freeside.biz>2013-02-28 23:21:19 -0800
commit6aa4566a38f2ef9a9580b976138bfa83e1a7d69d (patch)
tree618fc711ef02140efa611451d4059d1ab33e2fc9 /httemplate/edit/process
parent8e901031d883660ed0052f49600c5dd3c5c65e05 (diff)
enforce agent-ship_address in backend interface, #21327
Diffstat (limited to 'httemplate/edit/process')
-rwxr-xr-xhttemplate/edit/process/cust_main.cgi17
1 files changed, 17 insertions, 0 deletions
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