don't display useless finger and shell fields if uid is set to fixed & blank
[freeside.git] / httemplate / edit / svc_acct.cgi
index 681d8b5..d147a16 100755 (executable)
@@ -1,4 +1,4 @@
-<!-- $Id: svc_acct.cgi,v 1.14 2002-01-30 14:18:08 ivan Exp $ -->
+<!-- mason kludge -->
 <%
 
 my $conf = new FS::Conf;
@@ -47,9 +47,11 @@ if ( $cgi->param('error') ) {
     my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
     if ($cust_pkg) {
       my($cust_main)=qsearchs('cust_main',{'custnum'=> $cust_pkg->custnum } );
-      $svc_acct->setfield('finger',
-        $cust_main->getfield('first') . " " . $cust_main->getfield('last')
-      ) ;
+      unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
+        $svc_acct->setfield('finger',
+          $cust_main->getfield('first') . " " . $cust_main->getfield('last')
+        );
+      }
     }
 
     #set fixed and default fields from part_svc
@@ -72,7 +74,7 @@ my $otaker = getotaker;
 my $username = $svc_acct->username;
 my $password;
 if ( $svc_acct->_password ) {
-  if ( $conf->exists('showpasswords') ) {
+  if ( $conf->exists('showpasswords') || ! $svcnum ) {
     $password = $svc_acct->_password;
   } else {
     $password = "*HIDDEN*";
@@ -81,7 +83,8 @@ if ( $svc_acct->_password ) {
   $password = '';
 }
 
-my $ulen = $svc_acct->dbdef_table->column('username')->length;
+my $ulen = $conf->config('usernamemax')
+           || $svc_acct->dbdef_table->column('username')->length;
 my $ulen2 = $ulen+2;
 
 my $pmax = $conf->config('passwordmax') || 8;
@@ -103,8 +106,7 @@ print 'Service # '. ( $svcnum ? "<B>$svcnum</B>" : " (NEW)" ). '<BR>'.
       <INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">
 END
 
-print &itable("#cccccc",2), <<END;
-<TR><TD>
+print &ntable("#cccccc",2), <<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>
@@ -187,12 +189,20 @@ my($uid,$gid,$finger,$dir)=(
 print <<END;
 <INPUT TYPE="hidden" NAME="uid" VALUE="$uid">
 <INPUT TYPE="hidden" NAME="gid" VALUE="$gid">
-<TR><TD ALIGN="right">GECOS</TD><TD><INPUT TYPE="text" NAME="finger" VALUE="$finger"></TD></TR>
-<INPUT TYPE="hidden" NAME="dir" VALUE="$dir">
 END
 
+if ( !$finger && $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
+  print '<INPUT TYPE="hidden" NAME="finger" VALUE="">';
+} else {
+  print '<TR><TD ALIGN="right">GECOS</TD>'.
+        qq!<TD><INPUT TYPE="text" NAME="finger" VALUE="$finger"></TD></TR>!;
+}
+print qq!<INPUT TYPE="hidden" NAME="dir" VALUE="$dir">!;
+
 my $shell = $svc_acct->shell;
-if ( $part_svc->part_svc_column('shell')->columnflag eq "F" ) {
+if ( $part_svc->part_svc_column('shell')->columnflag eq "F"
+     || ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' )
+   ) {
   print qq!<INPUT TYPE="hidden" NAME="shell" VALUE="$shell">!;
 } else {
   print qq!<TR><TD ALIGN="right">Shell</TD><TD><SELECT NAME="shell" SIZE=1>!;