From: Ivan Kohler Date: Thu, 3 May 2012 21:35:11 +0000 (-0700) Subject: add cust_main-require_locale configuration setting, RT#17594 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=5e8073ffe5707504751b8df36f645b325a895f87 add cust_main-require_locale configuration setting, RT#17594 --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 517967cf6..bf7c5533e 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -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', diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 845d09848..cba28bc9f 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -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); diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html index 9f4cb74cd..0194d31a6 100644 --- a/httemplate/edit/cust_main/billing.html +++ b/httemplate/edit/cust_main/billing.html @@ -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, + &> % }