can't find any indication this did anything back to 3.x
[freeside.git] / httemplate / edit / cust_main / billing.html
index 3f87317..5714f9a 100644 (file)
@@ -1,123 +1,7 @@
-%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 %>">
-
-  <INPUT TYPE="hidden" NAME="<%$payby%>_payinfo" VALUE="<% $cust_main->paymask %>">
-
-% foreach my $field (qw( payname paycvv paystart_month paystart_year payissue payip paytype paystate billday )) { 
-
-    <INPUT TYPE="hidden" NAME="<% $payby.'_'.$field %>" VALUE="<% $cust_main->get($field) %>">
-
-% } 
-
-%  #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";
-%  }
-
-  <INPUT TYPE="hidden" NAME="<%$payby%>_exp_month" VALUE="<% $mon %>">
-  <INPUT TYPE="hidden" NAME="<%$payby%>_exp_year"  VALUE="<% $year %>">
-
-  <INPUT TYPE="hidden" NAME="tax" VALUE="<% $cust_main->tax %>">
-
-  <INPUT TYPE="hidden" NAME="invoicing_list" VALUE="<% join(', ', @invoicing_list) %>">
-
-% } else {
-%
 %  my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
 
-  <BR><FONT CLASS="fsinnerbox-title"><% mt('Billing information') |h %></FONT>
-  <% &ntable("#cccccc") %>
-
-    <TR>
-      <TD ALIGN="right" WIDTH="200"><%$r%><% mt('Billing type') |h %></TD>
-
   <SCRIPT>
 
-    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;
-    }
-
-    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;
-    }
-
-    function init_payauto_changed(){
-        var f = document.getElementById('CARD_payauto');
-        if(f != null) payauto_changed(f);
-        f = document.getElementById('CHEK_payauto');
-        if(f != null) payauto_changed(f);
-    }
-
-    function payauto_changed(payauto_field){
-        var select = (payauto_field.name == 'CARD_payauto') ? 'CARD_billday' : 'CHEK_billday';
-        var span = document.getElementById('td_'+select);
-        select = document.getElementById(select);
-        if (span == null || select == null) return;
-        if(payauto_field.checked) {
-            span.style.color = '#000000';
-            select.disabled = false;
-        }
-        else {
-            span.style.color = '#999999';
-            select.disabled = true;
-            //why? select.selectedIndex = 0;
-        }
-    }
-
     function tax_changed(what) {
       var num = document.getElementById(what.id + '_num'); 
       if ( what.checked ) {
     
   </SCRIPT>
 
-  <& /elements/init_overlib.html &>
-
-%  my $payby = $cust_main->payby;
-%  my $paytype = $cust_main->paytype;
-%  my( $account, $aba ) = split('@', $payinfo);
-%  my $branch = '';
-%  ($branch,$aba) = split('\.',$aba)
-%    if $conf->config('echeck-country') eq 'CA';
-%
-%  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 = '';
-%   for my $billday ( 1 .. 28 ) {
-%       my $sel = '';
-%       $sel = "SELECTED='SELECTED'" if $curr_value == $billday;
-%       $ret .= "<OPTION VALUE='$billday' $sel>$billday</OPTION>";
-%   }
-%   $ret;
-%  }
-%
-%  my $card_billday_style = $payby eq 'CARD' ? '' : 'style="color: #999999"';
-%  my $chek_billday_style = $payby eq 'CHEK' ? '' : 'style="color: #999999"';
-%  my $card_billday_select_disabled = $payby eq 'CARD' ? '' : 'DISABLED';
-%  my $chek_billday_select_disabled = $payby eq 'CHEK' ? '' : 'DISABLED';
-%
-%  #false laziness w/view/cust_main/billing.html and misc/payment.cgi
-%  my $routing_label = $conf->config('echeck-country') eq 'US'
-%                        ? 'ABA/Routing number'
-%                        : 'Routing number';
-%  my $routing_size      = $conf->config('echeck-country') eq 'CA' ? 4 : 10;
-%  my $routing_maxlength = $conf->config('echeck-country') eq 'CA' ? 3 : 9;
-%
-%
-%  my %payby = (
-%
-%    'CARD' =>
-%
-%      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}!.emt('Card number').qq! </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}!.emt('Expiration').qq! </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">!.emt('CVV2').qq!&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;">!.emt('help').qq!</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>!.emt('Start date').qq! </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>!.emt('or Issue number').qq! </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}!.emt('Exact name on card').qq! </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">!.
-%           qq!<INPUT TYPE="checkbox" onchange="payauto_changed(this);" ID="CARD_payauto" NAME="CARD_payauto" $CARD_payauto_checked> !.
-%           emt('Charge future payments to this [_1] automatically','credit card').'</TD></TR>'.
-%
-%      ( $conf->exists('cust_main-select-billday') ?
-%        qq!<TR><TD ALIGN="RIGHT" id="td_CARD_billday" $card_billday_style>
-%                    Charge on this day of each month</TD><TD> &nbsp; 
-%                   <SELECT id="CARD_billday" $card_billday_select_disabled NAME="CARD_billday">!
-%                . billday_options($cust_main->billday) . qq!</SELECT> </TD></TR>!
-%        : ''
-%      ).
-%
-%      '</TABLE>',
-%
-%    'CHEK' => 
-%
-%      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}!.emt('Account number').qq! </TD>!.
-%          qq!<TD><INPUT TYPE="text" SIZE=12 NAME="CHEK_payinfo1" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $account : '' ). '"></TD>'.
-%          qq!<TD ALIGN="right">!.emt('Type').qq!</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}!.emt($routing_label).qq! </TD>!.
-%          qq!<TD COLSPAN="3" WIDTH="408"><INPUT TYPE="text" SIZE=$routing_size MAXLENGTH=$routing_maxlength NAME="CHEK_payinfo2" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $aba : '' ). qq!"> !.
-%          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;">!.emt('help').qq!</A>)!.
-%          qq!</TD></TR>!.
-%
-%        qq!<INPUT TYPE="hidden" NAME="CHEK_exp_month" VALUE="12">!.
-%        qq!<INPUT TYPE="hidden" NAME="CHEK_exp_year" VALUE="2037">!.
-%
-%        ( $conf->config('echeck-country') eq 'CA' ? 
-%               qq!<TR><TD ALIGN="right">$r !.emt('Branch number').qq!</TD><TD COLSPAN="3">
-%                   <INPUT TYPE="text" name="CHEK_payinfo3" VALUE="$branch" SIZE=6 MAXLENGTH=5></TD></TR>! : '' ).
-%   
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}!.emt('Bank name').qq! </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'   => emt('(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">!.
-%           qq!<INPUT TYPE="checkbox" onchange="payauto_changed(this);" ID="CHEK_payauto" NAME="CHEK_payauto" $CHEK_payauto_checked> !.
-%           emt('Charge future payments to this [_1] automatically','electronic check').'</TD></TR>'.
-%
-%      ( $conf->exists('cust_main-select-billday') ?
-%        qq!<TR><TD ALIGN="RIGHT" id="td_CHEK_billday" $chek_billday_style>
-%                    Charge on this day of each month</TD><TD> &nbsp;
-%                   <SELECT id="CHEK_billday" $chek_billday_select_disabled NAME="CHEK_billday">!
-%                . billday_options($cust_main->billday) . qq!</SELECT> </TD></TR>!
-%        : ''
-%      ).
-%
-%      '</TABLE>',
-%
-%    'LECB' =>  
-%
-%      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}!.emt('Phone number').qq! </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">!.emt('P.O.').qq! </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">!.emt('Attention').qq! </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}!.emt('Approved by').qq! </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="COMP_payinfo" VALUE=""></TD></TR>!.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}!.emt('Expiration').qq! </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}!.emt('Amount').qq! </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}!.emt('Amount').qq! </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}!.emt('Amount').qq! </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">
-    <& /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}; },
-                  'onchange'    => 'init_payauto_changed();',
+  <BR><FONT CLASS="fsinnerbox-title"><% mt('Billing information') |h %></FONT>
+
+  <TABLE CLASS="fsinnerbox">
+
+%   my $curuser = $FS::CurrentUser::CurrentUser;
+
+%   ###
+%   # complimentry flag
+%   ###
+
+%   if ( $curuser->access_right('Complimentary customer') ) {
+
+    <& /elements/tr-checkbox.html,
+      field       => 'complimentary',
+      label       => emt('Complimentary customer'),
+      value       => 'Y',
+      curr_value  => $cust_main->complimentary,
+      box_first   => 1,
     &>
 
-  <% &ntable("#cccccc") %>
+%   } else {
+
+      <INPUT TYPE="hidden" NAME="complimentary" VALUE="<% $cust_main->complimentary eq 'Y' ? 'Y' : '' %>">
 
-    <TR><TD>&nbsp;</TD></TR>
+%   }
 
