-<%
- my( $cust_main ) = @_;
- my $conf = new FS::Conf;
-%>
+% my %addr_label = ('bill' => 'Billing address', 'ship' => 'Service address');
-Billing address
-<%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %>
-<TR>
- <TD ALIGN="right">Contact name</TD>
- <TD COLSPAN=3 BGCOLOR="#ffffff">
- <%= $cust_main->last. ', '. $cust_main->first %>
- </TD>
-<% if ( $conf->exists('show_ss') ) { %>
- <TD ALIGN="right">SS#</TD>
- <TD BGCOLOR="#ffffff"><%= $cust_main->ss || ' ' %></TD>
-<% } %>
-</TR>
-<TR>
- <TD ALIGN="right">Company</TD>
- <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->company %></TD>
-</TR>
-<TR>
- <TD ALIGN="right">Address</TD>
- <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->address1 %></TD>
-</TR>
-<% if ( $cust_main->address2 ) { %>
-<TR>
- <TD ALIGN="right"> </TD>
- <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->address2 %></TD>
-</TR>
-<% } %>
-<TR>
- <TD ALIGN="right">City</TD>
- <TD BGCOLOR="#ffffff"><%= $cust_main->city %></TD>
- <TD ALIGN="right">State</TD>
- <TD BGCOLOR="#ffffff"><%= state_label($cust_main->state, $cust_main->country) %></TD>
- <TD ALIGN="right">Zip</TD>
- <TD BGCOLOR="#ffffff"><%= $cust_main->zip %></TD>
-</TR>
-<TR>
- <TD ALIGN="right">Country</TD>
- <TD BGCOLOR="#ffffff"><%= code2country($cust_main->country) %></TD>
-</TR>
-<%
- my $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
- ? 'Day Phone'
- : FS::Msgcat::_gettext('daytime');
- my $night_label = FS::Msgcat::_gettext('night') =~ /^(night)?$/
- ? 'Night Phone'
- : FS::Msgcat::_gettext('night');
-%>
-<TR>
- <TD ALIGN="right"><%= $daytime_label %></TD>
- <TD COLSPAN=6 BGCOLOR="#ffffff">
- <%= include('/elements/phonenumber.html',
- $cust_main->daytime,
- 'callable'=>1
- )
- %>
- </TD>
-</TR>
-<TR>
- <TD ALIGN="right"><%= $night_label %></TD>
- <TD COLSPAN=6 BGCOLOR="#ffffff">
- <%= include('/elements/phonenumber.html',
- $cust_main->night,
- 'callable'=>1
- )
- %>
- </TD>
-</TR>
-<TR>
- <TD ALIGN="right">Fax</TD>
- <TD COLSPAN=5 BGCOLOR="#ffffff">
- <%= $cust_main->fax || ' ' %>
- </TD>
-</TR>
-</TABLE></TD></TR></TABLE>
+%# Locations (possibly break this out)
+% my @which = ('bill', 'ship');
+% while (@which) {
+% my $this = shift @which;
+% my $method = $this.'_location';
+% my $location = $cust_main->$method;
+<FONT CLASS="fsinnerbox-title"><% mt( $addr_label{$this} ) |h %>
+% if ( $this eq 'ship' and
+% $cust_main->bill_locationnum == $cust_main->ship_locationnum )
+% {
+ (<% emt('same as billing') %>)
+% }
+</FONT>
+% if (
+% ($this eq 'ship')
+% && $cust_main->invoice_ship_address
+% && !$conf->exists('invoice-ship_address') #it's always on, so hide per-cust config
+% ) {
+<SPAN STYLE="padding-left: .25em;">(<% emt('included on invoices') %>)</SPAN>
+% }
+<TABLE CLASS="fsinnerbox">
-<% if ( defined $cust_main->dbdef_table->column('ship_last') ) {
- my $pre = $cust_main->ship_last ? 'ship_' : '';
-%>
+% if ( $this eq 'bill' ) {
+% #billing contact fields
+ <TR>
+ <TH ALIGN="right"><% mt('Contact name') |h %></TH>
+ <TD COLSPAN=5><% $cust_main->contact |h %></TD>
+% if ( $conf->exists('show_ss') ) {
+ <TH ALIGN="right"><% mt('SS#') |h %></TH>
+ <TD>
+ <span id="ss_span" style="white-space:nowrap;">
+ <% $cust_main->masked('ss') || ' ' %>
+% if (
+% $cust_main->ss
+% && $FS::CurrentUser::CurrentUser->access_right('Unmask customer SSN')
+% ) {
+ <& /elements/link-replace_element_text.html, {
+ target_id => 'ss_span',
+ replace_text => $cust_main->ss,
+ element_type => 'span'
+ } &>
+% }
+ </span>
+ </TD>
+% }
+ </TR>
+% if ( $conf->exists('cust_main-enable_spouse') and
+% ($cust_main->spouse_last or $cust_main->spouse_first) ) {
+ <TR>
+ <TH ALIGN="right"><% mt('Spouse') |h %></TH>
+ <TD COLSPAN=5>
+ <% join(', ', grep $_,
+ $cust_main->spouse_last, $cust_main->spouse_first) %>
+ </TD>
+ </TR>
+% }
+%
+% # invoicing email
+% if ( scalar(@invoicing_list) == 1 ) { # typical individual user; show here
+ <TR>
+ <TH ALIGN="right"><% mt('Email address') |h %></TH>
+ <TD>
+ <% $invoicing_list[0] %>
+ </TD>
+ </TR>
+% } elsif ( scalar(@invoicing_list) > 1 ) {
+% # business customer with a contact list
+% # show nothing here
+%
+% } else { # there is no invoice email for them
+ <TR>
+ <TH ALIGN="right"><% mt('Email address') |h %></TH>
+% if ( !$cust_main->postal_invoice or
+% $conf->exists('cust_main-require_invoicing_list_email',
+% $cust_main->agentnum)
+% ) {
+% # we need a contact email for this customer (either because that's
+% # policy, or because otherwise they won't receive invoices) but we
+% # don't have one.
+ <TD CLASS="error"><% emt('none') %></TD>
+% } else {
+ <TD><% emt('no') %></TD>
+% }
+% } # end of invoicing email
+
+% if ( $cust_main->company ) {
+ <TR>
+ <TH ALIGN="right"><% mt('Company') |h %></TH>
+ <TD COLSPAN=7><% $cust_main->company |h %></TD>
+ </TR>
+% }
+% } elsif ( $this eq 'ship' ) {
+% if ( $cust_main->ship_company ) { # mostly obsolete these days...
+ <TR>
+ <TH ALIGN="right"><% mt('Company') |h %></TH>
+ <TD COLSPAN=7><% $cust_main->ship_company |h %></TD>
+ </TR>
+% }
+% }
+
+
+% if ( $location ) { # now the actual address
+
+% if ( $location->locationname ) {
+ <TR>
+ <TH ALIGN="right"><% mt('Location ID') |h %></TH>
+ <TD COLSPAN=7><% $location->locationname |h %></TD>
+ </TR>
+% }
-<BR>
-Service address
-<%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %>
-<TR>
- <TD ALIGN="right">Contact name</TD>
- <TD COLSPAN=5 BGCOLOR="#ffffff">
- <%= $cust_main->get("${pre}last"). ', '. $cust_main->get("${pre}first") %>
- </TD>
-</TR>
-<TR>
- <TD ALIGN="right">Company</TD>
- <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->get("${pre}company") %></TD>
-</TR>
-<TR>
- <TD ALIGN="right">Address</TD>
- <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->get("${pre}address1") %></TD>
-</TR>
-<% if ( $cust_main->get("${pre}address2") ) { %>
<TR>
- <TD ALIGN="right"> </TD>
- <TD COLSPAN=5 BGCOLOR="#ffffff"><%= $cust_main->get("${pre}address2") %></TD>
+ <TH ALIGN="right"><% mt('Address') |h %></TH>
+ <TD COLSPAN=7><% $location->address1 |h %></TD>
</TR>
-<% } %>
+
+% if ( $location->get('address2') ) {
+% my $address2_label = $conf->exists('cust_main-require_address2')
+% ? emt('Unit #')
+% : ' ';
+
<TR>
- <TD ALIGN="right">City</TD>
- <TD BGCOLOR="#ffffff"><%= $cust_main->get("${pre}city") %></TD>
- <TD ALIGN="right">State</TD>
- <TD BGCOLOR="#ffffff"><%= $cust_main->get("${pre}state") %></TD>
- <TD ALIGN="right">Zip</TD>
- <TD BGCOLOR="#ffffff"><%= $cust_main->get("${pre}zip") %></TD>
+ <TH ALIGN="right"><% $address2_label %></TH>
+ <TD COLSPAN=7><% $location->address2 |h %></TD>
</TR>
+
+% }
+
<TR>
- <TD ALIGN="right">Country</TD>
- <TD BGCOLOR="#ffffff"><%= code2country( $cust_main->get("${pre}country") ) %></TD>
+ <TH></TH>
+ <TD COLSPAN=5><% $location->city |h %>\
+% if ( $location->county ) {
+ (<% $location->county |h %> county)\
+% }
+<% ($location->city || $location->county) ? ', ' : ''%><% state_label( $location->state, $location->country ) |h %>
+ <% $location->zip |h %>
+</TD>
</TR>
<TR>
- <TD ALIGN="right"><%= $daytime_label %></TD>
- <TD COLSPAN=5 BGCOLOR="#ffffff">
- <%= include('/elements/phonenumber.html',
- $cust_main->get("${pre}daytime"),
- 'callable'=>1
- )
- %>
- </TD>
+ <TH></TH>
+ <TD><% $location->country_full |h %></TD>
</TR>
-<TR>
- <TD ALIGN="right"><%= $night_label %></TD>
- <TD COLSPAN=5 BGCOLOR="#ffffff">
- <%= include('/elements/phonenumber.html',
- $cust_main->get("${pre}night"),
- 'callable'=>1
- )
- %>
+
+% if ( $location->latitude && $location->longitude ) {
+ <& /elements/tr-coords.html, $location->latitude,
+ $location->longitude,
+ $cust_main->name_short,
+ $cust_main->agentnum,
+ &>
+% }
+<& /elements/tr-censustract.html, $location &>
+
+% }
+
+% if ( $this eq 'bill' ) {
+% # billing contact phone numbers
+% foreach my $phone (qw(daytime night mobile)) {
+% next if !$cust_main->get($phone);
+<TR>
+ <TH ALIGN="right"><% $phone_label{$phone} %></TD>
+ <TD COLSPAN=3>
+ <& /elements/phonenumber.html,
+ $cust_main->get($phone),
+ callable => 1,
+ calling_list_exempt => $cust_main->calling_list_exempt,
+ &>
</TD>
</TR>
+
+% } #foreach $phone
+% if ( $cust_main->get('fax') ) {
+
+ <TR>
+ <TH ALIGN="right"><% mt('Fax') |h %></TH>
+ <TD COLSPAN=3>
+ <% $cust_main->get('fax') || ' ' %>
+ </TD>
+ </TR>
+
+% }
+%
+% if ( $conf->exists('show_stateid') ) {
+
<TR>
- <TD ALIGN="right">Fax</TD>
- <TD COLSPAN=5 BGCOLOR="#ffffff">
- <%= $cust_main->get("${pre}fax") || ' ' %>
- </TD>
-</TR>
-</TABLE></TD></TR></TABLE>
+ <TH ALIGN="right"><% $stateid_label %></TH>
+ <TD>
+ <span id="stateid_span" style="white-space:nowrap;">
+ <% $cust_main->masked('stateid') || ' ' %>
+% if (
+% $cust_main->stateid
+% && $FS::CurrentUser::CurrentUser->access_right('Unmask customer DL')
+% ) {
+ <& /elements/link-replace_element_text.html, {
+ target_id => 'stateid_span',
+ replace_text => $cust_main->stateid,
+ element_type => 'span'
+ } &>
+% }
+ </span>
+ </TD>
+ <TH ALIGN="right"><% $stateid_state_label %></TH>
+ <TD><% $cust_main->stateid_state || ' ' %></TD>
+ </TR>
+
+% }
+% } #if $this eq 'bill'
+</TABLE>
+% if ( @which ) {
+<BR>
+% }
+% } #while @which
+<%once>
+
+my %phone_label = (
+
+ 'daytime' => ( FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
+ ? 'Day Phone'
+ : FS::Msgcat::_gettext('daytime')
+ ),
+
+ 'night' => ( FS::Msgcat::_gettext('night') =~ /^(night)?$/
+ ? 'Night Phone'
+ : FS::Msgcat::_gettext('night')
+ ),
+
+ 'mobile' => ( FS::Msgcat::_gettext('mobile') =~ /^(mobile)?$/
+ ? 'Mobile Phone'
+ : FS::Msgcat::_gettext('Mobile')
+ ),
+);
+
+my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
+ ? 'Driver’s License'
+ : FS::Msgcat::_gettext('stateid');
+my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
+ ? 'Driver’s License State'
+ : FS::Msgcat::_gettext('stateid_state');
+
+</%once>
+<%init>
+
+my $cust_main = shift;
+my $conf = new FS::Conf;
+my @invoicing_list = $cust_main->invoicing_list_emailonly;
-<% } %>
+</%init>