Merge branch 'xss_fixes' of https://github.com/mcreenan/Freeside
[freeside.git] / httemplate / view / cust_main / billing.html
1 <FONT CLASS="fsinnerbox-title"><% mt('Billing information') |h %></FONT>
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 <TABLE CLASS="fsinnerbox">
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-prorate_day') ) {
27 <TR>
28   <TD ALIGN="right"><% mt('Prorate day of month') |h %></TD>
29   <TD BGCOLOR="#ffffff"><% $cust_main->prorate_day %>
30   </TD>
31 </TR>
32 % }
33
34 % if ( $conf->exists('cust_main-select-billday') 
35 %    && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) {
36 <TR>
37   <TD ALIGN="right"><% mt('Billing day of month') |h %></TD>
38   <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
39   </TD>
40 </TR>
41 % }
42
43 <TR>
44   <TD ALIGN="right"><% mt('Billing type') |h %></TD>
45   <TD BGCOLOR="#ffffff">
46 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) { 
47
48 %   my $autodemand = $cust_main->payby eq 'CARD' ? 'automatic' : 'on-demand';
49     <% mt("Credit card ([_1])",$autodemand) |h %>
50   </TD>
51 </TR>
52 <TR>
53   <TD ALIGN="right"><% mt('Card number') |h %></TD>
54   <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
55 </TR>
56 %
57 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
58 %my( $mon, $year );
59 %my $date = $cust_main->paydate || '12-2037';
60 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
61 %  ( $mon, $year ) = ( $2, $1 );
62 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
63 %  ( $mon, $year ) = ( $1, $3 );
64 %} else {
65 %  warn "unrecognized expiration date format: $date";
66 %  ( $mon, $year ) = ( '', '' );
67 %}
68 %
69
70 <TR>
71   <TD ALIGN="right"><% mt('Expiration') |h %></TD>
72   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
73 </TR>
74 % if ( $cust_main->paystart_month ) { 
75
76   <TR>
77     <TD ALIGN="right"><% mt('Start date') |h %></TD>
78     <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
79   </TR>
80 % } elsif ( $cust_main->payissue ) { 
81
82   <TR>
83     <TD ALIGN="right"><% mt('Issue #') |h %></TD>
84     <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
85   </TR>
86 % } 
87
88
89 <TR>
90   <TD ALIGN="right"><% mt('Name on card') |h %></TD>
91   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
92 </TR>
93 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
94 %     my( $account, $aba ) = split('@', $cust_main->paymask );
95 %  my $branch = '';
96 %  ($branch,$aba) = split('\.',$aba) if $conf->config('echeck-country') eq 'CA';
97
98
99 % my $autodemand = $cust_main->payby eq 'CHEK' ? 'automatic' : 'on-demand';
100     <% mt("Electronic check ([_1])",$autodemand) |h %>
101   </TD>
102 </TR>
103
104 %  #false laziness w/edit/cust_main/billing.html and misc/payment.cgi
105 %  my $routing_label = $conf->config('echeck-country') eq 'US'
106 %                        ? 'ABA/Routing number'
107 %                        : 'Routing number';
108
109 <TR>
110   <TD ALIGN="right"><% mt($routing_label) |h %></TD>
111   <TD BGCOLOR="#ffffff"><% $aba %></TD>
112 </TR>
113
114 % if ( $conf->config('echeck-country') eq 'CA' ) {
115 <TR>
116   <TD ALIGN="right"><% mt('Branch number') |h %></TD>
117   <TD BGCOLOR="#ffffff"><% $branch %></TD>
118 <TR>
119 % }
120
121   <TD ALIGN="right"><% mt('Account number') |h %></TD>
122   <TD BGCOLOR="#ffffff"><% $account %></TD>
123 </TR>
124 <TR>
125   <TD ALIGN="right"><% mt('Account type') |h %></TD>
126   <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
127 </TR>
128 <TR>
129   <TD ALIGN="right"><% mt('Bank name') |h %></TD>
130   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
131 </TR>
132 % if ( $conf->exists('show_bankstate') ) {
133 <TR>
134   <TD ALIGN="right"><% $paystate_label %></TD>
135   <TD BGCOLOR="#ffffff"><% $cust_main->paystate || '&nbsp;&nbsp;&nbsp;' %></TD>
136 </TR>
137 % }
138 % } elsif ( $cust_main->payby eq 'LECB' ) {
139 %     $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
140 %     my $payinfo = "$1-$2-$3";
141
142     <% mt('Phone bill billing') |h %> 
143   </TD>
144 </TR>
145 <TR>
146   <TD ALIGN="right"><% mt('Phone number') |h %></TD>
147   <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
148 </TR>
149 % } elsif ( $cust_main->payby eq 'BILL' ) { 
150
151     <% mt('Billing') |h %> 
152   </TD>
153 </TR>
154 % if ( $cust_main->payinfo ) { 
155
156 <TR>
157   <TD ALIGN="right"><% mt('P.O.') |h %></TD>
158   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
159 </TR>
160 % } 
161
162
163 <TR>
164   <TD ALIGN="right"><% mt('Attention') |h %></TD>
165   <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
166 </TR>
167 % } elsif ( $cust_main->payby eq 'COMP' ) { 
168
169     <% mt('Complimentary') |h %> 
170   </TD>
171 </TR>
172 <TR>
173   <TD ALIGN="right"><% mt('Authorized by') |h %></TD>
174   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
175 </TR>
176 %
177 %#false laziness w/above etc.
178 %my( $mon, $year );
179 %my $date = $cust_main->paydate || '12-2037';
180 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
181 %  ( $mon, $year ) = ( $2, $1 );
182 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
183 %  ( $mon, $year ) = ( $1, $3 );
184 %} else {
185 %  warn "unrecognized expiration date format: $date";
186 %  ( $mon, $year ) = ( '', '' );
187 %}
188 %
189
190 <TR>
191   <TD ALIGN="right"><% mt('Expiration') |h %></TD>
192   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
193 </TR>
194 % } 
195
196 % my $yes = emt('yes');
197 % my $no = emt('no');
198
199 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
200
201 % unless (    $conf->exists('cust_class-tax_exempt')
202 %          || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
203 %        )
204 % {
205     <TR>
206       <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
207       <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
208     </TR>
209 % }
210
211 % foreach my $exempt_group ( @exempt_groups ) {
212 %   my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
213     <TR>
214       <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
215       <TD BGCOLOR="#ffffff"><% $cust_main_exemption ? $yes : $no %>
216         <% $cust_main_exemption ? $cust_main_exemption->exempt_number : '' |h %>
217       </TD>
218     </TR>
219 % }
220
221 % if ( $conf->exists('enable_taxproducts') ) {
222 <TR>
223   <TD ALIGN="right"><% mt('Tax location') |h %></TD>
224   <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
225 </TR>
226 % }
227 <TR>
228   <TD ALIGN="right"><% mt('Postal mail invoices') |h %></TD>
229   <TD BGCOLOR="#ffffff">
230     <% ( grep { $_ eq 'POST' } @invoicing_list ) ? $yes : $no %>
231   </TD>
232 </TR>
233 <TR>
234   <TD ALIGN="right"><% mt('Fax invoices') |h %></TD>
235   <TD BGCOLOR="#ffffff">
236     <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? $yes : $no %>
237   </TD>
238 </TR>
239 <TR>
240   <TD ALIGN="right"><% mt('Email invoices') |h %></TD>
241   <TD BGCOLOR="#ffffff">
242     <% $cust_main->invoice_noemail ? $no : $yes %>
243   </TD>
244 </TR>
245 % unless ( $conf->exists('cust-email-high-visibility')) {
246 <TR>
247   <TD ALIGN="right"><% mt('Email address(es)') |h %></TD>
248   <TD BGCOLOR="#ffffff">
249     <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
250 %   if ( $cust_main->message_noemail ) {
251     <BR>
252     <SPAN STYLE="font-size: small"><% emt('(do not send notices)') %></SPAN>
253 %   }
254   </TD>
255 </TR>
256 % }
257 <TR>
258   <TD ALIGN="right"><% mt('Invoice terms') |h %></TD>
259   <TD BGCOLOR="#ffffff">
260     <% $cust_main->invoice_terms || emt('Default').' ('. ( $conf->config('invoice_default_terms') || emt('Payable upon receipt') ). ')' %>
261   </TD>
262 </TR>
263 <TR>
264   <TD ALIGN="right"><% mt('Credit limit') |h %></TD>
265   <TD BGCOLOR="#ffffff">
266     <% length($cust_main->credit_limit) ? 
267         $money_char.sprintf("%.2f", $cust_main->credit_limit) :
268         emt('Unlimited') %>
269   </TD>
270 </TR>
271
272 % if ( $conf->exists('voip-cust_cdr_spools') ) { 
273   <TR>
274     <TD ALIGN="right"><% mt('Spool CDRs') |h %></TD>
275     <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? $yes : $no %></TD>
276   </TR>
277 % } 
278
279 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
280   <TR>
281     <TD ALIGN="right"><% mt($conf->exists('voip-cdr_email') ? 'Print CDRs' : 'Show CDRs') |h %></TD>
282     <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? $no : $yes %></TD>
283   </TR>
284 % } 
285
286 % if ( $conf->exists('voip-cust_accountcode_cdr') ) { 
287    <TR>
288      <TD ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TD>
289      <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
290    </TR>
291 % }
292
293 % if ( $conf->exists('voip-cust_email_csv_cdr') ) { 
294   <TR>
295     <TD ALIGN="right"><% mt('Email CDRs as CSV') |h %></TD>
296     <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
297   </TR>
298 % } 
299
300 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
301   <TR>
302     <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
303     <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
304   </TR>
305 % }
306
307 % if ( $cust_main->locale ) {
308 % my %locale_info = FS::Locales->locale_info($cust_main->locale);
309   <TR>
310     <TD ALIGN="right"><% mt('Invoicing locale') |h %></TD>
311     <TD BGCOLOR="#ffffff"><% $locale_info{name} . " (" . $locale_info{country} .")" %></TD>
312   </TR>
313 % }
314
315
316 </TABLE>
317 <%once>
318
319 my $paystate_label = FS::Msgcat::_gettext('paystate');
320 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
321
322 </%once>
323 <%init>
324
325 my( $cust_main ) = @_;
326 my @invoicing_list = $cust_main->invoicing_list;
327 my $conf = new FS::Conf;
328 my $money_char = $conf->config('money_char') || '$';
329
330 #false laziness w/edit/cust_main/billing.html
331 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
332 my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
333 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
334 my $show_term = $term_sth->fetchrow_arrayref->[0];
335
336 </%init>