customer bill/ship location refactoring, #940
[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');
5 % push @which, 'ship' if $cust_main->has_ship_address;
6 % while (@which) {
7 %   my $this = shift @which;
8 %   my $method = $this.'_location';
9 %   my $location = $cust_main->$method;
10 <FONT CLASS="fsinnerbox-title"><% mt( $addr_label{$this} ) |h %></FONT>
11 <TABLE CLASS="fsinnerbox">
12
13 % if ( $this eq 'bill' ) {
14 %   #billing contact fields
15   <TR>
16     <TD ALIGN="right"><% mt('Contact name') |h %></TD>
17     <TD COLSPAN=5 BGCOLOR="#ffffff"><% $cust_main->contact |h %></TD>
18 %   if ( $conf->exists('show_ss') ) {
19     <TD ALIGN="right"><% mt('SS#') |h %></TD>
20     <TD BGCOLOR="#ffffff"><% $conf->exists('unmask_ss')
21                               ? $cust_main->ss
22                               : $cust_main->masked('ss') || '&nbsp;' %></TD>
23 %   }
24   </TR>
25 %   if ( $conf->exists('cust-email-high-visibility') ) {
26   <TR>
27     <TD ALIGN="right"><% mt('Email address(es)') |h %></TD>
28     <TD BGCOLOR="#ffff00">
29       <% $cust_main->invoicing_list_emailonly_scalar || $no %>
30     </TD>
31   </TR>
32 %   }
33 %   if ( $cust_main->company ) {
34   <TR>
35     <TD ALIGN="right"><% mt('Company') |h %></TD>
36     <TD COLSPAN=7 BGCOLOR="#ffffff"><% $cust_main->company %></TD>
37   </TR>
38 %   }
39 % } # if $this eq 'bill'
40 % # now the actual address
41 <TR>
42   <TD ALIGN="right"><% mt('Address') |h %></TD>
43   <TD COLSPAN=7 BGCOLOR="#ffffff"><% $location->address1 |h %></TD>
44 </TR>
45
46 % if ( $location->get('address2') ) {
47 %   my $address2_label = $conf->exists('cust_main-require_address2') 
48 %                        ? emt('Unit #')
49 %                        : ' ';
50
51 <TR>
52   <TD ALIGN="right"><% $address2_label %></TD>
53   <TD COLSPAN=7 BGCOLOR="#ffffff"><% $location->address2 |h %></TD>
54 </TR>
55
56 % } 
57
58 <TR>
59   <TD ALIGN="right"><% mt('City') |h %></TD>
60   <TD BGCOLOR="#ffffff"><% $location->city |h %></TD>
61 % if ( $location->county ) {
62     <TD ALIGN="right"><% mt('County') |h %></TD>
63     <TD BGCOLOR="#ffffff"><% $location->county |h %></TD>
64 % }
65   <TD ALIGN="right"><% mt('State') |h %></TD>
66   <TD BGCOLOR="#ffffff"><% state_label( $location->state, $location->country ) |h %></TD>
67   <TD ALIGN="right"><% mt('Zip') |h %></TD>
68   <TD BGCOLOR="#ffffff"><% $location->zip %></TD>
69 </TR>
70 <TR>
71   <TD ALIGN="right"><% mt('Country') |h %></TD>
72   <TD BGCOLOR="#ffffff"><% code2country( $location->country ) %></TD>
73 </TR>
74
75 % if ( $location->latitude && $location->longitude ) {
76   <& /elements/tr-coords.html, $location->latitude,
77                                $location->longitude,
78                                $cust_main->name_short,
79                                $cust_main->agentnum,
80   &>
81 % }
82   
83 % if ( $this eq 'bill' ) {
84 %   # billing contact phone numbers
85 %   foreach my $phone (qw(daytime night mobile)) {
86 %     next if !$cust_main->get($phone);
87 <TR>
88   <TD ALIGN="right"><% $phone_label{$phone} %></TD>
89   <TD COLSPAN=3 BGCOLOR="#ffffff">
90     <& /elements/phonenumber.html,
91         $cust_main->get($phone),
92         callable => 1,
93         calling_list_exempt => $cust_main->calling_list_exempt,
94     &>
95   </TD>
96 </TR>
97
98 %   } #foreach $phone
99 %   if ( $cust_main->get('fax') ) {
100
101   <TR>
102     <TD ALIGN="right"><% mt('Fax') |h %></TD>
103     <TD COLSPAN=3 BGCOLOR="#ffffff">
104       <% $cust_main->get('fax') || '&nbsp;' %>
105     </TD>
106   </TR>
107
108 %   }
109 %
110 %   if ( $conf->exists('show_stateid') ) { 
111
112 <TR>
113     <TD ALIGN="right"><% $stateid_label %></TD>
114     <TD BGCOLOR="#ffffff"><% $cust_main->masked('stateid') || '&nbsp' %></TD>
115     <TD ALIGN="right"><% $stateid_state_label %></TD>
116     <TD BGCOLOR="#ffffff"><% $cust_main->stateid_state || '&nbsp' %></TD>
117   </TR>
118
119 %   }
120 % } #if $this eq 'bill'
121 </TABLE>
122 % if ( @which ) {
123 <BR>
124 % }
125 % } #while @which
126 <%once>
127
128 my %phone_label = (
129
130   'daytime' => ( FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
131                    ? 'Day&nbsp;Phone'
132                    : FS::Msgcat::_gettext('daytime')
133                ),
134
135   'night'   => ( FS::Msgcat::_gettext('night') =~ /^(night)?$/
136                    ? 'Night&nbsp;Phone'
137                    : FS::Msgcat::_gettext('night')
138                ),
139
140   'mobile'  => ( FS::Msgcat::_gettext('mobile') =~ /^(mobile)?$/
141                    ? 'Mobile&nbsp;Phone'
142                    : FS::Msgcat::_gettext('Mobile')
143                ),
144 );
145
146 my $stateid_label = FS::Msgcat::_gettext('stateid') =~ /^(stateid)?$/
147                       ? 'Driver&rsquo;s&nbsp;License'
148                       : FS::Msgcat::_gettext('stateid');
149 my $stateid_state_label = FS::Msgcat::_gettext('stateid_state') =~ /^(stateid_state)?$/
150                       ? 'Driver&rsquo;s&nbsp;License State'
151                       : FS::Msgcat::_gettext('stateid_state');
152
153 </%once>
154 <%init>
155
156 my $cust_main = shift;
157 my $conf = new FS::Conf;
158 my @invoicing_list = $cust_main->invoicing_list;
159 my $no = emt('no');
160
161 </%init>
162