-%   my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
+%   ###
+%   # tax exemptions
+%   ###
 
+%   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')
 %      )
 %   {
 
 
 %   } else {
 
-      <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>
+    <& /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,
+    &>
 
 %   }
 
-%   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>&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>
+%   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') ) {
+%   ###
+%   # postal invoices
+%   ###
 
-    <TR>
-      <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST" <%
-
-        ( 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,
+    &>
 
-        %>> <% mt('Postal mail invoice') |h %> 
+% }
 
-      </TD>
-    </TR>
+%   ###
+%   # email invoices
+%   ###
 
-    <TR>
-      <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_FAX" VALUE="FAX" <%
+    <& /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,
+    &>
 
-        ( grep { $_ eq 'FAX' } @invoicing_list )
-          ? 'CHECKED'
-          : ''
+    <& /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,
+    &>
 
-        %>> <% mt('Fax invoice') |h %> 
+%   ###
+%   # 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>
 
+%   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;
+%    }
+
+% } else {
+    <INPUT TYPE="hidden" NAME="prorate_day" VALUE="<% $cust_main->prorate_day %>">
 % }
 
-% unless ( $conf->exists('cust-email-high-visibility')) {
+%   ###
+%   # billday
+%   ###
+
     <TR>
-      <TD ALIGN="right" WIDTH="200">
-        <% $conf->exists('cust_main-require_invoicing_list_email', $agentnum) 
-            ? $r : '' %>Email address(es)
+      <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>
-      <TD WIDTH="408"><INPUT TYPE="text" NAME="invoicing_list" VALUE="<% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) %>"></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;
+%  }
+
+%   ###
+%   # invoice_terms
+%   ###
 
     <TR>
