[freeside-commits] branch master updated. 18459c4369f63b7fda11a3ff7a0af067bed0c9bf

Mark Wells mark at 420.am
Fri Apr 13 12:10:11 PDT 2012


The branch, master has been updated
       via  18459c4369f63b7fda11a3ff7a0af067bed0c9bf (commit)
      from  217bd576f8024ea541bdbb967e1c53f242980e61 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 18459c4369f63b7fda11a3ff7a0af067bed0c9bf
Author: Mark Wells <mark at freeside.biz>
Date:   Fri Apr 13 12:08:40 2012 -0700

    adjustment to display_custnum special format, #16815

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 80c0348..edfe3c2 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3889,7 +3889,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,
   },
 
   {
@@ -3898,6 +3898,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 1e0e6d3..845d098 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -3963,9 +3963,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 62464e4..1e9eee7 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);

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm             |    3 ++-
 FS/FS/cust_main.pm        |   11 +++++++++--
 FS/FS/cust_main/Search.pm |   36 ++++++++++++++++++++----------------
 3 files changed, 31 insertions(+), 19 deletions(-)




More information about the freeside-commits mailing list