1 % my $r = qq!<font color="#ff0000">*</font> !;
5 function tax_changed(what) {
6 var num = document.getElementById(what.id + '_num');
16 <BR><FONT CLASS="fsinnerbox-title"><% mt('Billing information') |h %></FONT>
18 <TABLE CLASS="fsinnerbox">
20 % my $curuser = $FS::CurrentUser::CurrentUser;
26 % if ( $curuser->access_right('Complimentary customer') ) {
28 <& /elements/tr-checkbox.html,
29 field => 'complimentary',
30 label => emt('Complimentary customer'),
32 curr_value => $cust_main->complimentary,
38 <INPUT TYPE="hidden" NAME="complimentary" VALUE="<% $cust_main->complimentary eq 'Y' ? 'Y' : '' %>">
46 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
47 % if ( $conf->exists('cust_class-tax_exempt')
48 % || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
49 % || $conf->config('tax-cust_exempt-groups-num_req') =~ /\w/
50 % || ! $curuser->access_right('Edit customer tax exemptions')
54 <INPUT TYPE="hidden" NAME="tax" VALUE="<% $cust_main->tax eq 'Y' ? 'Y' : '' %>">
58 <& /elements/tr-checkbox.html,
60 label => emt('Tax Exempt' . (scalar(@exempt_groups) ? '(all taxes)' : '') ),
62 curr_value => $cust_main->tax,
68 % if ( $curuser->access_right('Edit customer tax exemptions') ) {
69 % foreach my $exempt_group ( @exempt_groups ) {
70 % my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
71 % #escape $exempt_group for NAME etc.
72 % my $checked = ($cust_main_exemption || $cgi->param("tax_$exempt_group"));
74 <TD STYLE="white-space:nowrap"> <INPUT TYPE="checkbox" NAME="tax_<% $exempt_group %>" ID="tax_<% $exempt_group %>" VALUE="Y" <% $checked ? 'CHECKED' : '' %> onChange="tax_changed(this)"> Tax Exempt (<% $exempt_group %> taxes)</TD>
75 <TD> - Exemption number <INPUT TYPE="text" NAME="tax_<% $exempt_group %>_num" ID="tax_<% $exempt_group %>_num" VALUE="<% $cgi->param("tax_$exempt_group".'_num') || ( $cust_main_exemption ? $cust_main_exemption->exempt_number : '' ) |h %>" <% $checked ? '' : 'DISABLED' %>></TD>
84 % unless ( $conf->exists('emailinvoiceonly') ) {
86 <& /elements/tr-checkbox.html,
87 field => 'postal_invoice',
88 label => emt('Postal mail invoices'),
90 curr_value => $cust_main->postal_invoice,
100 <& /elements/tr-checkbox.html,
101 field => 'invoice_noemail',
102 label => emt('Do not send email invoices'),
104 curr_value => $cust_main->invoice_noemail,
108 <& /elements/tr-checkbox.html,
109 field => 'message_noemail',
110 label => emt('Do not send other email notices'),
112 curr_value => $cust_main->message_noemail,
120 % if ( $conf->exists('cust_main-select-prorate_day') ) {
122 <TH ALIGN="right" WIDTH="200"><% mt('Prorate day') |h %> </TD>
124 <SELECT NAME="prorate_day">
125 <% prorate_day_options($cust_main->prorate_day) %>
130 % sub prorate_day_options {
131 % my $curr_value = shift;
133 % for my $prorate_day ( 1 .. 28 ) {
135 % $sel = "SELECTED='SELECTED'" if $curr_value == $prorate_day;
136 % $ret .= "<OPTION VALUE='$prorate_day' $sel>$prorate_day</OPTION>";
142 <INPUT TYPE="hidden" NAME="prorate_day" VALUE="<% $cust_main->prorate_day %>">
150 <TH ALIGN="right" WIDTH="200"><% mt('Charge card/e-check on this day of the month') |h %> </TD>
152 <SELECT NAME="billday">
153 <% billday_options($cust_main->billday) %>
158 % sub billday_options {
159 % my $curr_value = shift;
161 % for my $billday ( 1 .. 28 ) {
163 % $sel = "SELECTED='SELECTED'" if $curr_value == $billday;
164 % $ret .= "<OPTION VALUE='$billday' $sel>$billday</OPTION>";
174 <TH ALIGN="right" WIDTH="200"><% mt('Invoice terms') |h %> </TD>
176 <& /elements/select-terms.html,
177 'curr_value' => $cust_main->invoice_terms,
178 'agentnum' => $cust_main->agentnum,
188 <TH ALIGN="right" WIDTH="200"><% mt('Credit limit') |h %> </TD>
190 <SCRIPT TYPE="text/javascript">
191 function toggle(obj) {
192 obj.form.credit_limit.disabled = obj.checked;
196 NAME = "credit_limit"
197 VALUE = "<% sprintf('%.2f', $cust_main->credit_limit) %>"
198 <% length($cust_main->credit_limit) ? '' : ' DISABLED' %>
200 % my $default_credit_limit = $conf->config('default_credit_limit');
201 <INPUT TYPE = "checkbox"
202 NAME = "no_credit_limit"
204 onClick="toggle(this)"
205 <% length($cust_main->credit_limit) ? '' : ' CHECKED'%>
206 > <FONT SIZE="-1" COLOR="#333333">
207 <% $default_credit_limit
208 ? "Default ($money_char". sprintf("%.2f", $default_credit_limit).
218 % # CDR flags / options
221 % if ( $conf->exists('voip-cust_cdr_spools') ) {
223 <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="spool_cdr" VALUE="Y" <% $cust_main->spool_cdr eq "Y" ? 'CHECKED' : '' %>> <% mt('Spool CDRs') |h %></TD>
226 <INPUT TYPE="hidden" NAME="spool_cdr" VALUE="<% $cust_main->spool_cdr %>">
229 % if ( $conf->exists('voip-cust_cdr_squelch') ) {
231 <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="squelch_cdr" VALUE="Y" <% $cust_main->squelch_cdr eq "Y" ? 'CHECKED' : '' %>> <% mt($conf->exists('voip-cdr_email') ? 'Omit CDRs from printed invoices' : 'Omit CDRs from invoices') |h %></TD>
234 <INPUT TYPE="hidden" NAME="squelch_cdr" VALUE="<% $cust_main->squelch_cdr %>">
237 % if ( my $attach = $conf->config('voip-cdr_email_attach') ) {
239 <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="email_csv_cdr" VALUE="Y" <% $cust_main->email_csv_cdr eq "Y" ? 'CHECKED' : '' %>> <% mt('Attach CDRs as '. uc($attach). ' to emailed invoices') |h %></TD>
242 <INPUT TYPE="hidden" NAME="email_csv_cdr" VALUE="<% $cust_main->email_csv_cdr %>">
245 % if ( $conf->exists('voip-cust_accountcode_cdr') ) {
248 <INPUT TYPE="checkbox"
249 NAME="accountcode_cdr"
251 <% $cust_main->accountcode_cdr eq "Y" ? 'CHECKED' : '' %>
252 > <% mt('Breakdown CDRs by accountcode') |h %></TD>
255 <INPUT TYPE="hidden" NAME="accountcode_cdr" VALUE="<% $cust_main->accountcode_cdr %>">
258 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
260 <TH ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
261 <TD><INPUT TYPE = "text"
262 NAME = "cdr_termination_percentage"
264 VALUE = "<% $cust_main->cdr_termination_percentage %>"
265 STYLE = "text-align:right;"
269 <INPUT TYPE="hidden" NAME="cdr_termination_percentage" VALUE="<% $cust_main->cdr_termination_percentage %>">
273 % # Invoicing currency
276 %my @currencies = $conf->config('currencies');
277 %if ( scalar(@currencies) ) {
278 % unshift @currencies, ''; #default
279 % my %currency_labels = map { $_ => "$_: ". code2currency($_) } @currencies;
280 % $currency_labels{''} =
281 % 'Default: '. code2currency( $conf->config('currency') || 'USD' );
283 <& /elements/tr-select.html,
284 'label' => emt('Invoicing currency'),
285 'field' => 'currency',
286 'options' => \@currencies,
287 'labels' => \%currency_labels,
288 'curr_value' => $cust_main->currency,
296 %my @available_locales = $conf->config('available-locales');
297 %if ( scalar(@available_locales) ) {
298 % push @available_locales, ''
299 % unless $cust_main->locale && $conf->exists('cust_main-require_locale');
300 % my %locale_labels = map {
302 % my %info = FS::Locales->locale_info($_);
303 % $ll{$_} = $info{name} . " (" . $info{country} . ")";
305 % } FS::Locales->locales;
307 % my $label = ( $conf->exists('cust_main-require_locale') ? $r : '' ).
308 % emt('Invoicing locale');
310 <& /elements/tr-select.html,
313 'options' => \@available_locales,
314 'labels' => \%locale_labels,
315 'curr_value' => $cust_main->locale,
322 <FONT CLASS="fsinnerbox-title"><% mt('Payment information') |h %></FONT>
323 <& cust_payby.html, 'cust_main'=>$cust_main, &>
327 my( $cust_main, %options ) = @_;
328 my @invoicing_list = @{ $options{'invoicing_list'} };
329 my $conf = new FS::Conf;
331 my $money_char = $conf->config('money_char') || '$';
334 if ( $cust_main->custnum ) {
335 #false laziness w/view/cust_main/billing.html
336 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
337 my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
338 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
339 $show_term = $term_sth->fetchrow_arrayref->[0];
342 my $agentnum = $cust_main->agentnum if $cust_main->custnum;