-      <TD ALIGN="right" WIDTH="200"><% mt('Invoice terms') |h %> </TD>
+      <TH ALIGN="right" WIDTH="200"><% mt('Invoice terms') |h %> </TD>
       <TD WIDTH="408">
         <& /elements/select-terms.html,
-                     'curr_value' => $cust_main->invoice_terms,
+             'curr_value' => $cust_main->invoice_terms,
+             'agentnum'   => $cust_main->agentnum,
         &>
       </TD>
     </TR>
 
+%   ###
+%   # credit_limit
+%   ###
+
     <TR>
-      <TD ALIGN="right" WIDTH="200"><% mt('Credit limit') |h %> </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'%>> <% mt('Unlimited') |h %> 
+        <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' : '' %>> <% mt('Spool CDRs') |h %></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>
@@ -548,9 +232,9 @@ function toggle(obj) {
       <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' : '' %>> <% mt('Attach CDRs as CSV to emailed invoices') |h %></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 %>">
@@ -571,7 +255,7 @@ function toggle(obj) {
 
 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
       <TR>
-       <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
+       <TH ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
        <TD><INPUT TYPE  = "text"
                   NAME  = "cdr_termination_percentage"
                   SIZE  = 6
@@ -583,6 +267,30 @@ function toggle(obj) {
       <INPUT TYPE="hidden" NAME="cdr_termination_percentage" VALUE="<% $cust_main->cdr_termination_percentage %>">
 % }
 
+%   ###
+%   # 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,
+    &>
+% }
+
+%   ###
+%   # Invoicing locale
+%   ###
+
 %my @available_locales = $conf->config('available-locales');
 %if ( scalar(@available_locales) ) {
 %  push @available_locales, ''
@@ -607,32 +315,18 @@ function toggle(obj) {
 % }
 
   </TABLE>
+  <BR>
 
-  <% $r %><% mt('required fields') |h %> 
-% } 
-
-<script type="text/javascript">
-    init_payauto_changed();
-</script>
-
-<%once>
-
-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 ) {