can't find any indication this did anything back to 3.x
[freeside.git] / httemplate / edit / cust_main / billing.html
index 1440db4..5714f9a 100644 (file)
-%if ( $payby_default eq 'HIDE' ) {
-%
-%  $cust_main->payby('BILL') unless $cust_main->payby;
-
-  <INPUT TYPE="hidden" NAME="select" VALUE="<% $cust_main->payby %>">
-
-  </FORM>
-
-  <FORM NAME="<% $cust_main->payby %>" STYLE="margin-top: 0; margin-bottom: 0"> 
-
-    <INPUT TYPE="hidden" NAME="payinfo" VALUE="<% $cust_main->paymask %>">
-
-% foreach my $field (qw( payname paycvv paystart_month paystart_year payissue payip paytype paystate )) { 
-
-    <INPUT TYPE="hidden" NAME="<% $field %>" VALUE="<% $cust_main->getfield($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="exp_month" VALUE="<% $mon %>">
-  <INPUT TYPE="hidden" NAME="exp_year"  VALUE="<% $year %>">
-
-  </FORM>
-
-  <FORM NAME="billing_bottomform" STYLE="margin-top: 0; margin-bottom: 0">
-
-  <INPUT TYPE="hidden" NAME="tax" VALUE="<% $cust_main->tax %>">
-
-  <INPUT TYPE="hidden" NAME="invoicing_list" VALUE="<% join(', ', @invoicing_list) %>">
-
-  </FORM>
-
-% } else {
-%
 %  my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
 
-  <BR>Billing information
-  <% &ntable("#cccccc") %>
-
-    <TR>
-      <TD ALIGN="right" WIDTH="200"><%$r%>Billing type</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';
+    function tax_changed(what) {
+      var num = document.getElementById(what.id + '_num'); 
+      if ( what.checked ) {
+        num.disabled = false;
       } 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';
+        num.disabled = true;
       }
-      return true;
     }
-
+    
   </SCRIPT>
 
-  <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT>
-  <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT>
-  <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_draggable.js"></SCRIPT>
-  <SCRIPT TYPE="text/javascript">
-  function OLiframeContent(src, width, height, name) {
-    return ('<iframe src="'+src+'" width="'+width+'" height="'+height+'"'
-     +(name?' name="'+name+'" id="'+name+'"':'')+' scrolling="auto">'
-     +'<div>[iframe not supported]</div></iframe>');
-  }
-  </SCRIPT>
-
-%  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 %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="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' => '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="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' => '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="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="payname" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!.
-%
-%        qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCRD' ? '' : 'CHECKED' ). '> Charge future payments to this card automatically</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="payinfo1" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $account : '' ). '"></TD>'.
-%          qq!<TD ALIGN="right">Type</TD><TD><SELECT="text" NAME="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="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="exp_month" VALUE="12">!.
-%        qq!<INPUT TYPE="hidden" NAME="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="payname" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!.
-%          qq!<TR><TD ALIGN="right" WIDTH="200">$paystate_label</TD>!.
-%          qq!<TD COLSPAN="3" WIDTH="408">!.
-%          include('select-state.html',
-%                    'empty'   => '(choose)',
-%                    'state'   => $cust_main->paystate,
-%                    'country' => $cust_main->country,
-%                    'prefix' => 'pay',
-%                 ). "</TD></TR>".
-%
-%
-%        qq!<TR><TD COLSPAN=4 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCHK' ? '' : 'CHECKED' ). '> Charge future payments to this electronic check automatically</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="payinfo" VALUE="!. ( $payby eq 'LECB' ? $cust_main->payinfo : '' ). qq!" MAXLENGTH=15 SIZE=16></TD></TR>!.
-%
-%        qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!.
-%        qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!.
-%        qq!<INPUT TYPE="hidden" NAME="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="payinfo" VALUE="!. ( $payby eq 'BILL' ? $cust_main->payinfo : '' ). qq!"></TD></TR>!.
-%
-%        qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!.
-%        qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">Attention </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $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="payinfo" VALUE=""></TD></TR>!.
-%
-%        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!.
-%          '<TD WIDTH="408">'.
-%
-%          include('/elements/select-month_year.html',
-%                    'prefix' => '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="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="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="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 = (
-%    'CARD' => 'Credit card',
-%    'CHEK' => 'Electronic check',
-%    'LECB' => 'Phone bill billing',
-%    'BILL' => 'Billing',
-%    'CASH' => 'Cash', # initial payment, then billing',
-%    'WEST' => 'Western Union', # initial payment, then billing',
-%    'MCRD' => 'Manual credit card', # initial payment, then billing',
-%    'COMP' => 'Complimentary',
-%  );
-%  if ( $cust_main->custnum ) { #don't offer CASH/WEST/MCRD initial payment types
-%                               # when editing customer
-%    delete $allopt{$_} for qw(CASH WEST MCRD);
-%  }
-%  
-%  tie my %options, 'Tie::IxHash',
-%    map  { $_ => $allopt{$_} }
-%    grep { exists $allopt{$_} }
-%         @payby;
-%
-%  my %payby2option = (
-%    ( map { $_ => $_ } keys %options ),
-%    'DCRD' => 'CARD',
-%    'DCHK' => 'CHEK',
-%  );
-%
-%  my $widget = new HTML::Widgets::SelectLayers(
-%    'options'        => \%options,
-%    #'form_name'      => 'dummy',
-%    #'form_action'    => 'nothingyet',
-%    #chops bottom of page in IE# 'under_position' => 'absolute',
-%    'html_between'   => '</TD></TR></TABLE>',
-%    'selected_layer' => $payby2option{$payby || $payby_default || $payby[0] },
-%    'layer_callback' => sub { my $layer = shift; $payby{$layer}; },
-%  );
-%
-%  
-
-
-  <TD WIDTH="408"><% $widget->html %>
-
-  <FORM NAME="billing_bottomform" STYLE="margin-top: 0; margin-bottom: 0">
-
-  <% &ntable("#cccccc") %>
-
-    <TR><TD>&nbsp;</TD></TR>
-
+  <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,
+    &>
+
+%   } else {
+
+      <INPUT TYPE="hidden" NAME="complimentary" VALUE="<% $cust_main->complimentary eq 'Y' ? 'Y' : '' %>">
+
+%   }
+
+%   ###
+%   # 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')
+%      )
+%   {
+
+      <INPUT TYPE="hidden" NAME="tax" VALUE="<% $cust_main->tax eq 'Y' ? 'Y' : '' %>">
+
+%   } else {
+
+    <& /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,
+    &>
+
+%   }
+
+%   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>
+%     } #"
+%   }
+
+%   ###
+%   # postal invoices
+%   ###
+
+% unless ( $conf->exists('emailinvoiceonly') ) {
+
+    <& /elements/tr-checkbox.html,
+      field       => 'postal_invoice',
+      label       => emt('Postal mail invoices'),
+      value       => 'Y',
+      curr_value  => $cust_main->postal_invoice,
+      box_first   => 1,
+    &>
+
+% }
+
+%   ###
+%   # 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>
-      <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="tax" VALUE="Y" <% $cust_main->tax eq "Y" ? 'CHECKED' : '' %>> Tax Exempt</TD>
+      <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_POST" VALUE="POST" <%
-
-        ( grep { $_ eq 'POST' } @invoicing_list )
+%   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;
+%    }
 
