summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/cust_main-contacts.html
blob: 6b7f1c2db294e0272a871392a2ba4644445ea76a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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.

</%doc>
<% include('elements/process.html',
     'table'          => 'cust_main',
     '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,
     },
     '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;
  }
  '';
};
</%init>