fix disappearing email invoice on errors, finally (closes: Bug#35)
[freeside.git] / httemplate / edit / cust_main.cgi
index 5642604..7065268 100755 (executable)
@@ -17,6 +17,7 @@ my $conf = new FS::Conf;
 
 my $error = '';
 my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart);
+my(@invoicing_list);
 if ( $cgi->param('error') ) {
   $error = $cgi->param('error');
   $cust_main = new FS::cust_main ( {
@@ -32,6 +33,7 @@ if ( $cgi->param('error') ) {
   $username = $cgi->param('username');
   $password = $cgi->param('_password');
   $popnum = $cgi->param('popnum');
+  @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
 } elsif ( $cgi->keywords ) { #editing
   my( $query ) = $cgi->keywords;
   $query =~ /^(\d+)$/;
@@ -41,6 +43,7 @@ if ( $cgi->param('error') ) {
   $username = '';
   $password = '';
   $popnum = 0;
+  @invoicing_list = $cust_main->invoicing_list;
 } else {
   $custnum='';
   $cust_main = new FS::cust_main ( {} );
@@ -50,6 +53,7 @@ if ( $cgi->param('error') ) {
   $username = '';
   $password = '';
   $popnum = 0;
+  @invoicing_list = ();
 }
 $cgi->delete_all();
 my $action = $custnum ? 'Edit' : 'Add';
@@ -383,7 +387,7 @@ if ( $payby_default eq 'HIDE' ) {
   print qq!>Tax Exempt</TD></TR><TR><TD>!.
         qq!<INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST"!;
 
-  my @invoicing_list = $cust_main->invoicing_list;
+  #my @invoicing_list = $cust_main->invoicing_list;
   print qq! CHECKED!
     if ( ! @invoicing_list && ! $conf->exists('disablepostalinvoicedefault') )
        || grep { $_ eq 'POST' } @invoicing_list;
@@ -412,7 +416,7 @@ if ( $payby_default eq 'HIDE' ) {
 
   my %paybychecked = (
     'CARD' => qq!Credit card<BR>${r}<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="$payinfo" MAXLENGTH=19><BR>${r}Exp !. expselect("CARD", $cust_main->paydate). qq!<BR>${r}Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="$payname">!,
-    'CHEK' => qq!Electronic check<BR>${r}Account number <INPUT TYPE="text" NAME="CHEK_payinfo1" VALUE="$account" MAXLENGTH=10><BR>${r}ABA/Routing code <INPUT TYPE="text" NAME="CHEK_payinfo2" VALUE="$aba" SIZE=10 MAXLENGTH=9><INPUT TYPE="hidden" NAME="CHEK_month" VALUE="12"><INPUT TYPE="hidden" NAME="CHEK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="CHEK_payname" VALUE="$payname">!,
+    'CHEK' => qq!Electronic check<BR>${r}Account number <INPUT TYPE="text" NAME="CHEK_payinfo1" VALUE="$account"><BR>${r}ABA/Routing code <INPUT TYPE="text" NAME="CHEK_payinfo2" VALUE="$aba" SIZE=10 MAXLENGTH=9><INPUT TYPE="hidden" NAME="CHEK_month" VALUE="12"><INPUT TYPE="hidden" NAME="CHEK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="CHEK_payname" VALUE="$payname">!,
     'LECB' => qq!Phone bill billing<BR>${r}Phone number <INPUT TYPE="text" BANE="LECB_payinfo" VALUE="$payinfo" MAXLENGTH=15 SIZE=16><INPUT TYPE="hidden" NAME="LECB_month" VALUE="12"><INPUT TYPE="hidden" NAME="LECB_year" VALUE="2037"><INPUT TYPE="hidden" NAME="LECB_payname" VALUE="">!,
     'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE="$payinfo"><BR><INPUT TYPE="hidden" NAME="BILL_month" VALUE="12"><INPUT TYPE="hidden" NAME="BILL_year" VALUE="2037">Attention<BR><INPUT TYPE="text" NAME="BILL_payname" VALUE="$payname">!,
     'COMP' => qq!Complimentary<BR>${r}Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE="$payinfo"><BR>${r}Exp !. expselect("COMP", $cust_main->paydate),