'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.',
$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";
}
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;
}
} );
}
+ #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 },