service and package disable!
[freeside.git] / httemplate / edit / cust_main.cgi
index d271dad..9588dcb 100755 (executable)
@@ -1,5 +1,5 @@
 <%
-#<!-- $Id: cust_main.cgi,v 1.7 2001-10-15 11:35:28 ivan Exp $ -->
+#<!-- $Id: cust_main.cgi,v 1.17 2001-12-27 09:26:14 ivan Exp $ -->
 
 use vars qw( $cgi $custnum $action $cust_main $p1 @agents $agentnum 
              $last $first $ss $company $address1 $address2 $city $zip 
@@ -74,7 +74,7 @@ $action = $custnum ? 'Edit' : 'Add';
 # top
 
 $p1 = popurl(1);
-print $cgi->header( '-expires' => 'now' ), header("Customer $action", '');
+print header("Customer $action", '');
 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $error, "</FONT>"
   if $error;
 
@@ -133,19 +133,21 @@ if ( $custnum && ! $conf->exists('editreferrals') ) {
 
 #referring customer
 
-print qq!<BR><BR>Referring Customer: !;
+#print qq!<BR><BR>Referring Customer: !;
 if ( $cust_main->referral_custnum ) {
   my $referring_cust_main =
     qsearchs('cust_main', { custnum => $cust_main->referral_custnum } );
-  print '<A HREF="'. popurl(1). '/cust_main.cgi?'.
+  print '<BR><BR>Referring Customer: <A HREF="'. popurl(1). '/cust_main.cgi?'.
         $cust_main->referral_custnum. '">'.
         $cust_main->referral_custnum. ': '.
         ( $referring_cust_main->company
           || $referring_cust_main->last. ', '. $referring_cust_main->first ).
         '</A><INPUT TYPE="hidden" NAME="referral_custnum" VALUE="'.
         $cust_main->referral_custnum. '">';
+} elsif ( ! $conf->exists('disable_customer_referrals') ) {
+  print '<BR><BR>Referring customer number: <INPUT TYPE="text" NAME="referral_custnum" VALUE="">';
 } else {
-  print '(none)<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">';
+  print '<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">';
 }
 
 # contact info
@@ -178,11 +180,16 @@ print <<END;
 <TR><TH ALIGN="right">${r}City</TH><TD><INPUT TYPE="text" NAME="city" VALUE="$city"></TD><TH ALIGN="right">${r}State/Country</TH><TD><SELECT NAME="state" SIZE="1">
 END
 
-$cust_main->country( $conf->config('countrydefault') || 'US' )
-  unless $cust_main->country;
+my $countrydefault = $conf->config('countrydefault') || 'US';
+$cust_main->country( $countrydefault ) unless $cust_main->country;
 $cust_main->state( $conf->config('statedefault') || 'CA' )
   unless $cust_main->state || $cust_main->country ne 'US';
-foreach ( qsearch('cust_main_county',{}) ) {
+foreach ( sort {
+     ( $b->country eq $countrydefault ) <=> ( $a->country eq $countrydefault )
+  or $a->country                        cmp $b->country
+  or $a->state                          cmp $b->state
+  or $a->county                         cmp $b->county
+} qsearch('cust_main_county',{}) ) {
   print "<OPTION";
   print " SELECTED" if ( $cust_main->state eq $_->state
                          && $cust_main->county eq $_->county 
@@ -340,7 +347,8 @@ print qq!>Tax Exempt</TD></TR>!;
 print qq!<TR><TD><INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST"!;
 @invoicing_list = $cust_main->invoicing_list;
 print qq! CHECKED!
-  if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list;
+  if ( ! @invoicing_list && ! $conf->exists('disablepostalinvoicedefault') )
+     || grep { $_ eq 'POST' } @invoicing_list;
 print qq!>Postal mail invoice</TD></TR>!;
 $invoicing_list = join(', ', grep { $_ ne 'POST' } @invoicing_list );
 print qq!<TR><TD>Email invoice <INPUT TYPE="text" NAME="invoicing_list" VALUE="$invoicing_list"></TD></TR>!;
@@ -404,7 +412,7 @@ unless ( $custnum ) {
   #eslaf
 
   my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } }
-    qsearch( 'part_pkg', {} );
+    qsearch( 'part_pkg', { 'disabled' => '' } );
 
   if ( @part_pkg ) {
 
@@ -428,11 +436,13 @@ unless ( $custnum ) {
     #$ulen = $svc_acct->dbdef_table->column('username')->length;
     $ulen = dbdef->table('svc_acct')->column('username')->length;
     $ulen2 = $ulen+2;
+    my $passwordmax = $conf->config('passwordmax') || 8;
+    my $pmax2 = $passwordmax + 2;
     print <<END;
 <TR><TD ALIGN="right">Username</TD>
 <TD><INPUT TYPE="text" NAME="username" VALUE="$username" SIZE=$ulen2 MAXLENGTH=$ulen></TD></TR>
 <TR><TD ALIGN="right">Password</TD>
-<TD><INPUT TYPE="text" NAME="_password" VALUE="$password" SIZE=10 MAXLENGTH=8>
+<TD><INPUT TYPE="text" NAME="_password" VALUE="$password" SIZE=$pmax2 MAXLENGTH=$passwordmax>
 (blank to generate)</TD></TR>
 END