can't find any indication this did anything back to 3.x
[freeside.git] / httemplate / edit / cust_main / billing.html
index 7c053dc..5714f9a 100644 (file)
-%if ( $payby_default eq 'HIDE' ) {
-%
-%  $cust_main->payby('BILL') unless $cust_main->payby;
-%  my $payby = $cust_main->payby;
-
-  <INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
+%  my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
 
-  <INPUT TYPE="hidden" NAME="<%$payby%>_payinfo" VALUE="<% $cust_main->paymask %>">
+  <SCRIPT>
 
-% foreach my $field (qw( payname paycvv paystart_month paystart_year payissue payip paytype paystate )) { 
+    function tax_changed(what) {
+      var num = document.getElementById(what.id + '_num'); 
+      if ( what.checked ) {
+        num.disabled = false;
+      } else {
+        num.disabled = true;
+      }
+    }
+    
+  </SCRIPT>
 
-    <INPUT TYPE="hidden" NAME="<% $payby.'_'.$field %>" VALUE="<% $cust_main->get($field) %>">
+  <BR><FONT CLASS="fsinnerbox-title"><% mt('Billing information') |h %></FONT>
 
-% } 
+  <TABLE CLASS="fsinnerbox">
 
-%  #false laziness w/elements/select-month_year.html & view/cust_main/billing.html
-%  my( $mon, $year );
-%  my $date = $cust_main->paydate || '12-2037';
-%  if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
-%    ( $mon, $year ) = ( $2, $1 );
-%  } elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
-%    ( $mon, $year ) = ( $1, $3 );
-%  } else {
-%    die "unrecognized expiration date format: $date";
-%  }
+%   my $curuser = $FS::CurrentUser::CurrentUser;
 
-  <INPUT TYPE="hidden" NAME="<%$payby%>_exp_month" VALUE="<% $mon %>">
-  <INPUT TYPE="hidden" NAME="<%$payby%>_exp_year"  VALUE="<% $year %>">
+%   ###
+%   # complimentry flag
+%   ###
 
-  <INPUT TYPE="hidden" NAME="tax" VALUE="<% $cust_main->tax %>">
+%   if ( $curuser->access_right('Complimentary customer') ) {
 
-  <INPUT TYPE="hidden" NAME="invoicing_list" VALUE="<% join(', ', @invoicing_list) %>">
+    <& /elements/tr-checkbox.html,
+      field       => 'complimentary',
+      label       => emt('Complimentary customer'),
+      value       => 'Y',
+      curr_value  => $cust_main->complimentary,
+      box_first   => 1,
+    &>
 
-% } else {
-%
-%  my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
+%   } else {
 
-  <BR><FONT SIZE="+1"><B>Billing information</B></FONT>
-  <% &ntable("#cccccc") %>
+      <INPUT TYPE="hidden" NAME="complimentary" VALUE="<% $cust_main->complimentary eq 'Y' ? 'Y' : '' %>">
 
-    <TR>
-      <TD ALIGN="right" WIDTH="200"><%$r%>Billing type</TD>
+%   }
 
-  <SCRIPT>
+%   ###
+%   # tax exemptions
+%   ###
 
