diff options
author | Ivan Kohler <ivan@freeside.biz> | 2016-03-21 13:35:21 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2016-03-21 13:35:21 -0700 |
commit | 26a30794544da000c65f0b8359254136129810d6 (patch) | |
tree | af196eb113fafe78ba12836a744df61dba8b253b /FS/FS/cust_main.pm | |
parent | 8b5956288e47e8835f25ed31e69d48c1fc2f724e (diff) |
optimize customer list, RT#20173
Diffstat (limited to 'FS/FS/cust_main.pm')
-rw-r--r-- | FS/FS/cust_main.pm | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 6d5d1d3..33e3eaf 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -98,12 +98,16 @@ our @encrypted_fields = ('payinfo', 'paycvv'); sub nohistory_fields { ('payinfo', 'paycvv'); } our $conf; +our $default_agent_custid; +our $custnum_display_length; #ask FS::UID to run this stuff for us later #$FS::UID::callback{'FS::cust_main'} = sub { install_callback FS::UID sub { $conf = new FS::Conf; #yes, need it for stuff below (prolly should be cached) - $ignore_invalid_card = $conf->exists('allow_invalid_cards'); + $ignore_invalid_card = $conf->exists('allow_invalid_cards'); + $default_agent_custid = $conf->exists('cust_main-default_agent_custid'); + $custnum_display_length = $conf->config('cust_main-custnum-display_length'); }; sub _cache { @@ -3812,34 +3816,16 @@ cust_main-default_agent_custid is set and it has a value, custnum otherwise. sub display_custnum { my $self = shift; + return $self->agent_custid + if $default_agent_custid && $self->agent_custid; + my $prefix = $conf->config('cust_main-custnum-display_prefix', $self->agentnum) || ''; - if ( my $special = $conf->config('cust_main-custnum-display_special') ) { - 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 =~ /^(..)/), - ($self->classnum ? $self->cust_class->classname =~ /^(..)/ : '__') - ) ); - } - # add any others here if needed - } - my $length = $conf->config('cust_main-custnum-display_length'); - if ( $conf->exists('cust_main-default_agent_custid') && $self->agent_custid ){ - return $self->agent_custid; - } elsif ( $prefix ) { - $length = 8 if !defined($length); + if ( $prefix ) { return $prefix . - sprintf('%0'.$length.'d', $self->custnum) - } elsif ( $length ) { - return sprintf('%0'.$length.'d', $self->custnum); + sprintf('%0'.($custnum_display_length||8).'d', $self->custnum) + } elsif ( $custnum_display_length ) { + return sprintf('%0'.$custnum_display_length.'d', $self->custnum); } else { return $self->custnum; } |