X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=845d0984889a2760e45ede4e0532ef4d69efea3e;hb=18459c4369f63b7fda11a3ff7a0af067bed0c9bf;hp=f3f66020a2542d3396b1092778627fcd7d722bcd;hpb=ca7ff572923114a72daae24e85f33ad89ebb5ab9;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index f3f66020a..845d09848 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -8,6 +8,7 @@ use base qw( FS::cust_main::Packages FS::cust_main::Status FS::cust_main::Billing_Discount FS::otaker_Mixin FS::payinfo_Mixin FS::cust_main_Mixin FS::geocode_Mixin + FS::o2m_Common FS::Record ); use vars qw( $DEBUG $me $conf @@ -1847,7 +1848,7 @@ sub check { return $error if $error; } - if ( $conf->exists('cust_main-require_phone') + if ( $conf->exists('cust_main-require_phone', $self->agentnum) && ! length($self->daytime) && ! length($self->night) && ! length($self->mobile) ) { @@ -3214,7 +3215,7 @@ sub check_invoicing_list { } return "Email address required" - if $conf->exists('cust_main-require_invoicing_list_email') + if $conf->exists('cust_main-require_invoicing_list_email', $self->agentnum) && ! grep { $_ !~ /^([A-Z]+)$/ } @$arrayref; ''; @@ -3961,11 +3962,35 @@ 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', $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 ( $conf->config('cust_main-custnum-display_prefix') ) { - return $conf->config('cust_main-custnum-display_prefix'). - sprintf('%08d', $self->custnum) + } elsif ( $prefix ) { + $length = 8 if !defined($length); + return $prefix . + sprintf('%0'.$length.'d', $self->custnum) + } elsif ( $length ) { + return sprintf('%0'.$length.'d', $self->custnum); } else { return $self->custnum; }