-    var mywindow = -1;
-    function myopen(filename,windowname,properties) {
-      myclose();
-      mywindow = window.open(filename,windowname,properties);
-    }
-    function myclose() {
-      if ( mywindow != -1 )
-        mywindow.close();
-      mywindow = -1;
-    }
-
-    var achwindow = -1;
-    function achopen(filename,windowname,properties) {
-      achclose();
-      achwindow = window.open(filename,windowname,properties);
-    }
-    function achclose() {
-      if ( achwindow != -1 )
-        achwindow.close();
-      achwindow = -1;
-    }
+%   my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
+%   if (    $conf->exists('cust_class-tax_exempt')
+%        || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
+%        || $conf->config('tax-cust_exempt-groups-num_req') =~ /\w/
+%        || ! $curuser->access_right('Edit customer tax exemptions')
+%      )
+%   {
 
-    function card_changed(what) {
-      if (
-             what.form.payinfo.value.substring(0, 4) == '4093' 
-          || what.form.payinfo.value.substring(0, 4) == '4911' 
-          || what.form.payinfo.value.substring(0, 4) == '4936' 
-          || what.form.payinfo.value.substring(0, 6) == '564132' 
-          || what.form.payinfo.value.substring(0, 2) == '63' 
-          || what.form.payinfo.value.substring(0, 2) == '67' 
-         )
-      {
-        what.form.paystart_month.disabled = false;
-        what.form.paystart_year.disabled = false;
-        what.form.payissue.disabled = false;
-        what.form.paystart_month.style.backgroundColor = '#ffffff';
-        what.form.paystart_year.style.backgroundColor = '#ffffff';
-        what.form.payissue.style.backgroundColor = '#ffffff';
-        document.getElementById('paystart_label').style.color = '#000000';
-        document.getElementById('payissue_label').style.color = '#000000';
-      } else {
-        what.form.paystart_month.disabled = true;
-        what.form.paystart_year.disabled = true;
-        what.form.payissue.disabled = true;
-        what.form.paystart_month.style.backgroundColor = '#dddddd';
-        what.form.paystart_year.style.backgroundColor = '#dddddd';
-        what.form.payissue.style.backgroundColor = '#dddddd';
-        document.getElementById('paystart_label').style.color = '#999999';
-        document.getElementById('payissue_label').style.color = '#999999';
-      }
-      return true;
-    }
+      <INPUT TYPE="hidden" NAME="tax" VALUE="<% $cust_main->tax eq 'Y' ? 'Y' : '' %>">
 
-    function payauto_changed(payauto_field){
-        var f = (payauto_field.name == 'CARD_payauto') ? 'card_billday' : 'chek_billday';
-        f = document.getElementById(f);
-        if ( f == null) return;
-        if(payauto_field.checked) f.style.display = 'inline';
-        else f.style.display = 'none';
-    }
+%   } else {
 
-  </SCRIPT>
+    <& /elements/tr-checkbox.html,
+      field       => 'tax',
+      label       => emt('Tax Exempt' . (scalar(@exempt_groups) ? '(all taxes)' : '') ),
+      value       => 'Y',
+      curr_value  => $cust_main->tax,
+      box_first   => 1,
+    &>
 
-  <% include('/elements/init_overlib.html') %>
-
-%  my $payby = $cust_main->payby;
-%  my $paytype = $cust_main->paytype;
-%  my( $account, $aba ) = split('@', $payinfo);
-%
-%  my $disabled = 'DISABLED style="background-color: #dddddd"';
-%  my $text_disabled = 'style="color: #999999"';
-%
-%  if ( $payby =~ /^(CARD|DCRD)$/ && cardtype($payinfo) =~ /^(Switch|Solo)$/ ) {
-%    $disabled = 'style="background-color: #ffffff"';
-%    $text_disabled = 'style="color: #000000";'
-%  }
-%
-%  my $disable_payauto = $conf->exists('disable_payauto_default');
-%  my $CARD_payauto_checked =   $payby eq 'DCRD' ? ''
-%                             : $payby eq 'CARD' ? 'CHECKED'
-%                             : $disable_payauto ? '' : 'CHECKED';
-%  my $CHEK_payauto_checked =   $payby eq 'DCHK' ? ''
-%                             : $payby eq 'CHEK' ? 'CHECKED'
-%                             : $disable_payauto ? '' : 'CHECKED';
-%
-%  sub billday_options {
-%   my $curr_value = shift;
-%   my $ret = '<OPTION></OPTION>';
-%   for my $billday ( 1 .. 28 ) {
-%       my $sel = '';
-%       $sel = "SELECTED='SELECTED'" if $curr_value == $billday;
-%       $ret .= "<OPTION VALUE='$billday' $sel>$billday</OPTION>";
 %   }
-%   $ret;
-%  }
-%  my $billday_card_display = $payby eq 'CARD' ? 'inline' : 'none';
-%  my $billday_chek_display = $payby eq 'CHEK' ? 'inline' : 'none';
-%
-%  my %payby = (
-%
-%    'CARD' =>
-%
-%      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Card number </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="CARD_payinfo" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $payinfo : '' ). qq!" MAXLENGTH=19 onChange="card_changed(this)" onKeyUp="card_changed(this)"></TD></TR>!.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!.
-%          '<TD WIDTH="408">'.
-%
-%          include('/elements/select-month_year.html',
-%                    'prefix' => 'CARD_exp',
-%                    'selected_date' =>
-%                      ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->paydate : '' ),
-%                 ).
-%
-%          '</TD></TR>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">CVV2&nbsp;!.
-%
-%          qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!.
-%          qq!</TD>!.
-%          '<TD WIDTH="408"><INPUT TYPE="text" NAME="CARD_paycvv" VALUE="'. ( $payby =~ /^(CARD|DCRD)$/ && !$cust_main->is_encrypted($cust_main->paycvv) ? $cust_main->paycvv : '' ). '" SIZE=4 MAXLENGTH=4>'.
-%
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200"><SPAN ID="paystart_label" $text_disabled>Start date </SPAN></TD>!.
-%          '<TD WIDTH="408">'.
-%
-%          include('/elements/select-month_year.html',
-%                    'prefix' => 'CARD_paystart',
-%                    'disabled' => $disabled,
-%                    'empty_option' => 1,
-%                    'start_year' => 2000,
-%                    'end_year'   => (localtime())[5] + 1900,
-%                    'selected_date' => (
-%                      ( $payby =~ /^(CARD|DCRD)$/
-%                        && cardtype($payinfo) =~ /^(Switch|Solo)$/ )
-%                          ? $cust_main->paystart_month. '-'.
-%                            $cust_main->paystart_year 
-%                          : ''
-%                    )
-%                 ).
-%
-%        qq!<SPAN ID="payissue_label" $text_disabled> or Issue number </SPAN>!.
-%          '<INPUT TYPE="text" NAME="CARD_payissue" VALUE="'. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payissue : '' ). qq!" SIZE=3 MAXLENGTH=2 $disabled></TD></TR>!.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Exact name on card </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="CARD_payname" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!.
-%
-%        qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" onchange="payauto_changed(this);" NAME="CARD_payauto" $CARD_payauto_checked> Charge future payments to this card automatically</TD></TR>!.
-%
-%      ( $conf->exists('cust_main-select-billday') ?
-%        qq!<TR><TD COLSPAN=2 WIDTH="608" id="card_billday" style="display: $billday_card_display">
-%                    Charge on the <SELECT NAME="billday">!
-%                . billday_options($cust_main->billday) . qq!</SELECT> day of each month</TD></TR>!
-%        : ''
-%      ).
-%
-%      '</TABLE>',
-%
-%    'CHEK' => 
-%
-%      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Account number </TD>!.
-%          qq!<TD><INPUT TYPE="text" SIZE=12 NAME="CHEK_payinfo1" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $account : '' ). '"></TD>'.
-%          qq!<TD ALIGN="right">Type</TD><TD><SELECT NAME="CHEK_paytype">!.
-%            join('', map { qq!<OPTION VALUE="$_" !.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>" } @FS::cust_main::paytypes).
-%          qq!</SELECT></TD></TR>!.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}ABA/Routing number </TD>!.
-%          qq!<TD COLSPAN="3" WIDTH="408"><INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="CHEK_payinfo2" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $aba : '' ). qq!" SIZE=10 MAXLENGTH=9> !.
-%          qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!.
-%          qq!</TD></TR>!.
-%
-%        qq!<INPUT TYPE="hidden" NAME="CHEK_exp_month" VALUE="12">!.
-%        qq!<INPUT TYPE="hidden" NAME="CHEK_exp_year" VALUE="2037">!.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Bank name </TD>!.
-%          qq!<TD COLSPAN="3" WIDTH="408"><INPUT TYPE="text" NAME="CHEK_payname" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!.
-%      ( $conf->exists('show_bankstate') ?
-%          qq!<TR><TD ALIGN="right" WIDTH="200">$paystate_label</TD>!.
-%          qq!<TD COLSPAN="3" WIDTH="408">!.
-%          include('/elements/select-state.html',
-%                    'empty'   => '(choose)',
-%                    'state'   => $cust_main->paystate,
-%                    'country' => $cust_main->country,
-%                    'prefix'  => 'CHEK_pay',
-%                 ). "</TD></TR>"
-%         : '<INPUT TYPE="hidden" NAME="CHEK_paystate" VALUE="'.
-%            $cust_main->paystate. '">'
-%       ).
-%
-%
-%        qq!<TR><TD COLSPAN=4 WIDTH="608"><INPUT TYPE="checkbox" onchange="payauto_changed(this);" NAME="CHEK_payauto" $CHEK_payauto_checked> Charge future payments to this electronic check automatically</TD></TR>!.
-%
-%      ( $conf->exists('cust_main-select-billday') ?
-%        qq!<TR><TD COLSPAN=2 WIDTH="608" id="chek_billday" style="display: $billday_chek_display">
-%                    Charge on the <SELECT NAME="billday">!
-%                . billday_options($cust_main->billday) . qq!</SELECT> day of each month</TD></TR>!
-%        : ''
-%      ).
-%
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%
-%      '</TABLE>',
-%
-%    'LECB' =>  
-%
-%      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Phone number </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="LECB_payinfo" VALUE="!. ( $payby eq 'LECB' ? $cust_main->payinfo : '' ). qq!" MAXLENGTH=15 SIZE=16></TD></TR>!.
-%
-%        qq!<INPUT TYPE="hidden" NAME="LECB_exp_month" VALUE="12">!.
-%        qq!<INPUT TYPE="hidden" NAME="LECB_exp_year" VALUE="2037">!.
-%        qq!<INPUT TYPE="hidden" NAME="LECB_payname" VALUE="">!.
-%
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%
-%      '</TABLE>',
-%
-%    'BILL' =>  
-%
-%      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">P.O. </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="BILL_payinfo" VALUE="!. ( $payby eq 'BILL' ? $cust_main->payinfo : '' ). qq!"></TD></TR>!.
-%
-%        qq!<INPUT TYPE="hidden" NAME="BILL_exp_month" VALUE="12">!.
-%        qq!<INPUT TYPE="hidden" NAME="BILL_exp_year" VALUE="2037">!.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">Attention </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="BILL_payname" VALUE="!. encode_entities( $payby eq 'BILL' ? $cust_main->payname : '' ). qq!"></TD></TR>!.
-%
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%
-%      '</TABLE>',
-%
-%    'COMP' =>   
-%
-%      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Approved by </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="COMP_payinfo" VALUE=""></TD></TR>!.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!.
-%          '<TD WIDTH="408">'.
-%
-%          include('/elements/select-month_year.html',
-%                    'prefix' => 'COMP_exp',
-%                    'selected_date' =>
-%                      ( $payby eq 'COMP' ? $cust_main->paydate : '' ),
-%                 ).
-%
-%          '</TD></TR>'.
-%
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%
-%      '</TABLE>',
-%
-%    'CASH' =>
-%
-%      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="CASH_paid" VALUE="!. ( $payby eq 'CASH' ? $cust_main->paid : '' ). qq!"></TD></TR>!.
-%
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%
-%      '</TABLE>',
-%
-%    'WEST' =>
-%
-%      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="WEST_paid" VALUE="!. ( $payby eq 'WEST' ? $cust_main->paid : '' ). qq!"></TD></TR>!.
-%
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%
-%      '</TABLE>',
-%
-%    'MCRD' =>
-%
-%      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Amount </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="MCRD_paid" VALUE="!. ( $payby eq 'MCRD' ? $cust_main->paid : '' ). qq!"></TD></TR>!.
-%
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%        '<TR><TD>&nbsp;</TD></TR>'.
-%
-%      '</TABLE>',
-%
-%  );
-%
-%  #this should use FS::payby
-%  my @allopt = qw( CARD CHEK LECB BILL CASH WEST MCRD COMP );
-%
-%  my %allopt = map { $_ => FS::payby->shortname($_) } @allopt;
-%
-%  if ( $cust_main->custnum ) {
-%    #don't offer CASH/WEST/MCRD initial payment types when editing customer
-%    delete $allopt{$_} for qw(CASH WEST MCRD);
-%  }
-%  
-%  my @options = grep exists( $allopt{$_} ), @payby;
-%
-%  my %payby2option = (
-%    ( map { $_ => $_ } @options ),
-%    'DCRD' => 'CARD',
-%    'DCHK' => 'CHEK',
-%  );
-
-  <TD WIDTH="408">
-    <% include( '/elements/selectlayers.html',
-                  'field'      => 'payby',
-                  'curr_value' => $payby2option{$payby || $payby_default || $payby[0] },
-                  'options'    => \@options,
-                  'labels'     => \%allopt,
-                  'html_between' => '</TD></TR></TABLE>',
-                  'layer_callback' => sub { my $layer = shift; $payby{$layer}; },
-              )
-    %>
-
-  <% &ntable("#cccccc") %>
-
-    <TR><TD>&nbsp;</TD></TR>
 
