<%
	/************************************************************************************************
	 *	File				: ErCtxOverviewJSON.jsp
	 *	Version				: 7.0
	 *	Author				: S.Ezhilarasi
	 *	Creation Date		: 02/Nov/2017
	 *
	 *************************************************************************************************/
%>
<%@ include file="ErReporterTracker.jsp"%>

<%@ page import="com.eg.EgReportInfo"%>
<%@ page import="com.eg.EgMappingInfo"%>
<%@ page import="com.egurkha.User"%>
<%@ page import="com.egurkha.UserRegistry"%>
<%@ page import="egurkha.reporter.ErBackgroundReportGenerator"%>
<%@ page import="egurkha.reporter.ErEsxVMutils"%>
<%@ page import="com.eg.EgSpecsInfo"%>
<%@ page import="egurkha.reporter.ErUtils"%>
<%@ page import="com.egurkha.util.StringUtils"%>
<%@ page import="com.egurkha.util.DateUtil"%>
<%@ page import="com.egurkha.util.DateTimeTokenizer"%>	
<%@ page import="com.eg.EgDateInfo"%>
<%@ page import="com.eg.EgConfigInfo"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.text.ParseException"%>

<%@ page import="java.util.List"%>
<%@ page import="java.util.Set"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.Iterator"%>
<%@ page import = "net.sf.json.*" %>


