[freeside-commits] branch FREESIDE_3_BRANCH updated. 0386bd107898cbfc728454d99e98db48ce15ace5

Ivan ivan at 420.am
Mon Mar 21 13:35:28 PDT 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  0386bd107898cbfc728454d99e98db48ce15ace5 (commit)
      from  9d39272b3a6f8e43ae54c57b8690aa2fa0f5aec7 (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 0386bd107898cbfc728454d99e98db48ce15ace5
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Mar 21 13:35:27 2016 -0700

    optimize customer list, RT#20173

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 028a949..7759a71 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4731,7 +4731,7 @@ and customer address. Include units.',
   {
     'key'         => 'cust_main-default_agent_custid',
     'section'     => 'UI',
-    'description' => 'Display the agent_custid field when available instead of the custnum field.',
+    'description' => 'Display the agent_custid field when available instead of the custnum field.  Restart Apache after changing.',
     'type'        => 'checkbox',
   },
 
@@ -4768,19 +4768,9 @@ and customer address. Include units.',
   },
 
   {
-    'key'         => 'cust_main-custnum-display_special',
-    'section'     => 'UI',
-    '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)' ],
-  },
-
-  {
     'key'         => 'cust_main-custnum-display_length',
     'section'     => 'UI',
-    'description' => 'Zero fill the customer number to this many digits for display purposes.',
+    'description' => 'Zero fill the customer number to this many digits for display purposes.  Restart Apache after changing.',
     'type'        => 'text',
   },
 
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index cf9bdb9..565b36b 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -14,7 +14,7 @@ use base qw( FS::cust_main::Packages FS::cust_main::Status
              FS::o2m_Common
              FS::Record
            );
-use vars qw( $DEBUG $me $conf
+use vars qw( $DEBUG $me $conf $default_agent_custid $custnum_display_length
              @encrypted_fields
              $import
              $ignore_expired_card $ignore_banned_card $ignore_illegal_zip
@@ -97,7 +97,8 @@ sub nohistory_fields { ('payinfo', 'paycvv'); }
 #$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)
+  $default_agent_custid   = $conf->exists('cust_main-default_agent_custid');
+  $custnum_display_length = $conf->config('cust_main-custnum-display_length');
 };
 
 sub _cache {
@@ -4094,34 +4095,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;
   }

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

Summary of changes:
 FS/FS/Conf.pm      |   14 ++------------
 FS/FS/cust_main.pm |   37 ++++++++++---------------------------
 2 files changed, 12 insertions(+), 39 deletions(-)




More information about the freeside-commits mailing list