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