<%@ page import="com.egurkha.util.StringUtils"%>
<%@ page import="com.eg.EgConMonHelper"%>
<%@ taglib prefix = "egui" uri = "../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>

<%
	String sessionInUse = request.getParameter("sessionInUse");
	String pwd = request.getParameter("pwd");
	String authenticated = (String)session.getAttribute("authenticated");
	if (authenticated == null)
	{
		// Direct access from the browser address bar or from inside the toolkit via the tool
		if (pwd == null)
		{
			if (sessionInUse == null)
			{
				response.sendRedirect(request.getContextPath()+"/toolkitlogin?comeFrom=ConfigFileDownload");
			}
			else
			{
%>
				<script>
					window.parent.location.href ="/final/toolkitlogin";
				</script>
<%
			}
		}
		else
		{
			// Direct access from the browser address bar
			if (!pwd.equals(EgConMonHelper.executePwd))
			{
				response.sendRedirect(request.getContextPath()+"/toolkitlogin?comeFrom=ConfigFileDownload");
			}
			else
			{
				session.setAttribute("reqFromForTk","ConfigFileDownload");
				String redirectURL = request.getContextPath()+"/toolkit";
				response.sendRedirect(redirectURL);
			}
		}
	}
	else
	{ 
		// Direct access from the browser address bar and session in use
		if (sessionInUse == null)
		{
			response.sendRedirect(request.getContextPath()+"/toolkit");
		}
	}
	session.setAttribute("reqFromForTk","ConfigFileDownload");

	String comeFrom = request.getParameter("comeFrom");
	if (!StringUtils.isNull(comeFrom) && comeFrom.equals("ConfigFileDownload"))
	{
		session.setAttribute("treeViewSrc","ConfigFileDownload");
	}
	String manager_label = com.eg.EgInstallInfo.isSuperManager ? "SuperManager" : "Manager";
	String btl_label = "admin.common."+manager_label;
%>
<html>
<head>
	<title>Configuration Files - Download</title>
	<meta name="created" content="09/04/2001">
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<Link REL = "StyleSheet" href = "eg_styles\adminstyle_blue.css"/>
	<style>

	#maintitle{padding-top: 3px;padding-left:3px;padding-right:3px;padding-bottom:3px;font-size: 13px; font-family: Arial,  Century Gothic, Verdana; font-weight: bold; color: #ffffff;background-color: #00003C;}

	#innerborder{padding-top: 3px;padding-bottom:3px;border-top-width:1px;border-left-width:1px;border-bottom-width:1px; border-right-width:1px;border-style: solid;border-color:#00003c;font-size: 12px; font-family: Arial, Verdana; font-weight: bold; color: #00003C;background-color: #CFD5E9;}

	#tdborderinner{padding-top: 3px;padding-left:3px;padding-right:3px;padding-bottom:3px; border-top-width:1px;border-left-width:0px;border-bottom-width:0px;border-right-width:1px;border-style:solid; border-color:#EBEEF6;font-size: 12px; font-family: Arial, Verdana ; color: #00003C;background-color: #DFE3EF}

	</style>
	<script language="javascript" src="/final/admin/eg_scripts/timeout.js"></script>
	<script language="JavaScript">

	function download(fields)
	{
		var entries = fields.entries();
		var form = document.createElement('form');
		form.setAttribute('target','_parent');
		form.setAttribute('method','post');
		form.setAttribute('action','/final/downloadconfig');
		for(var i=0;i<fields.size;i++)
		{
			var key = entries.next().value[0];
			var hiddenField = document.createElement('input');
			hiddenField.setAttribute('type','hidden');
			hiddenField.setAttribute('name',key);
			hiddenField.setAttribute('value',fields.get(key));
			form.appendChild(hiddenField);
		}
		document.body.appendChild(form);
		form.submit();
	}
	
	function getFields()
	{
		var fieldMap = new Map();
		fieldMap.set('downloadFrom','toolkit');
		fieldMap.set('configFilesOpt',document.ConfigFileDownload.configFilesOpt.value);
		return fieldMap;
	}
	</script>
</head>

<body style="overflow:auto" id="space6" >
	<form name="ConfigFileDownload" method="post" style="margin:0px">

<table align="center" cellspacing="0" cellpadding="0" width="100%" border="0" >
	<tr>
		<td id="eg_blankspace" height="10" nowrap>&nbsp;</td>
	</tr>
	<tr>
		<td width="100%" height="24" id="eg_title" align="center"> &nbsp; DOWNLOAD <%=manager_label.toUpperCase()%> / TOMCAT CONFIGURATION FILES</td>
	</tr>
	<tr>
		<td height="20" align="center" colspan="2">
			<table align="center" width="85%" cellspacing="0" cellpadding="4" border="0">
				<tr>
					<td height="24" nowrap align="right" width="25%" class="eg_cellbglits"><img src="/final/admin/eg_images/info2.gif"> </td>
					<td height="24" nowrap align="left" class="eg_cellbglits">
					This page enables the administrator to download the configuration files of the <%=manager_label%> / tomcat.</td>
				</tr>
			</table>
		</td>
	</tr>
</table><br>
<table border="0" align="center" cellspacing="0" cellpadding="0" width="60%" class="eg_cellbglits">
	<tr>
		<th class="form_border"  nowrap width="50%">
			<egui:intnl text="admin.common.Configuration files"/>&nbsp;
		</th>
		<td class="form_border"  nowrap width="4%"> &nbsp;:</td>
		<td class="form_border" nowrap width="50%">
			<table  width="75%" cellspacing="0" cellpadding="5" border="0">
				<tr>
					<td class="eg_subcontent" width="35%">
						<input type="radio" class="eg_input" id="configFilesOpt" value="manager" checked name="configFilesOpt">
						<egui:intnl text="<%=btl_label%>"/>
					</td>
					<td class="eg_subcontent" width="35%">
						<input type="radio" class="eg_input" id="configFilesOpt" name="configFilesOpt" value="tomcat">
						<egui:intnl text="admin.common.Tomcat"/>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td align="center" colspan="3">
			<table align="center" cellspacing="5" cellpadding="5" width="100%" border="0">
				<tr>
					<td colspan="3" align="center" nowrap>
					<input type="button" value='<egui:intnl text="admin.common.Download"/>' name="update" style="width: 85px;cursor:pointer;" id="eg_back" onClick="javascript:download(getFields());">
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</form>
</body>
</html>



