RT# 32234 Allow unmask of SSN/DL#
[freeside.git] / httemplate / edit / cust_main / billing.html
1 %  my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
2
3   <SCRIPT>
4
5     function tax_changed(what) {
6       var num = document.getElementById(what.id + '_num'); 
7       if ( what.checked ) {
8         num.disabled = false;
9       } else {
10         num.disabled = true;
11       }
12     }
13     
14   </SCRIPT>
15
16   <BR><FONT CLASS="fsinnerbox-title"><% mt('Billing information') |h %></FONT>
17
18   <TABLE CLASS="fsinnerbox">
19
20 %   my $curuser = $FS::CurrentUser::CurrentUser;
21
22 %   ###
23 %   # complimentry flag
24 %   ###
25
26 %   if ( $curuser->access_right('Complimentary customer') ) {
27
28     <& /elements/tr-checkbox.html,
29       field       => 'complimentary',
30       label       => emt('Complimentary customer'),
31       value       => 'Y',
32       curr_value  => $cust_main->complimentary,
33       box_first   => 1,
34     &>
35
36 %   } else {
37
38       <INPUT TYPE="hidden" NAME="complimentary" VALUE="<% $cust_main->complimentary eq 'Y' ? 'Y' : '' %>">
39
40 %   }
41
42 %   ###
43 %   # tax exemptions
44 %   ###
45
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')
51 %      )
52 %   {
53
54       <INPUT TYPE="hidden" NAME="tax" VALUE="<% $cust_main->tax eq 'Y' ? 'Y' : '' %>">
55
56 %   } else {
57
58     <& /elements/tr-checkbox.html,
59       field       => 'tax',
60       label       => emt('Tax Exempt' . (scalar(@exempt_groups) ? '(all taxes)' : '') ),
61       value       => 'Y',
62       curr_value  => $cust_main->tax,
63       box_first   => 1,
64     &>
65
66 %   }
67
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"));
73         <TR>
74           <TD STYLE="white-space:nowrap">&nbsp;&nbsp;<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>
76         </TR>
77 %     } #"
78 %   }
79
80 %   ###
81 %   # postal invoices
82 %   ###
83
84 % unless ( $conf->exists('emailinvoiceonly') ) {
85
86     <& /elements/tr-checkbox.html,
87       field       => 'postal_invoice',
88       label       => emt('Postal mail invoices'),
89       value       => 'Y',
90       curr_value  => $cust_main->postal_invoice,
91       box_first   => 1,
92     &>
93
94 % }
95
96 %   ###
97 %   # email invoices
98 %   ###
99
100     <& /elements/tr-checkbox.html,
101       field       => 'invoice_noemail',
102       label       => emt('Do not send email invoices'),
103       value       => 'Y',
104       curr_value  => $cust_main->invoice_noemail,
105       box_first   => 1,
106     &>
107
108     <& /elements/tr-checkbox.html,
109       field       => 'message_noemail',
110       label       => emt('Do not send other email notices'),
111       value       => 'Y',
112       curr_value  => $cust_main->message_noemail,
113       box_first   => 1,
114     &>
115
116 %   ###
117 %   # prorate_day
118 %   ###
119
120 % if ( $conf->exists('cust_main-select-prorate_day') ) {
121     <TR>
122       <TH ALIGN="right" WIDTH="200"><% mt('Prorate day') |h %> </TD>
123       <TD>
124         <SELECT NAME="prorate_day">
125           <% prorate_day_options($cust_main->prorate_day) %>
126         </SELECT>
127         <& /elements/checkbox.html,
128           field       => 'force_prorate_day',
129           value       => 'Y',
130           curr_value  => $cust_main->force_prorate_day
131         &>
132         <label><% emt('Force all packages to this day') %></label>
133       </TD>
134     </TR>
135
136 %   sub prorate_day_options {
137 %     my $curr_value = shift;
138 %     my $ret = '';
139 %     for my $prorate_day ( 1 .. 28 ) {
140 %       my $sel = '';
141 %       $sel = "SELECTED='SELECTED'" if $curr_value == $prorate_day;
142 %       $ret .= "<OPTION VALUE='$prorate_day' $sel>$prorate_day</OPTION>";
143 %     }
144 %     $ret;
145 %    }
146
147 % } else {
148     <INPUT TYPE="hidden" NAME="prorate_day" VALUE="<% $cust_main->prorate_day %>">
149 % }
150
151 %   ###
152 %   # billday
153 %   ###
154
155     <TR>
156       <TH ALIGN="right" WIDTH="200"><% mt('Charge card/e-check on this day of the month') |h %> </TD>
157       <TD>
158         <SELECT NAME="billday">
159           <% billday_options($cust_main->billday) %>
160         </SELECT>
161       </TD>
162     </TR>
163
164 %  sub billday_options {
165 %   my $curr_value = shift;
166 %   my $ret = '';
167 %   for my $billday ( 1 .. 28 ) {
168 %       my $sel = '';
169 %       $sel = "SELECTED='SELECTED'" if $curr_value == $billday;
170 %       $ret .= "<OPTION VALUE='$billday' $sel>$billday</OPTION>";
171 %   }
172 %   $ret;
173 %  }
174
175 %   ###
176 %   # invoice_terms
177 %   ###
178
179     <TR>
180       <TH ALIGN="right" WIDTH="200"><% mt('Invoice terms') |h %> </TD>
181       <TD WIDTH="408">
182 %       if ( $curuser->access_right('Edit customer invoice terms') ) {
183           <& /elements/select-terms.html,
184                'curr_value' => $cust_main->invoice_terms,
185                'agentnum'   => $cust_main->agentnum,
186           &>
187 %       } else {
188 %
189 %         my $terms =
190 %           $cust_main->invoice_terms
191 %             || emt('Default').' ('.
192 %                ( $conf->config('invoice_default_terms', $cust_main->agentnum)
193 %                    || emt('Payable upon receipt')
194 %                ).
195 %                ')';
196           <% $terms |h %>
197
198           <& /elements/hidden.html, 
199                'field'      => 'invoice_terms',
200                'curr_value' => $cust_main->invoice_terms,
201           &>
202 %       }
203       </TD>
204     </TR>
205
206 %   ###
207 %   # credit_limit
208 %   ###
209
210     <TR>
211       <TH ALIGN="right" WIDTH="200"><% mt('Credit limit') |h %> </TD>
212       <TD WIDTH="408">
213         <SCRIPT TYPE="text/javascript">
214 function toggle(obj) {
215   obj.form.credit_limit.disabled = obj.checked;
216 }
217         </SCRIPT>
218         <INPUT TYPE  = "text"
219                NAME  = "credit_limit"
220                VALUE = "<% sprintf('%.2f', $cust_main->credit_limit) %>"
221                <% length($cust_main->credit_limit) ? '' : ' DISABLED' %>
222         >
223 %       my $default_credit_limit = $conf->config('default_credit_limit');
224         <INPUT TYPE  = "checkbox"
225                NAME  = "no_credit_limit"
226                VALUE = 1
227                onClick="toggle(this)"
228                <% length($cust_main->credit_limit) ? '' : ' CHECKED'%>
229         > <FONT SIZE="-1" COLOR="#333333">
230           <% $default_credit_limit
231                ? "Default ($money_char". sprintf("%.2f", $default_credit_limit).
232                  ")"
233                : mt('Unlimited')
234             |h
235           %>
236           </FONT> 
237       </TD>
238     </TR>
239
240 %   ###
241 %   # CDR flags / options
242 %   ###
243
244 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
245       <TR>
246        <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>
247       </TR>
248 % } else { 
249       <INPUT TYPE="hidden" NAME="squelch_cdr" VALUE="<% $cust_main->squelch_cdr %>">
250 % }
251
252 % if ( my $attach = $conf->config('voip-cdr_email_attach') ) {
253       <TR>
254        <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>
255       </TR>
256 % } else { 
257       <INPUT TYPE="hidden" NAME="email_csv_cdr" VALUE="<% $cust_main->email_csv_cdr %>">
258 % }
259
260 % if ( $conf->exists('voip-cust_accountcode_cdr') ) { 
261        <TR>
262         <TD COLSPAN="2">
263             <INPUT TYPE="checkbox" 
264                    NAME="accountcode_cdr" 
265                    VALUE="Y" 
266                    <% $cust_main->accountcode_cdr eq "Y" ? 'CHECKED' : '' %>
267             > <% mt('Breakdown CDRs by accountcode') |h %></TD>
268        </TR>
269 % } else { 
270        <INPUT TYPE="hidden" NAME="accountcode_cdr" VALUE="<% $cust_main->accountcode_cdr %>">
271 % }
272
273 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
274       <TR>
275        <TH ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
276        <TD><INPUT TYPE  = "text"
277                   NAME  = "cdr_termination_percentage"
278                   SIZE  = 6
279                   VALUE = "<% $cust_main->cdr_termination_percentage %>"
280                   STYLE = "text-align:right;"
281         ><B>%</B></TD>
282       </TR>
283 % } else {
284       <INPUT TYPE="hidden" NAME="cdr_termination_percentage" VALUE="<% $cust_main->cdr_termination_percentage %>">
285 % }
286
287 %   ###
288 %   # Invoicing currency
289 %   ###
290
291 %my @currencies = $conf->config('currencies');
292 %if ( scalar(@currencies) ) {
293 %  unshift @currencies, ''; #default
294 %  my %currency_labels = map { $_ => "$_: ". code2currency($_) } @currencies;
295 %  $currency_labels{''} =
296 %    'Default: '. code2currency( $conf->config('currency') || 'USD' );
297
298     <& /elements/tr-select.html, 
299          'label'         => emt('Invoicing currency'),
300          'field'         => 'currency',
301          'options'       => \@currencies,
302          'labels'        => \%currency_labels,
303          'curr_value'    => $cust_main->currency,
304     &>
305 % }
306
307 %   ###
308 %   # Invoicing locale
309 %   ###
310
311 %my @available_locales = $conf->config('available-locales');
312 %if ( scalar(@available_locales) ) {
313 %  push @available_locales, ''
314 %    unless $cust_main->locale && $conf->exists('cust_main-require_locale');
315 %  my %locale_labels = map { 
316 %    my %ll;
317 %    my %info = FS::Locales->locale_info($_);
318 %    $ll{$_} = $info{name} . " (" . $info{country} . ")";
319 %    %ll;
320 %  } FS::Locales->locales;
321 %    
322 %  my $label = ( $conf->exists('cust_main-require_locale') ? $r : '' ).
323 %              emt('Invoicing locale');
324
325     <& /elements/tr-select.html, 
326          'label'         => $label,
327          'field'         => 'locale',
328          'options'       => \@available_locales,
329          'labels'        => \%locale_labels,
330          'curr_value'    => $cust_main->locale,
331     &>
332 % }
333
334   </TABLE>
335   <BR>
336
337   <FONT CLASS="fsinnerbox-title"><% mt('Payment information') |h %></FONT>
338   <& cust_payby.html, 'cust_main'=>$cust_main, &>  
339
340 <%init>
341
342 my( $cust_main, %options ) = @_;
343 my @invoicing_list = @{ $options{'invoicing_list'} };
344 my $conf = new FS::Conf;
345
346 my $money_char = $conf->config('money_char') || '$';
347
348 my $show_term = '';
349 if ( $cust_main->custnum ) {
350   #false laziness w/view/cust_main/billing.html
351   my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
352   my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
353   $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
354   $show_term = $term_sth->fetchrow_arrayref->[0];
355 }
356
357 my $agentnum = $cust_main->agentnum if $cust_main->custnum;
358
359 </%init>