multiple payment options, RT#23741
[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 %        && qsearch({ 'table'     => 'cust_payby',
36 %                     'hashref'   => { 'custnum' => $cust_main->custnum, },
37 %                     'extra_sql' => "AND payby IN ( 'CARD', 'CHEK' )",
38 %                     'order_by'  => 'LIMIT 1',
39 %                  })
40 %    )
41 % {
42     <TR>
43       <TD ALIGN="right"><% mt('Payment day of month') |h %></TD>
44       <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
45       </TD>
46     </TR>
47 % }
48
49 % if ( $cust_main->po_number ) { 
50     <TR>
51       <TD ALIGN="right"><% mt('Purchase Order #') |h %></TD>
52       <TD BGCOLOR="#ffffff"><% $cust_main->po_number %></TD>
53     </TR>
54 % } 
55
56 % my $yes = emt('yes');
57 % my $no = emt('no');
58
59 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
60
61 % unless (    $conf->exists('cust_class-tax_exempt')
62 %          || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
63 %        )
64 % {
65     <TR>
66       <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
67       <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
68     </TR>
69 % }
70
71 % foreach my $exempt_group ( @exempt_groups ) {
72 %   my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
73     <TR>
74       <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
75       <TD BGCOLOR="#ffffff"><% $cust_main_exemption ? $yes : $no %>
76         <% $cust_main_exemption ? $cust_main_exemption->exempt_number : '' |h %>
77       </TD>
78     </TR>
79 % }
80
81 % if ( $conf->exists('enable_taxproducts') ) {
82 <TR>
83   <TD ALIGN="right"><% mt('Tax location') |h %></TD>
84 % my $tax_location = $conf->exists('tax-ship_address')
85 %                    ? $cust_main->ship_location
86 %                    : $cust_main->bill_location;
87   <TD BGCOLOR="#ffffff"><% $tax_location->geocode('cch') %></TD>
88 </TR>
89 % }
90 <TR>
91   <TD ALIGN="right"><% mt('Postal mail invoices') |h %></TD>
92   <TD BGCOLOR="#ffffff">
93     <% ( grep { $_ eq 'POST' } @invoicing_list )
94          ? $yes. ( $cust_main->invoice_attn
95                      ? ', attn: '. $cust_main->invoice_attn
96                      : ''
97                  )
98          : $no
99     %>
100   </TD>
101 </TR>
102 <TR>
103   <TD ALIGN="right"><% mt('Email invoices') |h %></TD>
104   <TD BGCOLOR="#ffffff">
105     <% $cust_main->invoice_noemail ? $no : $yes %>
106   </TD>
107 </TR>
108 % unless ( $conf->exists('cust-email-high-visibility')) {
109 <TR>
110   <TD ALIGN="right"><% mt('Email address(es)') |h %></TD>
111   <TD BGCOLOR="#ffffff">
112     <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
113 %   if ( $cust_main->message_noemail ) {
114     <BR>
115     <SPAN STYLE="font-size: small"><% emt('(do not send notices)') %></SPAN>
116 %   }
117   </TD>
118 </TR>
119 % }
120 <TR>
121   <TD ALIGN="right"><% mt('Invoice terms') |h %></TD>
122   <TD BGCOLOR="#ffffff">
123     <% $cust_main->invoice_terms
124          || emt('Default').' ('. ( $conf->config('invoice_default_terms', $cust_main->agentnum)
125                                      || emt('Payable upon receipt')
126                                  ).
127                            ')'
128     %>
129   </TD>
130 </TR>
131 <TR>
132   <TD ALIGN="right"><% mt('Credit limit') |h %></TD>
133   <TD BGCOLOR="#ffffff">
134 %   my $default_credit_limit = $conf->config('default_credit_limit');
135     <% length($cust_main->credit_limit)
136          ? $money_char. sprintf("%.2f", $cust_main->credit_limit)
137          : $default_credit_limit
138            ? "Default ($money_char". sprintf("%.2f", $default_credit_limit). ")"
139            : emt('Unlimited')
140     %>
141 %   if ( $cust_main->num_cust_main_credit_limit ) {
142       <A HREF="<% $p %>search/cust_main_credit_limit.html?custnum=<% $cust_main->custnum %>">(incidents)</A>
143 %   }
144   </TD>
145 </TR>
146
147 % if ( $conf->exists('voip-cust_cdr_spools') ) { 
148   <TR>
149     <TD ALIGN="right"><% mt('Spool CDRs') |h %></TD>
150     <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? $yes : $no %></TD>
151   </TR>
152 % } 
153
154 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
155   <TR>
156     <TD ALIGN="right"><% mt($conf->exists('voip-cdr_email') ? 'Print CDRs' : 'Show CDRs') |h %></TD>
157     <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? $no : $yes %></TD>
158   </TR>
159 % } 
160
161 % if ( $conf->exists('voip-cust_accountcode_cdr') ) { 
162    <TR>
163      <TD ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TD>
164      <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
165    </TR>
166 % }
167
168 % if ( $conf->exists('voip-cust_email_csv_cdr') ) { 
169   <TR>
170     <TD ALIGN="right"><% mt('Email CDRs as CSV') |h %></TD>
171     <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
172   </TR>
173 % } 
174
175 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
176   <TR>
177     <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
178     <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
179   </TR>
180 % }
181
182 % if ( $cust_main->currency ) {
183   <TR>
184     <TD ALIGN="right"><% mt('Invoicing currency') |h %></TD>
185     <TD BGCOLOR="#ffffff"><% $cust_main->currency. ': '. code2currency($cust_main->currency) %></TD>
186   </TR>
187 % }
188
189 % if ( $cust_main->locale ) {
190 % my %locale_info = FS::Locales->locale_info($cust_main->locale);
191   <TR>
192     <TD ALIGN="right"><% mt('Invoicing locale') |h %></TD>
193     <TD BGCOLOR="#ffffff"><% $locale_info{name} . " (" . $locale_info{country} .")" %></TD>
194   </TR>
195 % }
196
197
198 </TABLE>
199 <%init>
200
201 my( $cust_main ) = @_;
202 my @invoicing_list = $cust_main->invoicing_list;
203 my $conf = new FS::Conf;
204 my $money_char = $conf->config('money_char') || '$';
205
206 #false laziness w/edit/cust_main/billing.html
207 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
208 my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
209 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
210 my $show_term = $term_sth->fetchrow_arrayref->[0];
211
212 </%init>