diff options
| author | Mark Wells <mark@freeside.biz> | 2012-04-13 12:09:51 -0700 | 
|---|---|---|
| committer | Mark Wells <mark@freeside.biz> | 2012-04-13 12:09:51 -0700 | 
| commit | 51f6b315033d81513640a373b3d4313246df1a91 (patch) | |
| tree | af2273b00858cd0e462e103446a224795351dfce /FS | |
| parent | e61c3867a93add32ffb00c88ad84da77473de37c (diff) | |
adjustment to display_custnum special format, #16815
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS/Conf.pm | 3 | ||||
| -rw-r--r-- | FS/FS/cust_main.pm | 11 | ||||
| -rw-r--r-- | FS/FS/cust_main/Search.pm | 36 | 
3 files changed, 31 insertions, 19 deletions
| diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 109e56148..047386478 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 997574288..b2373d30b 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 62464e4aa..1e9eee79d 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); | 