-          ? 'CHECKED'
-          : ''
+% } else {
+    <INPUT TYPE="hidden" NAME="prorate_day" VALUE="<% $cust_main->prorate_day %>">
+% }
 
-        %>> Postal mail 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>
 
-    <TR>
-      <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="invoicing_list_FAX" VALUE="FAX" <%
-
-        ( grep { $_ eq 'FAX' } @invoicing_list )
-          ? '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;
+%  }
 
-        %>> Fax invoice
+%   ###
+%   # invoice_terms
+%   ###
 
+    <TR>
+      <TH ALIGN="right" WIDTH="200"><% mt('Invoice terms') |h %> </TD>
+      <TD WIDTH="408">
+        <& /elements/select-terms.html,
+             'curr_value' => $cust_main->invoice_terms,
+             'agentnum'   => $cust_main->agentnum,
+        &>
       </TD>
     </TR>
 
-    <TR>
-      <TD ALIGN="right" WIDTH="200">Email invoice </TD>
-      <TD WIDTH="408"><INPUT TYPE="text" NAME="invoicing_list" VALUE="<% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) %>"></TD>
-    </TR>
+%   ###
+%   # credit_limit
+%   ###
 
     <TR>
-      <TD ALIGN="right" WIDTH="200">Invoice terms </TD>
+      <TH ALIGN="right" WIDTH="200"><% mt('Credit limit') |h %> </TD>
       <TD WIDTH="408">
