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 % $value = join(', ', map $_->emailaddress, $contact->contact_email);
26 % $value = $contact->get($field);
31 NAME = "<%$name%>_<%$field%>"
32 ID = "<%$id%>_<%$field%>"
33 SIZE = "<% $size{$field} || 15 %>"
34 VALUE = "<% scalar($cgi->param($name."_$field"))
38 <FONT SIZE="-1"><% $label{$field} %></FONT>
49 my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
50 my $id = $opt{'id'} || 'contactnum';
52 my $curr_value = $opt{'curr_value'} || $opt{'value'};
55 if ( $opt{'onchange'} ) {
56 $onchange = $opt{'onchange'};
57 $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
58 $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
59 #callbacks should act the same
60 $onchange = 'onChange="'. $onchange. '"';
65 $contact = qsearchs('contact', { 'contactnum' => $curr_value } );
67 $contact = new FS::contact {};
70 my %size = ( 'title' => 12 );
72 tie my %label, 'Tie::IxHash',
73 'first' => 'First name',
74 'last' => 'Last name',
75 'title' => 'Title/Position',
76 'emailaddress' => 'Email',
80 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
81 next if $phone_type->typename eq 'Home';
82 my $f = 'phonetypenum'.$phone_type->phonetypenum;
83 $label{$f} = $phone_type->typename. ' phone';
84 $size{$f} = $first++ ? 11 : 15;
87 $label{'comment'} = 'Comment';
89 my @fields = keys %label;