optional better visibility for invoicing email field, RT12944
[freeside.git] / httemplate / view / cust_main / billing.html
1 <% mt('Billing information') |h %> 
2 %# If we can't see the unencrypted card, then bill now is an exercise in
3 %# frustration (without some sort of job queue magic to send it to a secure
4 %# machine, anyway)
5 %if (  $FS::CurrentUser::CurrentUser->access_right('Bill customer now')
6 %      && ! $cust_main->is_encrypted($cust_main->payinfo)
7 %   ) { 
8 %#  (<A HREF="<% $p %>misc/bill.cgi?<% $cust_main->custnum %>"><% mt('Bill now') |h %></A>)
9   (<& /elements/bill.html,
10                 custnum   => $cust_main->custnum,
11                 label     => emt('Bill now'),
12                 url       => $p.'view/cust_main.cgi?'.$cust_main->custnum,
13    &>)
14 % } 
15
16 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
17
18 %( my $balance = $cust_main->balance )
19 %  =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/;
20
21 <TR>
22   <TD ALIGN="right"><% mt('Balance due') |h %></TD>
23   <TD BGCOLOR="#ffffff"><B><% $balance %></B></TD>
24 </TR>
25
26 % if ( $conf->exists('cust_main-select-billday') 
27 %    && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) {
28 <TR>
29   <TD ALIGN="right"><% mt('Billing day of month') |h %></TD>
30   <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
31   </TD>
32 </TR>
33 % }
34
35 <TR>
36   <TD ALIGN="right"><% mt('Billing type') |h %></TD>
37   <TD BGCOLOR="#ffffff">
38 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) { 
39
40 %   my $autodemand = $cust_main->payby eq 'CARD' ? 'automatic' : 'on-demand';
41     <% mt("Credit card ([_1])",$autodemand) |h %>
42   </TD>
43 </TR>
44 <TR>
45   <TD ALIGN="right"><% mt('Card number') |h %></TD>
46   <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
47 </TR>
48 %
49 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
50 %my( $mon, $year );
51 %my $date = $cust_main->paydate || '12-2037';
52 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
53 %  ( $mon, $year ) = ( $2, $1 );
54 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
55 %  ( $mon, $year ) = ( $1, $3 );
56 %} else {
57 %  warn "unrecognized expiration date format: $date";
58 %  ( $mon, $year ) = ( '', '' );
59 %}
60 %
61
62 <TR>
63   <TD ALIGN="right"><% mt('Expiration') |h %></TD>
64   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
65 </TR>
66 % if ( $cust_main->paystart_month ) { 
67
68   <TR>
69     <TD ALIGN="right"><% mt('Start date') |h %></TD>
70     <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
71   </TR>
72 % } elsif ( $cust_main->payissue ) { 
73
74   <TR>
75     <TD ALIGN="right"><% mt('Issue #') |h %></TD>
76     <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
77   </TR>
78 % } 
79
80
81 <TR>
82   <TD ALIGN="right"><% mt('Name on card') |h %></TD>
83   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
84 </TR>
85 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
86 %     my( $account, $aba ) = split('@', $cust_main->paymask );
87
88
89 % my $autodemand = $cust_main->payby eq 'CHEK' ? 'automatic' : 'on-demand';
90     <% mt("Electronic check ([_1])",$autodemand) |h %>
91   </TD>
92 </TR>
93 <TR>
94   <TD ALIGN="right"><% mt('ABA/Routing code') |h %></TD>
95   <TD BGCOLOR="#ffffff"><% $aba %></TD>
96 </TR>
97 <TR>
98   <TD ALIGN="right"><% mt('Account number') |h %></TD>
99   <TD BGCOLOR="#ffffff"><% $account %></TD>
100 </TR>
101 <TR>
102   <TD ALIGN="right"<% mt('>Account type') |h %></TD>
103   <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
104 </TR>
105 <TR>
106   <TD ALIGN="right"<% mt('>Bank name') |h %></TD>
107   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
108 </TR>
109 % if ( $conf->exists('show_bankstate') ) {
110 <TR>
111   <TD ALIGN="right"><% $paystate_label %></TD>
112   <TD BGCOLOR="#ffffff"><% $cust_main->paystate || '&nbsp;&nbsp;&nbsp;' %></TD>
113 </TR>
114 % }
115 % } elsif ( $cust_main->payby eq 'LECB' ) {
116 %     $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
117 %     my $payinfo = "$1-$2-$3";
118
119     <% mt('Phone bill billing') |h %> 
120   </TD>
121 </TR>
122 <TR>
123   <TD ALIGN="right"><% mt('Phone number') |h %></TD>
124   <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
125 </TR>
126 % } elsif ( $cust_main->payby eq 'BILL' ) { 
127
128     <% mt('Billing') |h %> 
129   </TD>
130 </TR>
131 % if ( $cust_main->payinfo ) { 
132
133 <TR>
134   <TD ALIGN="right"<% mt('>P.O.') |h %></TD>
135   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
136 </TR>
137 % } 
138
139
140 <TR>
141   <TD ALIGN="right"><% mt('Attention') |h %></TD>
142   <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
143 </TR>
144 % } elsif ( $cust_main->payby eq 'COMP' ) { 
145
146     <% mt('Complimentary') |h %> 
147   </TD>
148 </TR>
149 <TR>
150   <TD ALIGN="right"><% mt('Authorized by') |h %></TD>
151   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
152 </TR>
153 %
154 %#false laziness w/above etc.
155 %my( $mon, $year );
156 %my $date = $cust_main->paydate || '12-2037';
157 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
158 %  ( $mon, $year ) = ( $2, $1 );
159 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
160 %  ( $mon, $year ) = ( $1, $3 );
161 %} else {
162 %  warn "unrecognized expiration date format: $date";
163 %  ( $mon, $year ) = ( '', '' );
164 %}
165 %
166
167 <TR>
168   <TD ALIGN="right"><% mt('Expiration') |h %></TD>
169   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
170 </TR>
171 % } 
172
173 % my $yes = emt('yes');
174 % my $no = emt('no');
175
176 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
177 <TR>
178   <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
179   <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
180 </TR>
181 % foreach my $exempt_group ( @exempt_groups ) {
182 <TR>
183   <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
184   <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? $yes : $no %></TD>
185 </TR>
186 % }
187
188 % if ( $conf->exists('enable_taxproducts') ) {
189 <TR>
190   <TD ALIGN="right"><% mt('Tax location') |h %></TD>
191   <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
192 </TR>
193 % }
194 <TR>
195   <TD ALIGN="right"><% mt('Postal invoices') |h %></TD>
196   <TD BGCOLOR="#ffffff">
197     <% ( grep { $_ eq 'POST' } @invoicing_list ) ? $yes : $no %>
198   </TD>
199 </TR>
200 <TR>
201   <TD ALIGN="right"><% mt('FAX invoices') |h %></TD>
202   <TD BGCOLOR="#ffffff">
203     <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? $yes : $no %>
204   </TD>
205 </TR>
206 % unless ( $conf->exists('cust-email-high-visibility')) {
207 <TR>
208   <TD ALIGN="right"><% mt('Email invoices') |h %></TD>
209   <TD BGCOLOR="#ffffff">
210     <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
211   </TD>
212 </TR>
213 % }
214 <TR>
215   <TD ALIGN="right"><% mt('Invoice terms') |h %></TD>
216   <TD BGCOLOR="#ffffff">
217     <% $cust_main->invoice_terms || emt('Default').' ('. ( $conf->config('invoice_default_terms') || emt('Payable upon receipt') ). ')' %>
218   </TD>
219 </TR>
220 <TR>
221   <TD ALIGN="right"><% mt('Credit limit') |h %></TD>
222   <TD BGCOLOR="#ffffff">
223     <% length($cust_main->credit_limit) ? 
224         $money_char.sprintf("%.2f", $cust_main->credit_limit) :
225         emt('Unlimited') %>
226   </TD>
227 </TR>
228
229 % if ( $conf->exists('voip-cust_cdr_spools') ) { 
230   <TR>
231     <TD ALIGN="right"><% mt('Spool CDRs') |h %></TD>
232     <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? $yes : $no %></TD>
233   </TR>
234 % } 
235
236 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
237   <TR>
238     <TD ALIGN="right"><% mt('Print CDRs') |h %></TD>
239     <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? $no : $yes %></TD>
240   </TR>
241 % } 
242
243 % if ( $conf->exists('voip-cust_accountcode_cdr') ) { 
244    <TR>
245      <TD ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TD>
246      <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
247    </TR>
248 % }
249
250 % if ( $conf->exists('voip-cust_email_csv_cdr') ) { 
251   <TR>
252     <TD ALIGN="right"><% mt('Email CDRs as CSV') |h %></TD>
253     <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
254   </TR>
255 % } 
256
257 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
258   <TR>
259     <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
260     <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
261   </TR>
262 % }
263
264 </TABLE></TD></TR></TABLE>
265 <%once>
266
267 my $paystate_label = FS::Msgcat::_gettext('paystate');
268 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
269
270 </%once>
271 <%init>
272
273 my( $cust_main ) = @_;
274 my @invoicing_list = $cust_main->invoicing_list;
275 my $conf = new FS::Conf;
276 my $money_char = $conf->config('money_char') || '$';
277
278 #false laziness w/edit/cust_main/billing.html
279 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
280 my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
281 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
282 my $show_term = $term_sth->fetchrow_arrayref->[0];
283
284 </%init>