X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fcust_main-contacts.html;h=6b7f1c2db294e0272a871392a2ba4644445ea76a;hb=1fc8addc56f8daf12397da568eb1ac1b27fd3984;hp=ed874a55e89bb2b83f79365a131b8a0f15341adf;hpb=0456422b9eaf771e8c27cfb4ef4a0dd7e6f926f8;p=freeside.git diff --git a/httemplate/edit/process/cust_main-contacts.html b/httemplate/edit/process/cust_main-contacts.html index ed874a55e..6b7f1c2db 100644 --- a/httemplate/edit/process/cust_main-contacts.html +++ b/httemplate/edit/process/cust_main-contacts.html @@ -1,20 +1,40 @@ +<%doc> + + This form works indirectly with the tables contact_email and + contact_phone. The columns are updated against an FS::contact + object. The insert/update methods of FS::contact will make the + necessary inserts/updates to contact_email and contact_phone. + + <% include('elements/process.html', 'table' => 'cust_main', - 'error_redirect' => popurl(3). 'edit/cust_main-contacts.html?', + '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 ); -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; + } + ''; +};