-        <SELECT NAME="invoice_terms">
-          <OPTION VALUE="">Default (<% $conf->config('invoice_default_terms') || 'Payable upon receipt' %>)
-%         foreach my $term ( 'Payable upon receipt',
-%                            ( map "Net $_", 0, 10, 15, 30, 45, 60 ),
-%                          ) {
-            <OPTION VALUE="<% $term %>" <% $cust_main->invoice_terms eq $term ? ' SELECTED' : '' %>><% $term %>
-%         }
-        </SELECT>
+        <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' %>
+        >
+%       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') ) { 
+%   ###
+%   # CDR flags / options
+%   ###
+
+% if ( $conf->exists('voip-cust_cdr_squelch') ) { 
       <TR>
-       <TD COLSPAN="2"><INPUT TYPE="checkbox" NAME="spool_cdr" VALUE="Y" <% $cust_main->spool_cdr eq "Y" ? 'CHECKED' : '' %>> Spool CDRs</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 %>">
+% }
 
-      <INPUT TYPE="hidden" NAME="spool_cdr" VALUE="<% $cust_main->spool_cdr %>">
-% } 
-
-  </TABLE>
-
-  </FORM>
+% 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 '. uc($attach). ' to emailed invoices') |h %></TD>
+      </TR>
+% } else { 
+      <INPUT TYPE="hidden" NAME="email_csv_cdr" VALUE="<% $cust_main->email_csv_cdr %>">
+% }
+
+% if ( $conf->exists('voip-cust_accountcode_cdr') ) { 
+       <TR>
+        <TD COLSPAN="2">
+            <INPUT TYPE="checkbox" 
+                   NAME="accountcode_cdr" 
+                   VALUE="Y" 
+                   <% $cust_main->accountcode_cdr eq "Y" ? 'CHECKED' : '' %>
+            > <% mt('Breakdown CDRs by accountcode') |h %></TD>
+       </TR>
+% } else { 
+       <INPUT TYPE="hidden" NAME="accountcode_cdr" VALUE="<% $cust_main->accountcode_cdr %>">
+% }
 
-  <% $r %> required fields
-% } 
+% if ( $show_term || $cust_main->cdr_termination_percentage ) {
+      <TR>
+       <TH ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
+       <TD><INPUT TYPE  = "text"
+                  NAME  = "cdr_termination_percentage"
+                  SIZE  = 6
+                  VALUE = "<% $cust_main->cdr_termination_percentage %>"
+                  STYLE = "text-align:right;"
+        ><B>%</B></TD>
+      </TR>
+% } else {
+      <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, ''
+%    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 ) {
+  #false laziness w/view/cust_main/billing.html
+  my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
+  my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
+  $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
+  $show_term = $term_sth->fetchrow_arrayref->[0];
+}
+
+my $agentnum = $cust_main->agentnum if $cust_main->custnum;
 
 </%init>