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