X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fcust_main-contacts.html;h=2a7185b5c464864f91f129a6f4bf4b48660e7941;hb=a16891c16e0ddd389b32963b638cdfeadf86c447;hp=10ec3638f0a2638bdd746c96cf5cdacbff3c3b28;hpb=5499e8e571862b071e1b072a017aba16636ea34b;p=freeside.git diff --git a/httemplate/edit/process/cust_main-contacts.html b/httemplate/edit/process/cust_main-contacts.html index 10ec3638f..2a7185b5c 100644 --- a/httemplate/edit/process/cust_main-contacts.html +++ b/httemplate/edit/process/cust_main-contacts.html @@ -3,6 +3,7 @@ 'error_redirect' => popurl(3). 'edit/cust_main-contacts.html?', 'agent_virt' => 1, 'skip_process' => 1, #we don't want to make any changes to cust_main + 'precheck_callback' => $precheck_callback, 'process_o2m' => { 'table' => 'contact', 'fields' => FS::contact->cgi_contact_fields, @@ -10,3 +11,22 @@ 'redirect' => popurl(3). 'view/cust_main.cgi?', ) %> +<%init> +my $precheck_callback = sub { + my $cgi = shift; + my $conf = FS::Conf->new; + if ( $conf->exists('cust_main-require_invoicing_list_email') ) { + my $has_email = 0; + foreach my $prefix (grep /^contactnum\d+$/, $cgi->param) { + if ( length($cgi->param($prefix . '_emailaddress')) + and $cgi->param($prefix . '_invoice_dest') ) { + $has_email = 1; + last; + } + } + return "At least one contact must receive email invoices" + unless $has_email; + } + ''; +}; +