show imported region and rate #s, RT#83146
[freeside.git] / httemplate / edit / cust_main / contacts_new.html
1 <SCRIPT>
2   function checkPasswordValidation(fieldid)  {
3     var validationResult = document.getElementById(fieldid+'_result').innerHTML;
4     if (validationResult.match(/Password valid!/)) {
5       return true;
6     }
7     else {
8       return false;
9     }
10   }
11 </SCRIPT>
12
13 <& '/elements/validate_password_js.html', &>
14
15 <DIV ID="contacts_div" STYLE="display:<% $display %>">
16 <BR>
17 <FONT CLASS="fsinnerbox-title">Contacts</FONT>
18 <% include('/edit/elements/edit.html',
19      'embed'            => $opt{cust_main},
20      'table'            => 'cust_main',
21      'agent_virt'       => 1,
22      'submit_id'        => $opt{submit_id},
23      'html_table_class' => 'fsinnerbox',
24      'labels'           => { 'contactnum'  => '', #'Contact',
25                              #'locationnum' => '&nbsp;',
26                            },
27      'fields'           => [
28        { 'field'             => 'contactnum',
29          'type'              => 'contact',
30          'colspan'           => 6,
31          'custnum'           => $opt{cust_main}->custnum,
32          'm2m_method'        => 'cust_contact',
33          'm2m_dstcol'        => 'contactnum',   
34          'm2_label'          => ' ', #'Contact',
35          'm2_error_callback' => $m2_error_callback,
36        },
37      ],
38     )
39 %>
40 </DIV>
41 <%init>
42
43 my %opt = @_;
44
45 my $display = ($opt{'cust_main'}->residential_commercial eq 'Commercial')
46                 ? ''
47                 : 'none';
48
49 my $curuser = $FS::CurrentUser::CurrentUser;
50 my $conf = new FS::Conf;
51
52 my $m2_error_callback = sub {
53   my($cgi, $object) = @_;
54
55   #process_o2m fields in process/cust_main-contacts.html
56   my $fields = FS::contact->cgi_contact_fields;
57   my @gfields = ( '', map "_$_", @$fields );
58
59   map {
60         if ( /^contactnum(\d+)$/ ) {
61           my $num = $1;
62           if ( grep $cgi->param("contactnum$num$_"), @gfields ) {
63             my $x = new FS::contact {
64               'contactnum' => scalar($cgi->param("contactnum$num")),
65               map { $_ => scalar($cgi->param("contactnum${num}_$_")) } @$fields,
66             };
67             $x;
68           } else {
69             ();
70           }
71         } else {
72           ();
73         }
74       }
75       $cgi->param;
76 };
77
78 </%init>