<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Hashtable"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Collections"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
	try
	{
		response.setContentType("application/json;charset=UTF-8");
		Map allData = (Map)request.getAttribute("allData");
		EgReportInfo reportInfo= new EgReportInfo("manager");
		User this_user= UserRegistry.getInstance().getUser(session.getId());
		String thisUserLang= this_user.getLanguage();
		String loginid= this_user.getLoginID();
		ErComponentsUtils compUtil = new ErComponentsUtils(loginid);
		EgMappingInfo intlmap = new EgMappingInfo(thisUserLang);
		ErUserData erUser = new ErUserData(loginid,false);
		IniUI ui= IniUI.getInstance();

		JSONObject rootJson=  new JSONObject();
		JSONObject selectedField=new JSONObject();

		String er_timeline= request.getParameter("er_timeline");
		String s_st_time= request.getParameter("startdate");
		String s_en_time= request.getParameter("enddate");
		String s_st_hr= request.getParameter("starthr");
		String s_en_hr= request.getParameter("endhr");
		String startmin = request.getParameter("startmin");
		String endmin = request.getParameter("endmin");
		String strmin = startmin;
		String enmin = endmin;
		String currentDateFormat = strUserDateFormat;
		String er_view=request.getParameter("er_view");

		String inifile = "eg_report.ini";
		String inifileDir = EgInstallInfo.getInstallDir()+"/manager/config/";
		IniFile inifiles = new IniFile(inifileDir+inifile);
		String Days = inifiles.getValue("EXCLUDE_WEEKEND","Days");

		String analysisBy=request.getParameter("analysisBy");
		String er_subZone=request.getParameter("er_subZone");
		String method=request.getParameter("method");
		String er_status=request.getParameter("er_status");
		if(request.getParameter("fromMenu") != null)
		{
			String fromMenu=(String)request.getParameter("fromMenu");
			if(fromMenu.equalsIgnoreCase("yes") && session.getAttribute("Report_Query_String") != null)
			{
				session.removeAttribute("Report_Query_String");
			}
		}
		String[] er_siteDirectComponent=request.getParameterValues("er_siteDirectComponent");
		String[] er_XenAppComponents=request.getParameterValues("er_XenAppComponents");
		if(er_siteDirectComponent != null && session.getAttribute("directorComp") != null)
		{
			List siteDirectCompList=new ArrayList(Arrays.asList((String[])er_siteDirectComponent));
			if(siteDirectCompList != null && !siteDirectCompList.isEmpty())
			{
				String firstSite=(String)siteDirectCompList.get(0);
				if(firstSite != null && firstSite.equalsIgnoreCase("directorComp"))
				{
					er_siteDirectComponent=(String[])session.getAttribute("directorComp");
				}
			}
			
		}
		if(er_XenAppComponents != null && session.getAttribute("xenAppComp") != null)
		{
			List xenAppCompList=new ArrayList(Arrays.asList((String[])er_XenAppComponents));
			if(xenAppCompList != null && !xenAppCompList.isEmpty())
			{
				String firstXenApp=(String)xenAppCompList.get(0);
				if(firstXenApp != null && firstXenApp.equalsIgnoreCase("xenAppComp"))
				{
					er_XenAppComponents=(String[])session.getAttribute("xenAppComp");
				}
			}
		}
		String mngrIProc= new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
		String buttonId=request.getParameter("buttonId");
		String panelName=request.getParameter("panelName");
		Map tRequestMap=(Map)session.getAttribute("tRequestMap");
		String er_site = request.getParameter("er_site");
		if(er_status == null)
		{
			er_status="Avg";
		}
		JSONObject selectedStateObj=new JSONObject();
		selectedStateObj.put("selectedStatusCombo",er_status);
		String reportTitle=reportInfo.getValue("CitrixXenApp_OverView","reportTitle");				
		if(allData==null || allData.size()==0)
		{
			boolean getButtonInfo=false;
			List v_components= UBean.getAllUserComponents(3);
			ArrayList useSupportCompTypeList=new ArrayList();
			String CtxZoneComponents=inifiles.getValue("CitrixXenApp_OverView","componentType");
			List CtxZoneComponentsList=null;
			if(CtxZoneComponents != null && CtxZoneComponents.trim() != "" && CtxZoneComponents.length() > 2)
				CtxZoneComponentsList=Arrays.asList(CtxZoneComponents.split(","));
			for(int v=0;v<v_components.size();v++)
			{
				String eachComp=(String)v_components.get(v);
				if(eachComp != null && eachComp.indexOf(":") != -1)
				{
					eachComp=eachComp.substring(eachComp.lastIndexOf(":")+1,eachComp.length());
					if(CtxZoneComponentsList != null && CtxZoneComponentsList.contains(eachComp))
					{
						if(!useSupportCompTypeList.contains(eachComp))
						{
							useSupportCompTypeList.add(eachComp);
						}
					}
				}
			}
			//if(isLicenseButtonClick)
			//{
				useSupportCompTypeList.add("Citrix_license_server");
			//}
			if(method != null && method.equalsIgnoreCase("getButtonInfo") && buttonId != null)
			{
				getButtonInfo=true;
				JSONObject buttonInfoObj=new JSONObject();
				JSONArray buttonInfoArry=null;
				JSONArray buttonInfo=null;
				JSONObject tempWidgetObj=null;
				//System.out.println("===tRequestMap===333======>>>>>>"+tRequestMap);
				int totalPanel=0;
				JSONArray allButtonArry=new JSONArray();
				if(buttonId.equalsIgnoreCase("all"))
				{
					allButtonArry.add("citrixUserExperience");
					allButtonArry.add("citrixSessions");
					allButtonArry.add("citrixApplications");
					allButtonArry.add("citrixEvents");
					allButtonArry.add("citrixServer");
					allButtonArry.add("citrixLicense");
				}	
				else
				{
					allButtonArry.add(buttonId);
				}
				EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
				for(int a=0;a<allButtonArry.size();a++)
				{
					String eachButton=(String)allButtonArry.get(a);
					JSONArray eachButtonDetail=(JSONArray)tRequestMap.get(eachButton+"_orderDetail");
					//System.out.println("====eachButtonDetail==11>>>orderDetail>>>"+eachButtonDetail);
					buttonInfo=new JSONArray();
					if(!eachButton.equalsIgnoreCase("citrixEvents"))
					{	
						for(int b=0;b<eachButtonDetail.size();b++)
						{
							buttonInfoArry=new JSONArray();
							JSONArray eachButtonGroup=(JSONArray)eachButtonDetail.get(b);
							//JSONArray eachGroupArry=(JSONArray)JSONSerializer.toJSON((String)eachButtonGroup);
							for(int e=0;e<eachButtonGroup.size();e++)
							{
								tempWidgetObj=new JSONObject();
								String widgetNameStr=(String)eachButtonGroup.get(e);
								//System.out.println("=====widgetNameStr====12133==>>>>>>>>>"+widgetNameStr);
								//
								String eachPanelName = widgetNameStr+"_detail";
								String eachPanelDetail = (String)tRequestMap.get(eachPanelName);
								JSONObject eachPanelDetailObj = (JSONObject)JSONSerializer.toJSON(eachPanelDetail);
								String testName = null;
								if(eachPanelDetailObj != null && eachPanelDetailObj.containsKey("barTest"))
								{
									testName = (String)eachPanelDetailObj.get("barTest");
								}
								else if(eachPanelDetailObj != null && eachPanelDetailObj.containsKey("pieTest"))
								{
									testName = (String)eachPanelDetailObj.get("pieTest");
								}
								if(testName != null && testName.indexOf("_DDD")>-1)
									testName = testName.substring(0,testName.indexOf("_DDD"));
								for(int u=0;u<useSupportCompTypeList.size();u++)
								{
									String eachComp = (String) useSupportCompTypeList.get(u);
									if(testName==null || specsInfo.isTestRelevantForServer(eachComp,testName))
									{
										String eachWidgetStr=(String)tRequestMap.get(widgetNameStr);
										//System.out.println("===eachWidgetStr=11>>>>>>>>>"+eachWidgetStr);
										JSONObject eachWidget=(JSONObject)JSONSerializer.toJSON(eachWidgetStr);
										tempWidgetObj.put("type",eachWidget.get("type"));
										tempWidgetObj.put("panelName",widgetNameStr);
										tempWidgetObj.put("panelHeight",eachWidget.get("panelHeight"));
										tempWidgetObj.put("title",intlmap.getTextDescription("reporter.common." + (String)eachWidget.get("title")));
										totalPanel++;
										buttonInfoArry.add(tempWidgetObj);
										break;
									}
								}
							}
							buttonInfo.add(buttonInfoArry);
						}
					}
					else if(eachButton.equalsIgnoreCase("citrixEvents"))
					{
						for(int b=0;b<eachButtonDetail.size();b++)
						{
							buttonInfoArry=new JSONArray();
							JSONArray eachButtonGroup=(JSONArray)eachButtonDetail.get(b);
							JSONArray panelDetailsArry=null;
							JSONObject eachSubObj=null;
							for(int e=0;e<eachButtonGroup.size();e++)
							{
								tempWidgetObj=new JSONObject();
								String widgetNameStr=(String)eachButtonGroup.get(e);
								//
								String eachPanelDetail = (String)tRequestMap.get(widgetNameStr);
								JSONObject eachPanelDetailObj = (JSONObject)JSONSerializer.toJSON(eachPanelDetail);
								String testName = null;
								if(eachPanelDetailObj != null && eachPanelDetailObj.containsKey("barTest"))
								{
									testName = (String)eachPanelDetailObj.get("barTest");
								}
								else if(eachPanelDetailObj != null && eachPanelDetailObj.containsKey("pieTest"))
								{
									testName = (String)eachPanelDetailObj.get("pieTest");
								}
								if(testName != null && testName.indexOf("_DDD")>-1)
									testName = testName.substring(0,testName.indexOf("_DDD"));
								//System.out.println("=====widgetNameStr====event==>>>>>>>>>"+widgetNameStr);
								for(int u=0;u<useSupportCompTypeList.size();u++)
								{
									String eachComp = (String) useSupportCompTypeList.get(u);
									if(testName==null || specsInfo.isTestRelevantForServer(eachComp,testName))
									{
										String eachWidgetStr=(String)tRequestMap.get(widgetNameStr);
										//System.out.println("===eachWidgetStr=11>>>>event>>>>>"+eachWidgetStr);
										JSONObject eachWidget=(JSONObject)JSONSerializer.toJSON(eachWidgetStr);
										tempWidgetObj.put("type",eachWidget.get("type"));
										tempWidgetObj.put("panelName",widgetNameStr);
										tempWidgetObj.put("panelHeight",eachWidget.get("panelHeight"));
										tempWidgetObj.put("title",intlmap.getTextDescription("reporter.common." + (String)eachWidget.get("title")));
										panelDetailsArry=new JSONArray();
										if(widgetNameStr != null && widgetNameStr.indexOf("$$") != -1)
										{
											String subPanel=widgetNameStr.substring(widgetNameStr.indexOf("$$")+2);
											//System.out.println("====subPanel===11212>>>>>>>>>>>>"+subPanel);
											String subPanelStr=(String)tRequestMap.get(subPanel);
											//System.out.println("===subPanelStr====11>>>>>>>>>>"+subPanelStr);
											JSONArray subPanelArry=(JSONArray)JSONSerializer.toJSON(subPanelStr);
											for(int s=0;s<subPanelArry.size();s++)
											{
												eachSubObj=new JSONObject();
												JSONArray subPanelInfoArry=(JSONArray)subPanelArry.get(s);
												for(int k=0;k<subPanelInfoArry.size();k++)
												{
													String subPanelInfoStr=(String)subPanelInfoArry.get(k);
													String eachSubWidgetStr=(String)tRequestMap.get(subPanelInfoStr);
													JSONObject eachSubWidget=(JSONObject)JSONSerializer.toJSON(eachSubWidgetStr);
													eachSubObj.put("title",intlmap.getTextDescription("reporter.common." + (String)eachSubWidget.get("title")));
													eachSubObj.put("panelHeight",eachSubWidget.get("panelHeight"));
													eachSubObj.put("type",eachSubWidget.get("type"));
													eachSubObj.put("panelName",subPanelInfoStr);
													totalPanel++;
													panelDetailsArry.add(eachSubObj);
												}
											}
										}
										tempWidgetObj.put("panelDetails",panelDetailsArry);
										buttonInfoArry.add(tempWidgetObj);
										break;
									}
								}
							}
							buttonInfo.add(buttonInfoArry);
						}

					}
					buttonInfoObj.put(eachButton,buttonInfo);
				}
				//rootJson.put("buttonInfo",buttonInfo);
				rootJson.put("buttonInfo",buttonInfoObj);
				rootJson.put("totalPanel",totalPanel);			
				session.setAttribute("allData",null);
				session.setAttribute("selectionDetail",null);
				session.setAttribute("widgetOrder",null);
			}		
			String dispDate= null;
			String comFormat= null;						
			String logonLimit=reportInfo.getValue("CitrixXenApp_OverView","LogonLimit");
			String launchLimit=reportInfo.getValue("CitrixXenApp_OverView","LaunchLimit");
			if(request.getParameter("er_logon") != null)
			{
				logonLimit=request.getParameter("er_logon");
			}	
			if(request.getParameter("er_launch") != null)
			{
				launchLimit=request.getParameter("er_launch");
			}	
			if(logonLimit == "")
			{
				logonLimit="40";
			}
			if(launchLimit == "")
			{
				launchLimit="40";
			}
			String dispUserDomain=request.getParameter("dispUserDomain");
			if(!getButtonInfo)
			{
				rootJson.put("logonLimit",logonLimit);
				rootJson.put("launchLimit",launchLimit);
				rootJson.put("dispUserDomain",dispUserDomain);
			}
			boolean isLicenseButtonClick=false;
			if(buttonId != null && buttonId.equalsIgnoreCase("citrixLicense"))
				isLicenseButtonClick=true;
			String limitforbg= reportInfo.getValue("BACKGROUND_PROCESS","MinDurationForReport");
			int maxDays= ErUtils.getMaxDaysInMonth();
			String noFailMSG= reportInfo.getValue("CitrixXenApp_OverView","msg_no_error");
			EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
			JSONArray tempArry=new JSONArray();;
			JSONObject tempObj=null;

			ErEsxVMutils erEsxUtils= new ErEsxVMutils();
			List v_option = new ArrayList();
			Hashtable htAllGroups = new Hashtable();
			htAllGroups = erEsxUtils.getGroups(null, useSupportCompTypeList, this_user, loginid, "Yes", true);
			Hashtable tempHtAllGroups=new Hashtable(); //this report is for xenappServer or (xenappserver and license server)
			Iterator itr=htAllGroups.keySet().iterator();
			while(itr.hasNext())
			{
				String eachKey=(String)itr.next();
				Object valueObj=htAllGroups.get(eachKey);
				if(valueObj instanceof ArrayList)
				{
					ArrayList optionCompList=(ArrayList)valueObj;
					Set compTypeSet=new HashSet();
					boolean isXenAppComp=false;
					for(int c=0;c<optionCompList.size();c++)
					{
						String eachComp=(String)optionCompList.get(c);
						if(eachComp.indexOf(":") != -1)
						{
							eachComp=eachComp.substring(eachComp.lastIndexOf(":")+1);
							if(eachComp.equalsIgnoreCase("Citrix_XcXenApp_server"))
								isXenAppComp=true;
							compTypeSet.add(eachComp);
						}
					}
					if(isXenAppComp)
						tempHtAllGroups.put(eachKey,optionCompList);
				}
				else if(valueObj instanceof Hashtable)
				{
					Hashtable optionNonCompList=(Hashtable)valueObj;
					Hashtable tempHashtable=new Hashtable();
					Iterator itrS=optionNonCompList.keySet().iterator();
					while(itrS.hasNext())
					{
						String eachSubKey=(String)itrS.next();
						ArrayList compList=(ArrayList)optionNonCompList.get(eachSubKey);
						boolean isXenAppComp=false;
						for(int k=0;k<compList.size();k++)
						{
							String eachComp=(String)compList.get(k);
							if(eachComp.indexOf(":") != -1)
							{
								eachComp=eachComp.substring(eachComp.lastIndexOf(":")+1);
								if(eachComp.equalsIgnoreCase("Citrix_XcXenApp_server"))
									isXenAppComp=true;
							}
						}
						if(isXenAppComp)
							tempHashtable.put(eachSubKey,compList);
					}
					tempHtAllGroups.put(eachKey,tempHashtable);
				}
			}
			htAllGroups=tempHtAllGroups;
			ArrayList aListOption = erEsxUtils.getOptions(htAllGroups);
			if (aListOption != null && aListOption.size() > 0)
			{
				v_option.addAll(aListOption);
			}
			if(analysisBy == null)
			{
				analysisBy="Zone";
			}
			//System.out.println("===v_option==>>>>"+v_option);
			/*if(v_option.size() == 1 && !v_option.get(0).toString().equalsIgnoreCase("component"))
			{
				v_option=new ArrayList();
			}*/
			if (v_option.size() > 0)
			{
				selectedField.put("selectedAnalysisBy",analysisBy);
				for (int i = 0; i < v_option.size(); i++) 
				{
					String eachOption=(String)v_option.get(i);
				//	if(eachOption != null && eachOption.equalsIgnoreCase("component"))
						//continue;
					tempObj = new JSONObject();
					tempObj.put("displayField",intlmap.getTextDescription("reporter.common." + v_option.get(i)));
					tempObj.put("valueField", v_option.get(i));
					tempArry.add(tempObj);
				}
			} 
			else
			{
				tempObj = new JSONObject();
				tempObj.put("displayField", intlmap.getTextDescription("reporter.common.Not Applicable"));
				tempObj.put("valueField", "-1");
				tempArry.add(tempObj);
			}
			if(!getButtonInfo)
				rootJson.put("analysisBy",tempArry);		
			if(method == null)
			{
				method="init";
			}
			List v_site=new ArrayList();
			if(analysisBy != null)
			{
				String ctxDirectorCompTypes=inifiles.getValue("CitrixXenApp_OverView","DirectorCompType");
				List ctxDirectorCompList=null;
				if(ctxDirectorCompTypes != null && ctxDirectorCompTypes.trim() != "" && ctxDirectorCompTypes.length() > 2)
					ctxDirectorCompList=Arrays.asList(ctxDirectorCompTypes.split(","));
				v_site = erEsxUtils.getGroupsName(htAllGroups,analysisBy);
				if(v_site!=null )
					Collections.sort(v_site,String.CASE_INSENSITIVE_ORDER);
				List aListComponentTemp=null;
				List componentList=new ArrayList();
				if(analysisBy.equalsIgnoreCase("Segment") || analysisBy.equalsIgnoreCase("Service") || analysisBy.equalsIgnoreCase("Zone") || analysisBy.equalsIgnoreCase("component"))
				{
					boolean hasXenCompZone=false;
					if(er_site==null && v_site!=null && v_site.size()>0)
					{
						for(int v=0;v<v_site.size();v++)
						{
							er_site=(String)v_site.get(v);
							aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,analysisBy,er_site);
							if(aListComponentTemp != null)
							{
								for(int a=0;a<aListComponentTemp.size();a++)
								{
									String eachComp=(String)aListComponentTemp.get(a);
									if(eachComp.indexOf(":") != -1)
									{
										String compType=eachComp.substring(eachComp.lastIndexOf(":")+1);
										if(compType.equalsIgnoreCase("Citrix_XcXenApp_server"))
										{
											hasXenCompZone=true;
											break;
										}
									}
								}
								if(hasXenCompZone)
								{
									break;
								}
							}
						}
					}
					if(!getButtonInfo)
						rootJson.put("siteCombo",getJSONComboFromList(v_site,"zone",intlmap));
					selectedField.put("selectedSiteCombo",er_site);
					selectedField.put("analysisByLabel",intlmap.getTextDescription("reporter.uptime.Analyze by"));
					List subZoneList=new ArrayList();
					subZoneList.add("Yes");
					subZoneList.add("No");
					if(!getButtonInfo)
						rootJson.put("subZoneCombo",getJSONComboFromList(subZoneList,"subZone",intlmap));
					if(er_subZone == null)
					{
						er_subZone="Yes";
					}
					selectedField.put("selectedSubZone",er_subZone);
					selectedField.put("subZoneLabel",intlmap.getTextDescription("reporter.common.Sub Zones"));
					if(aListComponentTemp == null || aListComponentTemp.size()==0)
						aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,analysisBy,er_site);
					List xenAppComponentList=new ArrayList();
					String isLicenseTabEnable="no";
					if(aListComponentTemp != null)
					{
						for(int c=0;c<aListComponentTemp.size();c++)
						{
							String comp=(String)aListComponentTemp.get(c);
							if(comp != null && comp.indexOf(":") != -1)
							{
								String compTypeStr=comp.substring(comp.lastIndexOf(":")+1);
								if(ctxDirectorCompList.contains(compTypeStr))
								{
									if(!componentList.contains(comp))
									{
										if(comp.indexOf("Citrix_license_server") != -1)
										{
											isLicenseTabEnable="yes";
										}
										if(isLicenseButtonClick)
										{
											if(comp.indexOf("Citrix_license_server") != -1)
												componentList.add(comp);
										}
										else if(comp.indexOf("Citrix_license_server") == -1)
										{										
											componentList.add(comp);
										}
									}
								}
								else
								{
									xenAppComponentList.add(comp);
								}
							}
						}
					}
					if(!componentList.isEmpty())
					{
						tempArry=new JSONArray();
						if(componentList.size() > 1)
						{
							tempObj = new JSONObject();
							tempObj.put("displayField",intlmap.getTextDescription("reporter.common.All"));
							tempObj.put("valueField","All");
							tempArry.add(tempObj);
							//componentList.add("All");
						}
						JSONArray selectdSiteDirectoryArry=new JSONArray();
						List directoryCompSession=new ArrayList();
						if(er_siteDirectComponent != null )
						{
							for(int e=0;e<er_siteDirectComponent.length;e++)
							{
								String eachSiteDirec=(String)er_siteDirectComponent[e];
								if(componentList.contains(eachSiteDirec))
								{
									selectdSiteDirectoryArry.add(eachSiteDirec);
									if(eachSiteDirec.equalsIgnoreCase("all"))
									{
										directoryCompSession.addAll(componentList);
									}
									else
										directoryCompSession.add(eachSiteDirec);
								}
								else
								{
									if(componentList.size() > 1)
									{
										selectdSiteDirectoryArry.add("All");
										directoryCompSession.addAll(componentList);
									}
									else
									{
										selectdSiteDirectoryArry.add(componentList.get(0));
										directoryCompSession.add(componentList.get(0));
									}
								}
							}
						}
						else 
						{
							if(componentList.size() > 1)
							{
								selectdSiteDirectoryArry.add("All");
							}
							else
							{
								selectdSiteDirectoryArry.add(componentList.get(0));
							}
						}
						for(int c=0;c<componentList.size();c++)
						{
							String eachCompstr=(String)componentList.get(c);
							String tempComp=eachCompstr;
							String cType=eachCompstr.substring(eachCompstr.lastIndexOf(":")+1);
							cType=intlmap.getComponentTypeDescription(cType);
							String portNo=eachCompstr.substring(eachCompstr.indexOf(":")+1,eachCompstr.lastIndexOf(":"));
							if(portNo.equalsIgnoreCase("null"))
							{
								eachCompstr=eachCompstr.substring(0,eachCompstr.indexOf(":"))+":"+cType;
							}
							else
								eachCompstr=eachCompstr.substring(0,eachCompstr.lastIndexOf(":")+1)+cType;
							tempObj = new JSONObject();
							tempObj.put("displayField",eachCompstr);
							tempObj.put("valueField",tempComp);
							tempArry.add(tempObj);
						}
						rootJson.put("isSiteOrDirectory","yes");
						rootJson.put("siteDirectComponent",tempArry);
						if(selectdSiteDirectoryArry != null)
							selectedField.put("selectedSiteOrDirectory",selectdSiteDirectoryArry);
						if(isLicenseButtonClick)
							selectedField.put("siteOrDirectoryLabel",intlmap.getTextDescription("reporter.common.License Server"));
						else
							selectedField.put("siteOrDirectoryLabel",intlmap.getTextDescription("reporter.common.Sites/ Director"));
						String[] directoryCompSessionArry = new String[directoryCompSession.size()];
						for(int x=0;x<directoryCompSession.size();x++)
						{
							String eachDir=(String)directoryCompSession.get(x);
							directoryCompSessionArry[x]=eachDir;
						}
						//directoryCompSessionArry = directoryCompSession.toArray(new String[0]);
						session.setAttribute("er_componentDirectory",directoryCompSessionArry);
					}
					else
					{
						rootJson.put("isSiteOrDirectory","no");
					}			
					if(isLicenseTabEnable.equals("yes"))
						rootJson.put("isLicenseTabEnable","yes");
					else
						rootJson.put("isLicenseTabEnable","no");
					tempArry=new JSONArray();
					if(xenAppComponentList.size() > 0)
					{		
						List xenAppCompSession=new ArrayList();
						if(xenAppComponentList.size() > 1)
						{
							tempObj = new JSONObject();
							tempObj.put("displayField",intlmap.getTextDescription("reporter.common.All"));
							tempObj.put("valueField","All");
							tempArry.add(tempObj);
						}
						JSONArray selectdXenAppArry=new JSONArray();
						if(er_XenAppComponents != null)
						{
							for(int e=0;e<er_XenAppComponents.length;e++)
							{
								String eachXenApp=(String)er_XenAppComponents[e];
								if(eachXenApp.equalsIgnoreCase("all"))
								{
									xenAppCompSession.addAll(xenAppComponentList);
								}
								else
									xenAppCompSession.add(eachXenApp);
								selectdXenAppArry.add(eachXenApp);							
							}
						}
						else 
						{
							if(xenAppComponentList.size() > 1)
								selectdXenAppArry.add("All");
							else
								selectdXenAppArry.add(xenAppComponentList.get(0));
						}
						for(int c=0;c<xenAppComponentList.size();c++)
						{
							String eachCompstr=(String)xenAppComponentList.get(c);
							String tempComp=eachCompstr;
							String cType=eachCompstr.substring(eachCompstr.lastIndexOf(":")+1);
							cType=intlmap.getComponentTypeDescription(cType);
							String portNo=eachCompstr.substring(eachCompstr.indexOf(":")+1,eachCompstr.lastIndexOf(":"));
							if(portNo.equalsIgnoreCase("null"))
							{
								eachCompstr=eachCompstr.substring(0,eachCompstr.indexOf(":"))+":"+cType;
							}
							else
								eachCompstr=eachCompstr.substring(0,eachCompstr.lastIndexOf(":")+1)+cType;
							tempObj = new JSONObject();
							tempObj.put("displayField",eachCompstr);
							tempObj.put("valueField",tempComp);
							tempArry.add(tempObj);
							selectedField.put("selectdXenAppArry",selectdXenAppArry);
						}	
						String[] xenAppCompSessionArry = new String[xenAppCompSession.size()];
						for(int x=0;x<xenAppCompSession.size();x++)
						{
							String eachXenComp=(String)xenAppCompSession.get(x);
							xenAppCompSessionArry[x]=eachXenComp;
						}
						session.setAttribute("er_componentXenApp",xenAppCompSessionArry);
					}
					else
					{
						tempObj = new JSONObject();
						tempObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
						tempObj.put("valueField","-1");
						tempArry.add(tempObj);
					}
					rootJson.put("xenAppComponents",tempArry);					
				}
				rootJson.put("selectedField",selectedField);
			}
			if(!getButtonInfo)		//timeline
			{
				if (er_timeline == null || er_timeline.equals(" ")) 
				{
					er_timeline = "1 week";
				}
				EgDateInfo egDt = new EgDateInfo();
				long msecsPerHour = (long) 1000 * 60 * 60;
				String[] options = { "Any", "1 hour", "3 hours", "6 hours", "9 hours", "12 hours", "15 hours","18 hours", "21 hours", "1 day", "2 days", "3 days", "4 days", "5 days", "6 days", "1 week","2 weeks", "3 weeks", "4 weeks", "1 month", "2 months", "3 months" };
				String startDateTime = "";
				String endDateTime = "";
				if (er_timeline != null && !er_timeline.equals("Any")) 
				{
					int blankSpaceIndex = er_timeline.indexOf(DateTimeTokenizer.BLANK_SPACE);
					if (blankSpaceIndex > 0) 
					{
						SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm");
						java.util.Date today = egDt.egetRealDate();
						endDateTime = sdf.format(today);
						long value = Integer.parseInt(er_timeline.substring(0, blankSpaceIndex));
						String unit = er_timeline.substring(blankSpaceIndex + 1).toLowerCase();
						if (unit.startsWith("h"))
						{//hours
							value *= 3600;
						} 
						else if (unit.startsWith("d"))
						{//days
							value *= (24 * 3600);
						} 
						else if (unit.startsWith("w")) 
						{//weeks
							value *= (7 * 24 * 3600);
						} 
						else if (unit.startsWith("mo")) 
						{//months
							java.util.Date dt_temp = new java.util.Date(egDt.egetUTCDate());
							Calendar cal_temp = new GregorianCalendar();
							cal_temp.setTime(dt_temp);
							cal_temp.add(Calendar.HOUR_OF_DAY, 0);
							java.util.Date dt_temp1 = cal_temp.getTime();
							long l_temp = dt_temp1.getTime();
							int totalDays = 24 * (maxDays);
							startDateTime = egDt.egetDate(l_temp - (long) ((value * totalDays * msecsPerHour)));
							startDateTime = DateUtil.changeDateFormat(startDateTime, "dd/MM/yyyy HH:mm","MM/dd/yyyy HH:mm");
						}
						if (unit != null && !unit.startsWith("mo"))
						{
							java.util.Date start = egDt.egetRealDate();
							start.setTime(today.getTime() - (value * 1000));
							startDateTime = sdf.format(start);
						}

						if ((startDateTime != null) && (endDateTime != null)) 
						{
							int shr = Integer.parseInt(startDateTime.substring(startDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE) + 1,startDateTime.indexOf(":")));
							strmin = startDateTime.substring(startDateTime.indexOf(":") + 1);
							int en_hr = Integer.parseInt(endDateTime.substring(endDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE) + 1, endDateTime.indexOf(":")));
							enmin = endDateTime.substring(endDateTime.indexOf(":") + 1);
							s_en_time = endDateTime.substring(0, endDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE));
							s_st_time = startDateTime.substring(0, startDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE));
							s_st_hr = String.valueOf(shr);
							s_en_hr = String.valueOf(en_hr);
						}
					}
				}
				String disable = "";
				if (er_timeline != null && !er_timeline.equals("Any"))
				{
					disable = "disabled";
				}
				if (er_timeline != null && er_timeline.equals("Any")) 
				{
					String StrDate = "";
					try 
					{
						java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("MM/dd/yyyy k 'at' hh:mm");
						StrDate = df.format(egDt.egetRealDate());
					} 
					catch (Exception ee)
					{
						//System.out.println("Exception is"+ee);
					}
					String SDate = StrDate.substring(0, StrDate.indexOf(" "));
					String shour = StrDate.substring(StrDate.indexOf(" "), StrDate.lastIndexOf(""));
					shour = shour.substring(0, 3);
					if (s_st_time == null)
					{
						s_st_time = SDate;
					}
					if (s_en_time == null)
					{
						s_en_time = SDate;
					}
					if (s_st_hr == null)
					{
						shour = shour.trim();
						int starthr = Integer.parseInt(shour);
						starthr = starthr - 1;
						s_st_hr = String.valueOf(starthr);
					}
					if (s_en_hr == null)
					{
						shour = shour.trim();
						s_en_hr = shour;
					}
					strmin = "00";
					enmin = "00";
				}
				String hourFrom = "";
				String minFrom = "";
				String hourTo = "";
				String minTo = "";
				String fromTime = reportInfo.getTimeFrame("CitrixXenApp_OverView","FROM");
				String toTime = reportInfo.getTimeFrame("CitrixXenApp_OverView","TO");
				StringTokenizer	st = new StringTokenizer(fromTime,":");
				if(st.hasMoreTokens())
				{
					hourFrom = st.nextToken();
					minFrom = st.nextToken();
				}
				st = new StringTokenizer(toTime,":");
				if(st.hasMoreTokens())
				{
					hourTo = st.nextToken();
					minTo = st.nextToken();
				}
				String hourFromUI= request.getParameter("hourFromUI");
				String minFromUI= request.getParameter("minFromUI");
				String hourToUI= request.getParameter("hourToUI");
				String minToUI= request.getParameter("minToUI");
				String exclweekUI= request.getParameter("exclweek");
				String reportGenerationType = request.getParameter("repGenType");
				if(hourFromUI == null) hourFromUI = hourFrom;
				if(minFromUI== null) minFromUI= minFrom;
				if(hourToUI== null) hourToUI= hourTo;
				if(minToUI== null) minToUI= minTo;
				if(exclweekUI== null) 
					exclweekUI= "No";
				if (reportGenerationType==null) 
					reportGenerationType = "foreground";
				rootJson.put("sHrForSetting",hourFromUI);
				rootJson.put("sMinForSetting",minFromUI);
				rootJson.put("eHourForSetting",hourToUI);
				rootJson.put("eMinForSetting",minToUI);
				rootJson.put("sExclweekUI",exclweekUI);
				rootJson.put("sRepGenType",reportGenerationType);
				rootJson.put("sExclweekLbl",intlmap.getTextDescription("reporter.common.Exclude weekends"));
				JSONArray exclweekArray  =  new JSONArray();
				JSONObject tmpobj=new JSONObject();
				tmpobj.put("displayField",intlmap.getTextDescription("reporter.common.Yes")+" ("+Days+") ");
				tmpobj.put("valueField", "Yes");
				exclweekArray.add(tmpobj);
				tmpobj = new JSONObject();
				tmpobj.put("displayField",intlmap.getTextDescription("reporter.common.No"));
				tmpobj.put("valueField", "No");
				exclweekArray.add(tmpobj);
				rootJson.put("excludeWeekCombo",exclweekArray);
				rootJson.put("excludeMessage",intlmap.getTextDescription("reporter.common.Excludes")+" "+Days);
				JSONArray reportGenerationComboArray =  new JSONArray();
				tmpobj=new JSONObject();
				tmpobj.put("displayField", strforeground);
				tmpobj.put("valueField", "foreground");
				reportGenerationComboArray.add(tmpobj);
				tmpobj=new JSONObject();
				tmpobj.put("displayField", strbackground);
				tmpobj.put("valueField", "background");
				reportGenerationComboArray.add(tmpobj);
				rootJson.put("reportGenerationCombo",reportGenerationComboArray);
				%>
						<%@  include file="ErTimeFormatJSON.jsp"%>
				<%
				rootJson.put("timelineCombo", timelineComboArray);
				rootJson.put("selectedTimeline", er_timeline);
				rootJson.put("startDate", startDateJSON);
				rootJson.put("endDate", endDateJSON);
				rootJson.put("startHour", startHourJSON);
				rootJson.put("endHour", endHourJSON);
				rootJson.put("startmin", startMin);
				rootJson.put("endmin", endMin);
				rootJson.put("inidate",currentDateFormat);

				rootJson.put("startDateForDisplay",startDateForDisplay);
				rootJson.put("startHourForDisplay",startHourForDisplay);
				rootJson.put("startMinForDisplay",startMinForDisplay);
				rootJson.put("endDateForDisplay",endDateForDisplay);
				rootJson.put("endHourForDisplay",endHourForDisplay);
				rootJson.put("endMinForDisplay",endMinForDisplay);

				String userStDateTime  = startDateForDisplay+" "+startHourForDisplay+":"+startMinForDisplay+" hrs";
				String userEndDateTime = endDateForDisplay+" "+endHourForDisplay+":"+endMinForDisplay+" hrs";
				rootJson.put("userStDateTime",userStDateTime);
				rootJson.put("userEndDateTime",userEndDateTime);
				rootJson.put("loginid", loginid);
				rootJson.put("limitforbg", limitforbg);
				rootJson.put("maxDays", maxDays);
				rootJson.put("noFailMSG", noFailMSG);				
				//
				HashMap backreqMap  = (HashMap)session.getAttribute("backQuery");
				String backQnumber  = request.getParameter("backQnumber");
				String servlet2     = request.getParameter("backServletName");
				String bggroundStr  = (String)request.getAttribute("bggroundStr");
				String status       = (String)request.getAttribute("status");
				String queryString =(String)ErUtils.prepareQueryString(request.getParameterMap());
				ErHelperUtils erhelputils = null;
				if( servlet2!=null && !servlet2.equals(""))
					erhelputils = new ErHelperUtils(backreqMap,backQnumber,servlet2);
				else
					erhelputils = new ErHelperUtils(backreqMap,backQnumber);
				boolean enableBack =erhelputils.isBackButtonEnable();
				String backButtonEnable = request.getParameter("back");
				if(backButtonEnable != null && backButtonEnable.equalsIgnoreCase("True"))
				{
					status = (String)request.getParameter("status");
					bggroundStr = (String)request.getParameter("bggroundStr");
				}
				ArrayList listbackvar = new  ArrayList();
				if(request.getParameter("isSubmit")!=null)
				{
					listbackvar.add("ErCtxOverview.jsp");
					if(er_view != null && er_view.equalsIgnoreCase("submit"))
						listbackvar.add("status="+status+"&isSubmit=true&bggroundStr="+bggroundStr+"&"+queryString);
					else
						listbackvar.add("status="+status+"&bggroundStr="+bggroundStr+"&"+queryString);
					session.setAttribute("favSchBackDisplay","Yes");
				}
				else
				{
					listbackvar.add("ErCtxOverview.jsp");
					if(er_view != null && er_view.equalsIgnoreCase("submit"))
						listbackvar.add(queryString+"&isSubmit=true");
					else
						listbackvar.add(queryString);
					session.setAttribute("favSchBackDisplay","No");
				}
				if(request.getParameter("enableBack")==null)
				{
					String queryStringTemp="";
					if(queryString != null)
					{
						ArrayList strTok=ErUtils.egTokenizer(queryString,"&");
						for(int s=0;s<strTok.size();s++)
						{
							String param=(String)strTok.get(s);
							int ind=param.indexOf("=");
							if(ind<0)
							{
								continue;
							}
							String reqParam=param.substring(0,ind);
							String reqVal=param.substring(ind+1);
							reqVal=com.eg.EgURLEncoder.encode(reqVal,"UTF-8");
							if(reqParam != null && (reqParam.equalsIgnoreCase("er_siteDirectComponent") || reqParam.equalsIgnoreCase("er_XenAppComponents")))
							{
								continue;
							}
							queryStringTemp+=reqParam+"="+reqVal+"&";
						}
						queryStringTemp+="er_siteDirectComponent=directorComp&er_XenAppComponents=xenAppComp";
						queryString=queryStringTemp;
					}
					if(request.getParameter("isSubmit")!=null)
						session.setAttribute("reportLastAccessedURL","/final/reporter/ErCtxOverview.jsp?isSubmit=true&"+queryString);
					else
						session.setAttribute("reportLastAccessedURL","/final/reporter/ErCtxOverview.jsp?&"+queryString);
				}
				String backadded = erhelputils.getBackID();
				backreqMap = erhelputils.setBackQueryMap(backreqMap,backadded,listbackvar);
				session.setAttribute("backQuery",backreqMap);
				if(backreqMap != null && backreqMap.size() >0 && "true".equalsIgnoreCase(request.getParameter("enableBack")))
				{
					rootJson.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
				}
			}
		}
		else
		{
			HashMap backreqMap= (HashMap)session.getAttribute("backQuery");
			String backQnumber= request.getParameter("backQnumber");
			String servlet2= request.getParameter("backServletName");
			String bggroundStr= (String)request.getAttribute("bggroundStr");
			String status= (String)request.getAttribute("status");
			Map data= request.getParameterMap();
			String modifiedFormat = currentDateFormat;
			if (modifiedFormat.startsWith("yy") || modifiedFormat.startsWith("YY")|| modifiedFormat.startsWith("yyyy")||modifiedFormat.startsWith("YYYY"))
			{
				modifiedFormat=modifiedFormat.substring(modifiedFormat.lastIndexOf("y")+2,modifiedFormat.length());
			}
			else if (modifiedFormat.endsWith("yy") || modifiedFormat.endsWith("YY")|| modifiedFormat.endsWith("yyyy")||modifiedFormat.endsWith("YYYY"))
			{
				modifiedFormat=modifiedFormat.substring(0,modifiedFormat.indexOf("y")-1);
				if(modifiedFormat.endsWith(","))
				{
					modifiedFormat=modifiedFormat.substring(0,modifiedFormat.indexOf(",")-1);
				}
			}
			//System.out.println("====allData===>>>>>>>>>>>"+allData);
			JSONObject panelData=(JSONObject)allData.get(buttonId+panelName);
			Boolean isData=(Boolean)panelData.get("isData");
			//System.out.println("===isData===>>>>>>>>jsp>>>>>>>"+isData);
			JSONObject tempObj=new JSONObject();
			JSONObject subObj=new JSONObject();
			JSONArray tempArry=new JSONArray();
			if(isData != null && isData) //user experience logon time 
			{	
				/*String totalLogon="600";
				String maxLogon="10";
				String avgLogon="5";
				String minLogon="2";
				subObj.put("totalLogon",totalLogon);
				subObj.put("totalLogonDisplay","logons");
				tempArry.add(subObj);
				
				subObj=new JSONObject();
				subObj.put("maxLogon",maxLogon);
				subObj.put("maxLogonDisplay","max");
				tempArry.add(subObj);
				
				subObj=new JSONObject();
				subObj.put("avgLogon",avgLogon);
				subObj.put("avgLogonDisplay","avg");
				tempArry.add(subObj);
				
				subObj=new JSONObject();
				subObj.put("minLogon",minLogon);
				subObj.put("minLogonDisplay","min");
				tempArry.add(subObj);

				tempObj.put("digitalChartArry",tempArry);
				//..barchart data
				subObj=new JSONObject();
				tempArry=new JSONArray();
				JSONObject dataSetObj=new JSONObject();
				JSONArray dataArry=new JSONArray();
				JSONObject dataObj=new JSONObject();
				dataSetObj.put("color","#d5759c");
				dataSetObj.put("name","Avg");
				dataObj.put("y",new Double(10));
				dataArry.add(dataObj);
				
				dataObj=new JSONObject();
				dataObj.put("y",new Double(20));
				dataArry.add(dataObj);

				dataObj=new JSONObject();
				dataObj.put("y",new Double(10));
				dataArry.add(dataObj);

				dataSetObj.put("data",dataArry);
				tempArry.add(dataSetObj);
				subObj.put("DataSet",tempArry);
				tempArry=new JSONArray();
				tempArry.add("3-Nov");
				tempArry.add("4-Nov");
				tempArry.add("5-Nov");
				subObj.put("xAxisLabel",tempArry);
				subObj.put("chartType","column");
				tempObj.put("barChartDataObj",subObj);
				tempObj.put("isData",true);
				rootJson.put("userExpLogonTimeObj",tempObj);*/
			//	JSONObject panelData=(JSONObject)allData.get(buttonId+panelName);
				rootJson.put(buttonId+panelName,panelData);
			}
			else
			{
				rootJson.put(buttonId+panelName,panelData);
			}
			String queryString =(String)ErUtils.prepareQueryString(request.getParameterMap());
			String Qstring="";
			if(queryString!=null)
			{
				StringTokenizer strtok = new StringTokenizer(queryString,"&");
				while(strtok.hasMoreTokens())
				{
					String param = strtok.nextToken();
					int ind = param.indexOf("=");
					String reqparam = param.substring(0,ind);
					String value= param.substring(ind+1);
					value= com.eg.EgURLEncoder.encode(value, "UTF-8");
					Qstring=Qstring+reqparam+"="+value+"&";
				}
			}
			ErHelperUtils erhelputils = null;
			if( servlet2!=null && !servlet2.equals(""))
				erhelputils = new ErHelperUtils(backreqMap,backQnumber,servlet2);
			else
				erhelputils = new ErHelperUtils(backreqMap,backQnumber);
			boolean enableBack =erhelputils.isBackButtonEnable();

			String backButtonEnable = request.getParameter("back");
			if(backButtonEnable != null && backButtonEnable.equalsIgnoreCase("True"))
			{
				status = (String)request.getParameter("status");
				bggroundStr = (String)request.getParameter("bggroundStr");
			}
			ArrayList listbackvar = new  ArrayList();
			if(request.getParameter("isSubmit")!=null)
			{
				listbackvar.add("ErCtxOverview.jsp");
				if(er_view != null && er_view.equalsIgnoreCase("submit"))
					listbackvar.add("status="+status+"&isSubmit=true&bggroundStr="+bggroundStr+"&"+Qstring);
				else
					listbackvar.add("status="+status+"&bggroundStr="+bggroundStr+"&"+Qstring);
				session.setAttribute("favSchBackDisplay","Yes");
			}
			else
			{
				listbackvar.add("ErCtxOverview.jsp");
				if(er_view != null && er_view.equalsIgnoreCase("submit"))
					listbackvar.add(Qstring+"&isSubmit=true");
				else
					listbackvar.add(Qstring);
				session.setAttribute("favSchBackDisplay","No");
			}
			if(request.getParameter("enableBack")==null)
			{
				String queryStringTemp="";
				if(Qstring != null)
				{
					ArrayList strTok=ErUtils.egTokenizer(Qstring,"&");
					for(int s=0;s<strTok.size();s++)
					{
						String param=(String)strTok.get(s);
						int ind=param.indexOf("=");
						if(ind<0)
						{
							continue;
						}
						String reqParam=param.substring(0,ind);
						String reqVal=param.substring(ind+1);
						//reqVal=com.eg.EgURLEncoder.encode(reqVal,"UTF-8");
						if(reqParam != null && (reqParam.equalsIgnoreCase("er_siteDirectComponent") || reqParam.equalsIgnoreCase("er_XenAppComponents")))
						{
							continue;
						}
						queryStringTemp+=reqParam+"="+reqVal+"&";
					}
					queryStringTemp+="er_siteDirectComponent=directorComp&er_XenAppComponents=xenAppComp";
					Qstring=queryStringTemp;
				}
				session.setAttribute("reportLastAccessedURL","/final/reporter/ErCtxOverview.jsp?isSubmit=true&"+Qstring);
			}
			String backadded = erhelputils.getBackID();
			backreqMap = erhelputils.setBackQueryMap(backreqMap,backadded,listbackvar);
			session.setAttribute("backQuery",backreqMap);
			if(backreqMap != null && backreqMap.size() >0 && "true".equalsIgnoreCase(request.getParameter("enableBack")))
			{
				rootJson.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
			}
		}
		rootJson.put("selectedStateObj",selectedStateObj);
		session.setAttribute("PDF_URL", mngrIProc+"/final/reporter/ErCtxOverviewPrint.jsp");
		session.setAttribute("MAIL_URL",mngrIProc+"/final/reporter/ErCtxOverviewPrint.jsp;jsessionid="+ session.getId()+"?buttonId="+buttonId);
		
		HashMap paramval =new HashMap();
		paramval.put("filename","CitrixOverviewReport");
		session.setAttribute("parameters", paramval);

		StringTokenizer st1;
		String Hourfrom = "";
		String Minfrom = "";
		String Hourto= "";
		String Minto= "";
		String fromTime= "";
		String toTime= "";
		String  pdfStartDate = s_st_time+" "+s_st_hr+":"+strmin;
		String  pdfEndDate   = s_en_time+" "+s_en_hr+":"+enmin;
		String pdfTime = "From "+pdfStartDate+" hrs "+" "+" To "+pdfEndDate+" hrs";
		fromTime = reportInfo.getTimeFrame("CitrixXenApp_OverView","FROM");
		toTime = reportInfo.getTimeFrame("CitrixXenApp_OverView","TO");
		st1 = new StringTokenizer(fromTime,":");
		if(st1.hasMoreTokens())
		{
			Hourfrom = st1.nextToken();
			Minfrom = st1.nextToken();
		}
		st1=new StringTokenizer(toTime,":");
		if(st1.hasMoreTokens())
		{
			Hourto = st1.nextToken();
			Minto = st1.nextToken();
		}
		String hourFromUI= request.getParameter("hourFromUI");
		String minFromUI= request.getParameter("minFromUI");
		String hourToUI= request.getParameter("hourToUI");
		String minToUI= request.getParameter("minToUI");
		String exclweekUI= request.getParameter("exclweek");
		if(hourFromUI == null) hourFromUI = Hourfrom;
		if(minFromUI== null) minFromUI= Minfrom;
		if(hourToUI== null) hourToUI= Hourto;
		if(minToUI== null) minToUI= Minto;
		if(exclweekUI== null) 
			exclweekUI= "No";
		ErReportHelper helper = new ErReportHelper();
		
		if ("Yes".equalsIgnoreCase(exclweekUI))
		{
			exclweekUI = (helper.getExcludeWeekends("EXCLUDE_WEEKEND", "Days") == null) ? "Saturday,Sunday" : helper.getExcludeWeekends("EXCLUDE_WEEKEND", "Days");
		}
		else 
		{
			exclweekUI = "No";
		}
		JSONObject selectionDetails  =  new JSONObject();
		//selectionDetails.put(intlmap.getTextDescription("reporter.common.Report By"),analysisBy);
		selectionDetails.put(analysisBy,er_site);
		//selectionDetails.put(intlmap.getTextDescription("reporter.common.Time Period "),hourFromUI+":"+minFromUI+" <b>"+intlmap.getTextDescription("reporter.common.to")+" </b>"+hourToUI+":"+minToUI);
		selectionDetails.put((String)intlmap.getTextDescription("reporter.common.TimeLine"),pdfStartDate+" "+intlmap.getTextDescription("reporter.common.hrs")+" <b>  "+intlmap.getTextDescription("reporter.common.to")+" </b>"+pdfEndDate+" "+intlmap.getTextDescription("reporter.common.hrs"));
	//	reportTitle+=" for ";
		if(er_site != null && !analysisBy.equalsIgnoreCase("component"))
			reportTitle = intlmap.getTextDescription("reporter.common."+reportTitle) +" "+intlmap.getTextDescription("reporter.common.for")+" "+er_site+" "+intlmap.getTextDescription("reporter.common."+analysisBy);
		reportTitle+=",<span style='font-size:12px'> "+intlmap.getTextDescription("reporter.common.from")+" "+pdfStartDate+" "+intlmap.getTextDescription("reporter.common.hrs")+" <b>  "+intlmap.getTextDescription("reporter.common.to")+" </b>"+pdfEndDate+" "+intlmap.getTextDescription("reporter.common.hrs")+"<span>";
		rootJson.put("reportTitle",reportTitle);
	//	selectionDetails.put(intlmap.getTextDescription("reporter.common.Exclude weekends"),exclweekUI);
		
		rootJson.put("selectionDetails",selectionDetails);
		out.println(rootJson.toString());

	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
%>
<%!
public synchronized JSONArray getJSONComboFromList(List list,String infoVal,EgMappingInfo intlmap)
{
	JSONArray arr=new JSONArray();
	JSONObject obj=null;
	if(list !=null && list.size()>0)
	{
		for (int i=0;i<list.size();i++)
		{
			String text=(String)list.get(i);
			obj=new JSONObject();
			if(infoVal.equalsIgnoreCase("subZone")||text.equalsIgnoreCase("--Default--"))
				obj.put("displayField",intlmap.getTextDescription("reporter.common."+text));
			else
				obj.put("displayField",text);
			obj.put("valueField",text);
			arr.add(obj);
		}
	}
	else
	{
		obj=new JSONObject();
		obj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
		obj.put("valueField","-1");
		arr.add(obj);
	}
	return arr;
}
%>