summaryrefslogtreecommitdiff
path: root/httemplate/elements/contact.html
blob: 38703bfef6149964918f94927bff29723ce082de (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
% unless ( $opt{'js_only'} ) {

  <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">

  <TABLE>
    <TR>
      <TD>
        <INPUT TYPE = "text"
               NAME = "<%$name%>_first"
               ID   = "<%$id%>_id"
               VALUE = "<% $contact->first |h %>"
               <% $onchange %>
        ><BR>
        <FONT SIZE="-2">First name</FONT>
      </TD>
      <TD>
        <INPUT TYPE = "text"
               NAME = "<%$name%>_last"
               ID   = "<%$id%>_id"
               VALUE = "<% $contact->get('last') |h %>"
               <% $onchange %>
        ><BR>
        <FONT SIZE="-2">Last name</FONT>
      </TD>
      <TD>
        <INPUT TYPE = "text"
               NAME = "<%$name%>_title"
               ID   = "<%$id%>_id"
               VALUE = "<% $contact->title |h %>"
               <% $onchange %>
        ><BR>
        <FONT SIZE="-2">Title/Position</FONT>
      </TD>
      <TD>
        <INPUT TYPE = "text"
               NAME = "<%$name%>_comment"
               ID   = "<%$id%>_id"
               VALUE = "<% $contact->comment |h %>"
               <% $onchange %>
        ><BR>
        <FONT SIZE="-2">Comment</FONT>
      </TD>
    </TR>
  </TABLE>

% }
<%init>

my( %opt ) = @_;

my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
my $id = $opt{'id'} || 'contactnum';

my $curr_value = $opt{'curr_value'} || $opt{'value'};

my $onchange = '';
if ( $opt{'onchange'} ) {
  $onchange = $opt{'onchange'};
  $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
  $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack.  all onchange
                                        #callbacks should act the same
  $onchange = 'onChange="'. $onchange. '"';
}

my $contact;
if ( $curr_value ) {
  $contact = qsearchs('contact', { 'contactnum' => $curr_value } );
} else {
  $contact = new FS::contact {};
}

</%init>