<%
/*******************************************************************************
* File name	: ErCtxLogonSimulatorJSON.jsp
* Purpose	: Logon Simulator
* Author	: Vensar
*******************************************************************************/
%>

<%@ include file = "ErReporterTracker.jsp" %>
<%@ page import = "com.eg.EgDateInfo" %>
<%@ page import = "com.eg.EgGroupInfo" %>
<%@ page import = "com.eg.EgURLDecoder" %>
<%@ page import = "com.eg.EgURLEncoder" %>
<%@ page import = "com.eg.EgConfigInfo"%>
<%@ page import = "com.eg.EgDiscInfo" %>
<%@ page import = "com.eg.EgMappingInfo"%>
<%@ page import = "com.eg.EgExternalInfo" %>
<%@ page import = "com.eg.EgTestInfo"%>
<%@ page import = "com.egurkha.util.DateUtil" %>
<%@ page import = "com.egurkha.util.DateTimeTokenizer" %>
<%@ page import = "java.awt.Color"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page import = "net.sf.json.*" %>
<%@ page import = "com.eg.EgAgentInfo" %>
<%
		response.setContentType("application/json");

		JSONObject rootJson = new JSONObject();
		JSONObject screenLabelJson = new JSONObject();
		JSONObject hiddenfieldsJson=new JSONObject();
		JSONObject loopJsonObj = new JSONObject();
		EgExternalInfo egExt = new EgExternalInfo("Manager");
		ArrayList loctnLst = new ArrayList();

		//Back Button - Start
		String bggroundStr = (String)request.getAttribute("bggroundStr");
		String status = (String)request.getAttribute("status");
		HashMap backreqMap = (HashMap)session.getAttribute("backQuery");
		String backQnumber = request.getParameter("backQnumber");
		String isNeedBack = request.getParameter("isNeedBack");
		ErUtils utils= new ErUtils();
		if(isNeedBack==null)
		{
			isNeedBack="false";
		}
		String servlet2 = request.getParameter("backServletName");
		String mngrIProc = new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
		ErHelperUtils erhelputils = null;
		ErEsxVMutils erEsxUtils = new ErEsxVMutils();
		ErCtxLogonSimulatorBean logonBean = new ErCtxLogonSimulatorBean();
		if( servlet2!=null && !servlet2.equals(""))
			erhelputils = new ErHelperUtils(backreqMap,backQnumber,servlet2);
		else
			erhelputils = new ErHelperUtils(backreqMap,backQnumber);
		boolean enableBack=erhelputils.isBackButtonEnable();
		String queryString="";
		String backButtonEnable = request.getParameter("back");
		if(backButtonEnable != null && backButtonEnable.equalsIgnoreCase("True"))
		{
			status = (String)request.getParameter("status");
			bggroundStr = (String)request.getParameter("bggroundStr");
			request.setAttribute("CITRIX_SIMULATOR_REPORT", null);
		}
		//Back Button - End
	try
	{
		String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
		String uiFile = "eg_ui.ini";
		ErUtils erUtils = new ErUtils();
		ErReportHelper erh = new ErReportHelper();
		com.eg.IniFile egUI = new com.eg.IniFile(s_iniFile_dir + uiFile);
		com.egurkha.ini.IniUI ui = (com.egurkha.ini.IniUI)com.egurkha.ini.IniUI.getInstance();
		EgDateInfo egDt = new EgDateInfo();
		EgReportInfo reportInfo = new EgReportInfo("manager");
		com.eg.IniFile iniFileforMonitors = new com.eg.IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_external.ini", false);

		EgGroupInfo gpinfo = new EgGroupInfo();
		ErInfo erInfo = new ErInfo();
		EgDiscInfo discInfo = new EgDiscInfo("manager");
		ErComponentsUtils compUtil = new ErComponentsUtils(thisuser.getLoginID());
		EgTestInfo tokInfo = new EgTestInfo("manager");
		EgMappingInfo intlmap = new EgMappingInfo(thisuser.getLanguage());
	
		String reqFromSchedule = request.getParameter("fromSchedule");
		String fromScheduleModify = request.getParameter("fromScheduleModify");
		String er_favorite = request.getParameter("er_favorite");
		String fromFavoriteModify = request.getParameter("fromFavoriteModify");
		String favorite_id = request.getParameter("id");
		String showLegend = request.getParameter("showLegend");
		String erServer = request.getParameter("er_server");
		String er_trgttype = request.getParameter("er_trgttype");
		String selectedLoc = request.getParameter("selectedLoc");
		String selectedApp = request.getParameter("selectedApp");
		String appForAgent = request.getParameter("appForAgent");
		String pageNo = request.getParameter("pageNo");
		String fromLoc = request.getParameter("fromLoc");
		boolean isBackgroundProcess = false;
		String BLANK_SPACE = " ";
		String COMA = ",";
		String COLON = ":";
		String UTF_8 = "UTF-8";
		String timefrom="";
		String minfrom="";
		String timeto="";
		String minto="";
		String dispDate = null;
		String comFormat = null;	
		String er_timeline = request.getParameter("er_timeline");
		String s_st_time = request.getParameter("er_stdate");
		String s_en_time = request.getParameter("er_enddate");
		String modifiedFormat = strUserDateFormat;
		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.lastIndexOf(",")>-1)
			{
				modifiedFormat = modifiedFormat.substring(0,modifiedFormat.length()-1);
			}
		}
		if(s_st_time == null)
			s_st_time = request.getParameter("startdate");
		if(s_en_time == null)
			s_en_time = request.getParameter("enddate");
		String s_st_time_graph = null;
		if(s_st_time != null)
		{
			s_st_time_graph = new String(s_st_time);
		}
		String s_en_time_graph = null;
		if(s_en_time != null)
		{
			s_en_time_graph = new String(s_en_time);
		}
		if(er_timeline==null  || er_timeline.equals(" "))
		{
			er_timeline="1 day";
		}
		String s_st_hr = request.getParameter("starthr");
		String s_en_hr = request.getParameter("endhr");
		String s_inidate = request.getParameter("inidate");
		String strmin = request.getParameter("startmin");
		String enmin = request.getParameter("endmin");
		String s_farmserver = request.getParameter("er_zone");
		String s_compType = request.getParameter("er_compType");
		String[] s_application = request.getParameterValues("er_applicationX");
		String applicationName = request.getParameter("er_applicationX");
		String applicationX = request.getParameter("er_applicationX");
		String location = request.getParameter("er_location");
		String[] selectedCompArray = request.getParameterValues("er_component");
		String selectedTempComponent = request.getParameter("er_component");

		String isSubmit = request.getParameter("isSubmit");
		String schedule_id = request.getParameter("schedule_id");
		List selectedApplication = new ArrayList();
		List selectedComponent = new ArrayList();
		Vector v_comp_popup = new Vector();
		Vector v_comp_popup_disp = new Vector();
		String divStatus = request.getParameter("divStatus");
		String srcForImg="";
		List v_serverName=new ArrayList();
		String currentDateFormat =strUserDateFormat;
		String enumerationComponents=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","ExcludeEnumueration");
		String thrSch = request.getParameter("throughSchedule");
		String fromComponentChange = request.getParameter("fromComponentChange");
		boolean enableEnumulation=isEnumerationNeeded(s_compType,enumerationComponents);
		if(divStatus==null)
		{
			divStatus="none";
		}
		if(divStatus.equals("none"))
		{
			srcForImg="/final/images/moreoption.png";
		}
		else if(divStatus.equals("block"))
		{
			srcForImg="/final/images/lessoption.png";
		}
		if(er_trgttype!=null && er_trgttype.equalsIgnoreCase("locationBased"))
		{
			selectedApplication = new ArrayList();
			if(appForAgent!=null)
				selectedApplication.add(appForAgent);
		}
		else
		{
			selectedApplication = new ArrayList();
			if(s_application != null)
				selectedApplication = Arrays.asList(s_application);
		}
		if(selectedCompArray != null)
			selectedComponent  = Arrays.asList(selectedCompArray);
		List selectedCompList = new ArrayList();
		String excludeweekend ="";
		boolean noDataFound = true;
		Map resultMap = (Map) session.getAttribute("CITRIX_SIMULATOR_REPORT");
		if(resultMap != null && isSubmit != null && isSubmit.equalsIgnoreCase("true"))
		{
			Boolean noData = ((Boolean) resultMap.get("NO_DATA_FOUND"));
			if(noData != null)
			noDataFound = noData.booleanValue();
		}
		if(fromComponentChange != null && fromComponentChange.equalsIgnoreCase("yes")){
			session.removeAttribute("CITRIX_SIMULATOR_REPORT");
			session.removeAttribute("locationLogon_Details");
			session.removeAttribute("summaryTableApp");
			session.removeAttribute("logon_Details");
			session.removeAttribute("locationResults");
		}
		String dispCsvStartDate = s_st_time+" "+s_st_hr+" : "+strmin;
		String dispCsvEndDate = s_en_time+" "+s_en_hr+" : "+enmin;
		if(selectedCompArray != null) 
		{
			for (int i = 0; i < selectedCompArray.length; i++) 
			{
				try 
				{
					selectedCompList.add(EgURLDecoder.decode(selectedCompArray[i], "UTF-8"));
				}
				catch (Exception e1) {}
			}
		}
		String startDateTime="";
		String endDateTime="";
		String disable="";
		long msecsPerHour = (long) 1000 * 60 * 60;
		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 = egDt.egetRealDate();
					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*(erUtils.getMaxDaysInMonth());
					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 = new java.util.Date();
					java.util.Date startTmp=new java.util.Date(endDateTime);
					start.setTime(startTmp.getTime() - (value * 1000));
					startDateTime = sdf.format(start);
				}
			}
			if ((startDateTime != null) && (endDateTime != null))
			{
				s_inidate="MM/dd/yyyy";
				try
				{
					int shr=Integer.parseInt(startDateTime.substring(startDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE)+1, startDateTime.indexOf(COLON)));
					strmin=startDateTime.substring(startDateTime.indexOf(COLON)+1);
					int en_hr=Integer.parseInt(endDateTime.substring(endDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE)+1, endDateTime.indexOf(COLON)));
					enmin=endDateTime.substring(endDateTime.indexOf(COLON)+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);
				}
				catch(Exception e)
				{
					e.printStackTrace();
				}
			}
		}
		//String pageNo = request.getParameter("pageNo");
		String printPageIdentify = request.getParameter("printPageIdentify");
		String lastMyURL = (String)ErUtils.prepareQueryString(request.getParameterMap());
		if (printPageIdentify!=null && printPageIdentify.equalsIgnoreCase("locFirstPage"))
		{
			String forLocfirstPage = (String)ErUtils.prepareQueryString(request.getParameterMap());
			session.setAttribute("forLocfirstPage",forLocfirstPage);
		}
		else if (printPageIdentify!=null && printPageIdentify.equalsIgnoreCase("locMainTable"))
		{
			String forlocMainTable = (String)ErUtils.prepareQueryString(request.getParameterMap());
			session.setAttribute("forlocMainTable",forlocMainTable);
		}
		else
		{
			if(pageNo!=null) 
			{
				String pn="pageNo"+pageNo;
				HashMap sess = new HashMap();
				sess.put(pn,lastMyURL);
				sess= new HashMap();
				session.setAttribute(pn,lastMyURL);
			}
		}
		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(new java.util.Date());
			}
			catch(Exception ee)
			{
				ee.printStackTrace();
			}
			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;
				s_inidate="MM/dd/yyyy";
			}
			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;
			}
		}
		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"};
		Vector v_time = new Vector();
		v_time.add("00");
		v_time.add("01");
		v_time.add("02");
		v_time.add("03");
		v_time.add("04");
		v_time.add("05");
		v_time.add("06");
		v_time.add("07");
		v_time.add("08");
		v_time.add("09");
		v_time.add("10");
		v_time.add("11");
		v_time.add("12");
		v_time.add("13");
		v_time.add("14");
		v_time.add("15");
		v_time.add("16");
		v_time.add("17");
		v_time.add("18");
		v_time.add("19");
		v_time.add("20");
		v_time.add("21");
		v_time.add("22");
		v_time.add("23");

		Vector v_min = new Vector();
		v_min.add("00");
		v_min.add("05");
		v_min.add("10");
		v_min.add("15");
		v_min.add("20");
		v_min.add("25");
		v_min.add("30");
		v_min.add("35");
		v_min.add("40");
		v_min.add("45");
		v_min.add("50");
		v_min.add("55");
		v_min.add("59");
	
		String timefrom1=(erh.getTimeFrame("TIMEFRAME","From")==null) ? "00:00" :erh.getTimeFrame("TIMEFRAME","From");
		String timeto1=(erh.getTimeFrame("TIMEFRAME","To")==null) ? "23:59" :erh.getTimeFrame("TIMEFRAME","To");
		timefrom1 = reportInfo.getValue("CITRIX_LOGON_SIMULATOR","FROM");
		timeto1 = reportInfo.getValue("CITRIX_LOGON_SIMULATOR","TO");
		StringTokenizer st;
		if(timefrom1 != null)
		{
			st = new StringTokenizer(timefrom1,":");
			if(st.hasMoreTokens())
			{
				timefrom=st.nextToken();
				minfrom=st.nextToken();
			}
		}
		if(timeto1 != null)
		{
			st=new StringTokenizer(timeto1,":");
			if(st.hasMoreTokens())
			{
				timeto=st.nextToken();
				minto=st.nextToken();
			}
		}
		String timefrom2 = request.getParameter("timefrom");
		String minfrom2 = request.getParameter("minfrom");
		String timeto2 = request.getParameter("timeto");
		String minto2 = request.getParameter("minto");
		String stmin = "00";
		if (timefrom2!=null)
			timefrom = timefrom2;
		if (minfrom2!=null)
			minfrom = minfrom2;
		if (timeto2!=null)
			timeto = timeto2;
		if (minto2!=null)
			minto = minto2;

		ArrayList aListSupportedComponentType = new ArrayList();
		String getCompFromIni = reportInfo.getValue("CITRIX_LOGON_SIMULATOR","Components");
		StringTokenizer sts = new StringTokenizer(getCompFromIni,",");
		while(sts.hasMoreTokens())
		{
			String getOneComp = sts.nextToken();
			aListSupportedComponentType.add(getOneComp);
		}
		ArrayList aListAlltype = new ArrayList();
		for(int kk=0;kk<aListSupportedComponentType.size();kk++)
		{
			aListAlltype.add(aListSupportedComponentType.get(kk));
		}
		String er_option =request.getParameter("er_option");
		String er_site = request.getParameter("er_site");
		if(er_option == null || er_option.isEmpty())
		{
			er_option = "Zone";
		}
		User this_user = UserRegistry.getInstance().getUser(session.getId());
		String loginid = this_user.getLoginID();
		List v_option = new ArrayList();
		Hashtable htAllGroups=erEsxUtils.getGroups(null,aListSupportedComponentType, thisuser, loginid, "Yes",true);
		ArrayList aListOption = erEsxUtils.getOptions(htAllGroups);
		if(aListOption!=null && aListOption.size()>0)
			v_option.addAll(aListOption);
		JSONArray arr = new JSONArray();
		JSONObject obj=null;
		if(v_option!=null && v_option.size()>0)
		{
			rootJson.put("selectedAnalysisByCombo",er_option);
			for(int i=0; i<v_option.size(); i++)
			{
				obj = new JSONObject();
				obj.put("displayField", intlmap.getTextDescription("reporter.common."+v_option.get(i)));
				obj.put("valueField",v_option.get(i));
				arr.add(obj);
			}
		}
		else
		{
			obj = new JSONObject();
			obj.put("displayField", intlmap.getTextDescription("reporter.common.Not Applicable"));
			obj.put("valueField","-1");
			arr.add(obj);
		}
		rootJson.put("analysisByCombo",arr);

		List aListComponentTemp=null;
		String confrimation = reportInfo.getValue("BACKGROUND_PROCESS","NeedConfirmation");
		String strbgrepportName = reportInfo.getValue("BACKGROUND_PROCESS","EnableBackgroundReport");
		String limitforbg = reportInfo.getValue("BACKGROUND_PROCESS","MinDurationForReport");
		status = (String)request.getAttribute("status");
		List v_site=new ArrayList();
		Vector v_zone = new Vector();
		Vector v_componentType = new Vector();
		Vector v_component = compUtil.getAllUserComponents1();

		List aTemp = compUtil.getUserZones();
		if(aTemp != null && aTemp.contains("--Default--"))
			aTemp.remove("--Default--");
		String zones[] = new String[aTemp.size()];
		for(int m=0;m<aTemp.size();m++)
		{
			zones[m] = (String)aTemp.get(m);
		}

		List zonelist = aTemp;
		Vector v_zonelist = new Vector();
		ArrayList listSupportedComponentType = new ArrayList();
		v_zonelist.addAll(zonelist);
		String componentTypes = reportInfo.getValue("CITRIX_LOGON_SIMULATOR","ComponentsWithTest");
		StringTokenizer stk = new StringTokenizer(componentTypes,",");
		while(stk.hasMoreTokens())
		{
			String tempStr = stk.nextToken();
			tempStr = tempStr.substring(0,tempStr.indexOf(COLON));
			listSupportedComponentType.add(tempStr);
		}
		/*v_zone = erUtils.getAllThinClientZones(zones,v_zonelist,v_component,aListSupportedComponentType);
		if((v_zone != null) && v_zone.size() > 1)
		{
			Collections.sort(v_zone);
		}
		if(v_zone != null && !v_zone.isEmpty() && s_farmserver == null)
		{
			s_farmserver = (String)v_zone.get(0);
		}
		*/
		//-report by combo for zone, segment, service & component
		if (er_option!=null)
		{
			v_site = erEsxUtils.getGroupsName(htAllGroups,er_option);
			if(v_site!=null )
			Collections.sort(v_site,String.CASE_INSENSITIVE_ORDER);
			aListComponentTemp=null;
			if(er_option.equals("Segment") || er_option.equals("Service"))
			{
				if(er_site==null && v_site!=null && v_site.size()>0)
				{
					er_site=(String)v_site.get(0);
				}
				aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,er_site);
				rootJson.put("siteCombo",getJSONComboFromList(v_site,"",intlmap));
				rootJson.put("siteComboLabel",er_option);
				rootJson.put("selectedSiteCombo",er_site);
			}
			else if(er_option.equals("Zone"))
			{
				v_site = erEsxUtils.getGroupsName(htAllGroups,er_option);
				if(v_site!=null)
				{
					v_zonelist.addAll(v_site);
					v_zone.addAll(v_site);
				}
				if(s_farmserver==null && v_site!=null && v_site.size()>0)
				{
					s_farmserver=(String)v_site.get(0);
				}
				if((v_zone != null) && v_zone.size() > 1)
				{
					Collections.sort(v_zone);
				}
				aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,s_farmserver);
				rootJson.put("selectedZone",s_farmserver);
			}
			else if(er_option.equals("Component"))
			{
				aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,null);
			}
		}
		if(aListComponentTemp!=null && aListComponentTemp.size()>0)
		{
			v_serverName = new ArrayList();
			for(int i=0; i<aListComponentTemp.size(); i++) 
			{
				String loopComponent = (String) aListComponentTemp.get(i);
				if(loopComponent.lastIndexOf(":")>-1)
				{
					String loopComp = loopComponent.substring(0,loopComponent.lastIndexOf(":"));
					String  loopType = loopComponent.substring(loopComponent.lastIndexOf(":")+1);
					{
						if(v_serverName!=null && !v_serverName.contains(loopType))
							v_serverName.add(loopType);
					}
				}
			}
		}
		Collections.sort(v_serverName,String.CASE_INSENSITIVE_ORDER);
			// for component types [Component Type Combo]
		JSONArray comptypeArray = new JSONArray();
		if(er_option.equals("Zone"))
		{
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,s_farmserver);
		}
		else if (er_option.equals("Segment")||er_option.equals("Service"))
		{
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,er_site);
		}
		else
		{
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,null);
		}
		if(aListComponentTemp != null)
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Please choose a Component Type"));
			loopJsonObj.put("valueField", "-1");
			comptypeArray.add(loopJsonObj);
		}
		else
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "-1");
			comptypeArray.add(loopJsonObj);
		}
		if(aListComponentTemp!=null && !aListComponentTemp.isEmpty())
		{
			for(int n=0;n<aListComponentTemp.size();n++)
			{
				String comp = (String)aListComponentTemp.get(n);
				int index=comp.lastIndexOf(":");
				if(index>-1)
				{ 
					String  ctype = comp.substring(index+1); 
					if(!v_serverName.contains(ctype))
					{
						v_serverName.add(ctype);
					}
				}
			}
			for(int n=0;n<v_serverName.size();n++)
			{
				String ctype = (String) v_serverName.get(n);
				loopJsonObj = new JSONObject();
				loopJsonObj.put("displayField",intlmap.getComponentTypeDescription(ctype));
				loopJsonObj.put("valueField",ctype);
				comptypeArray.add(loopJsonObj);
			}
			if(s_compType==null && v_serverName!=null && v_serverName.size()>0)
			{
				s_compType=(String)v_serverName.get(0);
				rootJson.put("selectedCompType",s_compType);
			}
			else
			{
				rootJson.put("selectedCompType",s_compType);
			}
		}
		rootJson.put("compTypeCombo",comptypeArray);

 // for components [MultiSelectCombo]
	JSONArray compArray = new JSONArray();
	JSONArray selectedComponents =  new JSONArray();
	Collections.sort(v_serverName ,String.CASE_INSENSITIVE_ORDER);
	List componentsList=new ArrayList();
	if(aListComponentTemp!=null && !aListComponentTemp.isEmpty())
	{
		for(int n=0;n<aListComponentTemp.size();n++)
		{
			String comp = (String) aListComponentTemp.get(n);
			if(comp!=null && comp.lastIndexOf(":")>-1)
			{
				String strTempType = comp.substring(comp.lastIndexOf(":")+1);
				if(!strTempType.equalsIgnoreCase(s_compType))
					continue;
			}
			if(comp.endsWith(s_compType))
			{
				componentsList.add(comp);
			}
		}
	}
	if(aListComponentTemp!=null && aListComponentTemp.size()>0)
	{
		selectedComponents = new JSONArray();
		for(int n=0;n<componentsList.size();n++)
		{
			String loopComponent = (String) componentsList.get(n);
			if(loopComponent.lastIndexOf(":")>-1)
			{
				String loopComp = loopComponent.substring(0,loopComponent.lastIndexOf(":"));
				String tempComp = loopComp.substring(0,loopComp.indexOf(":"));
				String tempPort = loopComp.substring(loopComp.indexOf(":")+1);
				if(tempPort.equalsIgnoreCase("null"))
					loopComp = tempComp;
				String locationsTypeOptionsVar[] = egExt.getExternalAgentsForHost(loopComp);
				loctnLst.add(locationsTypeOptionsVar);
				if(locationsTypeOptionsVar!=null && locationsTypeOptionsVar.length>0)
				{
					List aListCompExter = Arrays.asList(locationsTypeOptionsVar);
					if(aListCompExter!=null && location!=null && !aListCompExter.contains(location) && !location.equalsIgnoreCase("All"))
						continue;
				}
					String selected = "";
				if(selectedCompList.size() == 0 || selectedCompList.contains("-1") || selectedCompList.contains(loopComp))
				{
					String singleSelComp = (String)componentsList.get(n);
					if(singleSelComp!=null && singleSelComp.indexOf(":")>-1)
					{
						singleSelComp = singleSelComp.substring(0,singleSelComp.indexOf(":"));
						selectedComponents.add(singleSelComp);
					}
					else
					{
						selectedComponents.add(singleSelComp);
					}
					selected = " selected ";
				}
				v_comp_popup.add(loopComponent);
				v_comp_popup_disp.add(loopComp);

				loopJsonObj = new JSONObject();
				loopJsonObj.put("displayField",loopComp);
				loopJsonObj.put("valueField",loopComp);
				compArray.add(loopJsonObj);
				rootJson.put("selectedComponents",selectedComponents);
			}
		}
	}
	else
	{
		v_comp_popup.add("-1");
		v_comp_popup_disp.add("Not Applicable");
		loopJsonObj = new JSONObject();
		loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
		loopJsonObj.put("valueField", "-1");
		compArray.add(loopJsonObj);
	}
	rootJson.put("componentCombo",compArray);
	if(selectedCompArray!=null && selectedCompArray.length>0)
	{
		rootJson.put("temp_Component",selectedCompArray);
	}
	// for component name
	v_component = new Vector();
	if(s_compType != null && !s_compType.equalsIgnoreCase("-1"))
	{
		if(!s_compType.equals("Host_system")) 
		{
			List removeList = new ArrayList();
			for(int i=0; i<v_component.size(); i++) 
			{
				String temp_component = (String)v_component.get(i);
				if(-1 == temp_component.indexOf(s_compType)) 
				{
					removeList.add(temp_component);
				}
			}
			v_component.removeAll(removeList);
		}
		// added for component selection based on zone
		Vector temp_Component = new Vector();
		String includezone = "yes";
		List listCompTypes =reportInfo.getComponent("CITRIX_LOGON_SIMULATOR",false);
		Vector tempComponent = new Vector();
		tempComponent.addAll(v_component);
		for(int i=0; i<tempComponent.size(); i++)
		{
			String loopComponent = (String) tempComponent.get(i);
			String loopType = loopComponent.substring(0, loopComponent.indexOf(":"));
			if(!listCompTypes.contains(loopType)) 
			{
				v_component.remove(loopComponent);
			}
		}
		tempComponent = new Vector();
		Vector newComponent = new Vector();
		tempComponent.addAll(v_component);
		for(int i=0; i<tempComponent.size(); i++)
		{
			String loopComponent = (String) tempComponent.get(i);
			String type = loopComponent.substring(0,loopComponent.indexOf(":"));
			String comp = loopComponent.substring(loopComponent.indexOf(":")+1);
			loopComponent = comp+":"+type;
			newComponent.add(loopComponent);
		}
		v_component.removeAllElements();
		v_component.addAll(newComponent);
	}
	//Application combo
	Vector v_application=new Vector();
	if(selectedComponent!=null && selectedComponent.size()>0)
	{
		selectedCompList=selectedComponent;
	}
	else if(componentsList  != null && componentsList.size() >0)
	{
		 selectedCompList=componentsList;
	}
	//if(er_trgttype!=null && er_trgttype.equalsIgnoreCase("applicationBased"))
	{
		if (s_compType!= null && !selectedCompList.isEmpty())
		{
			if (selectedCompList !=null)
			{
				v_application=new Vector();
				for (int i=0;i<selectedCompList.size();i++)
				{
					Vector v_app=new Vector();
					String server=(String)selectedCompList.get(i);
					String strComponentType = s_compType;
					String strTest = "";
					String compWithTest = reportInfo.getValue("CITRIX_LOGON_SIMULATOR","ComponentsWithTest");
					StringTokenizer testTK = new StringTokenizer(compWithTest,",");
					while(testTK.hasMoreTokens())
					{
						String tempStr = testTK.nextToken();
						String tempTest = tempStr.substring(tempStr.indexOf(COLON)+1);
						tempStr= tempStr.substring(0,tempStr.indexOf(COLON));
						if(tempStr.equalsIgnoreCase(s_compType))
						strTest = tempTest;
					}
					if(listSupportedComponentType!=null && listSupportedComponentType.contains(strComponentType))
					{
						if(erServer!=null)
							server =erServer;
						if(server.indexOf(":")==-1)
						{  
							server+=":NULL:"+strComponentType;
						}
						v_app.addAll(erInfo.getInfosForTest("NULL",strTest,server));
					}
					v_app = ErUtils.formatString(v_app,"$0+$1","$1");
					for (int j=0;j<v_app.size();j++)
					{
						String app=(String)v_app.get(j);
						if (!v_application.contains(app))
						{
							v_application.add(app);
						}
					}
				}
			}
		}
	}
	if(s_compType != null && !s_compType.equals("-1") &&!s_compType.equals("NotApplicable") && aListComponentTemp.contains(s_compType)) 
	{
		if(!s_compType.equals("Host_system")) 
		{
			List removeList = new ArrayList();
			for(int i=0; i<v_component.size(); i++) 
			{
				String v_comp = (String)v_component.get(i);
				if(-1 == v_comp.indexOf(s_compType)) 
				{
					removeList.add(v_comp);
				}
			}
			v_component.removeAll(removeList);
		}
	}
	JSONObject locationsTypeOPtions  = new JSONObject();
	HashMap loct =new HashMap();
	List locationComponent=null;//..
	if(loctnLst!=null && loctnLst.size()>0)
	{
		for(int k=0;k<loctnLst.size();k++)
		{
			String locationsTypeOptionsVar[] = (String[])loctnLst.get(k);
			for(int logT=0;logT<locationsTypeOptionsVar.length;logT++)
			{
				String locationsTypeOptionsVal = locationsTypeOptionsVar[logT];
				if(locationsTypeOptionsVal!=null && locationsTypeOptionsVal.length()>0)
				{
					if(loct.containsKey(locationsTypeOptionsVal))
					{
						String old_val=(String)loct.get(locationsTypeOptionsVal);
						locationComponent=ErUtils.egTokenizer(old_val,",");
						if(!locationComponent.contains(locationsTypeOptionsVar[logT]))
							old_val=old_val+","+locationsTypeOptionsVar[logT];
						loct.put(locationsTypeOptionsVal,(String)old_val);
					}
					else
					{
						loct.put(locationsTypeOptionsVal,locationsTypeOptionsVar[logT]);
					}
				}
			}
		}
	}
	JSONObject jOpt = new JSONObject();
	JSONArray  locationselectOptions = new JSONArray();
	if(loct!=null && loct.size()>0)
	{
		if (loct.size()>1)
		{
			jOpt = new JSONObject();
			jOpt.put("valueField","all");
			jOpt.put("displayField","All");
			locationselectOptions.add(jOpt);
		}
		if (loct.size()>1)
			locationsTypeOPtions.put("selectedLocationsType","all");
		Set locSet = (Set) loct.entrySet();
		Iterator loc_itr = locSet.iterator();
		while (loc_itr.hasNext())
		{
			Map.Entry mapEntry = (Map.Entry) loc_itr.next();
			String locKey = (String) mapEntry.getKey();
			jOpt  = new JSONObject();
			jOpt.put("valueField",loct.get(locKey));
			jOpt.put("displayField",locKey);
			locationselectOptions.add(jOpt);
			if (loct.size()==1 && location==null)
			{
				locationsTypeOPtions.put("selectedLocationsType",loct.get(locKey));
			}
			if(location!=null && location.equalsIgnoreCase((String)loct.get(locKey)))
			{
				locationsTypeOPtions.put("selectedLocationsType",loct.get(locKey));
			}
		}
	}
	else
	{
		locationsTypeOPtions = new JSONObject();
		locationselectOptions = new JSONArray();
		locationsTypeOPtions.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
		locationsTypeOPtions.put("valueField", "-1");
		locationselectOptions.add(locationsTypeOPtions);
	}
	rootJson.put("locationselectOptions",locationsTypeOPtions); 
	rootJson.put("locationCmbo",locationselectOptions); 
	if(location!=null && location.length()>0)
		rootJson.put("selectedLocation",location); 
	if(applicationX!=null && applicationX.length()>0)
		rootJson.put("selectedapplicationX",applicationX); 
		
		String majorValue=request.getParameter("uppermajor");
		String minorValue=request.getParameter("upperminor");
		String criticalValue=request.getParameter("upperCritical");
		String uppermajor_enum=request.getParameter("uppermajor_enum");
		String upperminor_enum=request.getParameter("upperminor_enum");
		String upperCritical_enum=request.getParameter("upperCritical_enum");

		String uppermajor_appl=request.getParameter("uppermajor_appl");
		String upperminor_appl=request.getParameter("upperminor_appl");
		String upperCritical_appl=request.getParameter("upperCritical_appl");
		
		String criticalColor=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","criticalColor");
		String majorColor=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","majorColor");
		String minorColor=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","minorColor");
		
		if(majorValue==null || majorValue.length()==0)
			majorValue=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","majorValue");
		if(minorValue==null || minorValue.length()==0)
			minorValue=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","minorValue");
		if(criticalValue==null || criticalValue.length()==0)
			criticalValue=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","criticalValue");
		if(uppermajor_enum==null || uppermajor_enum.length()==0)
			uppermajor_enum=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","majorValue");
		if(upperminor_enum==null || upperminor_enum.length()==0)
			upperminor_enum=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","minorValue");
		if(upperCritical_enum==null || upperCritical_enum.length()==0)
			upperCritical_enum=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","criticalValue");

		if(uppermajor_appl==null || uppermajor_appl.length()==0)
			uppermajor_appl=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","majorValue");
		if(upperminor_appl==null || upperminor_appl.length()==0)
			upperminor_appl=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","minorValue");
		if(upperCritical_appl==null || upperCritical_appl.length()==0)
			upperCritical_appl=reportInfo.getValue("CITRIX_LOGON_SIMULATOR","criticalValue");
		
		if(criticalColor!=null && criticalColor.indexOf("#")>-1)
		{
			criticalColor = criticalColor.substring(1,criticalColor.length());
			rootJson.put("criticalColor",criticalColor);
		}
		if(majorColor!=null && majorColor.indexOf("#")>-1)
		{
			majorColor = majorColor.substring(1,majorColor.length());
			rootJson.put("majorColor",majorColor);
		}
		if(minorColor!=null && minorColor.indexOf("#")>-1)
		{
			minorColor = minorColor.substring(1,minorColor.length());
			rootJson.put("minorColor",minorColor);
		}
		rootJson.put("uppermajor_enum",uppermajor_enum);
		rootJson.put("upperminor_enum",upperminor_enum);
		rootJson.put("upperCritical_enum",upperCritical_enum);

		rootJson.put("majorValue",majorValue);
		rootJson.put("criticalValue",criticalValue);
		rootJson.put("minorValue",minorValue);

		rootJson.put("uppermajor_appl",uppermajor_appl);
		rootJson.put("upperminor_appl",upperminor_appl);
		rootJson.put("upperCritical_appl",upperCritical_appl);

		HashMap dataList = new HashMap(); 
		HashMap dataListForApp = new HashMap();
		JSONObject logonAvaiMap = new JSONObject();
		JSONObject enumAvaiMap = new JSONObject();
		JSONObject avgDurationMap = new JSONObject();
		HashMap appLaunchSuccessFailAvg = new HashMap();
		JSONObject timelineLgnEnum = new JSONObject();
		JSONObject diffAppDuratn = new JSONObject();
		JSONObject applicationLaunchTime = new JSONObject();
		JSONObject appLaunchAvailLocation = new JSONObject();
		JSONObject totalAppAvail = new JSONObject();
		JSONObject totalAppDura = new JSONObject();
		JSONObject total_appLaunchDonutHealth = new JSONObject();
		ArrayList total_appDonutHealthLegends =  new ArrayList();
		
		JSONObject appLaunchDurationLocation = new JSONObject();
		JSONObject appLaunchDonutHealth = new JSONObject();
		JSONObject appLogonAvail =  new JSONObject();
		JSONObject appLogonDura =  new JSONObject();
		JSONObject appEnumAvail = new JSONObject();
		JSONObject appEnumDura =  new JSONObject();
		JSONObject logondonutHealth =  new JSONObject();
		ArrayList lg_legendDetails =  new ArrayList();
		ArrayList enum_legendDetails =  new ArrayList();
		ArrayList appl_legendDetails =  new ArrayList();
		JSONObject enumDonutHealth =  new JSONObject();
		JSONObject compObj = new JSONObject();
		String queryForTopApps = "";
		JSONObject jObj = new JSONObject();
		JSONArray dataSetter = new JSONArray();
		List colorLst = new ArrayList();
		//long diffDays = 1;
		double diffDays = 1;
		try
		{
			if(request.getParameter("startdate")!=null && request.getParameter("enddate")!=null)
			{
				String s_start_time = request.getParameter("startdate")+" "+s_st_hr+":"+strmin+":00";
				String s_end_time= request.getParameter("enddate")+" "+s_en_hr+":"+enmin+":00";
				SimpleDateFormat formatter = new SimpleDateFormat(currentDateFormat+" HH:mm:ss");
				java.util.Date s_date = formatter.parse(s_start_time);
				java.util.Date e_date = formatter.parse(s_end_time);
				//long diff = e_date.getTime() - s_date.getTime();
				double diff = e_date.getTime() - s_date.getTime();
				diffDays = diff / (24 * 60 * 60 * 1000);
			}
		}
		catch (Exception ve)
		{
			ve.printStackTrace();
		}
		
		JSONObject s1 = new JSONObject();
		JSONObject obj1 = new JSONObject();
		JSONArray jarr = new JSONArray();
		JSONArray xAxisLabel=new JSONArray();
		boolean checkData=false;
		String navi = request.getParameter("isNavigation");
	if((isSubmit != null && isSubmit.equalsIgnoreCase("true")) || thrSch != null && thrSch.equalsIgnoreCase("true")) 
	{
		if(resultMap!=null && resultMap.size()>0)
		{
			if(er_trgttype!=null && er_trgttype.equalsIgnoreCase("locationBased") )
			{
				dataList = (HashMap)resultMap.get("dataList");
				queryForTopApps = "../servlet/com.eg.ErCtxLogonSimulator?&firstpage=true&er_timeline=" + er_timeline+"&isSubmit=true&er_stdate=" + s_st_time + "&er_enddate=" + s_en_time + "&currTime=" +"&select_farm=" + s_farmserver + "&er_excwe=" + excludeweekend +"&er_compType=" + s_compType +"&startmin="+strmin+"&endmin="+enmin+ "&uid=" + loginid+"&startdate="+request.getParameter("startdate")+"&enddate="+request.getParameter("enddate")+"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&userID="+urs+"&timefrom="+timefrom2+"&minfrom="+minfrom2+"&timeto="+timeto2+"&minto="+minto2+"&er_trgttype="+er_trgttype+"&inidate="+currentDateFormat;
				if(appForAgent!=null)
				{
					queryForTopApps+="&appForAgent="+EgURLEncoder.encode(appForAgent,"UTF-8");
				}
			}
			else if(er_trgttype!=null && er_trgttype.equalsIgnoreCase("applicationBased"))
			{
				dataListForApp = (HashMap)resultMap.get("dataListForApp");
				queryForTopApps = "../servlet/com.eg.ErCtxLogonSimulator?&secondpage=true&er_timeline=" + er_timeline + "&isSubmit=true&er_stdate=" + s_st_time + "&er_enddate=" + s_en_time + "&currTime=" +"&select_farm=" + s_farmserver + "&er_excwe=" + excludeweekend +"&er_compType=" + s_compType +"&startmin="+strmin+"&endmin="+enmin+ "&uid=" + loginid+"&startdate="+request.getParameter("startdate")+"&enddate="+request.getParameter("enddate")+"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&userID="+urs+"&timefrom="+timefrom2+"&minfrom="+minfrom2+"&timeto="+timeto2+"&minto="+minto2+"&er_trgttype="+er_trgttype+"&inidate="+currentDateFormat;
				if(fromLoc!=null && fromLoc.equalsIgnoreCase("yes"))
				{
					queryForTopApps+="&fromLoc=yes";
				}
			}
			if(dataList!=null && dataList.size()>0)
			{
				Set dataSet = (Set) dataList.entrySet();
				Iterator data_itr = dataSet.iterator();
				while (data_itr.hasNext())
				{
					Map.Entry mapEntry = (Map.Entry) data_itr.next();
					String key = (String) mapEntry.getKey();
					ArrayList values = (ArrayList) mapEntry.getValue();
					compObj.put(key+"#"+values.size(),values);
				}
			}
			else if (dataListForApp!=null && dataListForApp.size()>0)
			{
				compObj = new JSONObject();
				Set dataSetforApp = (Set) dataListForApp.entrySet();
				Iterator app_data_itr = dataSetforApp.iterator();
				while (app_data_itr.hasNext())
				{
					Map.Entry mapEntry = (Map.Entry) app_data_itr.next();
					String key = (String) mapEntry.getKey();
					ArrayList values = (ArrayList) mapEntry.getValue();
					compObj.put(key+"#"+values.size(),values);
				}
			} 
			resultMap = (Map) session.getAttribute("logon_Details");
			Map summatyMapForApp = (Map) session.getAttribute("locationLogon_Details");
			Map summaryTableApp = null;
			if(er_trgttype!=null && er_trgttype.equalsIgnoreCase("applicationBased"))
			{
				summaryTableApp = (Map) session.getAttribute("summaryTableApp");
				rootJson.put("summaryTableApp", summaryTableApp);
			}
			JSONArray summaryLst = new JSONArray();
			JSONObject ob_1 = new JSONObject();
			JSONObject resLst = new JSONObject();

			//Logon Availability DonutChart starts
			if(resultMap!=null && resultMap.size()>0)
			{
				ob_1.put("totalLogon",(String)resultMap.get("totalLogon"));
				ob_1.put("successLogon",(String)resultMap.get("successLogon"));
				ob_1.put("failLogon",(String)resultMap.get("failLogon"));
				checkData=true;
				Double total_logons = new Double(0);
				total_logons = Double.parseDouble((String)resultMap.get("totalLogon"));
				//System.out.println("total_logons ------ "+total_logons);
				Double succVal = new Double(0);
				if(resultMap.get("successLogon")!=null && !resultMap.get("successLogon").toString().isEmpty())
					succVal= Double.parseDouble((String)resultMap.get("successLogon"));
				double d1 = succVal.doubleValue();
				if (d1>0)
				{
					resLst.put("name","Success");
					resLst.put("y",succVal);
					resLst.put("color", "#33B297");
					dataSetter.add(resLst);
					Double kq = (succVal/total_logons)*100;
					//String Perc = utils.round(kq, 0);
					String Perc = utils.round(kq, 2);//..
					rootJson.put("summSucc", "Success"+" ("+Perc+"%)");
					rootJson.put("succColor", "#33B297");
				}
				resLst = new JSONObject();
				Double failVal = new Double(0);
				if(resultMap.get("failLogon")!=null && !resultMap.get("failLogon").toString().isEmpty())
					failVal= Double.parseDouble((String)resultMap.get("failLogon"));
				double d2 = failVal.doubleValue();
				if (d2>0)
				{
					resLst.put("name","Failure");
					resLst.put("y",failVal);
					resLst.put("color", "#EE7773");
					dataSetter.add(resLst);
					Double kq = (failVal/total_logons)*100;
				//	String Perc = utils.round(kq, 0);
					String Perc = utils.round(kq, 2);//..
					rootJson.put("summFail", "Failure"+" ("+Perc+"%)");
					rootJson.put("failColor", "#EE7773"); 
				}
				JSONObject obj_d = new JSONObject();
				JSONArray jarr_d = new JSONArray();
				obj_d.put("data", dataSetter);
				jarr_d.add(obj_d);
				JSONObject donutChart = new JSONObject();
				donutChart.put("DataSet", jarr_d);
				//donutChart.put("borderWidth", "true");
				donutChart.put("pieSize", "100%");
				donutChart.put("innerSize", "60%");
				donutChart.put("chartHeight", "94");
				donutChart.put("chartWidth", "94");
				donutChart.put("cType", "donut");
				donutChart.put("chartType", "donut");
				donutChart.put("forLogOnSimulator", "yes");
				rootJson.put("donutChart", donutChart);
			}
			jObj.put("summaryList_1",ob_1);
			//Logon Availability DonutChart ends
			if(summatyMapForApp!=null && summatyMapForApp.size()>0)
			{
				dataSetter = new JSONArray();
				resLst = new JSONObject();
				ob_1 = new JSONObject();
				Double logons_total = new Double(0);
				logons_total = Double.parseDouble((String)summatyMapForApp.get("totalLogon"));
				ob_1.put("totalLogon",(String)summatyMapForApp.get("totalLogon"));
				ob_1.put("successLogon",(String)summatyMapForApp.get("successLogon"));
				ob_1.put("failLogon",(String)summatyMapForApp.get("failLogon"));
				if(enableEnumulation)
					ob_1.put("failedEnum",(String)summatyMapForApp.get("failedEnum"));
				ob_1.put("failedSimu",(String)summatyMapForApp.get("failedSimu"));
				ob_1.put("failedApp",(String)summatyMapForApp.get("failedApp"));
				checkData=true;
				Double succVal= Double.parseDouble((String)summatyMapForApp.get("successLogon")); 
				double d1 = succVal.doubleValue();
				if (d1>0)
				{
					resLst.put("name","Success");
					resLst.put("y",succVal);
					resLst.put("color", "#33B297");
					dataSetter.add(resLst);
					Double kq = (succVal/logons_total)*100;
					//String Perc = utils.round(kq, 0);
					String Perc = utils.round(kq, 2);//..
					rootJson.put("donSucc", "Successful Simulations"+" ("+Perc+"%)");
					rootJson.put("succLegn", "#33B297");
				}
				resLst = new JSONObject();
				Double failVal= Double.parseDouble((String)summatyMapForApp.get("failLogon")); 
				double d2 = failVal.doubleValue();
				if (d2>0)
				{
					resLst.put("name","Failure");
					resLst.put("y",failVal);
					resLst.put("color", "#EE7773");  
					dataSetter.add(resLst);
					Double kq = (failVal/logons_total)*100;
					//String Perc = utils.round(kq, 0);
					String Perc = utils.round(kq, 2);//..
					rootJson.put("donFail", "Failed Web Logons"+" ("+Perc+"%)");
					rootJson.put("failLegn", "#EE7773");
				}
				resLst = new JSONObject();
				if(enableEnumulation){
					Double fail_enum= Double.parseDouble((String)summatyMapForApp.get("failedEnum")); 
					double d3 = fail_enum.doubleValue();
					if (d3>0)
					{
						resLst.put("name","failedEnum");
						resLst.put("y",fail_enum);
						resLst.put("color","#F8ABA7");
						dataSetter.add(resLst);
						Double kq = (fail_enum/logons_total)*100;
						//String Perc = utils.round(kq, 0);
						String Perc = utils.round(kq, 2);//..
						rootJson.put("donEnum", "Failed Enumerations"+" ("+Perc+"%)");
						rootJson.put("enumLegn", "#F8ABA7");
					}
				}
				//if(request.getParameter("isFourthPage")!=null && !request.getParameter("isFourthPage").equals("true") && (request.getParameter("isFifthPage")!=null && !request.getParameter("isFifthPage").equals("true")) || (applicationName!=null && !applicationName.equalsIgnoreCase("all") && er_trgttype.equalsIgnoreCase("applicationBased")) || request.getParameter("checkFull")!=null && request.getParameter("byName")!=null)
				if(request.getParameter("isFifthPage") == null || (request.getParameter("isFifthPage")!=null && !request.getParameter("isFifthPage").equals("true")) || (applicationName!=null && !applicationName.equalsIgnoreCase("all") && er_trgttype.equalsIgnoreCase("applicationBased")) || request.getParameter("checkFull")!=null && request.getParameter("byName")!=null)
				{
					resLst = new JSONObject();
					Double fail_simu= Double.parseDouble((String)summatyMapForApp.get("failedSimu")); 
					double d4 = fail_simu.doubleValue();
					/*if (d4>0)
					{
						resLst.put("name","failedSimulation");
						resLst.put("y",fail_simu);
						resLst.put("color", "#DE4640");
						dataSetter.add(resLst);
						Double kq = (fail_simu/logons_total)*100;
						String Perc = utils.round(kq, 0);
						rootJson.put("donSimu", "Failure Simulations"+" ("+Perc+"%)");
						rootJson.put("simuLegn", "#DE4640");
					}*/
					if ((String)summatyMapForApp.get("failedApp")!=null)
					{
						resLst = new JSONObject();
						Double fail_app= Double.parseDouble((String)summatyMapForApp.get("failedApp")); 
						double d5 = fail_app.doubleValue();
						if (d5>0)
						{
							resLst.put("name","failedApplication");
							resLst.put("y",fail_app);
							resLst.put("color", "#F7BD42");
							dataSetter.add(resLst);
							Double kq = (fail_app/logons_total)*100;
							//String Perc = utils.round(kq, 0);
							String Perc = utils.round(kq, 2);//..
							rootJson.put("donfApp", "Failed Applications/Desktops"+" ("+Perc+"%)");
							rootJson.put("fAppLegn", "#F7BD42");
						}
					}
				}
				JSONObject obj_d = new JSONObject();
				JSONArray jarr_d = new JSONArray();
				obj_d.put("data", dataSetter);
				jarr_d.add(obj_d);
				JSONObject donutChartforApp = new JSONObject();
				donutChartforApp.put("DataSet", jarr_d);
				//donutChartforApp.put("borderWidth", "true");
				donutChartforApp.put("pieSize", "100%");
				donutChartforApp.put("innerSize", "64%");
				donutChartforApp.put("chartHeight", "94");
				donutChartforApp.put("chartWidth", "94");
				donutChartforApp.put("cType", "donut");
				donutChartforApp.put("forLogOnSimulator", "yes");
				donutChartforApp.put("chartType", "donut");
				rootJson.put("donutChartforApp", donutChartforApp);
			}
			jObj.put("summaryList",ob_1);
			resultMap = (Map) session.getAttribute("locationResults");
			JSONObject ob_2 = new JSONObject();
			if(resultMap!=null && resultMap.size()>0)
			{
				ob_2.put("avgLogonAvail",resultMap.get("avgLogonAvail"));
				if(enableEnumulation)
					ob_2.put("avgEnumAvail",resultMap.get("avgEnumAvail"));
				ob_2.put("avgAppLaunchAvail",resultMap.get("avgAppLaunchAvail"));
			}
			jObj.put("availabilityList",ob_2);
		}
		if(resultMap!=null)
		{
			logonAvaiMap = (JSONObject)resultMap.get("LogonAvailability");
			enumAvaiMap = (JSONObject)resultMap.get("EnumAvailability");
			appLaunchSuccessFailAvg = (HashMap)resultMap.get("appLaunchSuccessFailAvg");
			avgDurationMap = (JSONObject)resultMap.get("avg_Duarations");
			timelineLgnEnum = (JSONObject)resultMap.get("timelineChart_lgn_enum");
			diffAppDuratn = (JSONObject)resultMap.get("diffAppDuraLaunches");
			appLogonAvail = (JSONObject)resultMap.get("appLogonAvail");
			appLogonDura = (JSONObject)resultMap.get("appLogonDura");
			logondonutHealth = (JSONObject)resultMap.get("logonDonutHealth");
			lg_legendDetails = (ArrayList)resultMap.get("logonDonutHealthLegends");
			appEnumAvail = (JSONObject)resultMap.get("appEnumAvail");
			appEnumDura = (JSONObject)resultMap.get("appEnumDura");
			enum_legendDetails = (ArrayList)resultMap.get("enumDonutHealthLegends");
			enumDonutHealth = (JSONObject)resultMap.get("enumDonutHealth");
			applicationLaunchTime = (JSONObject)resultMap.get("applicationLaunchTime");
			appLaunchAvailLocation = (JSONObject)resultMap.get("appLaunchAvailLocation");
			totalAppAvail = (JSONObject)resultMap.get("totalAppAvail");
			totalAppDura = (JSONObject)resultMap.get("totalAppDura");
			appLaunchDurationLocation = (JSONObject)resultMap.get("appLaunchDurationLocation");
			appLaunchDonutHealth = (JSONObject)resultMap.get("appLaunchDonutHealth");
			appl_legendDetails = (ArrayList)resultMap.get("appDonutHealthLegends");
			total_appDonutHealthLegends = (ArrayList)resultMap.get("total_appDonutHealthLegends");
			total_appLaunchDonutHealth = (JSONObject)resultMap.get("total_appLaunchDonutHealth");
		}
		// Logon Availabilty Stacked BarChart starts
		if(logonAvaiMap!=null && logonAvaiMap.size()>0)
		{
			String availUrl="";
			colorLst = new ArrayList();
			colorLst.add("#33B297");  
			colorLst.add("#EE7773");
			checkData=true;
			jarr = new JSONArray();
			xAxisLabel=new JSONArray();
			List namelst = new ArrayList();
			namelst.add("Success");
			namelst.add("Failure");
			JSONArray valuLst  = new JSONArray();
			JSONObject logonAvaiStBar = new JSONObject();
			String startDates = null;
			String endDates = null;
			EgTimeZoneConverter startsTime = null;
			EgTimeZoneConverter endsTime = null;
			String strKeyy = null;
			for(int p=0;p<namelst.size();p++)
			{
				obj1 = new JSONObject();
				dataSetter = new JSONArray();
				Iterator itred = logonAvaiMap.keySet().iterator();
				while (itred.hasNext())
				{
					s1 = new JSONObject();
					String keyy = (String) itred.next();
					valuLst=(JSONArray)logonAvaiMap.get(keyy);
					if(valuLst == null || valuLst.size() ==0 )
						continue;
					if(keyy!=null && keyy.indexOf("#")>-1)
					{
						strKeyy = keyy.substring(keyy.indexOf("#")+1);
						keyy = keyy.substring(0, keyy.indexOf("#"));
					}
					if(diffDays>1 && diffDays<=7)
					{
						String splKey = DateUtil.changeDateFormat(keyy,"yyyy-MM-dd",modifiedFormat);
						xAxisLabel.add(splKey);
					}
					else
					{
						xAxisLabel.add(keyy);
					}
					if(strKeyy!=null && strKeyy.indexOf("|")>-1)
					{
						StringTokenizer stTokens = new StringTokenizer(strKeyy,"|");
						startDates = stTokens.nextToken();
						if(stTokens.hasMoreTokens())
							endDates = stTokens.nextToken();
					}
					else
					{
						startDates = endDates = strKeyy;
					}
					if(diffDays > 1)
					{
						startDates = DateUtil.changeDateFormat(startDates,"dd/MM/yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss");
						endDates = DateUtil.changeDateFormat(endDates,"dd/MM/yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss");
					}
					String strTempStartDate = null;
					String strTempEndDate = null;
					String strTempStartHr = null;
					String strTempEndHr = null;
					String strTempStartMin = null;
					String strTempEndMin = null;
					boolean bFlag = false;
					if(startDates!=null && startDates.indexOf(" ")>-1 && startDates.indexOf(":")>-1 && endDates!=null && endDates.indexOf(" ")>-1 && endDates.indexOf(":")>-1)
					{
						bFlag = true;
					}
					if(diffDays <= 1)
					{
						if(!DateUtil.isDate(startDates, currentDateFormat))
						{
							startDates = DateUtil.changeDateFormat(startDates,"dd/MM/yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss");
						}
						if(!DateUtil.isDate(endDates, currentDateFormat))
						{
							endDates = DateUtil.changeDateFormat(endDates,"dd/MM/yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss");
						} 
						startsTime = new EgTimeZoneConverter(startDates,this_user,true);
						endsTime = new EgTimeZoneConverter(endDates,this_user,true);
						strTempStartDate = (String)startsTime.getDate(false);
						strTempEndDate = (String)endsTime.getDate(false);
						strTempStartHr = startsTime.getHour();
						strTempEndHr = endsTime.getHour();
						strTempStartMin = startsTime.getMinute();
						strTempEndMin = endsTime.getMinute();
					}
					else
					{ 
						if(bFlag)
						{
							strTempStartDate = startDates.substring(0,startDates.lastIndexOf(" "));
							strTempEndDate = endDates.substring(0,endDates.lastIndexOf(" "));
							strTempStartHr = startDates.substring(startDates.lastIndexOf(" ")+1,startDates.indexOf(":"));
							strTempEndHr = endDates.substring(endDates.lastIndexOf(" ")+1,endDates.indexOf(":"));


							//strTempStartDate = startDates.substring(0,startDates.indexOf(" "));
							//strTempEndDate = endDates.substring(0,endDates.indexOf(" "));
							//strTempStartHr = startDates.substring(startDates.indexOf(" ")+1,startDates.indexOf(":"));
							//strTempEndHr = endDates.substring(endDates.indexOf(" ")+1,endDates.indexOf(":"));
							strTempStartMin = startDates.substring(startDates.indexOf(":")+1,startDates.lastIndexOf(":"));
							strTempEndMin = endDates.substring(endDates.indexOf(":")+1,endDates.lastIndexOf(":"));
						}
					}
					s1.put("y", valuLst.get(p));
					//availUrl="../reporter/ErCtxLogonSimulator.jsp?&isFourthPage=true&isFifthPage=false&firstpage=true&isSubmit=true&er_trgttype=locationBased&er_location="+location+"&er_timeline="+ er_timeline+"&er_stdate=" + s_st_time + "&er_enddate=" + s_en_time +"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&startmin="+strmin+"&endmin="+ enmin+"&startdate="+request.getParameter("startdate")+"&enddate="+request.getParameter("enddate")+"&timefrom="+timefrom2+"&minfrom="+minfrom2+"&timeto="+timeto2+"&minto="+minto2+"&inidate="+currentDateFormat+"&er_compType="+s_compType+"&er_component="+selectedTempComponent+"&isNavigation=false&isNeedBack="+isNeedBack;
					availUrl="../reporter/ErCtxLogonSimulator.jsp?&isFourthPage=true&isFifthPage=false&firstpage=true&isSubmit=true&er_trgttype=locationBased&er_location="+location+"&er_timeline=Any&er_stdate=" + strTempStartDate + "&er_enddate=" + strTempEndDate +"&starthr="+strTempStartHr+"&endhr="+strTempEndHr+"&startmin="+strTempStartMin+"&endmin="+ strTempEndMin+"&startdate="+strTempStartDate+"&enddate="+strTempEndDate+"&timefrom="+timefrom2+"&minfrom="+minfrom2+"&timeto="+timeto2+"&minto="+minto2+"&inidate="+currentDateFormat+"&er_compType="+s_compType+"&er_component="+selectedTempComponent+"&isNavigation=false&isNeedBack="+isNeedBack;
					//prakash
					availUrl += "&userID="+urs;
					//
					if(appForAgent!=null)
					{
						availUrl+="&appForAgent="+EgURLEncoder.encode(appForAgent,"UTF-8");
					}
					s1.put("url",availUrl);
					dataSetter.add(s1);
				}
				obj1.put("name", namelst.get(p));
				obj1.put("color", colorLst.get(p));
				obj1.put("data", dataSetter);
				jarr.add(obj1);
			}
			logonAvaiStBar.put("DataSet", jarr);
			logonAvaiStBar.put("legend", "true");
			logonAvaiStBar.put("isSimulator", "true");
			logonAvaiStBar.put("chartType", "column");
			logonAvaiStBar.put("inside", true);
			logonAvaiStBar.put("chartSubType", "stacked");
			logonAvaiStBar.put("xAxisLabel",xAxisLabel);
			logonAvaiStBar.put("chartHeight", "300");
			logonAvaiStBar.put("chartWidth", "300");
			logonAvaiStBar.put("yAxisLabel","Percentage(%)");
			logonAvaiStBar.put("xLabel","Percentage(%)");
			if(diffDays<=1)
			{
				logonAvaiStBar.put("xAxisLabelText","Hour(s)");
				logonAvaiStBar.put("yLabel","Hour(s)");
				logonAvaiStBar.put("yVal",new Integer(35));
			}
			else if(diffDays>1 && diffDays<=7)
			{
				logonAvaiStBar.put("xAxisLabelText","Day(s)");
				logonAvaiStBar.put("yLabel","Day(s)");
				logonAvaiStBar.put("yVal",new Integer(35));
			}
			else if(diffDays>7 && diffDays<=30)
			{
				logonAvaiStBar.put("xAxisLabelText","Week(s)");  
				logonAvaiStBar.put("yLabel","Week(s)"); 
				logonAvaiStBar.put("yVal",new Integer(58));
			}
			else
			{
				logonAvaiStBar.put("xAxisLabelText","Month(s)");
				logonAvaiStBar.put("yLabel","Month(s)");
				logonAvaiStBar.put("yVal",new Integer(40));
			}
			logonAvaiStBar.put("ymax",new Integer(100));
			logonAvaiStBar.put("endOnTick",new Boolean(true));
			logonAvaiStBar.put("drildown","sametab");
			logonAvaiStBar.put("isDataLabelEnabled",false); 
			logonAvaiStBar.put("cType","stackedBar");
			logonAvaiStBar.put("barAlignment","vertical");
			logonAvaiStBar.put("forLogOnSimulator","yes");
			//prakash for setEndOnTick to false
			logonAvaiStBar.put("percentEnableTick",true);
			logonAvaiStBar.put("showLastLabelForLogon",true);
			logonAvaiStBar.put("forLogonSimulatorLegend",true);
			//

			rootJson.put("logonAvaiStBar", logonAvaiStBar);
			rootJson.put("logonAvaiStBar_Url", availUrl);
		}
		// Logon Availabilty Stacked BarChart ends

		//Application Enumeration Availabilty Stacked BarChart starts
		if(enumAvaiMap!=null && enumAvaiMap.size()>0)
		{
			String enumUrl = "";
			colorLst = new ArrayList();
			colorLst.add("#33B297");  
			colorLst.add("#EE7773");
			checkData=true;
			jarr = new JSONArray();
			xAxisLabel=new JSONArray();
			List namelst = new ArrayList();
			namelst.add("Success");
			namelst.add("Failure");
			JSONArray valuLst  = new JSONArray();
			JSONObject enumAvaiStBar = new JSONObject();
			for(int p=0;p<namelst.size();p++)
			{
				obj1 = new JSONObject();
				dataSetter = new JSONArray();
				Iterator itred = enumAvaiMap.entrySet().iterator();
				while (itred.hasNext())
				{
					s1 = new JSONObject();
					Map.Entry pairing = (Map.Entry) itred.next();
					String keyy = (String) pairing.getKey();
					valuLst = (JSONArray)pairing.getValue();
					if(diffDays>1 && diffDays<=7)
					{
						String splKey = DateUtil.changeDateFormat(keyy,"yyyy-MM-dd",modifiedFormat);
						xAxisLabel.add(splKey);
					}
					else
					{
						xAxisLabel.add(keyy);
					}
					if(valuLst!=null && valuLst.size()>0)
						s1.put("y", valuLst.get(p));
					enumUrl = "../reporter/ErCtxLogonSimulator.jsp?&isFifthPage=true&isFourthPage=false&firstpage=true&isSubmit=true&er_trgttype=locationBased"+"&er_timeline="+ er_timeline+"&inidate="+currentDateFormat+"&er_compType="+s_compType+"&er_location="+location+"&er_stdate=" + s_st_time + "&er_enddate=" + s_en_time +"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&startmin="+strmin+"&endmin="+ enmin+"&startdate="+request.getParameter("startdate")+"&enddate="+request.getParameter("enddate")+"&timefrom="+timefrom2+"&minfrom="+minfrom2+"&timeto="+timeto2+"&minto="+minto2+"&er_component="+selectedTempComponent+"&isNavigation=false&isNeedBack="+isNeedBack;
					//
					if(appForAgent!=null)
					{
						enumUrl+="&appForAgent="+EgURLEncoder.encode(appForAgent,"UTF-8");
					}
					s1.put("url",enumUrl);
					dataSetter.add(s1);
				}
				obj1.put("name", namelst.get(p));
				obj1.put("color", colorLst.get(p));
				obj1.put("data", dataSetter);
				jarr.add(obj1);
			}
			enumAvaiStBar.put("DataSet", jarr);
			enumAvaiStBar.put("legend", "true");
			enumAvaiStBar.put("isSimulator", "true");
			enumAvaiStBar.put("chartType", "column");
			enumAvaiStBar.put("inside", true);
			enumAvaiStBar.put("chartSubType", "stacked");
			if(diffDays<=1)
			{
				enumAvaiStBar.put("xAxisLabelText","Hour(s)");
				enumAvaiStBar.put("yLabel","Hour(s)");
				enumAvaiStBar.put("yVal",new Integer(35));
			}
			else if(diffDays>1 && diffDays<=7)
			{
				enumAvaiStBar.put("xAxisLabelText","Day(s)");
				enumAvaiStBar.put("yLabel","Day(s)");
				enumAvaiStBar.put("yVal",new Integer(35));
			}
			else if(diffDays>7 && diffDays<=30)
			{
				enumAvaiStBar.put("xAxisLabelText","Week(s)");
				enumAvaiStBar.put("yLabel","Week(s)");
				enumAvaiStBar.put("yVal",new Integer(58));
			}
			else
			{
				enumAvaiStBar.put("xAxisLabelText","Month(s)");
				enumAvaiStBar.put("yLabel","Month(s)");
				enumAvaiStBar.put("yVal",new Integer(40));
			}
			enumAvaiStBar.put("xAxisLabel",xAxisLabel);
			enumAvaiStBar.put("chartHeight", "300");
			enumAvaiStBar.put("chartWidth", "300");
			enumAvaiStBar.put("ymax",new Integer(100));
			enumAvaiStBar.put("endOnTick",new Boolean(true));
			enumAvaiStBar.put("isDataLabelEnabled",false); 
			enumAvaiStBar.put("drildown","sametab");
			enumAvaiStBar.put("cType", "stackedBar");
			enumAvaiStBar.put("barAlignment","vertical");
			enumAvaiStBar.put("forLogOnSimulator","yes");
			enumAvaiStBar.put("yAxisLabel","Percentage (%)");
			enumAvaiStBar.put("xLabel","Percentage(%)");
			//prakash for allowing setendOnTick
			enumAvaiStBar.put("percentEnableTick",true);
			enumAvaiStBar.put("showLastLabelForLogon",true);
			enumAvaiStBar.put("forLogonSimulatorLegend",true);
			//
			rootJson.put("enumAvai_graphMap", enumAvaiStBar);
			rootJson.put("enumUrl", enumUrl);
		}
		//Application Enumeration Availabilty Stacked BarChart ends

		if(appLaunchSuccessFailAvg!=null && appLaunchSuccessFailAvg.size()>0)
		{
			String urlTemp ="";
			colorLst = new ArrayList();
			colorLst.add("#33B297");  
			colorLst.add("#EE7773");
			checkData=true;
			jarr = new JSONArray();
			xAxisLabel=new JSONArray();
			List namelst = new ArrayList();
			namelst.add("Success");
			namelst.add("Failure");
			ArrayList valuLst  = new ArrayList();
			JSONObject appSuFaAvg = new JSONObject();
			for(int p=0;p<namelst.size();p++)
			{
				obj1 = new JSONObject();
				JSONObject dataLabels  = new JSONObject();
				dataSetter = new JSONArray();
				Iterator itred = appLaunchSuccessFailAvg.entrySet().iterator();
				while (itred.hasNext())
				{
					s1 = new JSONObject();
					Map.Entry pairing = (Map.Entry) itred.next();
					valuLst = (ArrayList)pairing.getValue();
					String appNames = (String)pairing.getKey();
					int x = Integer.parseInt((String)valuLst.get(p));
					s1.put("y", new Integer((String)valuLst.get(p)));
					xAxisLabel.add(appNames);
					if(x>15) 
					{
					}
					else
					{
						dataLabels.put("enabled",false);
						s1.put("dataLabels",dataLabels);
					}
					urlTemp = "../reporter/ErCtxLogonSimulator.jsp?&isThirdPage=true&secondpage=true&isSubmit=true&er_trgttype=applicationBased&er_applicationX="+EgURLEncoder.encode(appNames,"UTF-8")+"&er_timeline="+ er_timeline+"&er_stdate=" + s_st_time + "&er_enddate=" + s_en_time +"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&startmin="+strmin+"&endmin="+ enmin+"&startdate="+request.getParameter("startdate")+"&enddate="+request.getParameter("enddate")+"&timefrom="+timefrom2+"&minfrom="+minfrom2+"&timeto="+timeto2+"&minto="+minto2+"&inidate="+currentDateFormat+"&er_compType="+s_compType+"&er_component="+selectedTempComponent+"&isBack=true&isNavigation=false&fromLoc=yes";
					//+"&appForAgent="+appForAgent;
					if(appForAgent!=null)
					{
						urlTemp+="&appForAgent="+EgURLEncoder.encode(appForAgent,"UTF-8");
					}
					s1.put("url",urlTemp);
					dataSetter.add(s1);
				}
				obj1.put("name", namelst.get(p));
				obj1.put("color", colorLst.get(p));
				obj1.put("data", dataSetter);
				jarr.add(obj1);
			}
			appSuFaAvg.put("DataSet", jarr);
			appSuFaAvg.put("legend", "true");
			appSuFaAvg.put("inside", true);
			appSuFaAvg.put("insidePad", "true");
			appSuFaAvg.put("isSimulator", "true");
			appSuFaAvg.put("chartType", "bar");
			appSuFaAvg.put("chartSubType", "stacked");
			appSuFaAvg.put("xAxisLabel",xAxisLabel);
			appSuFaAvg.put("yAxisLabel","Percentage (%)");
			appSuFaAvg.put("xAxisLabelText","Application(s)/Desktop(s)");
			appSuFaAvg.put("xLabel","Percentage(%)");
			appSuFaAvg.put("yLabel","Application(s)");
			appSuFaAvg.put("chartHeight", "300");
			appSuFaAvg.put("chartWidth", "300");
			appSuFaAvg.put("drildown","sametab");
			appSuFaAvg.put("xmax",new Integer(100));
			appSuFaAvg.put("endOnTick",new Boolean(false));
			appSuFaAvg.put("cType", "stackedBar");
			appSuFaAvg.put("barAlignment","horizontal");
			//prakash for giving max value
			appSuFaAvg.put("forLogonSimulatorLegend",true);
			//
			rootJson.put("appSuFaAvg", appSuFaAvg);
			rootJson.put("appUrl", urlTemp);
		}
		//Application Launches success fail Stacked BarChart ends

		//Logon Duration, Application Enumeration Duration, Application Launch PieChart starts
		if(avgDurationMap!=null && avgDurationMap.size()>0)
		{
			checkData=true;
			ArrayList colorLstforPie = new ArrayList();
			colorLstforPie.add("#D1E188");
			colorLstforPie.add("#0093D9");
			colorLstforPie.add("#616161");
			s1 = new JSONObject();
			jarr = new JSONArray();
			JSONArray legend_jarr = new JSONArray();
			obj1 = new JSONObject();
			dataSetter = new JSONArray();
			Iterator itred = avgDurationMap.entrySet().iterator();
			int c1=0;
			while (itred.hasNext())
			{
				Map.Entry pairing = (Map.Entry) itred.next();
				legend_jarr.add(pairing.getKey());
				s1.put("name", pairing.getKey());
				s1.put("color", colorLstforPie.get(c1++));
				if((String) pairing.getValue()!=null)
					s1.put("y", new Double((String) pairing.getValue()));
				dataSetter.add(s1);
			}
			obj1.put("data", dataSetter);
			jarr.add(obj1);
			JSONObject avgDurationPie = new JSONObject();
			avgDurationPie.put("DataSet", jarr);
			avgDurationPie.put("pieLabels", legend_jarr);
			avgDurationPie.put("legend", "true");
			avgDurationPie.put("enableTooltpPercent", "true");
			avgDurationPie.put("chartType", "pie");
			avgDurationPie.put("enable_Format", "simulator");
			avgDurationPie.put("chartHeight", "260");
			//avgDurationPie.put("chartWidth", "487");
			avgDurationPie.put("chartWidth", "450");
			avgDurationPie.put("pieSize", "90%");
			avgDurationPie.put("isDataLabelEnabled",true); 
			avgDurationPie.put("cType", "pie");
			rootJson.put("avgDurationPie", avgDurationPie);
		}
		//Logon Duration, Application Enumeration Duration, Application Launch PieChart ends

		//Timeline Chart for Logon Vs Enumeration starts
		if(timelineLgnEnum!=null && timelineLgnEnum.size()>0)
		{
			checkData=true;
			rootJson.put("timlinSuccFailAvg", timelineLgnEnum);
		}

		 //Application Launch Time Bar and Spline Chart starts
		if(diffAppDuratn!=null && diffAppDuratn.size()>0) 
		{
			checkData=true;
			rootJson.put("diffAppDuratn", diffAppDuratn);
		}

		//Timeline Chart for Application Launch Vs Time starts
		if(applicationLaunchTime!=null && applicationLaunchTime.size()>0) 
		{
			checkData=true;
			rootJson.put("applicationLaunchTime", applicationLaunchTime);
		}

		if(appLaunchAvailLocation!=null && appLaunchAvailLocation.size()>0) 
		{
			checkData=true;
			rootJson.put("appLaunchAvailLocation", appLaunchAvailLocation); 
		} 
		if(totalAppAvail!=null && totalAppAvail.size()>0) 
		{
			checkData=true;
			rootJson.put("totalAppAvail", totalAppAvail); 
		} 
		if(totalAppDura!=null && totalAppDura.size()>0) 
		{
			checkData=true;
			rootJson.put("totalAppDura", totalAppDura); 
		} 
		if(total_appLaunchDonutHealth!=null && total_appLaunchDonutHealth.size()>0) 
		{
			checkData=true;
			rootJson.put("total_appLaunchDonutHealth", total_appLaunchDonutHealth); 
		}
		if(total_appDonutHealthLegends!=null && total_appDonutHealthLegends.size()>0) 
		{
			checkData=true; 
			for(int q=0;q<total_appDonutHealthLegends.size();q++)
			{
				String sepLegend = (String)total_appDonutHealthLegends.get(q);
				String stage = sepLegend.substring(0,sepLegend.indexOf("-"));
				String numbr = sepLegend.substring(sepLegend.indexOf("-")+1,sepLegend.length());
				if(stage.equalsIgnoreCase("Critical"))
				{
					rootJson.put("tot_app_Critical", numbr);
				}
				if(stage.equalsIgnoreCase("Major"))
				{
					rootJson.put("tot_app_Major", numbr);
				}
				if(stage.equalsIgnoreCase("Minor"))
				{
					rootJson.put("tot_app_Minor", numbr);
				}
				if(stage.equalsIgnoreCase("Normal"))
				{
					rootJson.put("tot_app_Normal", numbr);
				}
				if(stage.equalsIgnoreCase("Unkown"))
				{
					rootJson.put("tot_app_Unkown", numbr);
				}
			}
		}
		if(appLaunchDurationLocation!=null && appLaunchDurationLocation.size()>0) 
		{
			checkData=true;
			rootJson.put("appLaunchDurationLocation", appLaunchDurationLocation); 
		}
		if(appLaunchDonutHealth!=null && appLaunchDonutHealth.size()>0) 
		{
			checkData=true;
			rootJson.put("appLaunchDonutHealth", appLaunchDonutHealth); 
		}
		if(appLogonAvail!=null && appLogonAvail.size()>0) 
		{
			checkData=true;
			rootJson.put("appLogonAvail", appLogonAvail);
		}
		if(appLogonDura!=null && appLogonDura.size()>0) 
		{
			checkData=true;
			rootJson.put("appLogonDura", appLogonDura);
		}
		if(appEnumAvail!=null && appEnumAvail.size()>0) 
		{
			checkData=true;
			rootJson.put("appEnumAvail", appEnumAvail);
		}
		if(appEnumDura!=null && appEnumDura.size()>0) 
		{
			checkData=true;
			rootJson.put("appEnumDura", appEnumDura);
		} 
		if(logondonutHealth!=null && logondonutHealth.size()>0) 
		{
			checkData=true;
			rootJson.put("logonDonutHealth", logondonutHealth);
		}
		if(lg_legendDetails!=null && lg_legendDetails.size()>0)
		{
			for(int q=0;q<lg_legendDetails.size();q++)
			{
				String sepLegend = (String)lg_legendDetails.get(q);
				String stage = sepLegend.substring(0,sepLegend.indexOf("-"));
				String numbr = sepLegend.substring(sepLegend.indexOf("-")+1,sepLegend.length());
				if(stage.equalsIgnoreCase("Critical"))
				{
					rootJson.put("lg_Critical", numbr);
				}
				if(stage.equalsIgnoreCase("Major"))
				{
					rootJson.put("lg_Major", numbr);
				}
				if(stage.equalsIgnoreCase("Minor"))
				{
					rootJson.put("lg_Minor", numbr);
				}
				if(stage.equalsIgnoreCase("Normal"))
				{
					rootJson.put("lg_Normal", numbr);
				}
				if(stage.equalsIgnoreCase("Unkown"))
				{
					rootJson.put("lg_Unkown", numbr);
				}
			}
		}
		if(enumDonutHealth!=null && enumDonutHealth.size()>0) 
		{
			checkData=true;
			rootJson.put("enumDonutHealth", enumDonutHealth);
		}
		if(enum_legendDetails!=null && enum_legendDetails.size()>0)
		{
			for(int q=0;q<enum_legendDetails.size();q++)
			{
				String sepLegend = (String)enum_legendDetails.get(q);
				String stage = sepLegend.substring(0,sepLegend.indexOf("-"));
				String numbr = sepLegend.substring(sepLegend.indexOf("-")+1,sepLegend.length());
				if(stage.equalsIgnoreCase("Critical"))
				{
					rootJson.put("enum_Critical", numbr);
				}
				if(stage.equalsIgnoreCase("Major"))
				{
					rootJson.put("enum_Major", numbr);
				}
				if(stage.equalsIgnoreCase("Minor"))
				{
					rootJson.put("enum_Minor", numbr);
				}
				if(stage.equalsIgnoreCase("Normal"))
				{
					rootJson.put("enum_Normal", numbr);
				}
				if(stage.equalsIgnoreCase("Unkown"))
				{
					rootJson.put("enum_Unkown", numbr);
				}
			}
		} 
		if(appl_legendDetails!=null && appl_legendDetails.size()>0)
		{
			for(int q=0;q<appl_legendDetails.size();q++)
			{
				String sepLegend = (String)appl_legendDetails.get(q);
				String stage = sepLegend.substring(0,sepLegend.indexOf("-"));
				String numbr = sepLegend.substring(sepLegend.indexOf("-")+1,sepLegend.length());
				if(stage.equalsIgnoreCase("Critical"))
				{
					rootJson.put("app_Critical", numbr);
				}
				if(stage.equalsIgnoreCase("Major"))
				{
					rootJson.put("app_Major", numbr);
				}
				if(stage.equalsIgnoreCase("Minor"))
				{
					rootJson.put("app_Minor", numbr);
				}
				if(stage.equalsIgnoreCase("Normal"))
				{
					rootJson.put("app_Normal", numbr);
				}
				if(stage.equalsIgnoreCase("Unkown"))
				{
					rootJson.put("app_Unkown", numbr);
				}
			}
		}
		if(er_trgttype!=null && er_trgttype.equalsIgnoreCase("locationBased"))
		{
			jObj.put("hrefUrl",queryForTopApps);
		}
		else if(er_trgttype!=null && er_trgttype.equalsIgnoreCase("applicationBased"))
		{
			jObj.put("hrefUrl",queryForTopApps);
		}
		rootJson.put("firstPageData",jObj);
		rootJson.put("secondPageData",jObj);
		rootJson.put("checkData",checkData);
		if(compObj!=null && compObj.size()>0)
			rootJson.put("table_data", compObj);
	}
		String isFavorite = request.getParameter("isFavorite");
		hiddenfieldsJson.put("inidate",currentDateFormat);
		hiddenfieldsJson.put("currTime","");
		hiddenfieldsJson.put("er_ViewName","CtxLogonSimulator.jsp");
		if(reqFromSchedule!=null)
			hiddenfieldsJson.put("fromSchedule",reqFromSchedule);
		else
			hiddenfieldsJson.put("fromSchedule","null");

		if(fromScheduleModify!=null)
			hiddenfieldsJson.put("fromScheduleModify",fromScheduleModify);
		else
			hiddenfieldsJson.put("fromScheduleModify","null");

		if(schedule_id!=null)
			hiddenfieldsJson.put("schedule_id",schedule_id);
		else
			hiddenfieldsJson.put("schedule_id","null");
		if(fromFavoriteModify!=null)
			hiddenfieldsJson.put("fromFavoriteModify",fromFavoriteModify);
		else
			hiddenfieldsJson.put("fromFavoriteModify","null");
		hiddenfieldsJson.put("favorite_id", favorite_id);
		hiddenfieldsJson.put("er_favorite", er_favorite);
		hiddenfieldsJson.put("uid",EgURLEncoder.encode(loginid,"UTF-8"));
		hiddenfieldsJson.put("userID",EgURLEncoder.encode(loginid,"UTF-8"));
		hiddenfieldsJson.put("getMaxDaysInMonth",String.valueOf(ErUtils.getMaxDaysInMonth()));
		hiddenfieldsJson.put("forwardto","ErCtxLogonSimulatorJSON");
		hiddenfieldsJson.put("bgenabled",strbgrepportName);
		hiddenfieldsJson.put("limitforbg",limitforbg);
		hiddenfieldsJson.put("savereport","save");
		hiddenfieldsJson.put("servletName","com.eg.ErCtxLogonSimulator");

		hiddenfieldsJson.put("er_trgttype",er_trgttype);
		hiddenfieldsJson.put("er_rtype","logon_simulator");
		hiddenfieldsJson.put("er_gtype","logon_simulator");
		hiddenfieldsJson.put("isFavorite",isFavorite);
		hiddenfieldsJson.put("isSchedule","false");
		if(er_trgttype!=null && er_trgttype.equalsIgnoreCase("applicationBased"))
		{
			hiddenfieldsJson.put("er_bgreportfrom",com.eg.EgURLEncoder.encode("Logon Simulator by Application","UTF-8"));
		}
		else
		{
			hiddenfieldsJson.put("er_bgreportfrom",com.eg.EgURLEncoder.encode("Logon Simulator by External Agent","UTF-8"));
		}
		hiddenfieldsJson.put("er_trenddata","No");
		hiddenfieldsJson.put("divStatus",divStatus);
		hiddenfieldsJson.put("criticalColor",criticalColor);
		hiddenfieldsJson.put("majorColor",majorColor);
		hiddenfieldsJson.put("minorColor",minorColor);
		String isSubmitted =request.getParameter("isSubmit");
		rootJson.put("isSubmit",isSubmitted);
		String reportTitle = "";
		if(er_trgttype!=null)
		{
			if(er_trgttype.equalsIgnoreCase("applicationBased"))
			{
				reportTitle = intlmap.getTextDescription("reporter.common.by Application/Desktop");
			}
			else
			{
				reportTitle = intlmap.getTextDescription("reporter.common.by External Agent");
			}
			rootJson.put("reportTitle",intlmap.getTextDescription("reporter.common.LOGON SIMULATOR")+" - "+reportTitle);
		}
		String strwidth = "90%";
		if(backreqMap == null || backreqMap != null && backreqMap.size() == 0)
			strwidth="100%";
		String fromFavSch = request.getParameter("fromFavSch");
		if(backreqMap != null && backreqMap.size() > 0 &&  enableBack && request.getParameter("enableBack")!=null && request.getParameter("enableBack").equalsIgnoreCase("true") || (fromFavSch!=null && fromFavSch.equalsIgnoreCase("true")))
		{
			rootJson.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
		}
		queryString = request.getQueryString();
		screenLabelJson.put("reporter.common.Zone",intlmap.getTextDescription("reporter.common.Zone"));
		JSONArray zoneArray = new JSONArray();
		if(v_zone != null && v_zone.size()>0)
		{
			loopJsonObj = new JSONObject();
			zoneArray.add(loopJsonObj);
			for(int n=0;n<v_zone.size();n++)
			{
				String s=(String)v_zone.get(n);
				loopJsonObj = new JSONObject();
				if(s.equalsIgnoreCase("--default--"))
				{
					loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common."+s));
					loopJsonObj.put("valueField",s);
				}
				else
				{
				loopJsonObj.put("displayField",s);
				loopJsonObj.put("valueField",s);
				}
				zoneArray.add(loopJsonObj);
				if(s_farmserver!=null && s_farmserver.equalsIgnoreCase(s))
				{
					rootJson.put("selectedZone",s_farmserver);
				}
			}
		}
		else
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "-1");
			zoneArray.add(loopJsonObj);
		}
		rootJson.put("zoneCombo",zoneArray);
		screenLabelJson.put("reporter.common.Component Type",intlmap.getTextDescription("reporter.common.Component Type"));
		screenLabelJson.put("reporter.common.Component",intlmap.getTextDescription("reporter.common.Component"));
		Collections.sort(v_application,String.CASE_INSENSITIVE_ORDER);
		if(v_application!=null && v_application.size()>1)
		{
			v_application.add(0,"All");
		}
		screenLabelJson.put("reporter.common.Application",intlmap.getTextDescription("reporter.common.Application"));
		JSONArray applnArray = new JSONArray();
		if(v_application != null && v_application.size() >0)
		{
			if(selectedApplication.size() > 0)
			{
				for(int n=0;n<v_application.size();n++)
				{
					String s=(String)v_application.get(n);
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",s);
					loopJsonObj.put("valueField",s);
					applnArray.add(loopJsonObj);
					if(selectedApplication!=null && selectedApplication.contains(s))
					{
						rootJson.put("selectedAppln",s);
					}
				}
			}
			else
			{
				for(int n=0;n<v_application.size();n++)
				{
					String s=(String)v_application.get(n);
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",s);
					loopJsonObj.put("valueField",s);
					applnArray.add(loopJsonObj);
					if(n ==0)
					{
						rootJson.put("selectedAppln",s);
					}
				}
			}
		}
		else
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "-1");
			applnArray.add(loopJsonObj);
			rootJson.put("selectedAppln","-1");
		}
		rootJson.put("applnCombo",applnArray);
