Merge branch 'master' of git.freeside.biz:/home/git/freeside
[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>
33       <span id="ss_span" style="white-space:nowrap;">
34       <% $conf->exists('unmask_ss')
35            ? $cust_main->ss
36            : $cust_main->masked('ss') || '&nbsp;' %>
37 %   if (
38 %         $cust_main->ss
39 %         && !$conf->exists('unmask_ss')
40 %         && $FS::CurrentUser::CurrentUser->access_right('Unmask customer SSN')
41 %   ) {
42       <& /elements/link-replace_element_text.html, {
43            target_id    => 'ss_span',
44            replace_text => $cust_main->ss,
45            element_type => 'span'
46       } &>
47 %   }
48       </span>
49     </TD>
50 %   }
51   </TR>
52 %   if ( $conf->exists('cust_main-enable_spouse') and
53 %        ($cust_main->spouse_last or $cust_main->spouse_first) ) {
54   <TR>
55     <TH ALIGN="right"><% mt('Spouse') |h %></TH>
56     <TD COLSPAN=5>
57       <% join(', ', grep $_, 
58                     $cust_main->spouse_last, $cust_main->spouse_first) %>
59     </TD>
60   </TR>
61 %   }
62 %
63 %   # invoicing email
64 %   if ( scalar(@invoicing_list) == 1 ) { # typical individual user; show here
65   <TR>
66     <TH ALIGN="right"><% mt('Email address') |h %></TH>
67     <TD>
68       <% $invoicing_list[0] %>
69     </TD>
70   </TR>
71 %   } elsif ( scalar(@invoicing_list) > 1 ) {
72 %   # business customer with a contact list
73 %   # show nothing here
74 %
75 %   } else { # there is no invoice email for them
76   <TR>
77     <TH ALIGN="right"><% mt('Email address') |h %></TH>
78 %     if ( !$cust_main->postal_invoice or
79 %          $conf->exists('cust_main-require_invoicing_list_email',
80 %                        $cust_main->agentnum)
81 %     ) {
82 %       # we need a contact email for this customer (either because that's
83 %       # policy, or because otherwise they won't receive invoices) but we
84 %       # don't have one.
85     <TD CLASS="error"><% emt('none') %></TD>
86 %     } else {
87     <TD><% emt('no') %></TD>
88 %     }
89 %   } # end of invoicing email
90  
91 %   if ( $cust_main->company ) {
92   <TR>
93     <TH ALIGN="right"><% mt('Company') |h %></TH>
94     <TD COLSPAN=7><% $cust_main->company |h %></TD>
95   </TR>
96 %   }
97 % } elsif ( $this eq 'ship' ) {
98 %   if ( $cust_main->ship_company ) { # mostly obsolete these days...
99   <TR>
100     <TH ALIGN="right"><% mt('Company') |h %></TH>
101     <TD COLSPAN=7><% $cust_main->ship_company |h %></TD>
102   </TR>
103 %   }
104 % }
105
106
107 % if ( $location ) { # now the actual address
108
109 %   if ( $location->locationname ) {
110       <TR>
111         <TH ALIGN="right"><% mt('Location ID') |h %></TH>
112         <TD COLSPAN=7><% $location->locationname |h %></TD>
113       </TR>
114 %   }
115
116 <TR>
117   <TH ALIGN="right"><% mt('Address') |h %></TH>
118   <TD COLSPAN=7><% $location->address1 |h %></TD>
119 </TR>
120
121 % if ( $location->get('address2') ) {
122 %   my $address2_label = $conf->exists('cust_main-require_address2') 
123 %                        ? emt('Unit #')
124 %                        : ' ';
125
126 <TR>
127   <TH ALIGN="right"><% $address2_label %></TH>
128   <TD COLSPAN=7><% $location->address2 |h %></TD>
129 </TR>
130
131 % } 
132
133 <TR>
134   <TH></TH>
135   <TD COLSPAN=5><% $location->city |h %>\
136 % if ( $location->county ) {
137  (<% $location->county |h %> county)\
138 % }
139 <% ($location->city || $location->county) ? ', ' : ''%><% state_label( $location->state, $location->country ) |h %>
140   <% $location->zip |h %>
141 </TD>
142 </TR>
143 <TR>
144   <TH></TH>
145   <TD><% $location->country_full |h %></TD>
146 </TR>
147
148 % if ( $location->latitude && $location->longitude ) {
149   <& /elements/tr-coords.html, $location->latitude,
150                                $location->longitude,
151                                $cust_main->name_short,
152                                $cust_main->agentnum,
153   &>
154 % }
155 <& /elements/tr-censustract.html, $location &>
156
157 % }
158   
159 % if ( $this eq 'bill' ) {
160 %   # billing contact phone numbers
161 %   foreach my $phone (qw(daytime night mobile)) {
162 %     next if !$cust_main->get($phone);
163 <TR>
164   <TH ALIGN="right"><% $phone_label{$phone} %></TD>
165   <TD COLSPAN=3>
166     <& /elements/phonenumber.html,
167         $cust_main->get($phone),
168         callable => 1,
169         calling_list_exempt => $cust_main->calling_list_exempt,
170     &>
171   </TD>
172 </TR>
173
174 %   } #foreach $phone
175 %   if ( $cust_main->get('fax') ) {
176
177   <TR>
178     <TH ALIGN="right"><% mt('Fax') |h %></TH>
179     <TD COLSPAN=3>
180       <% $cust_main->get('fax') || '&nbsp;' %>
181     </TD>
182   </TR>
183
184 %   }
185 %
186 %   if ( $conf->exists('show_stateid') ) { 
187
188 <TR>
189     <TH ALIGN="right"><% $stateid_label %></TH>
190     <TD>
191       <span id="stateid_span" style="white-space:nowrap;">
192       <% $cust_main->masked('stateid') || '&nbsp' %>
193 %   if (
194 %         $cust_main->stateid
195 %         && $FS::CurrentUser::CurrentUser->access_right('Unmask customer DL')
196 %   ) {
197       <& /elements/link-replace_element_text.html, {
198            target_id => 'stateid_span',
199            replace_text => $cust_main->stateid,
200            element_type => 'span'
201       } &>
202 %   }
203       </span>
204     </TD>
205     <TH ALIGN="right"><% $stateid_state_label %></TH>
206     <TD><% $cust_main->stateid_state || '&nbsp' %></TD>
207   </TR>
208
209 %   }
210 % } #if $this eq 'bill'
211 </TABLE>
212 % if ( @which ) {
213 <BR>
214 % }
215 % } #while @which
216 <%once>
217
218 my %phone_label = (
219
220   'daytime' => ( FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
221                    ? 'Day&nbsp;Phone'
222                    : FS::Msgcat::_gettext('daytime')
223                ),
224
225   'night'   => ( FS::Msgcat::_gettext('night') =~ /^(night)?$/
226                    ? 'Night&nbsp;Phone'
227                    : FS::Msgcat::_gettext('night')
228                ),
229
230   'mobile'  => ( FS::Msgcat::_gettext('mobile') =~ /^(mobile)?$/
231                    ? 'Mobile&nbsp;Phone'
232                    : FS::Msgcat::_gettext('Mobile')
233                ),
234 );
235
236 my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
237                       ? 'Driver&rsquo;s&nbsp;License'
238                       : FS::Msgcat::_gettext('stateid');
239 my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
240                       ? 'Driver&rsquo;s&nbsp;License State'
241                       : FS::Msgcat::_gettext('stateid_state');
242
243 </%once>
244 <%init>
245
246 my $cust_main = shift;
247 my $conf = new FS::Conf;
248 my @invoicing_list = $cust_main->invoicing_list_emailonly;
249
250 </%init>