[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 51f6b315033d81513640a373b3d4313246df1a91
Mark Wells
mark at 420.am
Fri Apr 13 12:09:59 PDT 2012
The branch, FREESIDE_2_3_BRANCH has been updated
via 51f6b315033d81513640a373b3d4313246df1a91 (commit)
from e61c3867a93add32ffb00c88ad84da77473de37c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 51f6b315033d81513640a373b3d4313246df1a91
Author: Mark Wells <mark at freeside.biz>
Date: Fri Apr 13 12:09:51 2012 -0700
adjustment to display_custnum special format, #16815
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 109e561..0473864 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3894,7 +3894,7 @@ and customer address. Include units.',
'section' => 'UI',
'description' => 'Prefix the customer number with this string for display purposes.',
'type' => 'text',
- #and then probably agent-virt this to merge these instances
+ 'per_agent' => 1,
},
{
@@ -3903,6 +3903,7 @@ and customer address. Include units.',
'description' => 'Use this customer number prefix format',
'type' => 'select',
'select_hash' => [ '' => '',
+ 'CoStAg' => 'CoStAg (country, state, agent name or display_prefix)',
'CoStCl' => 'CoStCl (country, state, class name)' ],
},
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 9975742..b2373d3 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -3912,9 +3912,16 @@ cust_main-default_agent_custid is set and it has a value, custnum otherwise.
sub display_custnum {
my $self = shift;
- my $prefix = $conf->config('cust_main-custnum-display_prefix') || '';
+ my $prefix = $conf->config('cust_main-custnum-display_prefix', $self->agentnum) || '';
if ( my $special = $conf->config('cust_main-custnum-display_special') ) {
- if ( $special eq 'CoStCl' ) {
+ if ( $special eq 'CoStAg' ) {
+ $prefix = uc( join('',
+ $self->country,
+ ($self->state =~ /^(..)/),
+ $prefix || ($self->agent->agent =~ /^(..)/)
+ ) );
+ }
+ elsif ( $special eq 'CoStCl' ) {
$prefix = uc( join('',
$self->country,
($self->state =~ /^(..)/),
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index 62464e4..1e9eee7 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -127,6 +127,12 @@ sub smart_search {
|| ( $conf->config('cust_main-agent_custid-format') eq 'ww?d+'
&& $search =~ /^\s*(\w\w?\d+)\s*$/
)
+ || ( $conf->config('cust_main-custnum-display_special')
+ # it's not currently possible for special prefixes to contain
+ # digits, so just strip off any alphabetic prefix and match
+ # the rest to custnum
+ && $search =~ /^\s*[[:alpha:]]*(\d+)\s*$/
+ )
|| ( $conf->exists('address1-search' )
&& $search =~ /^\s*(\d+\-?\w*)\s*$/ #i.e. 1234A or 9432-D
)
@@ -143,25 +149,23 @@ sub smart_search {
} );
}
- #if this becomes agent-virt need to get a list of all prefixes the current
- #user can see (via their agents)
- my $prefix = $conf->config('cust_main-custnum-display_prefix');
- if ( $prefix && $prefix eq substr($num, 0, length($prefix)) ) {
- push @cust_main, qsearch( {
- 'table' => 'cust_main',
- 'hashref' => { 'custnum' => 0 + substr($num, length($prefix)),
- %options,
+ # for all agents this user can see, if any of them have custnum prefixes
+ # that match the search string, include customers that match the rest
+ # of the custnum and belong to that agent
+ foreach my $agentnum ( $FS::CurrentUser::CurrentUser->agentnums ) {
+ my $p = $conf->config('cust_main-custnum-display_prefix', $agentnum);
+ next if !$p;
+ if ( $p eq substr($num, 0, length($p)) ) {
+ push @cust_main, qsearch( {
+ 'table' => 'cust_main',
+ 'hashref' => { 'custnum' => 0 + substr($num, length($p)),
+ 'agentnum' => $agentnum,
+ %options,
},
- 'extra_sql' => " AND $agentnums_sql", #agent virtualization
- } );
+ } );
+ }
}
- push @cust_main, qsearch( {
- 'table' => 'cust_main',
- 'hashref' => { 'agent_custid' => $num, %options },
- 'extra_sql' => " AND $agentnums_sql", #agent virtualization
- } );
-
if ( $conf->exists('address1-search') ) {
my $len = length($num);
$num = lc($num);
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Conf.pm | 3 ++-
FS/FS/cust_main.pm | 11 +++++++++--
FS/FS/cust_main/Search.pm | 36 ++++++++++++++++++++----------------
3 files changed, 31 insertions(+), 19 deletions(-)
More information about the freeside-commits
mailing list