From b92e0eafc315618a40e5de2f7b214e7a125d29fe Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Fri, 2 Sep 2016 22:02:03 -0500 Subject: [PATCH] 72225: OQH - Mandatory Fields on Customer Creation --- FS/FS/Conf.pm | 7 +++++++ FS/FS/cust_main.pm | 4 ++++ httemplate/edit/cust_main/basics.html | 7 +++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index cf6e90960..84acf02d4 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -4146,6 +4146,13 @@ and customer address. Include units.', }, { + 'key' => 'cust_main-require_classnum', + 'section' => 'customer_fields', + 'description' => 'Customer class is required: require customer class for all customer records.', + 'type' => 'checkbox', + }, + + { 'key' => 'cust_main-check_unique', 'section' => 'customer_fields', 'description' => 'Warn before creating a customer record where these fields duplicate another customer.', diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 7bbed1bc2..2f05af69a 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1869,6 +1869,10 @@ sub check { && ! $self->custnum && $conf->exists('cust_main-require_locale'); + return "Please select a customer class" + if ! $self->classnum + && $conf->exists('cust_main-require_classnum'); + 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/basics.html b/httemplate/edit/cust_main/basics.html index a30d7f88c..3290756a8 100644 --- a/httemplate/edit/cust_main/basics.html +++ b/httemplate/edit/cust_main/basics.html @@ -169,9 +169,12 @@ % } %# class +% my $rclass = $conf->exists('cust_main-require_classnum') ? $r : ''; <& /elements/tr-select-cust_class.html, - 'curr_value' => $cust_main->classnum, - 'label' => emt("Class"), + 'curr_value' => $cust_main->classnum, + 'label' => $rclass . emt("Class"), + 'empty_label' => $rclass ? 'Select class' : '(none)', + 'disable_empty' => ($rclass && $cust_main->classnum) ? 1 : 0, &> %# tax status -- 2.11.0