X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fcust_main-contacts.html;h=2a7185b5c464864f91f129a6f4bf4b48660e7941;hb=fe58901b811f0ab26e8f93a9563fb93bc98e4c19;hp=d902dee09868d1c1a1d28909917821b01ee53aa6;hpb=cb6cca67db487271ce96b49289ada58691a2067d;p=freeside.git diff --git a/httemplate/edit/process/cust_main-contacts.html b/httemplate/edit/process/cust_main-contacts.html index d902dee09..2a7185b5c 100644 --- a/httemplate/edit/process/cust_main-contacts.html +++ b/httemplate/edit/process/cust_main-contacts.html @@ -3,20 +3,30 @@ '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' => \@contact_fields, + 'fields' => FS::contact->cgi_contact_fields, }, 'redirect' => popurl(3). 'view/cust_main.cgi?', ) %> <%init> - -my @contact_fields = qw( - classnum first last title comment emailaddress selfservice_access -); -foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) { - push @contact_fields, 'phonetypenum'.$phone_type->phonetypenum; -} - +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; + } + ''; +};