add inter.net numbering on freeside custnum instead, RT#15326
authorivan <ivan>
Mon, 28 Nov 2011 01:40:17 +0000 (01:40 +0000)
committerivan <ivan>
Mon, 28 Nov 2011 01:40:17 +0000 (01:40 +0000)
FS/FS/Conf.pm
FS/FS/cust_main.pm
FS/FS/cust_main/Search.pm

index e27a885..d4983ae 100644 (file)
@@ -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.',
index 32912af..12dc9ef 100644 (file)
@@ -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;
   }
index 5636fc6..e017400 100644 (file)
@@ -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 },