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