6e36e99e87823a09d918b06f03a0905d79f4cb65
[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 %  my $branch = '';
88 %  ($branch,$aba) = split('\.',$aba) if $conf->exists('cust_main-require-bank-branch');
89
90
91 % my $autodemand = $cust_main->payby eq 'CHEK' ? 'automatic' : 'on-demand';
92     <% mt("Electronic check ([_1])",$autodemand) |h %>
93   </TD>
94 </TR>
95
96 <TR>
97   <TD ALIGN="right"><% mt('ABA/Routing code') |h %></TD>
98   <TD BGCOLOR="#ffffff"><% $aba %></TD>
99 </TR>
100
101 % if ( $conf->exists('cust_main-require-bank-branch') ) {
102 <TR>
103   <TD ALIGN="right"><% mt('Branch number') |h %></TD>
104   <TD BGCOLOR="#ffffff"><% $branch %></TD>
105 <TR>
106 % }
107
108   <TD ALIGN="right"><% mt('Account number') |h %></TD>
109   <TD BGCOLOR="#ffffff"><% $account %></TD>
110 </TR>
111 <TR>
112   <TD ALIGN="right"><% mt('Account type') |h %></TD>
113   <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
114 </TR>
115 <TR>
116   <TD ALIGN="right"><% mt('Bank name') |h %></TD>
117   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
118 </TR>
119 % if ( $conf->exists('show_bankstate') ) {
120 <TR>
121   <TD ALIGN="right"><% $paystate_label %></TD>
122   <TD BGCOLOR="#ffffff"><% $cust_main->paystate || '&nbsp;&nbsp;&nbsp;' %></TD>
123 </TR>
124 % }
125 % } elsif ( $cust_main->payby eq 'LECB' ) {
126 %     $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
127 %     my $payinfo = "$1-$2-$3";
128
129     <% mt('Phone bill billing') |h %> 
130   </TD>
131 </TR>
132 <TR>
133   <TD ALIGN="right"><% mt('Phone number') |h %></TD>
134   <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
135 </TR>
136 % } elsif ( $cust_main->payby eq 'BILL' ) { 
137
138     <% mt('Billing') |h %> 
139   </TD>
140 </TR>
141 % if ( $cust_main->payinfo ) { 
142
143 <TR>
144   <TD ALIGN="right"<% mt('P.O.') |h %></TD>
145   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
146 </TR>
147 % } 
148
149
150 <TR>
151   <TD ALIGN="right"><% mt('Attention') |h %></TD>
152   <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
153 </TR>
154 % } elsif ( $cust_main->payby eq 'COMP' ) { 
155
156     <% mt('Complimentary') |h %> 
157   </TD>
158 </TR>
159 <TR>
160   <TD ALIGN="right"><% mt('Authorized by') |h %></TD>
161   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
162 </TR>
163 %
164 %#false laziness w/above etc.
165 %my( $mon, $year );
166 %my $date = $cust_main->paydate || '12-2037';
167 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
168 %  ( $mon, $year ) = ( $2, $1 );
169 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
170 %  ( $mon, $year ) = ( $1, $3 );
171 %} else {
172 %  warn "unrecognized expiration date format: $date";
173 %  ( $mon, $year ) = ( '', '' );
174 %}
175 %
176
177 <TR>
178   <TD ALIGN="right"><% mt('Expiration') |h %></TD>
179   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
180 </TR>
181 % } 
182
183 % my $yes = emt('yes');
184 % my $no = emt('no');
185
186 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
187 <TR>
188   <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
189   <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
190 </TR>
191 % foreach my $exempt_group ( @exempt_groups ) {
192 <TR>
193   <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
194   <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? $yes : $no %></TD>
195 </TR>
196 % }
197
198 % if ( $conf->exists('enable_taxproducts') ) {
199 <TR>
200   <TD ALIGN="right"><% mt('Tax location') |h %></TD>
201   <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
202 </TR>
203 % }
204 <TR>
205   <TD ALIGN="right"><% mt('Postal invoices') |h %></TD>
206   <TD BGCOLOR="#ffffff">
207     <% ( grep { $_ eq 'POST' } @invoicing_list ) ? $yes : $no %>
208   </TD>
209 </TR>
210 <TR>
211   <TD ALIGN="right"><% mt('FAX invoices') |h %></TD>
212   <TD BGCOLOR="#ffffff">
213     <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? $yes : $no %>
214   </TD>
215 </TR>
216 % unless ( $conf->exists('cust-email-high-visibility')) {
217 <TR>
218   <TD ALIGN="right"><% mt('Email invoices') |h %></TD>
219   <TD BGCOLOR="#ffffff">
220     <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
221   </TD>
222 </TR>
223 % }
224 <TR>
225   <TD ALIGN="right"><% mt('Invoice terms') |h %></TD>
226   <TD BGCOLOR="#ffffff">
227     <% $cust_main->invoice_terms || emt('Default').' ('. ( $conf->config('invoice_default_terms') || emt('Payable upon receipt') ). ')' %>
228   </TD>
229 </TR>
230 <TR>
231   <TD ALIGN="right"><% mt('Credit limit') |h %></TD>
232   <TD BGCOLOR="#ffffff">
233     <% length($cust_main->credit_limit) ? 
234         $money_char.sprintf("%.2f", $cust_main->credit_limit) :
235         emt('Unlimited') %>
236   </TD>
237 </TR>
238
239 % if ( $conf->exists('voip-cust_cdr_spools') ) { 
240   <TR>
241     <TD ALIGN="right"><% mt('Spool CDRs') |h %></TD>
242     <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? $yes : $no %></TD>
243   </TR>
244 % } 
245
246 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
247   <TR>
248     <TD ALIGN="right"><% mt($conf->exists('voip-cdr_email') ? 'Print CDRs' : 'Show CDRs') |h %></TD>
249     <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? $no : $yes %></TD>
250   </TR>
251 % } 
252
253 % if ( $conf->exists('voip-cust_accountcode_cdr') ) { 
254    <TR>
255      <TD ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TD>
256      <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
257    </TR>
258 % }
259
260 % if ( $conf->exists('voip-cust_email_csv_cdr') ) { 
261   <TR>
262     <TD ALIGN="right"><% mt('Email CDRs as CSV') |h %></TD>
263     <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
264   </TR>
265 % } 
266
267 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
268   <TR>
269     <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
270     <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
271   </TR>
272 % }
273
274 % if ( $cust_main->locale ) {
275 % my %locale_info = FS::Locales->locale_info($cust_main->locale);
276   <TR>
277     <TD ALIGN="right"><% mt('Invoicing locale') |h %></TD>
278     <TD BGCOLOR="#ffffff"><% $locale_info{name} . " (" . $locale_info{country} .")" %></TD>
279   </TR>
280 % }
281
282
283 </TABLE></TD></TR></TABLE>
284 <%once>
285
286 my $paystate_label = FS::Msgcat::_gettext('paystate');
287 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
288
289 </%once>
290 <%init>
291
292 my( $cust_main ) = @_;
293 my @invoicing_list = $cust_main->invoicing_list;
294 my $conf = new FS::Conf;
295 my $money_char = $conf->config('money_char') || '$';
296
297 #false laziness w/edit/cust_main/billing.html
298 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
299 my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
300 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
301 my $show_term = $term_sth->fetchrow_arrayref->[0];
302
303 </%init>