#!/usr/bin/perl
# tta_delusr.cgi
# Del Users to Services with Tarantella
# STTA Rev. 1.3 Copyright (c) 2001-2002 Jesús Pérez Lorenzo  --- license GNU GPL 

require './stta-lib.pl';
&ReadParse();

 $dn = $in{dn};
 if (!$dn) { &redirect("tta_selusr.cgi?form=delusr"); }
 $username=$in{username};
 $userou=$in{userou};
&headerstta($text{'index_delusr'}, "", "delusr",undef,1,1,$text{headpage_rigth} );

 print "<hr><p>\n";
 print "<SCRIPT SRC=\"global.js\">\n"; 
 print "</SCRIPT>\n"; 
 print "<SCRIPT LANGUAGE=\"JavaScript\">\n"; 
 print "<!--\n"; 
 print "/*  Strings for locales  */\n"; 
 print "var msg0=\"".$text{'msg_0'},"\";\n"; 
 print "var msg1=\"".$text{'msg_1'},"\";\n"; 
 print "var msg2=\"".$text{'msg_2'},"\";\n"; 
 print "var msg3=\"".$text{'msg_3'},"\";\n"; 
 print "var msg4=\"".$text{'msg_4'},"\";\n"; 
 print "var msg5=\"".$text{'msg_5'},"\";\n"; 
 print "var msg6=\"".$text{'msg_6'},"\";\n"; 
 print "var msg7=\"".$text{'msg_7'},"\";\n"; 
 print "/******************************************************************\n";
 print "   showValue(obj)\n";
 print "   Show Password value from form.\n";
 print "*******************************************************************/\n";
 print "function showValue(obj) {\n";
 print "   unsetDN(obj);\n";
 print "   alert(obj.dn.value);\n";
 print "}\n";
 print "/******************************************************************\n";
 print "   unsetDN(obj)\n";
 print "   unset DN value.\n";
 print "*******************************************************************/\n";
 print "function unsetDN(obj) {\n";
 print "   if ( obj.username.value != \"$username\" ) {\n";
 print "        obj.dn.value=\"-\";\n";
 print "     }         \n"; 
 print "   if ( get_value(\"select\",obj.userou) != \"$userou\" ) {\n"; 
 print "        obj.dn.value=\"-\";\n";
 print "     }         \n"; 
 print "}\n";
 print "/******************************************************************\n"; 
 print "   Chek_fields(obj)\n"; 
 print "*******************************************************************/\n"; 
 print "function Chek_fields(obj) {\n"; 
 print "     if ( emptyField(obj.username) == true ) {\n"; 
 print "          alert(obj.username.name+\":\"+msg1+\"->\"+obj.username.value+\"<-\");\n"; 
 print "		    obj.username.focus();\n"; 
 print "          return false;\n"; 
 print "     }         \n"; 
 print "     if ( get_value(\"select\",obj.userou) == \"none\" ) {\n"; 
 print "          alert(obj.userou.name+\":\"+msg1);\n"; 
 print "		    obj.userou.focus();\n"; 
 print "          return false;\n"; 
 print "     }         \n"; 
 print "     unsetDN(obj);\n";
 print "     return true;\n"; 
 print "}\n"; 
 print "//-->\n"; 
 print "</SCRIPT>\n"; 
 print "<p>\n"; 
 print "<table width=100% border>\n";
 print "<tr $tb> <td><b>$text{'titidx_delusr'} $username ($userou) </b></td> </tr>\n";
 print "<tr $cb> <td><table width=100%>\n";
 print "<form METHOD=POST name=tta_delusr ACTION=\"delusr.cgi\" onSubmit=\"return Chek_fields(this)\">\n"; 

 print "        <input TYPE=\"hidden\" NAME=\"dn\" VALUE=\"",$dn,"\">\n";
 print "	<td valign=top>",&hlink("<b>$text{'f_username'}</b>","fusername"),"&nbsp;";
 print "	<input TYPE=\"button\" NAME=\"?\" VALUE=\"?\" ";

 print "			onChange=\"unsetDN(tta_delusr)\" onClick=\"showValue(tta_delusr);\" ></td>\n"; 
 print "        <td valign=top><input TYPE=\"text\" NAME=\"username\" VALUE=\"$username\" cols=\"22\" size=\"12\" ALIGN=left </td></tr>\n"; 
 print "   <tr><td valign=top>",&hlink("<b>$text{'f_userou'}</b>","fuserou"),"&nbsp;</td><td valign=top><select NAME=\"userou\">\n"; 
 print " 		<option VALUE=\"none\">",&hlink("<b>$text{'f_selecou'}</b>","fselecou"),"\n"; 

%h_ous=&list_ous();
$nItems=0;
foreach $item (keys (%h_ous)) {
     if ( $h_ous{$item}->{'alias'} eq $userou ) {
          print " <option VALUE=\"".$h_ous{$item}->{'alias'}."\" selected>". $h_ous{$item}->{'name'}."\n";
    }
     else {
          print " <option VALUE=\"".$h_ous{$item}->{'alias'}."\" >".$h_ous{$item}->{'name'}."  ";
     }
     $nItems++;
}
 print "	</select></td></tr>\n"; 
 print "        <tr><td valign=top><input TYPE=\"submit\" NAME=\"",$text{'f_sendreq'},"\" VALUE=\"",$text{'f_sendreq'},"\">\n";
 print "        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>\n";
 print "        <td valign=top><input TYPE=\"reset\" NAME=\"",$text{'f_cancelreq'},"\" VALUE=\"",$text{'f_cancelreq'},"\"></td></tr>\n";
 print "	</form></td></tr>\n"; 
 print "<tr><tr></table></table><hr><p>\n";
 &footer($config{'back_return'},$text{'index'}); 
 print "<p><p><p>\n";
 do "footer.pl";
 exit;


