remove fax from short contact info, RT#25536
[freeside.git] / httemplate / elements / contact.html
1 % unless ( $opt{'js_only'} ) {
2
3   <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
4
5   <TABLE STYLE="display:inline">
6     <TR>
7 %     if ( @contact_class && ! $opt{name_only} ) {
8         <TD>
9           <SELECT NAME="<%$name%>_classnum" <% $onchange %>>
10             <OPTION VALUE="">
11 %           my $classnum = scalar($cgi->param($name.'_classnum'))
12 %                            || $X_contact->classnum;
13 %           foreach my $contact_class (@contact_class) {
14               <OPTION VALUE="<% $contact_class->classnum %>"
15                  <% ($contact_class->classnum == $classnum) ? 'SELECTED' : '' %>
16               ><% $contact_class->classname |h %>
17 %           }
18           </SELECT><BR>
19           <FONT SIZE="-1">Type</FONT>
20         </TD>
21 %     } else {
22         <INPUT TYPE="hidden" NAME="<%$name%>_classnum" VALUE="">
23 %     }
24 %
25 %     foreach my $field ( @fields ) {
26 %
27 %       my $value = '';
28 %       if ( $field =~ /^phonetypenum(\d+)$/ ) {
29 %         my $contact_phone = qsearchs('contact_phone', {
30 %           'contactnum'   => $curr_value,
31 %           'phonetypenum' => $1,
32 %         });
33 %         if ( $contact_phone ) {
34 %           $value = $contact_phone->phonenum_pretty;
35 %           $value .= 'x'.$contact_phone->extension
36 %             if $contact_phone->extension;
37 %           $value = '+'. $contact_phone->countrycode. " $value"
38 %             if $contact_phone->countrycode
39 %             && $contact_phone->countrycode ne '1';
40 %         }
41 %       } elsif ( $field eq 'emailaddress' ) {
42 %         $value = join(', ', map $_->emailaddress, $contact->contact_email);
43 %       } elsif ( $field eq 'selfservice_access' || $field eq 'comment' ) {
44 %         $value = $X_contact->get($field);
45 %       } else {
46 %         $value = $contact->get($field);
47 %       }
48
49         <TD>
50 %         if ( $field eq 'selfservice_access' ) {
51             <SELECT NAME = "<%$name%>_<%$field%>"
52                     ID   = "<%$id%>_<%$field%>"
53             >
54               <OPTION VALUE="">Disabled
55 %             if ( $value || $self_base_url ) {
56                 <OPTION VALUE="Y" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
57 %               if ( $value eq 'Y' && $self_base_url ) {
58                   <OPTION VALUE="R">Re-email
59 %               }
60 %             }
61             </SELECT>
62
63 %         } else {
64             <INPUT TYPE  = "text"
65                    NAME  = "<%$name%>_<%$field%>"
66                    ID    = "<%$id%>_<%$field%>"
67                    SIZE  = "<% $size{$field} || 14 %>"
68                    VALUE = "<% scalar($cgi->param($name."_$field"))
69                                || $value |h %>"
70                    <% $onchange %>
71             >
72 %         }
73           <BR>
74           <FONT SIZE="-1"><% $label{$field} %></FONT>
75         </TD>
76 %     }
77     </TR>
78   </TABLE>
79
80 % }
81 <%init>
82
83 my( %opt ) = @_;
84
85 my $conf = new FS::Conf;
86 my $self_base_url = $conf->config('selfservice_server-base_url');
87
88 my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum';
89 my $id = $opt{'id'} || 'contactnum';
90
91 my $curr_value = $opt{'curr_value'} || $opt{'value'};
92
93 my $onchange = '';
94 if ( $opt{'onchange'} ) {
95   $onchange = $opt{'onchange'};
96   $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
97   $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack.  all onchange
98                                         #callbacks should act the same
99   $onchange = 'onChange="'. $onchange. '"';
100 }
101
102 my @contact_class = qsearch('contact_class', { 'disabled' => '' });
103
104 my $contact;
105 my $X_contact;
106 if ( $curr_value ) {
107   $contact = qsearchs('contact', { 'contactnum' => $curr_value } );
108   if ( $opt{'custnum'} ) {
109     $X_contact = qsearchs('cust_contact', {
110                             'contactnum' => $curr_value,
111                             'custnum'    => $opt{'custnum'},
112                  });
113   } elsif ( $opt{'prospectnum'} ) {
114     $X_contact = qsearchs('prospect_contact', {
115                    'contactnum'  => $curr_value,
116                    'prospectnum' => $opt{'prospectnum'},
117                  });
118   } else {
119     die 'neither custnum nor prospectnum specified';
120   }
121 } else {
122   $contact = new FS::contact {};
123   $X_contact = new FS::cust_contact; #arbitrary, it could be prospect_contact
124 }
125
126 my %size = ( 'title' => 12 );
127
128 tie my %label, 'Tie::IxHash',
129   'first'              => 'First name',
130   'last'               => 'Last name',
131   'title'              => 'Title/Position',
132   'emailaddress'       => 'Email',
133   'selfservice_access' => 'Self-service'
134 ;
135
136 my $first = 0;
137 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
138   next if $phone_type->typename =~ /^(Home|Fax)$/;
139   my $f = 'phonetypenum'.$phone_type->phonetypenum;
140   $label{$f} = $phone_type->typename. ' phone';
141   $size{$f} = $first++ ? 10 : 15;
142 }
143
144 $label{'comment'} = 'Comment';
145
146 my @fields = $opt{'name_only'} ? qw( first last ) : keys %label;
147
148 </%init>