From 0924aec8b98b4056357bfdd19f45686a3e9008e2 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Tue, 28 Feb 2012 17:35:56 -0800 Subject: [PATCH] per-agent agent-ship_address config, #6678 --- FS/FS/ClientAPI/Signup.pm | 24 ++++++++++++++---------- FS/FS/Conf.pm | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index d0d088ad4..f17752a45 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -185,7 +185,6 @@ sub signup_info { 'signup_service' => $svc_x, 'company_name' => scalar($conf->config('company_name')), #per-agent? - 'agent_ship_address' => scalar($conf->exists('agent-ship_address')), 'logo' => scalar($conf->config_binary('logo.png')), 'prepaid_template_custnum' => $conf->exists('signup_server-prepaid-template-custnum'), }; @@ -374,13 +373,6 @@ sub signup_info { $signup_info->{'company_name'} = $conf->config('company_name', $agentnum); - if ( $signup_info->{'agent_ship_address'} && $agent->agent_custnum ) { - my $cust_main = $agent->agent_cust_main; - my $prefix = length($cust_main->ship_last) ? 'ship_' : ''; - $signup_info->{"ship_$_"} = $cust_main->get("$prefix$_") - foreach qw( address1 city county state zip country ); - } - #some of the above could probably be cached, too my $signup_info_cache_agent = $cache->get("signup_info_cache_agent$agentnum"); @@ -406,9 +398,19 @@ sub signup_info { qw( terms_of_service ) ), ( map { $_ => scalar($conf->exists($_, $agentnum)) } - qw(cust_main-require_phone) ), + qw(cust_main-require_phone agent-ship_address) ), }; + if ( $signup_info_cache_agent->{'agent-ship_address'} + && $agent->agent_cust_main ) { + + my $cust_main = $agent->agent_cust_main; + my $prefix = length($cust_main->ship_last) ? 'ship_' : ''; + $signup_info_cache_agent->{"ship_$_"} = $cust_main->get("$prefix$_") + foreach qw( address1 city county state zip country ); + + } + $cache->set("signup_info_cache_agent$agentnum", $signup_info_cache_agent); } @@ -576,7 +578,9 @@ sub new_customer { } my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); - if ( $conf->exists('agent_ship_address') && $agent->agent_custnum ) { + if ( $conf->exists('agent-ship_address', $agentnum) + && $agent->agent_custnum ) { + my $agent_cust_main = $agent->agent_cust_main; my $prefix = length($agent_cust_main->ship_last) ? 'ship_' : ''; $cust_main->set("ship_$_", $agent_cust_main->get("$prefix$_") ) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 38a689448..d84ca00f0 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2898,6 +2898,7 @@ and customer address. Include units.', 'section' => '', 'description' => "Use the agent's master service address as the service address (only ship_address2 can be entered, if blank on the master address). Useful for multi-tenant applications.", 'type' => 'checkbox', + 'per_agent' => 1, }, { 'key' => 'referral_credit', -- 2.11.0