From 7109bfc5e06bbabb3d61c6298ce59cf287541667 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 28 Nov 2011 01:40:17 +0000 Subject: [PATCH] add inter.net numbering on freeside custnum instead, RT#15326 --- FS/FS/Conf.pm | 9 ++++++++- FS/FS/cust_main.pm | 12 +++--------- FS/FS/cust_main/Search.pm | 13 +++++++++++++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index e27a88584..d4983ae48 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -3779,11 +3779,18 @@ and customer address. Include units.', 'type' => 'select', 'select_hash' => [ '' => 'No', '1YMMXXXXXXXX' => '1YMMXXXXXXXX', - '1001XXXXXXXX' => '1001XXXXXXXX', ], }, { + 'key' => 'cust_main-custnum-display_prefix', + 'section' => 'UI', + 'description' => 'Prefix the customer number with this number for display purposes (and zero fill to 8 digits).', + 'type' => 'text', + #and then probably agent-virt this to merge these instances + }, + + { 'key' => 'cust_main-default_areacode', 'section' => 'UI', 'description' => 'Default area code for customers.', diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 32912afe7..12dc9ef43 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -676,15 +676,6 @@ sub auto_agent_custid { $counter->unlock; - } elsif ( $format eq '1001XXXXXXXX' ) { - - my $counter = new File::CounterFile 'cust_main.agent_custid'; - $counter->lock; - - $agent_custid = '1001'. $counter->inc; - - $counter->unlock; - } else { die "Unknown cust_main-auto_agent_custid format: $format"; } @@ -3888,6 +3879,9 @@ sub display_custnum { my $self = shift; if ( $conf->exists('cust_main-default_agent_custid') && $self->agent_custid ){ return $self->agent_custid; + } elsif ( $conf->config('cust_main-custnum-display_prefix') ) { + return $conf->config('cust_main-custnum-display_prefix'). + sprintf('%08d', $self->custnum) } else { return $self->custnum; } diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index 5636fc6e4..e017400a5 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -142,6 +142,19 @@ 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, + }, + 'extra_sql' => " AND $agentnums_sql", #agent virtualization + } ); + } + push @cust_main, qsearch( { 'table' => 'cust_main', 'hashref' => { 'agent_custid' => $num, %options }, -- 2.11.0