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