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