%>
	<%@  include file ="ErTimeFormatJSON.jsp"%> 
<%
		hiddenfieldsJson.put("userTimeline",strUsrTimeline);
		screenLabelJson.put("reporter.common.Timeline", intlmap.getTextDescription("reporter.common.Timeline"));
		screenLabelJson.put("reporter.common.From", intlmap.getTextDescription("reporter.common.From"));
		screenLabelJson.put("reporter.common.To", intlmap.getTextDescription("reporter.common.To"));
		screenLabelJson.put("reporter.common.Hr", intlmap.getTextDescription("reporter.common.Hr"));
		screenLabelJson.put("reporter.common.Graph", intlmap.getTextDescription("reporter.common.Graph"));

		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);
		//User TimeZone changes
		rootJson.put("startDateForDisplay",startDateForDisplay);
		rootJson.put("startHourForDisplay",startHourForDisplay);
		rootJson.put("startMinForDisplay",startMinForDisplay);
		rootJson.put("endDateForDisplay",endDateForDisplay);
		rootJson.put("endHourForDisplay",endHourForDisplay);
		rootJson.put("endMinForDisplay",endMinForDisplay);
		chartTypeForUI=ErHighchartUtils.getChartType(startDateForHighchart,endDateForHighchart,currentDateFormat+" HH:mm");
		rootJson.put("chartType",chartTypeForUI);

		screenLabelJson.put("reporter.common.Time period", intlmap.getTextDescription("reporter.common.Time period"));
		screenLabelJson.put("reporter.common.Hrs", intlmap.getTextDescription("reporter.common.Hrs"));
		screenLabelJson.put("reporter.common.Mins", intlmap.getTextDescription("reporter.common.Mins"));
		rootJson.put("selectedTimeFrom",timefrom);
		rootJson.put("selectedMinsFrom",minfrom);
		rootJson.put("selectedTimeTo",timeto);
		rootJson.put("selectedMinsTo",minto);
		screenLabelJson.put("reporter.common.Report Generation", intlmap.getTextDescription("reporter.common.Report Generation"));
		screenLabelJson.put("reporter.common.Report Name", intlmap.getTextDescription("reporter.common.Report Name"));
		JSONArray reportGenerationComboArray =  new JSONArray();
		JSONObject tmpobj=new JSONObject();
		tmpobj.put("displayField", strbackground);
		tmpobj.put("valueField", "background");
		reportGenerationComboArray.add(tmpobj);
		tmpobj=new JSONObject();
		tmpobj.put("displayField", strforeground);
		tmpobj.put("valueField", "foreground");
		reportGenerationComboArray.add(tmpobj);
		rootJson.put("reportGenerationCombo",reportGenerationComboArray);

		screenLabelJson.put("reporter.common.View Application", intlmap.getTextDescription("reporter.common.View Application"));

		String pdfStartDate = startDateForDisplay+" "+startHourForDisplay+":"+startMinForDisplay;
		String pdfEndDate = endDateForDisplay+" "+endHourForDisplay+":"+endMinForDisplay;

		String er_reportgenration = request.getParameter("er_reportgenration");
		String er_background ="";
		String er_foreground ="";
		if (er_reportgenration != null && er_reportgenration.equals("background"))
		{
			er_background = "selected";
			er_foreground = "";
			rootJson.put("reportGeneration","background");
		}
		else
		{
			er_background = "";
			er_foreground = "selected";
			rootJson.put("reportGeneration","foreground");
		}
		String bg_reportname = request.getParameter("bg_reportname");
		if(bg_reportname == null)
		{
			bg_reportname = "";
		}
		if(bggroundStr != null && !bggroundStr.equals(""))
		{
			isBackgroundProcess = true;
			rootJson.put("backgroundReportStatus",status);
			String strreportName ="Logon Simulator";
			if(er_trgttype!=null && er_trgttype.equalsIgnoreCase("applicationBased"))
			{
				strreportName ="Logon Simulator by Application";
			}
			else
			{
				strreportName ="Logon Simulator by External Agent";
			}
			if(status != null && (status.equalsIgnoreCase("duplicate") || status.equalsIgnoreCase("exceedLimit")))
			{
				strreportName ="All Report Types";
			}
			rootJson.put("bgGroundMsg",bggroundStr);
			String bgroundResponseTxt=bggroundStr;
			if(status != null && !status.equalsIgnoreCase("exceedLimit"))
			{
				bgroundResponseTxt=erbgreport.getlangsupportedString(bggroundStr,bgString,urs);
			}
			rootJson.put("bgroundResponseTxt",bgroundResponseTxt);
			rootJson.put("bgroundReportsURL","/final/servlet/com.eg.ErStartBackGroundReportC?back=true&er_bgreportfrom="+com.eg.EgURLEncoder.encode(strreportName,"UTF-8")+"&userID="+com.eg.EgURLEncoder.encode(urs, "UTF-8")+"&savereport=search&er_filterby=Report_Name&forwardto=ErBackGoundProcess");
			rootJson.put("backgroundAnchor", intlmap.getTextDescription("reporter.common.Click here to see a list of generated and processing reports"));
		}
		if(isSubmit != null && isSubmit.equalsIgnoreCase("true") && !isBackgroundProcess)
		{
			JSONObject reportDataJson = new JSONObject();
			JSONObject selectionDetails=new JSONObject();
			rootJson.put("reporter.common.SelectionDetailsfor", intlmap.getTextDescription("reporter.common.Selection Details for ")+" "+ applicationName);
		
			if(er_option.equalsIgnoreCase("Zone"))
			{
				if(s_farmserver.equalsIgnoreCase("--default--"))
					selectionDetails.put(intlmap.getTextDescription("reporter.cpacity.Zone"),intlmap.getTextDescription("reporter.common."+s_farmserver));
				else
				selectionDetails.put(intlmap.getTextDescription("reporter.cpacity.Zone"),s_farmserver);
			}
			else if(er_option.equalsIgnoreCase("Segment")||er_option.equalsIgnoreCase("Service"))
			{
				selectionDetails.put(intlmap.getTextDescription("reporter.cpacity."+er_option),er_site);
			}
			selectionDetails.put(intlmap.getTextDescription("reporter.cpacity.Component Type"),intlmap.getComponentTypeDescription(s_compType));
			selectionDetails.put(intlmap.getTextDescription("reporter.cpacity.Application"),applicationName);

			//selectionDetails.put(intlmap.getTextDescription("reporter.common.Time Period"),"<span class='font_bold'> </span> "+timefrom+":"+minfrom+"<span class='font_bold'>  "+intlmap.getTextDescription("reporter.common.to")+" </span>  "+timeto+":"+minto);

			selectionDetails.put((String)intlmap.getTextDescription("reporter.common.Timeline"),
			"<span class='font_bold'> </span>"+pdfStartDate+" "
			+intlmap.getTextDescription("reporter.common.hrs")+"<span class='font_bold'>"+" "
			+intlmap.getTextDescription("reporter.common.to")+"</span>"+" "+pdfEndDate+" "+intlmap.getTextDescription("reporter.common.hrs"));

			rootJson.put("selectionDetails",selectionDetails);

			s_st_hr = request.getParameter("starthr");
			s_en_hr = request.getParameter("endhr");
			rootJson.put("reportData",reportDataJson);
			rootJson.put("enableEnumulation",enableEnumulation);
		}
		//for mail starts
		String strEncodeer_timeline = er_timeline;
		if(er_timeline != null)
			strEncodeer_timeline = com.eg.EgURLEncoder.encode(er_timeline,UTF_8);
		if(s_st_time_graph != null && s_en_time_graph != null && s_inidate != null)
		{
			s_st_time_graph = com.eg.EgURLEncoder.encode(s_st_time_graph,UTF_8);
			s_en_time_graph = com.eg.EgURLEncoder.encode(s_en_time_graph,UTF_8);
			s_inidate = com.eg.EgURLEncoder.encode(s_inidate,UTF_8);
		}
		String strEncodeApplicationName = applicationName;
		if(applicationName!=null)
			strEncodeApplicationName = com.eg.EgURLEncoder.encode(applicationName,"UTF-8");

		String strEncodeLocationame = location;
		if(location!=null)
			strEncodeLocationame = com.eg.EgURLEncoder.encode(location,"UTF-8");

		String strEncodecmpType = "";
		if(s_compType!=null)
			strEncodecmpType = EgURLEncoder.encode(s_compType,"UTF-8");

		String strEncodefarmServer = "";
		if(s_farmserver!=null)
			strEncodefarmServer = EgURLEncoder.encode(s_farmserver,"UTF-8");
		String stren_timefrom = "";
		if (timefrom2!=null)
			stren_timefrom =  EgURLEncoder.encode(timefrom2,"UTF-8");
		String stren_minfrom = "";
		if (minfrom2!=null)
			stren_minfrom =  EgURLEncoder.encode(minfrom2,"UTF-8");
		String stren_timeto = "";
		if (timeto2!=null)
			stren_timeto =  EgURLEncoder.encode(timeto2,"UTF-8");
		String stren_minto = "";
		if (minto2!=null)
			stren_minto =  EgURLEncoder.encode(minto2,"UTF-8");
		String strEncodeusrtime = "";
		String strenuser = "";
		if(strUsrTimeline!=null)
			strEncodeusrtime = EgURLEncoder.encode(strUsrTimeline,"UTF-8");
		if(loginid!=null)
			strenuser = EgURLEncoder.encode(loginid,"UTF-8");
		
		// for redirecting same page in reporter Starts
		queryString=(String)ErUtils.prepareQueryString(request.getParameterMap());
		String qString="";
		String qStringBackUrl = "";
		if(queryString!=null)
		{
			if(er_trgttype!=null)
				queryString+="&er_trgttype="+er_trgttype;
			StringTokenizer strtok = new StringTokenizer(queryString,"&");
			while(strtok.hasMoreTokens())
			{
				String parameter = strtok.nextToken();
				int ind = parameter.indexOf("=");
				if (ind < 0)
					continue;
				String reqparam =parameter.substring(0,ind);
				String value = parameter.substring(ind+1);
				if(reqparam!=null) 
				{
					if(reqparam.equals("er_zone"))
					{
						value=com.eg.EgURLEncoder.encode(value, UTF_8);
					} 
					else if(reqparam.equals("startdate"))
					{
						value=com.eg.EgURLEncoder.encode(value, UTF_8);
					}
					else if(reqparam.equals("enddate"))
					{
						value=com.eg.EgURLEncoder.encode(value, UTF_8);
					}
					else if(reqparam.equals("inidate"))
					{
						value=com.eg.EgURLEncoder.encode(value, UTF_8);
					}
					else if(reqparam.equals("er_trgttype"))
					{
						value=com.eg.EgURLEncoder.encode(value, UTF_8);
					}
					else if(reqparam.equals("firstpage"))
					{
						value=com.eg.EgURLEncoder.encode(value, UTF_8);
					}
					else if(reqparam.equals("secondpage"))
					{
						value=com.eg.EgURLEncoder.encode(value, UTF_8);
					}
					else if( reqparam.equals("er_timeline") || reqparam.equals("inidate") || reqparam.equals("pdfTime") || reqparam.equals("er_applicationX")|| reqparam.equals("limitforbg")|| reqparam.equals("er_rtype") ) 
					{
						value=com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					else if(reqparam.equals("appForAgent"))
					{
						if(value.indexOf("]")>-1 || value.indexOf("[")>-1)
						continue;
					}
					qStringBackUrl+= reqparam+"="+value+"&";
					qString += reqparam+"="+value+"&";
				}
			}
			//sending mail for application second page
			//if(location!=null && !location.equalsIgnoreCase("all") && applicationX!=null && !applicationX.equalsIgnoreCase("all"))
			{
				if(request.getParameter("secondpage")!=null && request.getParameter("secondpage").equals("true") && er_trgttype!=null && er_trgttype.equalsIgnoreCase("applicationBased") && applicationName!=null && !applicationName.equalsIgnoreCase("all") && fromLoc!=null && fromLoc.equalsIgnoreCase("yes"))
				{
					qString+="fromLoc=yes";
				}
				//if(request.getParameter("secondpage")!=null && request.getParameter("secondpage").equals("true") && er_trgttype!=null && er_trgttype.equalsIgnoreCase("applicationBased") && applicationName!=null && !applicationName.equalsIgnoreCase("all"))
				if(er_trgttype!=null && er_trgttype.equalsIgnoreCase("applicationBased") && applicationName!=null && !applicationName.equalsIgnoreCase("all"))
				{
					qString+="&printPageIdentify=appSecondPage&secondpage=true";
				}
				if(request.getParameter("firstpage")!=null && request.getParameter("firstpage").equals("true") && er_trgttype!=null && er_trgttype.equalsIgnoreCase("locationBased") && location!=null && !location.equalsIgnoreCase("all")&& request.getParameter("isFourthPage")!=null && !request.getParameter("isFourthPage").equals("true")&& request.getParameter("isFifthPage")!=null && !request.getParameter("isFifthPage").equals("true"))
				{
					qString+="&printPageIdentify=locFirstPage";
				}
				if(request.getParameter("isFourthPage")!=null && request.getParameter("isFourthPage").equals("true"))
				{
					qString+="&printPageIdentify=locSecondPage";
				}
				if(request.getParameter("commonPage")!=null && request.getParameter("commonPage").equals("yes"))
				{
					qString+="&printPageIdentify=commonPage";
				}
				if(request.getParameter("isFifthPage")!=null && request.getParameter("isFifthPage").equals("true"))
				{
					qString+="&printPageIdentify=locThirdPage";
				} 
				if(request.getParameter("commonPage")!=null && request.getParameter("commonPage").equals("true"))
				{
					qString+="&commonPage=yes";
				}
				
				if(request.getParameter("checkFull")!=null && request.getParameter("checkFull").equals("full"))
				{
					qString+="&checkFull=full";
				}
				if(request.getParameter("byName")!=null && request.getParameter("byName").equals("fromLogon"))
				{
					qString+="&byName=fromLogon";
				}
				if(request.getParameter("byName")!=null && request.getParameter("byName").equals("fromEnum"))
				{
					qString+="&byName=fromEnum";
				}
				if(request.getParameter("byName")!=null && request.getParameter("byName").equals("fromApp"))
				{
					qString+="&byName=fromApp";
				}
			}
			if(er_trgttype!=null && !er_trgttype.equalsIgnoreCase("applicationBased") && appForAgent!=null)
			{
				qString+="&appForAgent="+EgURLEncoder.encode(appForAgent,"UTF-8");
			}
			String dataProcess = mngrIProc+"/final/reporter/ErCtxLogonSimulatorPRINT.jsp;jsessionid="+ session.getId()+"?"+qString+"&options=graph&selectedLoc="+location+"&selectedCompnt="+selectedTempComponent+"&er_option="+er_option+"&er_site="+er_site+"&er_server="+request.getParameter("er_server")+"&er_zone=" + s_farmserver;
			if(applicationX!=null)
			{
				dataProcess+="&selectedApp="+EgURLEncoder.encode(applicationX,"UTF-8")+"&fromLoc="+fromLoc;
			}
			//System.out.println("dataProcess ---------- "+dataProcess);
			session.setAttribute("MAIL_URL",dataProcess);
			ArrayList listbackvar = new  ArrayList();
			if((request.getParameter("isSubmit")!=null && request.getParameter("isSubmit").equals("true")))
			{
				qString += "&isSubmit=true&";
				if(er_trgttype!=null)
					qString+="er_trgttype="+er_trgttype+"&";
				session.setAttribute("reportLastAccessedURL","/final/reporter/ErCtxLogonSimulator.jsp?"+qString);
				listbackvar.add("ErCtxLogonSimulator.jsp");
				listbackvar.add("status="+status+"&bggroundStr="+bggroundStr+"&"+queryString);
				session.setAttribute("favSchBackDisplay","Yes");
			}
			else
			{
				session.setAttribute("reportLastAccessedURL","/final/reporter/ErCtxLogonSimulator.jsp?"+qString);
				listbackvar.add("ErCtxLogonSimulator.jsp");
				listbackvar.add(queryString);
				session.setAttribute("favSchBackDisplay","No");
			}
			if(request.getParameter("enableBack")==null)
			{
				session.setAttribute("reportLastAccessedURL","/final/reporter/ErCtxLogonSimulator.jsp?"+qString);
				String backadded = erhelputils.getBackID();
				backreqMap = erhelputils.setBackQueryMap(backreqMap,backadded,listbackvar);
				session.setAttribute("backQuery",backreqMap);
			}
		}
		session.setAttribute("PDF_URL", mngrIProc+"/final/reporter/ErCtxLogonSimulatorPRINT.jsp");
		rootJson.put("saveQString",qString);
		rootJson.put("hiddenfields",hiddenfieldsJson);
		rootJson.put("screenLabels",screenLabelJson);
		rootJson.put("viewReportFor","Logon Simulator");
		session.setAttribute("printSessionData",rootJson);
		//
		HashMap param =new HashMap();
		//param.put("REPORT_PARAM",ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap())));
		//param.put("REPORT_DATA",pdfQuery);
		param.put("fileName","logon_simulator");
		session.setAttribute("parameters", param);
		//
		String responsePage = null;
		if(thrSch !=null && thrSch.equalsIgnoreCase("true"))
		{
			responsePage="/reporter/ErCtxLogonSimulatorPRINT.jsp";
			getServletContext().getRequestDispatcher(responsePage).forward(request, response);
		}
		else
		{
			out.println(rootJson.toString());
		}
	}
	catch(Throwable t)
	{
		t.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();
			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;
}
public boolean isEnumerationNeeded(String CompName,String enumerationComponents){
	boolean needEnumeration=true;
	try{
		if(enumerationComponents != null && CompName != null && enumerationComponents.indexOf(CompName) > -1)
			needEnumeration=false;
	}catch(Exception ee){
		ee.printStackTrace();
	}
	return needEnumeration;
}
%>