1 % unless ( $opt{'js_only'} ) {
3 <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
7 % foreach my $field ( @fields ) {
10 % if ( $field =~ /^phonetypenum(\d+)$/ ) {
11 % my $contact_phone = qsearchs('contact_phone', {
12 % 'contactnum' => $curr_value,
13 % 'phonetypenum' => $1,
15 % if ( $contact_phone ) {
16 % $value = $contact_phone->phonenum;
17 % $value .= 'x'.$contact_phone->extension
18 % if $contact_phone->extension;
19 % $value = '+'. $contact_phone->countrycode. " $value"
20 % if $contact_phone->countrycode
21 % && $contact_phone->countrycode ne '1';
23 % } elsif ( $field eq 'emailaddress' ) {
24 % #XXX multiple not yet supported
25 % my $contact_email = qsearchs('contact_email', {
26 % 'contactnum' => $curr_value,
28 % $value = $contact_email->emailaddress if $contact_email;
30 % $value = $contact->get($field);
35 NAME = "<%$name%>_<%$field%>"
36 ID = "<%$id%>_<%$field%>"
37 SIZE = "<% $size{$field} || 15 %>"
38 VALUE = "<% scalar($cgi->param($name."_$field"))
42 <FONT SIZE="-1"><% $label{$field} %></FONT>
53 my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
54 my $id = $opt{'id'} || 'contactnum';
56 my $curr_value = $opt{'curr_value'} || $opt{'value'};
59 if ( $opt{'onchange'} ) {
60 $onchange = $opt{'onchange'};
61 $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
62 $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
63 #callbacks should act the same
64 $onchange = 'onChange="'. $onchange. '"';
69 $contact = qsearchs('contact', { 'contactnum' => $curr_value } );
71 $contact = new FS::contact {};
74 my %size = ( 'title' => 12 );
76 tie my %label, 'Tie::IxHash',
77 'first' => 'First name',
78 'last' => 'Last name',
79 'title' => 'Title/Position',
80 'emailaddress' => 'Email',
84 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
85 next if $phone_type->typename eq 'Home';
86 my $f = 'phonetypenum'.$phone_type->phonetypenum;
87 $label{$f} = $phone_type->typename. ' phone';
88 $size{$f} = $first++ ? 11 : 15;
91 $label{'comment'} = 'Comment';
93 my @fields = keys %label;