-%   my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
-
-    <TR>
-      <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="tax" VALUE="Y" <% $cust_main->tax eq "Y" ? 'CHECKED' : '' %>> Tax Exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
-    </TR>
-
-%   foreach my $exempt_group ( @exempt_groups ) {
-%     #escape $exempt_group for NAME
-      <TR>
-        <TD WIDTH="608" COLSPAN="2">&nbsp;&nbsp;<INPUT TYPE="checkbox" NAME="tax_<% $exempt_group %>" VALUE="Y" <% $cust_main->tax_exemption($exempt_group) ? 'CHECKED' : '' %>> Tax Exempt (<% $exempt_group %> taxes)<TD>
-      </TR>
+%   if ( $curuser->access_right('Edit customer tax exemptions') ) {
+%     foreach my $exempt_group ( @exempt_groups ) {
+%       my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
+%       #escape $exempt_group for NAME etc.
+%       my $checked = ($cust_main_exemption || $cgi->param("tax_$exempt_group"));
+        <TR>
+          <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>
+          <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>
+        </TR>
+%     } #"
 %   }
 
-% unless ( $conf->exists('emailinvoiceonly') ) {
-
-    <TR>
-      <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST" <%
+%   ###
+%   # postal invoices
+%   ###
 
-        ( grep { $_ eq 'POST' } @invoicing_list )
+% unless ( $conf->exists('emailinvoiceonly') ) {
 
-          ? 'CHECKED'
-          : ''
+    <& /elements/tr-checkbox.html,
+      field       => 'postal_invoice',
+      label       => emt('Postal mail invoices'),
+      value       => 'Y',
+      curr_value  => $cust_main->postal_invoice,
+      box_first   => 1,
+    &>
 
-        %>> Postal mail invoice
+% }
 
+%   ###
+%   # email invoices
+%   ###
+
+    <& /elements/tr-checkbox.html,
+      field       => 'invoice_noemail',
+      label       => emt('Do not send email invoices'),
+      value       => 'Y',
+      curr_value  => $cust_main->invoice_noemail,
+      box_first   => 1,
+    &>
+
+    <& /elements/tr-checkbox.html,
+      field       => 'message_noemail',
+      label       => emt('Do not send other email notices'),
+      value       => 'Y',
+      curr_value  => $cust_main->message_noemail,
+      box_first   => 1,
+    &>
+
+%   ###
+%   # prorate_day
+%   ###
+
+% if ( $conf->exists('cust_main-select-prorate_day') ) {
+    <TR>
+      <TH ALIGN="right" WIDTH="200"><% mt('Prorate day') |h %> </TD>
+      <TD>
+        <SELECT NAME="prorate_day">
+          <% prorate_day_options($cust_main->prorate_day) %>
+        </SELECT>
+        <& /elements/checkbox.html,
+          field       => 'force_prorate_day',
+          value       => 'Y',
+          curr_value  => $cust_main->force_prorate_day
+        &>
+        <label><% emt('Force all packages to this day') %></label>
       </TD>
     </TR>
 
-    <TR>
-      <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_FAX" VALUE="FAX" <%
+%   sub prorate_day_options {
+%     my $curr_value = shift;
+%     my $ret = '';
+%     for my $prorate_day ( 1 .. 28 ) {
+%       my $sel = '';
+%       $sel = "SELECTED='SELECTED'" if $curr_value == $prorate_day;
+%       $ret .= "<OPTION VALUE='$prorate_day' $sel>$prorate_day</OPTION>";
+%     }
+%     $ret;
+%    }
 
-        ( grep { $_ eq 'FAX' } @invoicing_list )
-          ? 'CHECKED'
-          : ''
+% } else {
+    <INPUT TYPE="hidden" NAME="prorate_day" VALUE="<% $cust_main->prorate_day %>">
+% }
 
-        %>> Fax invoice
+%   ###
+%   # billday
+%   ###
 
+    <TR>
+      <TH ALIGN="right" WIDTH="200"><% mt('Charge card/e-check on this day of the month') |h %> </TD>
+      <TD>
+        <SELECT NAME="billday">
+          <% billday_options($cust_main->billday) %>
+        </SELECT>
       </TD>
     </TR>
 
-% }
+%  sub billday_options {
+%   my $curr_value = shift;
+%   my $ret = '';
+%   for my $billday ( 1 .. 28 ) {
+%       my $sel = '';
+%       $sel = "SELECTED='SELECTED'" if $curr_value == $billday;
+%       $ret .= "<OPTION VALUE='$billday' $sel>$billday</OPTION>";
+%   }
+%   $ret;
+%  }
 
-    <TR>
-      <TD ALIGN="right" WIDTH="200">
-        <% $conf->exists('cust_main-require_invoicing_list_email') ? $r : '' %>Email address(es)
-      </TD>
-      <TD WIDTH="408"><INPUT TYPE="text" NAME="invoicing_list" VALUE="<% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) %>"></TD>
-    </TR>
+%   ###
+%   # invoice_terms
+%   ###
 
     <TR>
-      <TD ALIGN="right" WIDTH="200">Invoice terms </TD>
+      <TH ALIGN="right" WIDTH="200"><% mt('Invoice terms') |h %> </TD>
       <TD WIDTH="408">
-        <% include('/elements/select-terms.html',
-                     'curr_value' => $cust_main->invoice_terms,
-                  )
-        %>
+        <& /elements/select-terms.html,
+             'curr_value' => $cust_main->invoice_terms,
+             'agentnum'   => $cust_main->agentnum,
+        &>
       </TD>
     </TR>
 
+%   ###
+%   # credit_limit
+%   ###
+
     <TR>
-      <TD ALIGN="right" WIDTH="200">Credit limit </TD>
+      <TH ALIGN="right" WIDTH="200"><% mt('Credit limit') |h %> </TD>
       <TD WIDTH="408">
         <SCRIPT TYPE="text/javascript">
 function toggle(obj) {
   obj.form.credit_limit.disabled = obj.checked;
 }
         </SCRIPT>
-        <INPUT TYPE="text" NAME="credit_limit" VALUE=<% sprintf('"%.2f"', $cust_main->credit_limit) %><% length($cust_main->credit_limit) ? '' : ' DISABLED' %>>
-        <INPUT TYPE="checkbox" NAME="no_credit_limit" VALUE=1 onclick="toggle(this)"<% length($cust_main->credit_limit) ? '' : ' CHECKED'%>> Unlimited
+        <INPUT TYPE  = "text"
+               NAME  = "credit_limit"
+               VALUE = "<% sprintf('%.2f', $cust_main->credit_limit) %>"
+               <% length($cust_main->credit_limit) ? '' : ' DISABLED' %>
+        >
+%       my $default_credit_limit = $conf->config('default_credit_limit');
+        <INPUT TYPE  = "checkbox"
+               NAME  = "no_credit_limit"
+               VALUE = 1
+               onClick="toggle(this)"
+               <% length($cust_main->credit_limit) ? '' : ' CHECKED'%>
+        > <FONT SIZE="-1" COLOR="#333333">
+          <% $default_credit_limit
+               ? "Default ($money_char". sprintf("%.2f", $default_credit_limit).
+                 ")"
+               : mt('Unlimited')
+            |h
+          %>
+          </FONT> 
       </TD>
     </TR>
 
-% if ( $conf->exists('voip-cust_cdr_spools') ) { 
-      <TR>
-       <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="spool_cdr" VALUE="Y" <% $cust_main->spool_cdr eq "Y" ? 'CHECKED' : '' %>> Spool CDRs</TD>
-      </TR>
-% } else { 
-      <INPUT TYPE="hidden" NAME="spool_cdr" VALUE="<% $cust_main->spool_cdr %>">
-% }
+%   ###
+%   # CDR flags / options
+%   ###
 
 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
       <TR>
-       <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="squelch_cdr" VALUE="Y" <% $cust_main->squelch_cdr eq "Y" ? 'CHECKED' : '' %>> Omit CDRs from printed invoices</TD>
+       <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>
       </TR>
 % } else { 
       <INPUT TYPE="hidden" NAME="squelch_cdr" VALUE="<% $cust_main->squelch_cdr %>">
 % }
 
