add cust_main-require_locale configuration setting, RT#17594
authorIvan Kohler <ivan@freeside.biz>
Thu, 3 May 2012 21:35:11 +0000 (14:35 -0700)
committerIvan Kohler <ivan@freeside.biz>
Thu, 3 May 2012 21:35:11 +0000 (14:35 -0700)
FS/FS/Conf.pm
FS/FS/cust_main.pm
httemplate/edit/cust_main/billing.html

index 517967c..bf7c553 100644 (file)
@@ -4977,6 +4977,13 @@ and customer address. Include units.',
     },
     'option_sub'  => sub { FS::Locales->description(shift) },
   },
+
+  {
+    'key'         => 'cust_main-require_locale',
+    'section'     => 'UI',
+    'description' => 'Require an explicit locale to be chosen for new customers.',
+    'type'        => 'checkbox',
+  },
   
   {
     'key'         => 'translate-auto-insert',
index 845d098..cba28bc 100644 (file)
@@ -1538,6 +1538,10 @@ sub replace {
     $self->censusyear($conf->config('census_year')||'2012');
   }
 
+  return "Invoicing locale is required"
+    if $old->locale
+    && ! $self->locale
+    && $conf->exists('cust_main-require_locale');
 
   local $SIG{HUP} = 'IGNORE';
   local $SIG{INT} = 'IGNORE';
@@ -2139,6 +2143,11 @@ sub check {
     $self->payname($1);
   }
 
+  return "Please select an invoicing locale"
+    if ! $self->locale
+    && ! $self->custnum
+    && $conf->exists('cust_main-require_locale');
+
   foreach my $flag (qw( tax spool_cdr squelch_cdr archived email_csv_cdr )) {
     $self->$flag() =~ /^(Y?)$/ or return "Illegal $flag: ". $self->$flag();
     $self->$flag($1);
index 9f4cb74..0194d31 100644 (file)
@@ -570,20 +570,25 @@ function toggle(obj) {
 
 %my @available_locales = $conf->config('available-locales');
 %if ( scalar(@available_locales) ) {
-%   push @available_locales, '';
-%    my %locale_labels = map { 
-%        my %ll;
-%        my %info = FS::Locales->locale_info($_);
-%        $ll{$_} = $info{name} . " (" . $info{country} . ")";
-%        %ll;
-%    } FS::Locales->locales;
-  <& /elements/tr-select.html, 
-        'label'         => emt('Invoicing locale'),
-        'field'         => 'locale',
-        'options'       => \@available_locales,
-        'labels'        => \%locale_labels,
-        'curr_value'    => $cust_main->locale,
-  &>
+%  push @available_locales, ''
+%    unless $cust_main->locale && $conf->exists('cust_main-require_locale');
+%  my %locale_labels = map { 
+%    my %ll;
+%    my %info = FS::Locales->locale_info($_);
+%    $ll{$_} = $info{name} . " (" . $info{country} . ")";
+%    %ll;
+%  } FS::Locales->locales;
+%    
+%  my $label = ( $conf->exists('cust_main-require_locale') ? $r : '' ).
+%              emt('Invoicing locale');
+
+    <& /elements/tr-select.html, 
+         'label'         => $label,
+         'field'         => 'locale',
+         'options'       => \@available_locales,
+         'labels'        => \%locale_labels,
+         'curr_value'    => $cust_main->locale,
+    &>
 % }
 
   </TABLE>