#!/usr/bin/perl
# tta_addgrpapps.cgi
# Add Hosts 

require './tarantella-lib.pl';
	&header($text{'index_addgrpapps'}, "","addgrpapps" );

if ( $config{'is_ldapcache'} ne "true" ) { &footCacheHere; exit }

 $ttacmd="new_grpapps";
 $ntdomain="";
 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 "var ask_confadmin=true;\n"; 
 print "\n"; 
 &htmlCheckAlias("grpapps");
if ( $config{'is_ldapcache'} eq "true" ) { &htmlCacheaShowPassw }
 print "/******************************************************************\n"; 
 print "   Chek_fields(obj)\n"; 
 print "*******************************************************************/\n"; 
 print "function Chek_fields(obj) {\n"; 
 print "     if ( get_value(\"select\",obj.grpapps) == \"none\" ) {\n";
 print "          alert(obj.grpapps.name+\":\"+msg1);\n";
 print "                    obj.grpapps.focus();\n";
 print "          return false;\n";
 print "     }         \n";
 print "     if ( emptyField(obj.grpappsname) == true ) {\n"; 
 print "          alert(obj.grpappsname.name+\":\"+msg1+\"->\"+obj.grpappsname.value+\"<-\");\n"; 
 print "		    obj.grpappsname.focus();\n"; 
 print "          return false;\n"; 
 print "     }         \n"; 
 print "     if ( emptyField(obj.aliasgrpapps) == true ) {\n"; 
 print "          alert(obj.aliasgrpapps.name+\":\"+msg1+\"->\"+obj.aliasgrpapps.value+\"<-\");\n"; 
 print "		    obj.aliasgrpapps.focus();\n"; 
 print "          return false;\n"; 
 print "     }         \n"; 
 print "     if ( checkAlias_grpapps(obj.aliasgrpapps) == true ) {\n";
 print "          return false;\n";
 print "     }         \n";
 if ( $config{'is_ldapcache'} eq "true" ) { &script_cache_chek; };
 print "     if ( get_value(\"select\",obj.grpapps) != \"none\" ) {\n"; 
 print "          return confirm(obj.grpappsname.value+msg7+get_value('select',obj.grpapps));\n"; 
 print "     }         \n"; 
 print "\n"; 
 print "     return true;\n"; 
 print "}\n"; 
 print "//-->\n"; 
 print "</SCRIPT>\n"; 
 print "\n"; 
 print "<table width=100% border>\n";
 print "<tr $tb> <td><b>$text{'titidx_adgrpapps'}</b></td> </tr>\n";
 print "<tr $cb> <td><table width=100%>\n";
 print "<form METHOD=POST name=newgrpapps ACTION=\"addgrpapps.cgi\" onSubmit=\"return Chek_fields(this)\">\n"; 
 print "	<input TYPE=\"hidden\" NAME=\"ttacmd\" VALUE=\"",$ttacmd,"\">\n"; 
 print "	<tr><td valign=top>",&hlink("<b>$text{'f_grpappsobjname'}</b>","fgrpappsobjname"),"&nbsp;</td>\n";
print "		<td valign=top><input TYPE=\"text\" NAME=\"grpappsname\" VALUE=\"\" cols=\"35\" size=\"35\" ALIGN=left></td></tr>\n"; 
 print "	<tr><td valign=top>",&hlink("<b>$text{'f_descrip'}</b>","fdescrip"),"</td>\n"; 
 print "	<td valign=top><input TYPE=\"text\" NAME=\"descrip\" VALUE=\"$descrip\" cols=\"40\" size=\"40\" ALIGN=left></td></tr>\n"; 
 print "   <tr><td valign=top>",&hlink("<b>$text{'f_grpapps'}</b>","fgrpapps"),"&nbsp;</td>\n";

 print "   <td valign=top><select NAME=\"grpapps\">\n";
 print "                <option VALUE=\"none\">",&hlink("<b>$text{'f_selecgrpapps'}</b>","fselecgrpapps"),"\n";
$nItems=0;
foreach $item (&list_grpapps()) {
     if ( $nItems == 0 ) {
          print " <option VALUE=\"".$item->{'alias'}."\">". $item->{'name'}."\n";
    }
     else {
          print " <option VALUE=\"".$item->{'alias'}."\" >".$item->{'name'}."  ";
     }
     $nItems++;
}
 print "        </select></td></tr>\n";
 print "	<tr><td valign=top>",&hlink("<b>$text{'f_aliasgrpapps'}</b>","faliasgrpapps"),"&nbsp;</td>\n";
print "         <td valign=top> <input TYPE=\"text\" NAME=\"aliasgrpapps\" VALUE=\"\" cols=\"12\" size=\"12\" ALIGN=left onChange=\"checkAlias_grpapps(this)\"></td></tr>\n";  

if ( $config{'is_ldapcache'} eq "true" ) { $formObj="newgrpapps";$msgObj=$text{'default_obj'};&htmlCacheapp(msgObj) }

 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>\n"; 
 print "<tr><tr></table></table><hr><p>\n"; 
 &footer($config{'back_return'},$text{'index'}); 
 print "<p><p><p>\n";
 do "footer.pl";
 exit;