-% if ( $conf->exists('voip-cust_email_csv_cdr') ) { 
+% if ( my $attach = $conf->config('voip-cdr_email_attach') ) {
       <TR>
-       <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="email_csv_cdr" VALUE="Y" <% $cust_main->email_csv_cdr eq "Y" ? 'CHECKED' : '' %>> Attach CDRs as CSV to emailed invoices</TD>
+       <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>
       </TR>
 % } else { 
       <INPUT TYPE="hidden" NAME="email_csv_cdr" VALUE="<% $cust_main->email_csv_cdr %>">
@@ -505,7 +247,7 @@ function toggle(obj) {
                    NAME="accountcode_cdr" 
                    VALUE="Y" 
                    <% $cust_main->accountcode_cdr eq "Y" ? 'CHECKED' : '' %>
-            > Breakdown CDRs by accountcode</TD>
+            > <% mt('Breakdown CDRs by accountcode') |h %></TD>
        </TR>
 % } else { 
        <INPUT TYPE="hidden" NAME="accountcode_cdr" VALUE="<% $cust_main->accountcode_cdr %>">
@@ -513,7 +255,7 @@ function toggle(obj) {
 
 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
       <TR>
-       <TD ALIGN="right">CDR termination settlement</TD>
+       <TH ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
        <TD><INPUT TYPE  = "text"
                   NAME  = "cdr_termination_percentage"
                   SIZE  = 6
@@ -525,29 +267,66 @@ function toggle(obj) {
       <INPUT TYPE="hidden" NAME="cdr_termination_percentage" VALUE="<% $cust_main->cdr_termination_percentage %>">
 % }
 
-  </TABLE>
+%   ###
+%   # Invoicing currency
+%   ###
+
+%my @currencies = $conf->config('currencies');
+%if ( scalar(@currencies) ) {
+%  unshift @currencies, ''; #default
+%  my %currency_labels = map { $_ => "$_: ". code2currency($_) } @currencies;
+%  $currency_labels{''} =
+%    'Default: '. code2currency( $conf->config('currency') || 'USD' );
+
+    <& /elements/tr-select.html, 
+         'label'         => emt('Invoicing currency'),
+         'field'         => 'currency',
+         'options'       => \@currencies,
+         'labels'        => \%currency_labels,
+         'curr_value'    => $cust_main->currency,
+    &>
+% }
 
-  <% $r %> required fields
-% } 
+%   ###
+%   # Invoicing locale
+%   ###
+
+%my @available_locales = $conf->config('available-locales');
+%if ( scalar(@available_locales) ) {
+%  push @available_locales, ''
+%    unless $cust_main->locale && $conf->exists('cust_main-require_locale');
+%  my %locale_labels = map { 
+%    my %ll;
+%    my %info = FS::Locales->locale_info($_);
+%    $ll{$_} = $info{name} . " (" . $info{country} . ")";
+%    %ll;
+%  } FS::Locales->locales;
+%    
+%  my $label = ( $conf->exists('cust_main-require_locale') ? $r : '' ).
+%              emt('Invoicing locale');
+
+    <& /elements/tr-select.html, 
+         'label'         => $label,
+         'field'         => 'locale',
+         'options'       => \@available_locales,
+         'labels'        => \%locale_labels,
+         'curr_value'    => $cust_main->locale,
+    &>
+% }
 
-<%once>
+  </TABLE>
+  <BR>
 
-my $paystate_label = FS::Msgcat::_gettext('paystate');
-$paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
+  <FONT CLASS="fsinnerbox-title"><% mt('Payment information') |h %></FONT>
+  <& cust_payby.html, 'cust_main'=>$cust_main, &>  
 
-</%once>
 <%init>
 
 my( $cust_main, %options ) = @_;
 my @invoicing_list = @{ $options{'invoicing_list'} };
-my $payinfo = $options{'payinfo'};
 my $conf = new FS::Conf;
-my $payby_default = $conf->config('payby-default');
 
-my @payby = grep /\w/, $conf->config('payby');
-#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
-@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
-  unless @payby;
+my $money_char = $conf->config('money_char') || '$';
 
 my $show_term = '';
 if ( $cust_main->custnum ) {
@@ -558,4 +337,6 @@ if ( $cust_main->custnum ) {
   $show_term = $term_sth->fetchrow_arrayref->[0];
 }
 
+my $agentnum = $cust_main->agentnum if $cust_main->custnum;
+
 </%init>