1660c1c2272a649ce8783c6864287d0a2160b299
[freeside.git] / httemplate / view / cust_main / contacts.html
1 % my %addr_label = ('bill' => 'Billing address', 'ship' => 'Service address');
2
3 %# Locations (possibly break this out)
4 % my @which = ('bill', 'ship');
5 % while (@which) {
6 %   my $this = shift @which;
7 %   my $method = $this.'_location';
8 %   my $location = $cust_main->$method;
9 <FONT CLASS="fsinnerbox-title"><% mt( $addr_label{$this} ) |h %>
10 %   if ( $this eq 'ship' and 
11 %       $cust_main->bill_locationnum == $cust_main->ship_locationnum )
12 %   {
13  (<% emt('same as billing') %>)
14 %   }
15 </FONT>
16 %   if (
17 %     ($this eq 'ship')
18 %     && $cust_main->invoice_ship_address 
19 %     && !$conf->exists('invoice-ship_address') #it's always on, so hide per-cust config
20 %    ) {
21 <SPAN STYLE="padding-left: .25em;">(<% emt('included on invoices') %>)</SPAN>
22 %   }
23 <TABLE CLASS="fsinnerbox">
24
25 % if ( $this eq 'bill' ) {
26 %   #billing contact fields
27   <TR>
28     <TH ALIGN="right"><% mt('Contact name') |h %></TH>
29     <TD COLSPAN=5><% $cust_main->contact |h %></TD>
30 %   if ( $conf->exists('show_ss') ) {
31     <TH ALIGN="right"><% mt('SS#') |h %></TH>
32     <TD><% $conf->exists('unmask_ss')
33                               ? $cust_main->ss
34                               : $cust_main->masked('ss') || '&nbsp;' %></TD>
35 %   }
36   </TR>
37 %   if ( $conf->exists('cust_main-enable_spouse') and
38 %        ($cust_main->spouse_last or $cust_main->spouse_first) ) {
39   <TR>
40     <TH ALIGN="right"><% mt('Spouse') |h %></TH>
41     <TD COLSPAN=5>
42       <% join(', ', grep $_, 
43                     $cust_main->spouse_last, $cust_main->spouse_first) %>
44     </TD>
45   </TR>
46 %   }
47 %
48 %   # invoicing email
49 %   if ( scalar(@invoicing_list) == 1 ) { # typical individual user; show here
50   <TR>
51     <TH ALIGN="right"><% mt('Email address') |h %></TH>
52     <TD>
53       <% $invoicing_list[0] %>
54     </TD>
55   </TR>
56 %   } elsif ( scalar(@invoicing_list) > 1 ) {
57 %   # business customer with a contact list
58 %   # show nothing here
59 %
60 %   } else { # there is no invoice email for them
61   <TR>
62     <TH ALIGN="right"><% mt('Email address') |h %></TH>
63 %     if ( !$cust_main->postal_invoice or
64 %          $conf->exists('cust_main-require_invoicing_list_email',
65 %                        $cust_main->agentnum)
66 %     ) {
67 %       # we need a contact email for this customer (either because that's
68 %       # policy, or because otherwise they won't receive invoices) but we
69 %       # don't have one.
70     <TD CLASS="error"><% emt('none') %></TD>
71 %     } else {
72     <TD><% emt('no') %></TD>
73 %     }
74 %   } # end of invoicing email
75  
76 %   if ( $cust_main->company ) {
77   <TR>
78     <TH ALIGN="right"><% mt('Company') |h %></TH>
79     <TD COLSPAN=7><% $cust_main->company |h %></TD>
80   </TR>
81 %   }
82 % } elsif ( $this eq 'ship' ) {
83 %   if ( $cust_main->ship_company ) { # mostly obsolete these days...
84   <TR>
85     <TH ALIGN="right"><% mt('Company') |h %></TH>
86     <TD COLSPAN=7><% $cust_main->ship_company |h %></TD>
87   </TR>
88 %   }
89 % }
90
91
92 % if ( $location ) { # now the actual address
93
94 %   if ( $location->locationname ) {
95       <TR>
96         <TH ALIGN="right"><% mt('Location ID') |h %></TH>
97         <TD COLSPAN=7><% $location->locationname |h %></TD>
98       </TR>
99 %   }
100
101 <TR>
102   <TH ALIGN="right"><% mt('Address') |h %></TH>
103   <TD COLSPAN=7><% $location->address1 |h %></TD>
104 </TR>
105
106 % if ( $location->get('address2') ) {
107 %   my $address2_label = $conf->exists('cust_main-require_address2') 
108 %                        ? emt('Unit #')
109 %                        : ' ';
110
111 <TR>
112   <TH ALIGN="right"><% $address2_label %></TH>
113   <TD COLSPAN=7><% $location->address2 |h %></TD>
114 </TR>
115
116 % } 
117
118 <TR>
119   <TH></TH>
120   <TD COLSPAN=5><% $location->city |h %>\
121 % if ( $location->county ) {
122  (<% $location->county |h %> county)\
123 % }
124 <% ($location->city || $location->county) ? ', ' : ''%><% state_label( $location->state, $location->country ) |h %>
125   <% $location->zip |h %>
126 </TD>
127 </TR>
128 <TR>
129   <TH></TH>
130   <TD><% $location->country_full |h %></TD>
131 </TR>
132
133 % if ( $location->latitude && $location->longitude ) {
134   <& /elements/tr-coords.html, $location->latitude,
135                                $location->longitude,
136                                $cust_main->name_short,
137                                $cust_main->agentnum,
138   &>
139 % }
140 <& /elements/tr-censustract.html, $location &>
141
142 % }
143   
144 % if ( $this eq 'bill' ) {
145 %   # billing contact phone numbers
146 %   foreach my $phone (qw(daytime night mobile)) {
147 %     next if !$cust_main->get($phone);
148 <TR>
149   <TH ALIGN="right"><% $phone_label{$phone} %></TD>
150   <TD COLSPAN=3>
151     <& /elements/phonenumber.html,
152         $cust_main->get($phone),
153         callable => 1,
154         calling_list_exempt => $cust_main->calling_list_exempt,
155     &>
156   </TD>
157 </TR>
158
159 %   } #foreach $phone
160 %   if ( $cust_main->get('fax') ) {
161
162   <TR>
163     <TH ALIGN="right"><% mt('Fax') |h %></TH>
164     <TD COLSPAN=3>
165       <% $cust_main->get('fax') || '&nbsp;' %>
166     </TD>
167   </TR>
168
169 %   }
170 %
171 %   if ( $conf->exists('show_stateid') ) { 
172
173 <TR>
174     <TH ALIGN="right"><% $stateid_label %></TH>
175     <TD><% $cust_main->masked('stateid') || '&nbsp' %></TD>
176     <TH ALIGN="right"><% $stateid_state_label %></TH>
177     <TD><% $cust_main->stateid_state || '&nbsp' %></TD>
178   </TR>
179
180 %   }
181 % } #if $this eq 'bill'
182 </TABLE>
183 % if ( @which ) {
184 <BR>
185 % }
186 % } #while @which
187 <%once>
188
189 my %phone_label = (
190
191   'daytime' => ( FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
192                    ? 'Day&nbsp;Phone'
193                    : FS::Msgcat::_gettext('daytime')
194                ),
195
196   'night'   => ( FS::Msgcat::_gettext('night') =~ /^(night)?$/
197                    ? 'Night&nbsp;Phone'
198                    : FS::Msgcat::_gettext('night')
199                ),
200
201   'mobile'  => ( FS::Msgcat::_gettext('mobile') =~ /^(mobile)?$/
202                    ? 'Mobile&nbsp;Phone'
203                    : FS::Msgcat::_gettext('Mobile')
204                ),
205 );
206
207 my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
208                       ? 'Driver&rsquo;s&nbsp;License'
209                       : FS::Msgcat::_gettext('stateid');
210 my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
211                       ? 'Driver&rsquo;s&nbsp;License State'
212                       : FS::Msgcat::_gettext('stateid_state');
213
214 </%once>
215 <%init>
216
217 my $cust_main = shift;
218 my $conf = new FS::Conf;
219 my @invoicing_list = $cust_main->invoicing_list_emailonly;
220
221 </%init>