<%
/************************************************************************************************
*	File				: ErUserLogonDetailsReportJson.jsp
*	Version			:	1.0
*	Author			:	Arul Edward J
*	Creation Date	:	23/04/14 
*
*************************************************************************************************/
%>
<%@ page import = "egurkha.reporter.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.text.SimpleDateFormat" %>
<%@ page import = "java.text.ParseException" %>
<%@ page import ="com.eg.ErDbServer"%>
<%@ page import = "egurkha.*" %>
<%@ page import = "com.eg.EgDbInfo" %>
<%@ page import ="com.eg.EgInstallInfo"%>
<%@ page import ="com.eg.IniFile"%>
<%@ page import="com.egurkha.ini.*" %>
<%@ page import="com.eg.EgDateInfo" %>
<%@ page import="com.eg.EgGroupInfo" %>
<%@ page import="com.eg.EgReportInfo" %>
<%@ page import = "com.egurkha.*" %>
<%@ include file = "ErReporterTracker.jsp" %>
<%@ page import = "java.net.*" %>
<%@ page import="com.eg.EgThresholdInfo" %>
<%@ page import="com.eg.EgTablesInfo" %>
<%@ page import="com.eg.EgMappingInfo" %>
<%@ page import = "java.net.URLEncoder" %>
<%@ page import = "java.net.URLDecoder" %>
<%@ page import = "com.eg.EgURLEncoder" %>
<%@ page import = "com.egurkha.util.DateTimeTokenizer" %>
<%@ page import = "com.egurkha.util.DateUtil" %>
<%@ page import = "com.egurkha.util.StringUtils" %>
<%@ page import = "egurkha.reporter.ErFusionChartBean" %>
<%@ page import = "egurkha.reporter.ErUserLogonDetailsReportBean" %>
<%@ page import = "egurkha.reporter.*" %>
<%@ page import = "java.text.*" %>
<%@ page import = "com.eg.EgConfigInfo"%>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import = "net.sf.json.*" %>
<%@ page import ="com.eg.MappingNameSorter"%>
<%@ page import ="com.eg.EgName"%>
<%!
	int logOnDurationTestFreq;//*1000*60;
	String currentDateFormat =null;
%>
<%
try
{
	Map resultMap=null;
	response.setContentType("application/json;charset=UTF-8");

	JSONObject screenLabelJson = new JSONObject();
	JSONObject hiddenfieldsJson=new JSONObject();
	JSONObject rootJson = new JSONObject();
	JSONObject loopJsonObj = new JSONObject();
	boolean isEnglishLanguage=false;
	if(trackerLanguage!=null && trackerLanguage.equals("en_US"))
	{
		isEnglishLanguage=true;
	}
	ErFusionChartBean chartbean = new ErFusionChartBean();
	String bggroundStr = (String)request.getAttribute("bggroundStr");
	String status = (String)request.getAttribute("status");
    String er_componentType=request.getParameter("er_componentType");
 
	//Back Button - Start

	HashMap backreqMap = (HashMap)session.getAttribute("backQuery");
	String backQnumber = request.getParameter("backQnumber");
	String servlet2 = request.getParameter("backServletName");
	ErHelperUtils erhelputils = null;

	if(servlet2!=null && !servlet2.equals(""))
		erhelputils = new ErHelperUtils(backreqMap,backQnumber,servlet2);
	else
		erhelputils = new ErHelperUtils(backreqMap,backQnumber);

	boolean enableBack=erhelputils.isBackButtonEnable();
	String backButtonEnable = request.getParameter("back");
	if(backButtonEnable != null && backButtonEnable.equalsIgnoreCase("True"))
	{
		status = (String)request.getParameter("status");
		request.setAttribute("htdata",null);
		request.setAttribute("app_topusers",null);
		request.setAttribute("appChartData",null);
		bggroundStr = (String)request.getParameter("bggroundStr");
	}
	//Back Button - End
	 resultMap = (HashMap) session.getAttribute("USER_LOGON_REPORT");

	String mngrIProc = new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
	int pageWidthProces=1024;
	String s_tit1= "";
	Hashtable ht1 = new Hashtable();
	List lst_dat1 = new LinkedList();
	Hashtable sen1 = new Hashtable();
	Vector vec1 = new Vector();
	Vector chHeader = new Vector();
	List lst = new LinkedList();
	int forDetails=0;
	int forSummary=0;
	int Dummy = 0;
	IniUI ui = IniUI.getInstance();
	EgDateInfo egDt = new EgDateInfo();
	String Hourfrom="";
	String Minfrom="";
	String Hourto="";
	String Minto="";
	String fromTime,toTime;
	String variable;
	String s_QSGraph="";
	StringTokenizer st;
	JSONObject childMapDir = new JSONObject();
	JSONObject checkChild = new JSONObject();
	JSONObject childDataForDirComp = new JSONObject();
	boolean chkChilds=false;
	JSONObject childMapDirForSummary = new JSONObject();
	JSONObject checkChildForSummary = new JSONObject();
	JSONObject childDataForDirCompForSummary = new JSONObject();

	EgMappingInfo intlmap=new EgMappingInfo(thisuser.getLanguage());
	ErComponentsUtils compUtils = new ErComponentsUtils(thisuser.getLoginID());
	ErUtils erUtils = new ErUtils();
	ErInfo erInfo = new ErInfo();
	EgReportInfo reportInfo=new EgReportInfo("manager");
	String confrimation = reportInfo.getValue("BACKGROUND_PROCESS","NeedConfirmation");
	String strbgrepportName = reportInfo.getValue("BACKGROUND_PROCESS","EnableBackgroundReport");
	String limitforbg = reportInfo.getValue("BACKGROUND_PROCESS","MinDurationForReport");
	EgThresholdInfo hreshholdInfo = new EgThresholdInfo("manager");
	EgTablesInfo tablesInfo = new EgTablesInfo("manager");
	String s_user[] = request.getParameterValues("er_user");
	String strGraphViewType = request.getParameter("graphViewtype");
	String strSelectedCompType = request.getParameter("er_comptype");
	String selectedCompType = request.getParameter("er_comptype");
	boolean getMoreUsers = false;
	int countForUser = reportInfo.getMoreUsers("USER_LOGON_REPORT");

	Hashtable htt=new Hashtable();
	htt=(Hashtable)request.getAttribute("htdata");
	session.setAttribute("htdata",htt);
	Vector v_components = compUtils.getAllUserComponents1();
	Vector v_component = new Vector();
	Vector v_temp = new Vector();
	Vector defComps = new Vector();
	Vector colZoneComps = new Vector();
	Vector v_comptype=new Vector();
	ArrayList aListCompType = new ArrayList();
	Vector v_tmp = new Vector();
	Vector v_infos=null;
	Vector v_application=new Vector();

	String installDir = EgInstallInfo.getInstallDir();
	IniFile inifile = new IniFile(installDir +"/manager/config/eg_report.ini");
	String sub = "MISC";
	String var = "CtxServer";
	String values = inifile.getValue(sub,var);
	String val="";
	String s_component = "";
	String s_qryString	="";
	String timeline =request.getParameter("er_timeline");
	String all_comb =request.getParameter("all_comb");
	String testmes = request.getParameter("select_testmes");
	String rtype =request.getParameter("er_type");
	String show_timeinuse = request.getParameter("sh_timeinuse");
	String reqFromSchedule = request.getParameter("fromSchedule");
	String fromScheduleModify = request.getParameter("fromScheduleModify");
	String schedule_id = request.getParameter("schedule_id");
	String fromFavoriteModify = request.getParameter("fromFavoriteModify");
	String favorite_id = request.getParameter("id");
	String er_favorite = request.getParameter("er_favorite");
	String divStatus = request.getParameter("divStatus");
	String searchUser = request.getParameter("er_tapplication");
	String er_mode = request.getParameter("er_mode");
	String er_glduration = request.getParameter("glduration");
	String er_duration = request.getParameter("duration");
	String er_brokeringFrom=request.getParameter("er_brokeringFrom");
	String er_showDeliveryGroup=request.getParameter("er_showDeliveryGroup");
	if(er_duration!=null)
		er_duration="0";
	String er_duraSelect = request.getParameter("duraSelect");
	String srcForImg="";
	if(divStatus==null)
	{
		divStatus="none";
	}
	if(er_showDeliveryGroup==null)
	{
		er_showDeliveryGroup="No";
	}
	if(divStatus.equals("none"))
	{
		srcForImg="/final/images/moreoption.png";
	}
	else if(divStatus.equals("block"))
	{
		srcForImg="/final/images/lessoption.png";
	}
	ArrayList aListSupportedComponentType = reportInfo.getComponentsList("USER_LOGON_REPORT",false);
	ArrayList aListAlltype = new ArrayList();
	for(int kk=0;kk<aListSupportedComponentType.size();kk++)
	{
		aListAlltype.add("All "+aListSupportedComponentType.get(kk));
	}
	if (rtype==null)
	{
		rtype="Yes";
	}
	if(rtype.equalsIgnoreCase("No"))
	{
		aListSupportedComponentType.add("Horizon_Pod");
		aListSupportedComponentType.add("VMware_View_server");
	}
	boolean termpresent=false;
	Vector v_testmes = new Vector();
	for(int i=0;i<v_components.size();i++)
	{
		String s_tmp = (String)v_components.get(i);
		StringTokenizer tk = new StringTokenizer(values,",");
		while(tk.hasMoreTokens())
		{
			val = tk.nextToken();
			if(val==null || val.equals(""))
			{
				if (s_tmp.endsWith(val))
				{
					v_tmp.add(s_tmp);
				}
			}
			else
			{
				if(s_tmp.endsWith(val))
				{
					v_tmp.add(s_tmp);
				}
			}
		}
	}
	ErReportHelper er_helper = new ErReportHelper();
	int maxInfo = er_helper.getMaxInfos("INFOS","Showtop");
	Vector v_show=new Vector();
	v_show.add("TOP  - " +maxInfo/4);
	v_show.add("TOP  - " +maxInfo/2);
	v_show.add("TOP  - " +maxInfo);
	v_show.add("ALL");
	String priority=request.getParameter("er_priority");
	if(priority==null || priority.equals(""))
		priority="TOP  - " +maxInfo;

	Hashtable ht_data = (Hashtable)request.getAttribute("Report_data");
	Vector app_data = (Vector)request.getAttribute("App_data");
	session.setAttribute("App_data",app_data);
	
	ArrayList app_topusers = (ArrayList)request.getAttribute("app_topusers");
	Vector v_qry_string = (Vector)request.getAttribute("appChartData");
	Vector pdfQuery = (Vector)request.getAttribute("appPdfData");
	String backQS = (String)session.getAttribute("topBackQuery");
	String backQSserver = (String)session.getAttribute("topBackQuery_server");
	
	// For Analaysis By Combo
	String enableAggregation =request.getParameter("enableAggregation"); 
	String er_aggregateValue =request.getParameter("er_aggregateValue"); 
	String uppermajor =request.getParameter("uppermajor");
	String upperCritical =request.getParameter("upperCritical");
	String er_option =request.getParameter("er_option");

	if(enableAggregation==null)	
	{
		enableAggregation="false";
	}
	if(er_option == null || (er_option!=null && er_option.isEmpty())|| "-1".equals(er_option))
	{
		 er_option = "Zone";
	}
	String er_dataFrom =request.getParameter("er_dataFrom");
	String er_service = request.getParameter("er_service");
	if(er_dataFrom!=null && (er_dataFrom.equalsIgnoreCase("Group")||er_dataFrom.equalsIgnoreCase("Segment")||er_dataFrom.equalsIgnoreCase("Service")||er_dataFrom.equalsIgnoreCase("Zone")))
	{
		if(er_service!=null)
		{
			er_option=er_dataFrom;
		}
	}
	else if(er_dataFrom!=null && er_dataFrom.equalsIgnoreCase("Component"))
	{
		er_option=er_dataFrom;
	}
	session.setAttribute("ApplicationReport",app_data);
	session.setAttribute("appForPrint",app_topusers);
	session.removeAttribute("topBackQuery");
	session.removeAttribute("backQSserver");

	HashMap Report_data=null;
	Hashtable h_data = new Hashtable();
	Hashtable h_rep = new Hashtable();
	Vector v_data1 = new Vector();
	Vector  v_add = new Vector();
	Vector v_sort=new Vector();

	ArrayList subjects = (ArrayList)reportInfo.getVariables("USER_LOGON_REPORT");
	String numTopUsers = reportInfo.getTop("USER_LOGON_REPORT");

	String s_variable="";
	StringTokenizer tok1=null;
	String type="";
	String mes="";
	
	String s_uisort=request.getParameter("er_uisortby");
	String tbound = request.getParameter("er_tbound");
	String cTime = request.getParameter("currTime");
	String s_application1 = request.getParameter("er_application1");
	String key="";
	ErReqData erd = new ErReqData(request);
	EgDateInfo egDate = new EgDateInfo();
	String stdate="";
	String enddate="";
	String sthr="";
	String endhr="";
	String sthr1 = "";
	String endhr1 = "";
	long msecsPerHour = (long) 1000 * 60 * 60;
	fromTime = reportInfo.getTimeFrame("USER_LOGON_REPORT","FROM");
	toTime = reportInfo.getTimeFrame("USER_LOGON_REPORT","TO");
	st = new StringTokenizer(fromTime,":");
	if(st.hasMoreTokens())
	{
		Hourfrom = st.nextToken();
		Minfrom = st.nextToken();
	}
	st=new StringTokenizer(toTime,":");
	if(st.hasMoreTokens())
	{
		Hourto = st.nextToken();
		Minto = st.nextToken();
	}
	String Days = reportInfo.getExcludeWeekend("USER_LOGON_REPORT");
	String NoofServers = reportInfo.getNoOfBars("USER_LOGON_REPORT","top");
	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("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 timefrom2=request.getParameter("timefrom");
	String minfrom2=request.getParameter("minfrom");
	String timeto2=request.getParameter("timeto");
	String minto2=request.getParameter("minto");

	if (timefrom2!=null)
		Hourfrom=timefrom2;
	if (minfrom2!=null)
		Minfrom=minfrom2;
	if (timeto2!=null)
		Hourto=timeto2;
	if (minto2!=null)
		Minto=minto2;

	String value1 = inifile.getValue(sub,var);
	sub ="LIST_OF_ZONES";
	inifile = new IniFile(installDir +"/manager/config/eg_group.ini");
	String vari[] = inifile.getVariables(sub);
	for(int i=0;i<vari.length;i++)
	{
		variable = vari[i];
		v_component.add(variable);
	}

	String s_farmserver = request.getParameter("select_farm");
	String s_application[] = request.getParameterValues("er_user");
	if (s_application != null && s_application.length>0)
	{
		s_application = s_application;
		for(int appCnt=0;appCnt<s_application.length;appCnt++)
		{
			String strApp = s_application[appCnt];
			if(strApp!=null && strApp.length()>0)
			{
				strApp = erUtils.specialCharDecode(strApp);
			}
			s_application[appCnt] = strApp;
		}
	}
	String s_server = request.getParameter("er_server");
	String s_servers[] = request.getParameterValues("er_component");
	String er_poolType[]=request.getParameterValues("er_poolType");
	ArrayList serverList = new ArrayList();
	if (s_servers != null)
		serverList = new ArrayList(Arrays.asList(s_servers));
	String serverForSorting=null;
	String strzoneCheck = "";
	String strServercheck = "";
	String s_perserver=request.getParameter("er_perserver");
	if (s_perserver==null || s_perserver.equals(""))
		s_perserver="Yes";

	String strEncodeFarmserver = s_farmserver;
	String strEncodeServer = s_server;
	if(strEncodeFarmserver!=null)
		strEncodeFarmserver = EgURLEncoder.encode(strEncodeFarmserver,"UTF-8");
	if(strEncodeServer!=null)
		strEncodeServer = EgURLEncoder.encode(strEncodeServer,"UTF-8");
	String sortRowDisplaySatus = "table-row";
	String sortRowDisplaySatus_1 = "none";
	if(s_application!=null && !s_application[0].equals("-1") && !s_application[0].equalsIgnoreCase("Not Applicable"))
	{
		sortRowDisplaySatus = "none";
		sortRowDisplaySatus_1 = "block";
	}
	if(s_server !=null && s_server.equals("-1"))
	{
		sortRowDisplaySatus = "none";
		sortRowDisplaySatus_1 = "block";
	}
	EgGroupInfo gpinfo = new EgGroupInfo();
	String tmpComponent="";
	Vector v_comp = compUtils.getAllUserComponents1();
	String sub1 = "MISC";
	String var1 = "CtxServer";
	Vector v_server=new Vector();
	Vector dup_v_server=new Vector();
	boolean present=false;
	User this_user = UserRegistry.getInstance().getUser(session.getId());
	String loginid = this_user.getLoginID();
	Vector dispzone=new Vector();
	List zonelist = compUtils.getUserZones();
	if(zonelist != null && zonelist.contains("--Default--"))
		zonelist.remove("--Default--");
	ArrayList getComponent=new ArrayList();
	Vector v_zonelist = new Vector();
	v_zonelist.addAll(zonelist);
	List aTemp = zonelist;
	String zones[] = new String[aTemp.size()];
	for(int m=0;m<aTemp.size();m++)
	{
		zones[m] = (String)aTemp.get(m);
	}
	ArrayList aListSelectedList = null;
	MappingNameSorter sorter = new MappingNameSorter(thisuser.getLanguage());
	ErEsxVMutils erEsxUtils = new ErEsxVMutils();
	erEsxUtils.setNeedGroupTire(true);
	List v_option = new ArrayList();	
	Hashtable htAllGroups =new 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 v_optionObj=null;
	if(v_option!=null && v_option.size()>0)
	{
		rootJson.put("selectedAnalysisByCombo",er_option);	
	
		for(int i=0; i<v_option.size(); i++)
		{
			v_optionObj = new JSONObject();
			v_optionObj.put("displayField", intlmap.getTextDescription("reporter.common."+v_option.get(i)));
			v_optionObj.put("valueField",v_option.get(i));
			arr.add(v_optionObj);
		}
	}
	else
	{
		v_optionObj = new JSONObject();
		v_optionObj.put("displayField", intlmap.getTextDescription("reporter.common.Not Applicable"));
		v_optionObj.put("valueField","-1");
		arr.add(v_optionObj);
	}
	rootJson.put("analysisByCombo",arr);
	rootJson.put("enableAggregationValue",enableAggregation);	
	
	String majorValue=request.getParameter("uppermajor");
	String minorValue=request.getParameter("upperminor");
	String criticalValue=request.getParameter("upperCritical");
	String criticalColor=reportInfo.getValue("USER_LOGON_REPORT","criticalColor");
	String majorColor=reportInfo.getValue("USER_LOGON_REPORT","majorColor");
	String minorColor=reportInfo.getValue("USER_LOGON_REPORT","minorColor");
	
	if(majorValue==null || majorValue.length()==0)
		majorValue=reportInfo.getValue("USER_LOGON_REPORT","majorValue");
	if(minorValue==null || minorValue.length()==0)
		minorValue=reportInfo.getValue("USER_LOGON_REPORT","minorValue");
	if(criticalValue==null || criticalValue.length()==0)
		criticalValue=reportInfo.getValue("USER_LOGON_REPORT","criticalValue");
	
	rootJson.put("criticalColor",criticalColor);
	rootJson.put("majorColor",majorColor);
	rootJson.put("minorColor",minorColor);
	rootJson.put("majorValue",majorValue);
	rootJson.put("criticalValue",criticalValue);
	rootJson.put("minorValue",minorValue);
	JSONObject threshObj=new JSONObject();
	threshObj.put("majorValue",majorValue);
	threshObj.put("minorValue",minorValue);
	threshObj.put("criticalValue",criticalValue);
	screenLabelJson.put("reporter.common.Major",intlmap.getTextDescription("reporter.common.Medium"));
	screenLabelJson.put("reporter.common.Minor",intlmap.getTextDescription("reporter.common.Low"));
	screenLabelJson.put("reporter.common.Critical",intlmap.getTextDescription("reporter.common.High"));
	screenLabelJson.put("reporter.common.AggregateValue",intlmap.getTextDescription("reporter.common.Report By Logons"));
	screenLabelJson.put("reporter.common.Show Delivery Groups",intlmap.getTextDescription("reporter.common.Show Delivery Groups"));
	
	rootJson.put("aggregateSessionCombo",getAggregateSessionComboValue(intlmap));
	if(er_aggregateValue==null)
		er_aggregateValue="Summary";
	rootJson.put("selectedAggregateSessionValue",er_aggregateValue);
	List v_site = new ArrayList();
	if(er_option!=null)
	{
		List aListComponentTemp=null;
		v_site = erEsxUtils.getGroupsName(htAllGroups,er_option);
		if(v_site!=null && v_site.size()>0)
		{
			Collections.sort(v_site,String.CASE_INSENSITIVE_ORDER);
		
			if(!er_option.equalsIgnoreCase("Component"))
			{
				dispzone.addAll(v_site);
				if((s_farmserver==null && v_site!=null && v_site.size()>0) || (s_farmserver!=null && !v_site.contains(s_farmserver) && v_site!=null && v_site.size()>0 && !s_farmserver.equalsIgnoreCase("-1")))
				{
					s_farmserver=(String)v_site.get(0);
				}
				aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,s_farmserver);
			}
			else 
			{
				aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,null);
			}
		}
		if(aListComponentTemp!=null && aListComponentTemp.size()>0)
		{
			v_components = new Vector();
			v_components.addAll(aListComponentTemp);
		}
		if(aListComponentTemp!=null && aListComponentTemp.size()>0)
		{
			aListCompType = 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(aListCompType!=null && !aListCompType.contains(loopType))
						aListCompType.add(loopType);
				}
			}
		}
		if(er_option.equalsIgnoreCase("Component"))
		{
			if(aListComponentTemp!=null && aListComponentTemp.size()>0)
			{
				v_components = new Vector();
				v_components.addAll(aListComponentTemp);
			}
			List compTypes = compUtils.getAllComponentType();
			if(compTypes!=null && compTypes.size()>0)
			{
				for(int aa=0;aa<compTypes.size();aa++)
				{
					if(aListSupportedComponentType.contains(compTypes.get(aa)))
					{
						if(aListCompType!=null && !aListCompType.contains(compTypes.get(aa)))
							aListCompType.add(compTypes.get(aa));
					}
				}
			}
		}
		if(aListCompType != null && !aListCompType.isEmpty() && strSelectedCompType == null)
		{
			ArrayList sortedNameList1 = new ArrayList();
			sortedNameList1 = sorter.getSortedCompTypeList(aListCompType);
			EgName obj_name1 = (EgName) sortedNameList1.get(0); 
			strSelectedCompType = obj_name1.getActualName();
		}
	}
	Collections.sort(v_components,String.CASE_INSENSITIVE_ORDER);
	Collections.sort(v_tmp,String.CASE_INSENSITIVE_ORDER);
	Collections.sort(v_temp,String.CASE_INSENSITIVE_ORDER);
	if(strSelectedCompType == null || strSelectedCompType.equals("")  || strSelectedCompType.equals("-1"))
	{
		if(aListCompType!=null && aListCompType.size()>0){
			ArrayList sortedNameList1 = new ArrayList();
			sortedNameList1 = sorter.getSortedCompTypeList(aListCompType);
			EgName obj_name1 = (EgName) sortedNameList1.get(0); 
			strSelectedCompType = obj_name1.getActualName();
		}
	}
	Collections.sort(v_components,String.CASE_INSENSITIVE_ORDER);
	Collections.sort(v_tmp,String.CASE_INSENSITIVE_ORDER);
	Collections.sort(v_temp,String.CASE_INSENSITIVE_ORDER);
	if(strSelectedCompType == null || strSelectedCompType.equals("")  || strSelectedCompType.equals("-1"))
	{
		if(aListCompType!=null && aListCompType.size()>0)
			strSelectedCompType = (String)aListCompType.get(0);
	}
	int v_componentSize=v_components.size();
	boolean allServerPresent=false;
	Hashtable htComponentcount = new Hashtable();
	Vector vecAll = new Vector();
	if(v_components!=null )
	{
		for(int m=0;m< v_components.size();m++)
		{
			String tempcomp=(String)v_components.get(m);
			StringTokenizer t_token= new StringTokenizer(tempcomp,":");
			while(t_token.hasMoreTokens())
			{
				String tempcomptype=t_token.nextToken();
				if(strSelectedCompType!=null && strSelectedCompType.equalsIgnoreCase(tempcomptype))
				{
					vecAll.add(tempcomp);
				}
				
			}
		}
	}
	v_components=vecAll;
	if(v_components !=null && v_components.size()>0)
	{
		if(s_server==null || s_server.equals("undefined"))
			s_server=(String)v_components.get(0);
		if(vecAll.size()>1)
			allServerPresent=true;
	}
	if((strGraphViewType!=null && strGraphViewType.equalsIgnoreCase("Timeline")) || (rtype!=null && rtype.equalsIgnoreCase("No") && !v_components.contains(s_server) && s_server!=null))
		s_server = "-1";
	String compontType=er_componentType;
	if(compontType == null && s_server != null && s_server.indexOf(":") > -1)
		compontType=s_server.substring(s_server.lastIndexOf(":")+1);

	if(compontType != null && reportInfo.isVmComponent(compontType)) {

		Vector frmNewTable=erInfo.getComponentForTest("VmgLogOnDetTest",compontType);
		Vector frmCtrxTable=erInfo.getComponentForTest("VmgCtxXcXAEuemTest",compontType);

		if(frmNewTable != null && frmNewTable.size() > 0 && frmCtrxTable != null && frmCtrxTable.size() > 0){
			rootJson.put("enableBrokering","yes");
			if(er_brokeringFrom != null && (er_brokeringFrom.equalsIgnoreCase("Others") || er_brokeringFrom.equalsIgnoreCase("Citrix")))
				rootJson.put("enableBrokeringFor",er_brokeringFrom);
			else
				rootJson.put("enableBrokeringFor","Citrix");
		}
		else{
			rootJson.put("enableBrokering","No");
			if(frmCtrxTable != null && frmCtrxTable.size() > 0)
				rootJson.put("enableBrokeringFor","Citrix");
			if(frmNewTable != null && frmNewTable.size() > 0)
				rootJson.put("enableBrokeringFor","Others");
		}
		if(er_brokeringFrom == null || er_brokeringFrom.equalsIgnoreCase("null")){
			if(frmNewTable != null && frmNewTable.size() > 0)
				er_brokeringFrom="Others";
			if(frmCtrxTable != null && frmCtrxTable.size() > 0)
				er_brokeringFrom="Citrix";
		}
		if(er_option != null && !er_option.equalsIgnoreCase("component")){
			if(v_components != null && v_components.size() > 0){
				if(frmNewTable != null && frmNewTable.size() > 0 && frmCtrxTable != null && frmCtrxTable.size() > 0){
					boolean forctrx=false;
					boolean forOthers=false;
					for(int i=0;i<v_components.size();i++){
						String tmpStr=(String)v_components.get(i);
						if(tmpStr != null && tmpStr.indexOf(":") > -1){
							tmpStr=tmpStr.substring(0,tmpStr.lastIndexOf(":"));
							if(!forOthers && frmNewTable.contains(tmpStr))
								forOthers=true;
							if(!forctrx && frmCtrxTable.contains(tmpStr))
								forctrx=true;
						}
					}
					if(!forctrx || !forOthers){
						rootJson.put("enableBrokering","No");
						if(!forctrx)
							rootJson.put("enableBrokeringFor","Others");
						else if(!forOthers)
							rootJson.put("enableBrokeringFor","Citrix");
					}
				}
			}
		}
		if(er_brokeringFrom != null && er_brokeringFrom.equalsIgnoreCase("Others")){
			Vector vectrArr=new Vector();
			if(v_components != null){
				for(int k=0;k<v_components.size();k++){
					String str1=(String)v_components.get(k);
					String strTemp=str1.substring(0,str1.lastIndexOf(":"));
					if(frmNewTable.contains(strTemp))
						vectrArr.add(str1);
					else if(frmNewTable.contains(strTemp.toUpperCase()))
						vectrArr.add(str1);
				}
			}
			v_components=vectrArr;
		}
		else {
			Vector vectrArr=new Vector();
			if(v_components != null){
				for(int k=0;k<v_components.size();k++){
					String str1=(String)v_components.get(k);
					String strTemp=str1.substring(0,str1.lastIndexOf(":"));
					if(frmCtrxTable.contains(strTemp))
						vectrArr.add(str1);
					else if(frmCtrxTable.contains(strTemp.toUpperCase()))
						vectrArr.add(str1);
				}
			}
			v_components=vectrArr;
		}
	}

	if(s_server!=null && !s_server.equals(""))
	{
		v_application=new Vector();
		HashSet v_app=new HashSet();
		if (s_server.equals("-1")) // Get list of applications for All  Servers
		{
			for (int l=0;l<v_components.size();l++)
			{
				String server=(String)v_components.get(l);
				String strTempComponentType1 = "";
				if(server!=null && server.lastIndexOf(":")>-1)
				strTempComponentType1 = server.substring(server.lastIndexOf(":")+1);
				String strTest = reportInfo.getTestName("USER_LOGON_REPORT",strTempComponentType1,false);
				if(reportInfo.isVmComponent(strTempComponentType1))
				{
					v_app.addAll(reportInfo.getUserNameAlonefromVM(strTest,server));
				}
				else
					v_app.addAll(erInfo.getInfosForTest("NULL",strTest,server));
			}
		}
		else if(s_server.indexOf("All")>-1 && s_server.indexOf(" ")>-1) //Get list of applications for Spefic Components type Ex :Citrix Server
		{
			String strComponentType = "";
			StringTokenizer stToken = new StringTokenizer(s_server);
			if(stToken.countTokens()>=2)
			{
				stToken.nextToken();
				strComponentType = stToken.nextToken();
			}
			for (int l=0;l<v_components.size();l++)
			{
				String server=(String)v_components.get(l);
				String strTempComponentType1 = "";
				if(server!=null && server.lastIndexOf(":")>-1)
				strTempComponentType1 = server.substring(server.lastIndexOf(":")+1);
				if(strTempComponentType1!=null && strTempComponentType1.equalsIgnoreCase(strComponentType))
				{
					String strTest ="";
					String cTest = reportInfo.getValue("USER_LOGON_REPORT","Components");
					if(er_componentType!=null && er_componentType.length()>0)
					{
						String[]comp_testArray=StringUtils.getTokens(cTest,",");
						for(int i=0;i<comp_testArray.length;i++)
						{
							String compTestPair=comp_testArray[i];
							String[]compTestPairArray=StringUtils.getTokens(compTestPair,"::");
							if(compTestPairArray.length>=4)
							{
								String componentName=compTestPairArray[0];
								String testNameee=compTestPairArray[1];
								String measure=compTestPairArray[2];
								String userMeasureName=compTestPairArray[3];
								if(er_componentType.equalsIgnoreCase(componentName))
								{
									strTest=testNameee;
									break;
								}
							}
						}
					}
					if(reportInfo.isVmComponent(strTempComponentType1))
					{
						v_app.addAll(reportInfo.getUserNameAlonefromVM(strTest,server));
					}
					else
					{
						v_app.addAll(erInfo.getInfosForTest("NULL",strTest,server));
					}
				}
			}
		}
		else // Get list fo application for specfic components
		{
			String strTempComponentType1 = s_server.substring(s_server.lastIndexOf(":")+1);
			String cTest = reportInfo.getValue("USER_LOGON_REPORT","Components");
			String[]comp_testArray=StringUtils.getTokens(cTest,",");
			EgUserRole loginUserRole = EgUserRole.getRoleObject(this_user.getLoginType());
			boolean hasAllComponentAccess = loginUserRole.hasAllComponentAccess();
			for(int i=0;i<comp_testArray.length;i++)
			{
				String compTestPair=comp_testArray[i];
				String[]compTestPairArray=StringUtils.getTokens(compTestPair,"::");
				if(compTestPairArray.length>=4)
				{
					String componentName=compTestPairArray[0];
					String testNameee=compTestPairArray[1];
					String measure=compTestPairArray[2];
					String userMeasureName=compTestPairArray[3];
					ArrayList aListTemp =  new ArrayList();
					if(componentName != null && componentName.equalsIgnoreCase(er_componentType)){
						if(serverList == null || serverList.size()==0 || "All".equals(serverList.get(0))){
							aListTemp.addAll(v_components);
							if(reportInfo.isVmComponent(strTempComponentType1))
							{
								v_app.addAll(reportInfo.getUserNameAlonefromVM(testNameee,aListTemp));
//								if(er_componentType != null && er_componentType.equalsIgnoreCase("VmVdi_i_server") && er_brokeringFrom != null && er_brokeringFrom.equalsIgnoreCase("Others"))
								if(er_componentType != null && reportInfo.isVmComponent(er_componentType) && er_brokeringFrom != null && er_brokeringFrom.equalsIgnoreCase("Others"))
									v_app.addAll(reportInfo.getUserNameAlonefromVM("VmgLogOnDetTest",aListTemp));
							}else{
							//	v_app.addAll(erInfo.getInfosForUser(testNameee));
								if(testNameee  != null && testNameee.indexOf("_DDD") > -1)
									testNameee=testNameee.substring(0,testNameee.indexOf("_DDD"));

								if(!hasAllComponentAccess){
									for (int l=0;l<v_components.size();l++)
									{
										String server=(String)v_components.get(l);
										if(server!=null && server.lastIndexOf(":")>-1)
											strTempComponentType1 = server.substring(server.lastIndexOf(":")+1);
										if(strTempComponentType1!=null && strTempComponentType1.equalsIgnoreCase(er_componentType))
										{
											v_app.addAll(erInfo.getInfosForTest("NULL",testNameee,server));
										}
									}
								}else{
									v_app.addAll(erInfo.getInfosForTest(testNameee));
								}
							}
						}
						else{
							aListTemp.addAll(serverList);
							if(reportInfo.isVmComponent(strTempComponentType1))
							{
								v_app.addAll(reportInfo.getUserNameAlonefromVM(testNameee,aListTemp));
//								if(er_componentType != null && er_componentType.equalsIgnoreCase("VmVdi_i_server") && er_brokeringFrom != null && er_brokeringFrom.equalsIgnoreCase("Others"))
								if(er_componentType != null && reportInfo.isVmComponent(er_componentType) && er_brokeringFrom != null && er_brokeringFrom.equalsIgnoreCase("Others"))
									v_app.addAll(reportInfo.getUserNameAlonefromVM("VmgLogOnDetTest",aListTemp));
							}else
								v_app.addAll(erInfo.getInfosForTest(testNameee,aListTemp));
						}
					}
				}
			}
		}
		ArrayList al=new ArrayList();
		al.add("+Total");
		al.add("+Summary");
		al.add("+\\");
		v_app.removeAll(al);
		v_app.addAll(v_application);
		v_application = new Vector();
		v_application.addAll(v_app);
		/*for (int m=0;m<v_app.size();m++)
		{
			String app=(String)v_app.get(m);
			if (!v_application.contains(app))
				v_application.add(app);
		}*/
		
	}
	Collections.sort(v_application,String.CASE_INSENSITIVE_ORDER);
	int cntUserForFarm = 0;
	if(v_application!=null)
		cntUserForFarm = v_application.size();
	if(cntUserForFarm > countForUser)
		getMoreUsers = true;

	serverForSorting=s_server;
	for(int m=0;m<subjects.size();m++)
	{
		s_variable = (String)subjects.get(m);
		tok1 = new StringTokenizer(s_variable,":");
		String displayname="";
		String s_test="";
		String s_measure="";
		while(tok1.hasMoreTokens())
		{
			String com=tok1.nextToken();
			if(aListCompType !=null && !aListCompType.contains(com))
				continue;
			if(strSelectedCompType!=null && !strSelectedCompType.equals(com))
				continue;
			s_test = tok1.nextToken();
			String val2=tok1.nextToken();
			StringTokenizer meas=new StringTokenizer(val2,"#");
			if(meas.hasMoreTokens())
				 mes=meas.nextToken();
			else
				 mes=val2;
			if(meas.hasMoreTokens())
				displayname=meas.nextToken();
			else
				displayname=val2;
			if (!v_testmes.contains(s_test+"/"+mes))
				v_testmes.add(s_test+"/"+mes);
		}
		if(serverForSorting!=null && !serverForSorting.equals("All") && !serverForSorting.equals("-1"))
		{
			if(serverForSorting.indexOf(":")>-1)
			{
				serverForSorting=serverForSorting.substring(serverForSorting.lastIndexOf(":")+1,serverForSorting.length());
			}
			else if(serverForSorting.indexOf("All")>-1 && serverForSorting.indexOf(" ")>-1)
			{
				serverForSorting=serverForSorting.substring(serverForSorting.indexOf("All")+4,serverForSorting.length());
			}
			if(s_variable.indexOf(":")>-1)
			{
				String str_temp=s_variable.substring(0,s_variable.indexOf(":"));
				if(str_temp.equalsIgnoreCase(serverForSorting))
				{
					String st_value=reportInfo.getValue("USER_LOGON_REPORT",s_variable);
					StringTokenizer cols=new StringTokenizer(st_value,",");
					while (cols.hasMoreTokens())
					{
						v_sort.add(displayname+"_"+cols.nextToken());
					}
				}
			}
		}
	}
	int totalspan=1;
	if(v_sort!=null && v_sort.size()>0)
		totalspan +=v_sort.size();
	if(testmes == null && v_testmes != null && v_testmes.size() >0)
	{
		testmes = (String)v_testmes.get(0);
	}
	if(s_uisort == null || s_uisort.equals(""))
	{
		s_uisort = "1";
	}
	String uiFile = "eg_ui.ini";
	String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
	IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
	currentDateFormat = strUserDateFormat;
	logOnDurationTestFreq = Integer.parseInt(reportInfo.getTimeFrame("USER_LOGON_REPORT","TimeIntervalForDirectorComp"));
	String starttimeformat="";
	String endtimeformat="";
	String dispDate = null;
	String comFormat = null;
	String  s_st_time = request.getParameter("startdate");
	String s_en_time = request.getParameter("enddate");
	String s_st_hr = request.getParameter("starthr");
	String s_en_hr = request.getParameter("endhr");
	String strmin = request.getParameter("startmin");
	String enmin = request.getParameter("endmin");
	String  er_timeline = request.getParameter("er_timeline");
	String  pdfStartDate = s_st_time+" "+s_st_hr+":"+strmin;
	String  pdfEndDate   = s_en_time+" "+s_en_hr+":"+enmin;
	String pdfTime = "From "+pdfStartDate+" hrs "+" "+" To "+pdfEndDate+" hrs";
	Vector applnPdfData = new Vector();
	applnPdfData = (Vector)request.getAttribute("applnPdfData");
	if(applnPdfData == null)
		applnPdfData = new Vector();
	pdfTime = "Application Report "+pdfTime;
	if(applnPdfData!=null && !applnPdfData.isEmpty())
	{
		Vector forTime = (Vector)applnPdfData.get(1);
		forTime.removeElementAt(0);
		forTime.insertElementAt(pdfTime,0);
		applnPdfData.removeElementAt(1);
		applnPdfData.insertElementAt(forTime,1);
	}
	if(er_timeline==null  || er_timeline.equals(" "))
	{
		er_timeline="1 day";
	}
	//Date calculation according to time select
	String[] options = {"Any","1 hour", "3 hours", "6 hours", "9 hours", "12 hours", "15 hours", "18 hours", "21 hours","1 day", "2 days", "3 days", "4 days", "5 days", "6 days","1 week","2 weeks","3 weeks","4 weeks","1 month","2 months","3 months"};

	String startDateTime="";
	String endDateTime="";
	if(er_timeline!=null&&!er_timeline.equals("Any"))
	{
		int blankSpaceIndex = er_timeline.indexOf(DateTimeTokenizer.BLANK_SPACE);
		if (blankSpaceIndex > 0)
		{
			SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm");
			java.util.Date today =egDt.egetRealDate();
			endDateTime = sdf.format(today);
			long value = Integer.parseInt(er_timeline.substring(0, blankSpaceIndex));
			String unit = er_timeline.substring(blankSpaceIndex+1).toLowerCase();
			if (unit.startsWith("h"))
			{//hours
				value *= 3600;
			}
			else if (unit.startsWith("d"))
			{//days
				value *= (24 * 3600);
			}
			else if (unit.startsWith("w"))
			{//weeks
				value *= (7 * 24 * 3600);
			}
			else if (unit.startsWith("mo"))
			{//months
				java.util.Date dt_temp = new java.util.Date(egDt.egetUTCDate());
				Calendar cal_temp = new GregorianCalendar();
				cal_temp.setTime(dt_temp);
				cal_temp.add(Calendar.HOUR_OF_DAY,0);
				java.util.Date dt_temp1 = cal_temp.getTime();
				long l_temp = dt_temp1.getTime();
				int  totalDays=24*(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 = egDt.egetRealDate();
				start.setTime(today.getTime() - (value * 1000));
				startDateTime = sdf.format(start);
			}
			if ((startDateTime != null) && (endDateTime != null))
			{
				int shr = Integer.parseInt(startDateTime.substring(startDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE)+1, startDateTime.indexOf(":")));
				strmin=startDateTime.substring(startDateTime.indexOf(":")+1);
				int en_hr = Integer.parseInt(endDateTime.substring(endDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE)+1, endDateTime.indexOf(":")));
				enmin=endDateTime.substring(endDateTime.indexOf(":")+1);
				s_en_time=endDateTime.substring(0, endDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE));
				s_st_time=startDateTime.substring(0, startDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE));
				s_st_hr = String.valueOf(shr);
				s_en_hr = String.valueOf(en_hr);
			}
		}
	}
	String disable="";
	if(er_timeline!=null&&!er_timeline.equals("Any"))
	{
		disable ="disabled";
	}
	if(er_timeline!=null&&er_timeline.equals("Any"))
	{
		String StrDate="";
		try
		{
			java.text.SimpleDateFormat df=new java.text.SimpleDateFormat("MM/dd/yyyy k 'at' hh:mm");
			StrDate =df.format(egDt.egetRealDate());
		}
		catch(Exception ee)
		{
			System.out.println("Exception is"+ee);
		}
		String SDate =StrDate.substring(0,StrDate.indexOf(" "));
		String shour =StrDate.substring(StrDate.indexOf(" "),StrDate.lastIndexOf(""));
		shour = shour.substring(0,3);
		if(s_st_time==null)
		{
			s_st_time=SDate;
		}
		if(s_en_time==null)
		{
			s_en_time=SDate;
		}
		if(s_st_hr==null)
		{
			shour =shour.trim();
			int starthr = Integer.parseInt(shour);
			starthr = starthr-1;
			s_st_hr=String.valueOf(starthr);
		}
		if(s_en_hr==null)
		{
			shour =shour.trim();
			s_en_hr =shour;
		}
		strmin="00";
		enmin="00";
	}
	String selectedArrangeOrder   = request.getParameter("arrangeOrderBy");
	if(selectedArrangeOrder == null || selectedArrangeOrder.trim().length()==0)
		selectedArrangeOrder = "desc";
	String nextOrderBy="asc";
	String imgurl="/final/monitor/eg_images/arrow_down_black_small.gif";
	if(selectedArrangeOrder!=null && selectedArrangeOrder.equals("desc"))
	{
		nextOrderBy="asc";
		imgurl="/final/monitor/eg_images/arrow_down_black_small.gif";
	}
	else if(selectedArrangeOrder!=null && selectedArrangeOrder.equals("asc"))
	{
		nextOrderBy="desc";
		imgurl="/final/monitor/eg_images/arrow_up_black_small.gif";
	}
	String strScreenWidth = request.getParameter("screenWidth");
	int screenWidth = 990;
	try
	{
		screenWidth = Integer.parseInt(strScreenWidth);
	}
	catch(Exception e)
	{
		screenWidth = 990;
	}
	String excludeweekend=request.getParameter("er_excwe");
	if (excludeweekend==null ||	excludeweekend.equals(""))
		excludeweekend="No";
	String includeReconnects=request.getParameter("er_inclReconnect");
	if (includeReconnects == null || includeReconnects.equals(""))
		includeReconnects="Yes";
	if(includeReconnects != null){
		if(!(includeReconnects.equalsIgnoreCase("Yes") || includeReconnects.equalsIgnoreCase("No")))
			includeReconnects="Yes";
	}
	hiddenfieldsJson.put("option","Citrix");
	hiddenfieldsJson.put("inidate",currentDateFormat);
	hiddenfieldsJson.put("currTime","");
	hiddenfieldsJson.put("er_rtype","CtxUserActivity");
	hiddenfieldsJson.put("er_trgttype",EgURLEncoder.encode("User Logon Report","UTF-8"));
	hiddenfieldsJson.put("er_gtype","CtxUserActivity");
	hiddenfieldsJson.put("pdfTime",pdfTime);
	hiddenfieldsJson.put("uid",EgURLEncoder.encode(loginid,"UTF-8"));
	hiddenfieldsJson.put("userID",EgURLEncoder.encode(loginid,"UTF-8"));
	hiddenfieldsJson.put("er_trenddata","No");
	if(request.getParameter("servers")!=null)
		hiddenfieldsJson.put("servers",request.getParameter("servers"));
	else
		hiddenfieldsJson.put("servers","null");
	if(request.getParameter("er_check")!=null)
		hiddenfieldsJson.put("er_check",request.getParameter("er_check"));
	else
		hiddenfieldsJson.put("er_check","null");
	if(request.getParameter("er_application1")!=null)
		hiddenfieldsJson.put("er_application1",request.getParameter("er_application1"));
	else
		hiddenfieldsJson.put("er_application1","null");
	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(fromFavoriteModify!=null)
		hiddenfieldsJson.put("fromFavoriteModify",fromFavoriteModify);
	else
		hiddenfieldsJson.put("fromFavoriteModify","null");
	hiddenfieldsJson.put("er_RmDispName", request.getParameter("er_RmDispName"));
	hiddenfieldsJson.put("favorite_id", favorite_id);
	hiddenfieldsJson.put("er_favorite", er_favorite);
	if(schedule_id!=null)
		hiddenfieldsJson.put("schedule_id",schedule_id);
	else
		hiddenfieldsJson.put("schedule_id","null");

	hiddenfieldsJson.put("er_ViewName","ErUserLogonDetailsReport.jsp");
	hiddenfieldsJson.put("getMaxDaysInMonth",String.valueOf(ErUtils.getMaxDaysInMonth()));
	hiddenfieldsJson.put("forwardto","ErUserLogonDetailsReportJson");
	hiddenfieldsJson.put("er_bgreportfrom","Thin_Client_User_Logon");
	hiddenfieldsJson.put("bgenabled",strbgrepportName);
	hiddenfieldsJson.put("limitforbg",limitforbg);
	hiddenfieldsJson.put("savereport","save");
	hiddenfieldsJson.put("servletName","com.eg.ErUserLogonDetailsReportC");
	hiddenfieldsJson.put("divStatus",divStatus);
	hiddenfieldsJson.put("arrangeOrderBy",selectedArrangeOrder);
	hiddenfieldsJson.put("showSearch",String.valueOf(getMoreUsers));
	if(rtype!=null&&rtype.equals("Yes"))
	{
		hiddenfieldsJson.put("opt","chart");
	}
	else
	{
		hiddenfieldsJson.put("opt","data");
	}
	hiddenfieldsJson.put("er_uisortby",s_uisort);

	String isSubmitted =request.getParameter("isSubmit");
	rootJson.put("isSubmit",isSubmitted);

	String strwidth = "90%";
	if(backreqMap == null || backreqMap != null && backreqMap.size() == 0)
		strwidth="100%";

	String fromFavSch = request.getParameter("fromFavSch");
	if(backreqMap != null && backreqMap.size() > 0  && request.getParameter("enableBack")!=null && request.getParameter("enableBack").equalsIgnoreCase("true"))
	{
		rootJson.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
	}
	if (dispzone != null)
		Collections.sort(dispzone,String.CASE_INSENSITIVE_ORDER);
	screenLabelJson.put("reporter.consolidated.Zone",intlmap.getTextDescription("reporter.consolidated."+er_option));
	JSONArray zoneArray = new JSONArray();

	if(rtype == null || (rtype!=null && rtype.equalsIgnoreCase("No")))
	{
		if((s_farmserver!=null && !s_farmserver.equals("-1"))|| (dispzone != null && !dispzone.isEmpty()))
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Please choose a "+er_option));
			loopJsonObj.put("valueField", "-1");
			zoneArray.add(loopJsonObj);
		}
		else
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "-1");
			zoneArray.add(loopJsonObj);
		}
		for(int n=0;n<dispzone.size();n++)
		{
			String s=(String)dispzone.get(n);
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",s);
			loopJsonObj.put("valueField",s);
			zoneArray.add(loopJsonObj);

			if(s_farmserver!=null && s_farmserver.equalsIgnoreCase(s))
			{
				rootJson.put("selectedZone",s_farmserver);
			}
		}
		rootJson.put("zoneCombo",zoneArray);
	}
	else
	{
		if((s_farmserver!=null && !s_farmserver.equals("-1") )|| (dispzone != null && !dispzone.isEmpty()))
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Please choose a "+er_option));
			loopJsonObj.put("valueField", "-1");
			zoneArray.add(loopJsonObj);
		}
		else
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "-1");
			zoneArray.add(loopJsonObj);
		}
		for(int n=0;n<dispzone.size();n++)
		{
			String s=(String)dispzone.get(n);
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",s);
			loopJsonObj.put("valueField",s);
			zoneArray.add(loopJsonObj);
			if(s_farmserver!=null && s_farmserver.equalsIgnoreCase(s))
				rootJson.put("selectedZone",s_farmserver);
		}
		rootJson.put("zoneCombo",zoneArray);
	}
	screenLabelJson.put("reporter.thin.Component Type",intlmap.getTextDescription("reporter.thin.Component Type"));
	JSONArray comptypeArray = new JSONArray();
	if (aListCompType != null)
		Collections.sort(aListCompType,String.CASE_INSENSITIVE_ORDER);
	
	String s_CompType = null;
	if(aListCompType!=null && aListCompType.size()>0)
	{
		loopJsonObj = new JSONObject();
		loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Please choose a Component Type"));
		loopJsonObj.put("valueField", "-1");
		comptypeArray.add(loopJsonObj);
		for(int n=0;n<aListCompType.size();n++)
		{
			String sCompType = (String)aListCompType.get(n);
			if(strSelectedCompType!=null && strSelectedCompType.equals(sCompType)&& ! strSelectedCompType.equals("-1"))
			{
				rootJson.put("selectedCompType",sCompType);
				s_CompType = sCompType;
				if(sCompType != null && reportInfo.isVmComponent(sCompType)){
					rootJson.put("isVm","true");
				}
			}
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getComponentTypeDescription(sCompType));
			loopJsonObj.put("valueField",sCompType);
			comptypeArray.add(loopJsonObj);
		}
	}
	else
	{
		loopJsonObj = new JSONObject();
		loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
		loopJsonObj.put("valueField", "-1");
		comptypeArray.add(loopJsonObj);
	}
	rootJson.put("compTypeCombo",comptypeArray);
	if(rtype == null || (rtype!=null && rtype.equalsIgnoreCase("No")))
	{
		JSONArray serverArray =  new JSONArray();
		JSONArray selectedServerArray =  new JSONArray();
	
		if(selectedCompType!=null && selectedCompType.equalsIgnoreCase("-1"))
			v_components=null;
		if(v_components !=null && !v_components.isEmpty())
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField", intlmap.getTextDescription("reporter.common.All Components"));
			loopJsonObj.put("valueField", "All");
			serverArray.add(loopJsonObj);
			for(int n=0;n<v_components.size();n++)
			{
				String s=(String)v_components.get(n);
				String s1 = s;
				if(s1.indexOf(":NULL")>-1)
					s1 = s1.substring(0,s1.indexOf(":NULL"))+s1.substring(s1.indexOf(":NULL")+5);
					
				if(serverList!=null && serverList.size()>0)
				{
					for(int i=0;i<serverList.size();i++)
					{
						if(serverList.get((i)).toString().equalsIgnoreCase(s))
							selectedServerArray.add(serverList.get((i)));
					}
				}
				else if(all_comb!=null && all_comb.equalsIgnoreCase("true"))
					selectedServerArray.add(s);
				if(s.indexOf(":")>-1 || s.indexOf("All ")>-1)
				{
					String strTemp="";
					String strTemp1="";
					if(s.indexOf(":")>-1)
					{
						strTemp = s1.substring(0,s1.lastIndexOf(":"));
					}
					if(s.indexOf("All ")>-1)
					{
						strTemp = s.substring(0,s.lastIndexOf("All ")+("All ".length()));
					}
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",strTemp);
					loopJsonObj.put("valueField",s);
					serverArray.add(loopJsonObj);
				}
				else
				{
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common."+s1));
					loopJsonObj.put("valueField",s);
					serverArray.add(loopJsonObj);
				}
			}
		}
		else
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "-1");
			serverArray.add(loopJsonObj);
		}
		// By Gowtham to show multiselected component in view
		if(selectedServerArray.size()==0)
		{
			if(v_components !=null && !v_components.isEmpty())
			{
				selectedServerArray.add("All");
			}
			else
			{
				String s="-1";
				selectedServerArray.add(s);
			}
		}
		//-------end 
		if(s_CompType!=null && !s_CompType.equals("-1") && (s_CompType.equalsIgnoreCase("Citrix_XcXenDesktop_Director") ||s_CompType.equalsIgnoreCase("Citrix_XcXenDesktop_Site") || s_CompType.equalsIgnoreCase("Citrix_Cloud_Site")) && rtype.equalsIgnoreCase("No"))
		{
			JSONArray pooTypeAry = new JSONArray();
			List selectedPool = new ArrayList();
			if(selectedServerArray.size()==1 && selectedServerArray.contains("-1"))
			{
				loopJsonObj = new JSONObject();
				loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
				loopJsonObj.put("valueField", "-1");
				pooTypeAry.add(loopJsonObj);
				selectedPool.add("-1");
			}
			else
			{
				ArrayList testList = new ArrayList();
				String otherTest=reportInfo.getValue("USER_LOGON_REPORT","OtherOption_applicable");
				//testList.add("CtxXcXDCSessionTest");
				if(s_CompType.equalsIgnoreCase("Citrix_Cloud_Site"))
					testList.add("CtxCdUserTest_DDD");
				else
					testList.add("CtxXcXDUserTest_DDD");

				List hostList = new ArrayList();
				if(selectedServerArray.size()==1 && selectedServerArray.contains("All"))
				{
					for(int v=0;v<serverArray.size();v++)
					{
						JSONObject tempObj = (JSONObject)serverArray.get(v);
						String temp = (String)tempObj.get("valueField");
						hostList.add(temp);
					}
				}
				else
				{
					for(int v=0;v<selectedServerArray.size();v++)
					{
						String temp = (String)selectedServerArray.get(v);
						hostList.add(temp);
					}
				}
				Vector desktopsList = erInfo.getDistinctDataForReport(testList,"Delivery_group", hostList, false, 0, null,null, null, null, null, "No", null);
				if(desktopsList==null || desktopsList.size()==0)
				{
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
					loopJsonObj.put("valueField","-1");
					pooTypeAry.add(loopJsonObj);
					selectedPool.add("-1");
				}
				else
				{
					if(er_poolType!=null&&er_poolType.length>0)
					{
						selectedPool = Arrays.asList(er_poolType);
					}
					else
					{
						selectedPool.add("all");
					}
					loopJsonObj=new JSONObject();
					loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.All Desktops pools"));
					loopJsonObj.put("valueField","all");
					pooTypeAry.add(loopJsonObj);
					for(int v=0;v<desktopsList.size();v++)
					{
						String desktopsListStr = (String)desktopsList.get(v);
						if((s_CompType.equalsIgnoreCase("Citrix_XcXenDesktop_Director") || s_CompType.equalsIgnoreCase("Citrix_XcXenDesktop_Site") || s_CompType.equalsIgnoreCase("Citrix_Cloud_Site"))  && desktopsListStr.indexOf(":")>-1)
						{
							desktopsListStr = desktopsListStr.substring(desktopsListStr.indexOf(":")+1);
						}
						if(desktopsListStr!=null && (desktopsListStr.equalsIgnoreCase("Total")||desktopsListStr.equalsIgnoreCase("All")))
						{
							continue;
						}
						loopJsonObj=new JSONObject();
						loopJsonObj.put("displayField",desktopsListStr);
						loopJsonObj.put("valueField",desktopsListStr);
						pooTypeAry.add(loopJsonObj);
					}
				}
			}
			rootJson.put("poolTypeCombo",pooTypeAry);
			rootJson.put("poolTypeSelected",selectedPool);
			rootJson.put("selectedShowDeliveryGroup",er_showDeliveryGroup);
			screenLabelJson.put("reporter.thin.poolTypeLabel",intlmap.getTextDescription("reporter.thin.Desktops pools"));
		}
		if(s_CompType!=null && !s_CompType.equals("-1") && (s_CompType.equalsIgnoreCase("Horizon_Pod")||s_CompType.equalsIgnoreCase("VMware_View_server")))
		{
			JSONArray pooTypeAry = new JSONArray();
			List selectedPool = new ArrayList();
			if(selectedServerArray.size()==1 && selectedServerArray.contains("-1"))
			{
				loopJsonObj = new JSONObject();
				loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable")+"!");
				loopJsonObj.put("valueField", "-1");
				pooTypeAry.add(loopJsonObj);
				selectedPool.add("-1");
			}
			else
			{
				ArrayList testList = new ArrayList();
				testList.add("METATEST");
				String queryComp = "";
				String queryCompType = "";
				if(selectedServerArray.size()==1 && selectedServerArray.contains("All"))
				{
					for(int v=0;v<serverArray.size();v++)
					{
						JSONObject tempObj = (JSONObject)serverArray.get(v);
						String temp = (String)tempObj.get("valueField");
						if(temp!=null && temp.indexOf(":")>-1)
						{
							queryCompType = temp.substring(temp.lastIndexOf(":")+1);
							queryComp+="'"+temp.substring(0,temp.lastIndexOf(":"))+"',";
						}
					}
				}
				else
				{
					for(int v=0;v<selectedServerArray.size();v++)
					{
						String temp = (String)selectedServerArray.get(v);
						if(temp!=null && temp.indexOf(":")>-1)
						{
							queryCompType = temp.substring(temp.lastIndexOf(":")+1);
							queryComp+="'"+temp.substring(0,temp.lastIndexOf(":"))+"',";
						}
					}
				}
				if(queryComp.endsWith(","))
				{
					queryComp = queryComp.substring(0,queryComp.length()-1);
				}
				StringBuffer sb_query = new StringBuffer();
				sb_query.append(" comp_name  in (" + queryComp + ") AND ");
				sb_query.append(" comp_type in ('" + queryCompType + "','Host_system') AND ");
				if(queryCompType.equalsIgnoreCase("Horizon_Pod"))
				{
					sb_query.append(" test_name ='HrznPODPoolTest'");
				}
				else if(queryCompType.equalsIgnoreCase("VMware_View_server"))
				{
					sb_query.append(" test_name ='VMViewPoolDetTest'");
				}
				else
				{
					sb_query.append(" test_name ='CtxXcXDCGroupTest'");
					sb_query.append(" AND INFO LIKE '+Desktop OS Machines%'");
				}
				System.out.println("sb_query________ "+sb_query);
				Vector desktopsList = erInfo.getDistinctDataForReport(testList,"INFO", null, false, 0, sb_query.toString(),null, null, null, null, "No", null);
				if(desktopsList==null || desktopsList.size()==0)
				{
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
					loopJsonObj.put("valueField","-1");
					pooTypeAry.add(loopJsonObj);
					selectedPool.add("-1");
				}
				else
				{
					if(er_poolType!=null&&er_poolType.length>0)
					{
						selectedPool = Arrays.asList(er_poolType);
					}
					else
					{
						selectedPool.add("all");
					}
					loopJsonObj=new JSONObject();
					loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.All Desktops pools"));
					loopJsonObj.put("valueField","all");
					pooTypeAry.add(loopJsonObj);
					for(int v=0;v<desktopsList.size();v++)
					{
						String desktopsListStr = (String)desktopsList.get(v);
						if(s_CompType.equalsIgnoreCase("Citrix_XcXenDesktop_server") && desktopsListStr.indexOf(":")>-1)
						{
							desktopsListStr = desktopsListStr.substring(desktopsListStr.indexOf(":")+1);
						}
						if(desktopsListStr!=null && (desktopsListStr.equalsIgnoreCase("Total")||desktopsListStr.equalsIgnoreCase("All")))
						{
							continue;
						}
						loopJsonObj=new JSONObject();
						loopJsonObj.put("displayField",desktopsListStr);
						loopJsonObj.put("valueField",desktopsListStr);
						pooTypeAry.add(loopJsonObj);
					}
				}
			}
			rootJson.put("poolTypeCombo",pooTypeAry);
			rootJson.put("poolTypeSelected",selectedPool);
			screenLabelJson.put("reporter.thin.poolTypeLabel",intlmap.getTextDescription("reporter.thin.Desktops pools"));
		}
		rootJson.put("selectedServer",selectedServerArray);
		rootJson.put("serverCombo",serverArray);
	}
	screenLabelJson.put("reporter.thin.Report Type",intlmap.getTextDescription("reporter.thin.Report Type"));
	JSONArray reporttypeArray =  new JSONArray();
	loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.thin.Summary"));
	loopJsonObj.put("valueField", "Yes");
	reporttypeArray.add(loopJsonObj);
	loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.thin.Details"));
	loopJsonObj.put("valueField", "No");
	reporttypeArray.add(loopJsonObj);
	rootJson.put("reportTypeCombo",reporttypeArray);
	rootJson.put("selectedreportType",rtype);
	rootJson.put("getMoreUsers",String.valueOf(getMoreUsers));
	//
	String maxCountStr = reportInfo.getValue("MISC","NoOfDescriptorforChartTopN");
	if(maxCountStr == null){
		maxCountStr = "500";
	}
	int maxCount = Integer.parseInt(maxCountStr);
	//
	if(rtype!=null && rtype.equalsIgnoreCase("No"))
	{
		JSONArray userArray = new JSONArray();
		screenLabelJson.put("reporter.thin.User",intlmap.getTextDescription("reporter.thin.User"));
		if(v_application!=null && v_application.size()>0)
		{
			if(rtype!=null&&rtype.equalsIgnoreCase("No"))
			{
				loopJsonObj = new JSONObject();
				loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.All Users"));
				loopJsonObj.put("valueField", "--All--");
				userArray.add(loopJsonObj);
			}
			JSONArray selectedUser = new JSONArray();
			for(int n=0;n<v_application.size();n++)
			{
				String s=(String)v_application.get(n);
				if (s.indexOf("+") > -1)
					s = s.substring(s.indexOf("+")+1);
				if(this.isArraycontains(s_application,s))
				{
					selectedUser.add(s);
				}
				loopJsonObj = new JSONObject();
				loopJsonObj.put("displayField",s);
				loopJsonObj.put("valueField",s);
				userArray.add(loopJsonObj);
			}
			if(maxCount<=v_application.size())
			{
				rootJson.put("disableUserCombo", "yes");
				if(s_application==null || s_application.length==0 || s_application[0].equalsIgnoreCase("Not Applicable") || s_application[0].equalsIgnoreCase("--All--"))
				{
					rootJson.put("userTextFieldValue", "*");
				}
				else
				{
					String info_str = "";
					for(int i=0;i<selectedUser.size();i++)
					{
						info_str+=selectedUser.get(i)+",";
					}
					if(info_str.endsWith(","))
					{
						info_str = info_str.substring(0,info_str.length()-1);
						rootJson.put("userTextFieldValue", info_str);
					}
					else if(info_str.length() == 0)
					{
						if(s_application.length > 0)
						{
							for(int i=0;i<s_application.length;i++)
							{
								info_str+=s_application[i]+",";
							}
							if(info_str.endsWith(","))
							{
								info_str = info_str.substring(0,info_str.length()-1);
								rootJson.put("userTextFieldValue", info_str);
							}
						}
					else
						{
							rootJson.put("userTextFieldValue", "*");
						}
					
					}
				}
			}
			rootJson.put("selectedUser",selectedUser);
		}
		else
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "Not Applicable");
			userArray.add(loopJsonObj);
		}
		rootJson.put("userCombo",userArray);
	}
	if(rtype!=null && rtype.equals("Yes"))
	{
		if(strGraphViewType == null || strGraphViewType.length() == 0)
			strGraphViewType = "Distribution"; 
		String strTimeLineSelect = "";
		String strDistributionSelect = "";
		screenLabelJson.put("reporter.thin.Graph Type",intlmap.getTextDescription("reporter.thin.Graph Type"));
		JSONArray graphTypeArray =  new JSONArray();
		loopJsonObj=new JSONObject();
		loopJsonObj.put("displayField", "Distribution");
		loopJsonObj.put("valueField", "distribution");
		graphTypeArray.add(loopJsonObj);
		loopJsonObj=new JSONObject();
		loopJsonObj.put("displayField", "Timeline");
		loopJsonObj.put("valueField", "timeline");
		graphTypeArray.add(loopJsonObj);
		rootJson.put("graphTypeArray",graphTypeArray);
		if(strGraphViewType!=null && strGraphViewType.equalsIgnoreCase("Timeline"))
		{
			strTimeLineSelect = "selected";
			rootJson.put("selectedGraphType","timeline");
		}
		else if(strGraphViewType!=null && strGraphViewType.equalsIgnoreCase("Distribution"))
		{
			strDistributionSelect = "selected";
			rootJson.put("selectedGraphType","distribution");
		}
		if(strGraphViewType!=null && strGraphViewType.equalsIgnoreCase("Timeline"))
		{
			if(s_perserver == null || s_perserver.length() == 0)
				s_perserver = "Yes"; 

			screenLabelJson.put("reporter.thin.Aggregate across servers",intlmap.getTextDescription("reporter.thin.Aggregate across servers"));
			JSONArray aggTypeArray =  new JSONArray();
			loopJsonObj=new JSONObject();
			loopJsonObj.put("displayField", "Yes");
			loopJsonObj.put("valueField", "No");
			aggTypeArray.add(loopJsonObj);
			loopJsonObj=new JSONObject();
			loopJsonObj.put("displayField", "No");
			loopJsonObj.put("valueField", "Yes");
			aggTypeArray.add(loopJsonObj);
			rootJson.put("aggbasedOn",aggTypeArray);
			if (s_perserver!=null && s_perserver.equals("Yes"))
			{
				strzoneCheck = "CHECKED";
				rootJson.put("selectedAgg","Yes");
			}
			else 
			{
				strServercheck = "CHECKED";
				rootJson.put("selectedAgg","No");
			}
		}
		else
		{
			screenLabelJson.put("reporter.thin.Measure",intlmap.getTextDescription("reporter.thin.Measure"));
			JSONArray measureArray = new JSONArray();
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Please choose a Test")+"/"+intlmap.getTextDescription("reporter.common.Measure"));
			loopJsonObj.put("valueField", "-1");
			measureArray.add(loopJsonObj);
			for(int n=0;n<v_testmes.size();n++)
			{
				String s=(String)v_testmes.get(n);
				if(s.indexOf("/")>-1)
				{
					String testdisp=s.substring(0,s.indexOf("/"));
					String mesdisp =s.substring(s.indexOf("/")+1);
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",intlmap.getTestDescription(testdisp)+"/"+intlmap.getMeasureDescription(testdisp,mesdisp));
					loopJsonObj.put("valueField",s);
					measureArray.add(loopJsonObj);
					if(testmes!=null && testmes.equalsIgnoreCase(s))
					{
						rootJson.put("selectedMeasure",testmes);
					}
				}
				else
				{
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",intlmap.getTestDescription("reporter.common."+s));
					loopJsonObj.put("valueField",s);
					measureArray.add(loopJsonObj);

					if(testmes!=null && testmes.equalsIgnoreCase(s))
					{
						rootJson.put("selectedMeasure",testmes);
					}
				}
			}
			rootJson.put("measureCombo",measureArray);
		}
	}
	screenLabelJson.put("reporter.comparison.Show Top",intlmap.getTextDescription("reporter.comparison.Show"));	
	JSONArray priorityArray =  new JSONArray();
	for(int n=0;n<v_show.size();n++)
	{
		String s=(String)v_show.get(n);
		loopJsonObj = new JSONObject();
		loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common."+s));
		loopJsonObj.put("valueField", s);
		priorityArray.add(loopJsonObj);
		if(priority!=null && priority.equalsIgnoreCase(s))
		{
			rootJson.put("selectedPriority",priority);
		}
	}
	rootJson.put("priorityCombo",priorityArray);
	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",Hourfrom);
	rootJson.put("selectedMinsFrom",Minfrom);
	rootJson.put("selectedTimeTo",Hourto);
	rootJson.put("selectedMinsTo",Minto);

	screenLabelJson.put("reporter.common.Exclude weekends",intlmap.getTextDescription("reporter.common.Exclude weekends"));
	JSONArray exclweekArray  =  new JSONArray();
	loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Yes")+" ("+Days+") ");
	loopJsonObj.put("valueField", "Yes");
	exclweekArray.add(loopJsonObj);
	loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.No"));
	loopJsonObj.put("valueField", "No");
	exclweekArray.add(loopJsonObj);
	rootJson.put("excludeWeekCombo",exclweekArray);
	rootJson.put("excludeWeek",excludeweekend);
	rootJson.put("includeReconnects",includeReconnects);
// need to reoved starts 
	JSONArray durationArray  =  new JSONArray();
	loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.greater than"));
	loopJsonObj.put("valueField", "g");
	durationArray.add(loopJsonObj);
	loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.lesser than"));
	loopJsonObj.put("valueField", "l");
	durationArray.add(loopJsonObj);
	rootJson.put("durationCombo",durationArray);
	if(er_glduration!=null)
		rootJson.put("selectedDuration",er_glduration);
	else
		rootJson.put("selectedDuration","g");

	rootJson.put("durationValue",er_duration);

	JSONArray unitsArray  =  new JSONArray();
	loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.seconds"));
	loopJsonObj.put("valueField", "seconds");
	unitsArray.add(loopJsonObj);
	loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.minutes"));
	loopJsonObj.put("valueField", "minutes");
	unitsArray.add(loopJsonObj);
	rootJson.put("unitCombo",unitsArray);
	if(er_duraSelect!=null)
		rootJson.put("selectedUnit",er_duraSelect);
	else 
		rootJson.put("selectedUnit","seconds");
	// need to reoved ends 
	screenLabelJson.put("MappedExcludeDays", intlmap.getTextDescription("reporter.common.Excludes")+" "+Days);
	if(rtype!=null&&rtype.equalsIgnoreCase("No") || rtype== null)
	{
		rootJson.put("selectedAggServer",s_perserver);
	}
	if(excludeweekend.equalsIgnoreCase("Yes") )
	{

		lst.add('"'+intlmap.getTextDescription("reporter.common.Time period")+":"+intlmap.getTextDescription("reporter.common.From")+" "+request.getParameter("timefrom")+":"+request.getParameter("minfrom")+intlmap.getTextDescription("reporter.common.Hrs")+" "+intlmap.getTextDescription("reporter.common.To")+" "+request.getParameter("timeto")+":"+request.getParameter("minto")+intlmap.getTextDescription("reporter.common.Hrs")+'"'+","+'"'+
		intlmap.getTextDescription("reporter.common.Exclude weekends")+":"+Days+'"');
	}
	else
	{
		lst.add(intlmap.getTextDescription("reporter.common.Time period")+":"+intlmap.getTextDescription("reporter.common.From")+" "+request.getParameter("timefrom")+":"+request.getParameter("minfrom")+intlmap.getTextDescription("reporter.common.Hrs")+" "+intlmap.getTextDescription("reporter.common.To")+" "+request.getParameter("timeto")+":"+request.getParameter("minto")+intlmap.getTextDescription("reporter.common.Hrs"));
	}
%>
	<%@  include file ="ErTimeFormatJSON.jsp"%>
<%
	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 = "";
	}
	else if(er_reportgenration != null && er_reportgenration.equals("background-csv"))
	{
		rootJson.put("reportGenerationSelected","background-csv");
		er_background = "selected";
		er_foreground = "";
	}
	else
	{
		er_background = "";
		er_foreground = "selected";
	}
	String bg_reportname = request.getParameter("bg_reportname");
	if(bg_reportname == null)
	{
		bg_reportname = "";
	}
	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);
	rootJson.put("selectedGraphMode",selectedGraphMode);

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

	//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.Report Generation", intlmap.getTextDescription("reporter.common.Report Generation"));
	screenLabelJson.put("reporter.common.SUBMIT", intlmap.getTextDescription("reporter.common.SUBMIT"));
	screenLabelJson.put("reporter.common.Report Name", intlmap.getTextDescription("reporter.common.Report Name"));
	JSONArray reportGenerationComboArray =  new JSONArray();
	JSONObject tmpobj=new JSONObject();

	tmpobj.put("displayField", strforeground);
	tmpobj.put("valueField", "foreground");
	reportGenerationComboArray.add(tmpobj);

	tmpobj=new JSONObject();
	tmpobj.put("displayField", strbackground);
	tmpobj.put("valueField", "background");
	reportGenerationComboArray.add(tmpobj);
	if(rtype!=null && rtype.equalsIgnoreCase("No"))
	{
		tmpobj=new JSONObject();
		tmpobj.put("displayField","Background Save - CSV");
		tmpobj.put("valueField","background-csv");
		reportGenerationComboArray.add(tmpobj);
	}
	rootJson.put("reportGenerationCombo",reportGenerationComboArray);
	screenLabelJson.put("reporter.common.Report For", intlmap.getTextDescription("reporter.common.Report For"));

	JSONArray viewApplnCombo =  new JSONArray();
	tmpobj=new JSONObject();
	tmpobj.put("displayField", intlmap.getTextDescription("reporter.common.User Activity"));
	tmpobj.put("valueField", "user_activity");
	viewApplnCombo.add(tmpobj);
	tmpobj=new JSONObject();
	tmpobj.put("displayField", intlmap.getTextDescription("reporter.common.User Usage"));
	tmpobj.put("valueField", "user_usage");
	viewApplnCombo.add(tmpobj);
	rootJson.put("reportForCombo",viewApplnCombo);
	rootJson.put("reportFor","user_activity");

	String sdate = request.getParameter("startdate");
	String edate = request.getParameter("enddate");
	String shr = request.getParameter("starthr");
	String ehr = request.getParameter("endhr");
	String smin = request.getParameter("startmin");
	String emin = request.getParameter("endmin");
	
	starttimeformat = sdate+ " " +shr+":"+smin+" "+"Hrs ";
	endtimeformat   = edate+ " " +ehr+":"+emin+" Hrs ";
	
	Vector dvec = new Vector();
	String stimefmt = "Start Date : "+pdfStartDate;
	String etimefmt = "End Date : "+pdfEndDate;
	dvec.add('"'+stimefmt+'"');
	dvec.add('"'+etimefmt+'"');
	lst.add(dvec);
	if(strbgrepportName != null && strbgrepportName.equalsIgnoreCase("Yes"))
	{
		if (er_reportgenration != null && er_reportgenration.equals("background"))
		{
			rootJson.put("reportGeneration","background");
		}
		else if(er_reportgenration != null && er_reportgenration.equals("background-csv"))
		{
			rootJson.put("reportGenerationSelected","background-csv");
		}
		else
		{
			rootJson.put("reportGeneration","foreground");
		}
	}
	if(bggroundStr != null && !bggroundStr.equals(""))
	{
		rootJson.put("backgroundReportStatus",status);
		String strreportName ="Thin_Client_User_Logon";
		if(status != null && (status.equalsIgnoreCase("duplicate") || status.equalsIgnoreCase("exceedLimit")))
		{
			strreportName ="All Report Types";
		}
		if(strreportName!=null && strreportName.indexOf(" ") > -1)
		{
			strreportName = com.eg.EgURLEncoder.encode(strreportName, "UTF-8");
		}
		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="+strreportName+"&er_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"));
	}
	
	String isNeedGeo = reportInfo.getValue("USER_LOGON_REPORT","needGeoDetails");
	if(isNeedGeo!=null && isNeedGeo.equalsIgnoreCase("yes"))
	{
		String[] filterValue = request.getParameterValues("filterValue");
		String screachStr = request.getParameter("searchBasedOn");
		if(filterValue==null || filterValue.length==0)
		{
			filterValue = new String[]{"All"};
		}
		List filterValLst = Arrays.asList(filterValue);
		if(screachStr==null || screachStr.length()==0)
		{
			screachStr = reportInfo.getValue("USER_LOGON_REPORT","searchBasedOn");
		}
		ErGeoDetailsBean geoBean = new ErGeoDetailsBean();
		ArrayList filterList = geoBean.getList(screachStr);
		JSONArray filterAry = new JSONArray();
		if(filterList==null)
		{
			filterList = new ArrayList();
			filterList.add(0,"All");
		}
		else
		{
			filterList.add(0,"All");
		}
		if(filterList!=null && filterList.size()>0)
		{
			for(int i=0;i<filterList.size();i++)
			{
				String tempStr = (String)filterList.get(i);
				loopJsonObj = new JSONObject();
				if(tempStr.equalsIgnoreCase("All"))
				{
					loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.All")+" "+intlmap.getTextDescription("reporter.common."+screachStr));
				}
				else
				{
					loopJsonObj.put("displayField",tempStr);
				}
				loopJsonObj.put("valueField", tempStr);
				filterAry.add(loopJsonObj);
			}
		}
		rootJson.put("geoFilterCombo",filterAry);
		rootJson.put("selectedgeoFilter",filterValLst);
		rootJson.put("geoFilterScreachStr",screachStr);
		screenLabelJson.put("geoFilterLabel",intlmap.getTextDescription("reporter.common.Search by")+" "+intlmap.getTextDescription("reporter.common."+screachStr));
	}
	int appValue=0;
	if(htt!=null && !htt.isEmpty())
	{
		for(Enumeration en = htt.keys(); en.hasMoreElements();)
		{
			Vector v_value = (Vector)htt.get((String)en.nextElement());
			if(v_value!=null && !v_value.isEmpty())
				appValue++;
		}
	}
	if((htt!=null && appValue >0) || (app_topusers!=null && app_topusers.size()>0) || (v_qry_string!=null && v_qry_string.size()>0))
	{
		JSONObject selectionDetails=new JSONObject();
		if (strSelectedCompType != null)
			rootJson.put("reporter.common.SelectionDetailsfor", intlmap.getTextDescription("reporter.common.Selection Details for ")+" "+ intlmap.getComponentTypeDescription(strSelectedCompType));

		String s_reportType="";
		if(rtype!=null && rtype.equals("Yes"))
		{
			s_reportType="Summary";
		} 
		else 
		{
			s_reportType="Details";
		}
		selectionDetails.put(intlmap.getTextDescription("reporter.common.Report Type"),s_reportType);
		String server = (s_server!=null && s_server.equals("-1")) ? "All Server" : s_server;
		if(server != null && server.indexOf(":NULL")>-1)
			server = server.substring(0,server.indexOf(":NULL"))+server.substring(server.indexOf(":NULL")+5);
		
		if(rtype!=null && rtype.equalsIgnoreCase("No") && server!=null && !server.equals("-1"))
		{
			selectionDetails.put(intlmap.getTextDescription("reporter.common.Server"),server.substring(0,server.lastIndexOf(":")));
		}
		if(testmes!=null && rtype!= null && rtype.equals("Yes"))
		{
			if(testmes.indexOf("/") >-1)
			{
				String str_test = testmes.substring(0,testmes.indexOf("/"));
				String s_meas = testmes.substring(testmes.indexOf("/")+1);
				selectionDetails.put(intlmap.getTextDescription("reporter.common.Measure"),intlmap.getTestDescription(str_test) + "/" +intlmap.getMeasureDescription(str_test, s_meas));
			}
			else
			{
				selectionDetails.put(intlmap.getTextDescription("reporter.common.Measure"),intlmap.getTextDescription("reporter.common."+testmes));
			}
		}
		String strApp = (s_application!=null && s_application[0].equals("-1")) ? "All Users" : s_application[0];
		if(rtype!=null && rtype.equalsIgnoreCase("No") && strApp!=null && !strApp.equals("-1"))
		{
			selectionDetails.put(intlmap.getTextDescription("reporter.common.User"),strApp);
		}
		selectionDetails.put(intlmap.getTextDescription("reporter.common.Exclude weekends"),excludeweekend);
		selectionDetails.put(intlmap.getTextDescription("reporter.common.Time Period "),"<b>"+" : </b>"+Hourfrom+":"+Minfrom+" <b>"+intlmap.getTextDescription("reporter.common.to")+" </b>"+Hourto+":"+Minto);
		selectionDetails.put((String)intlmap.getTextDescription("reporter.common.TimeLine"),"<b>"+" : </b>"+pdfStartDate+" "+intlmap.getTextDescription("reporter.common.hrs")+" <b>  "+intlmap.getTextDescription("reporter.common.to")+" </b>"+pdfEndDate+" "+intlmap.getTextDescription("reporter.common.hrs"));
		rootJson.put("selectionDetails",selectionDetails);
	}
	ArrayList sublist=(ArrayList)reportInfo.getVariables("USER_LOGON_REPORT");
	for(int i=0; i<sublist.size(); i++)
	{
		String tempsub1=(String)sublist.get(i);
		String s=request.getParameter("er_server");
		if(s!=null && !s.equals("All") && !s.equals("-1") && s.lastIndexOf(":")>0)
		{
			s=s.substring(s.lastIndexOf(":")+1,s.length());
			s=s.trim();
			if(tempsub1.indexOf(s)==-1)
			{
				sublist.remove(i);
				i=i-1;
			}
		}
	}
	if(rtype==null)
	{
		rtype="No";
	}
	JSONObject selectionDetails=new JSONObject();
	if (strSelectedCompType != null)
		rootJson.put("reporter.common.SelectionDetailsfor", intlmap.getTextDescription("reporter.common.Selection Details for ")+" "+ intlmap.getComponentTypeDescription(strSelectedCompType));

	String server = (s_server!=null && s_server.equals("-1")) ? "All Server" : s_server;
	if(server != null && server.indexOf(":NULL")>-1)
		server = server.substring(0,server.indexOf(":NULL"))+server.substring(server.indexOf(":NULL")+5);
	if(rtype!=null && rtype.equalsIgnoreCase("No") && server!=null && !server.equals("-1"))
	{
		selectionDetails.put(intlmap.getTextDescription("reporter.common.Server"),server.substring(0,server.lastIndexOf(":")));
	
		if(serverList != null && serverList.size()  > 0){
			String SelectdServrs="";
			for(int n=0;n<serverList.size();n++){
				String srvrname=(String)serverList.get(n);
					if(srvrname.indexOf(":") > -1 )
						srvrname=srvrname.substring(0,srvrname.lastIndexOf(":"));
				if(n == 0)
					SelectdServrs+=srvrname;
				else
					SelectdServrs+=", "+srvrname;
			}
			if(SelectdServrs != null && SelectdServrs.length()> 32)
				SelectdServrs=SelectdServrs.substring(0,32)+"...";
			selectionDetails.put(intlmap.getTextDescription("reporter.common.Server"),SelectdServrs);
		}
	}
	selectionDetails.put(intlmap.getTextDescription("reporter.common.Exclude weekends"),excludeweekend);
	selectionDetails.put(intlmap.getTextDescription("reporter.common.Time Period "),"<b></b>"+Hourfrom+":"+Minfrom+" <b> "+intlmap.getTextDescription("reporter.common.to")+" </b>"+Hourto+":"+Minto);
	selectionDetails.put((String)intlmap.getTextDescription("reporter.common.TimeLine"),"<b></b>"+pdfStartDate+" "+intlmap.getTextDescription("reporter.common.hrs")+" <b>   "+intlmap.getTextDescription("reporter.common.to")+" </b>"+pdfEndDate+" "+intlmap.getTextDescription("reporter.common.hrs"));
	rootJson.put("selectionDetails",selectionDetails);
	
	String enableDetailedData = reportInfo.getValue("USER_LOGON_REPORT","enableDetailedData");
    enableDetailedData = "No".equalsIgnoreCase(enableDetailedData)? "No":"Yes";
	String enableDetailedDataCHECK = reportInfo.getValue("USER_LOGON_REPORT","enableDetailedDataCHECK");
    enableDetailedDataCHECK = "No".equalsIgnoreCase(enableDetailedDataCHECK)? "No":"Yes";
	String eDd = request.getParameter("eDd");
    if(eDd!=null)
		enableDetailedData=eDd;
	rootJson.put("enableDetailedData",enableDetailedData);

	//Data View starts here
	if((rtype!=null && rtype.equalsIgnoreCase("No") || rtype== null) && (isSubmitted!=null && isSubmitted.equalsIgnoreCase("true")))
	{
		String queryString_Data =(String)ErUtils.prepareQueryString(request.getParameterMap());
		String qstringForGraph="";
		if(queryString_Data!=null)
		{
			StringTokenizer strtok = new StringTokenizer(queryString_Data,"&");
			while(strtok.hasMoreTokens())
			{
				String param = strtok.nextToken();
				int ind = param.indexOf("=");
				if (ind < 0 || param.indexOf("responseType")>-1)
					continue;
				String reqparam =param.substring(0,ind);
				String value = param.substring(ind+1);
				
				if(reqparam!=null&&reqparam.equals("select_farm"))
				{
					value=com.eg.EgURLEncoder.encode(value, "UTF-8");
				}
				if(reqparam!=null&&reqparam.equals("er_userid"))
				{
					value=com.eg.EgURLEncoder.encode(value, "UTF-8");
				}
				if(reqparam!=null&&reqparam.equals("uid"))
				{
					value=com.eg.EgURLEncoder.encode(value, "UTF-8");
				}
				if(reqparam!=null&&reqparam.equals("glduration"))
				{
					value=com.eg.EgURLEncoder.encode(value, "UTF-8");
				}
				if(reqparam!=null && ( reqparam.equals("startdate") || reqparam.equals("enddate") || reqparam.equals("inidate") || reqparam.equals("pdfTime") || reqparam.equals("select_testmes") ) )
				{
					value=com.eg.EgURLEncoder.encode(value, "UTF-8");
				}
				if(reqparam!=null&&reqparam.equalsIgnoreCase("opt"))
				{
					value="Chart";
				}
				qstringForGraph=qstringForGraph+reqparam+"="+value+"&";
			}
		}
		if(s_CompType!=null && (s_CompType.equalsIgnoreCase("Horizon_Pod")||s_CompType.equalsIgnoreCase("VMware_View_server")))
		{
			JSONObject resultMapJson = (JSONObject)session.getAttribute("USER_LOGON_REPORT_POD");
			if(resultMapJson!=null)
			{
				String noDataStr = (String)resultMapJson.get("NO_DATA");
				rootJson.put("compType",s_CompType);
				if(er_option!=null && !er_option.equalsIgnoreCase("component"))
				{
					lst.add("User Logon Details for "+er_option+" : "+request.getParameter("select_farm"));
				}
				if(noDataStr!=null && noDataStr.equalsIgnoreCase("No"))
				{
					rootJson.put("NO_DATA",false);
					JSONObject summaryObj = new JSONObject();
					String Avg_Logons = (String)resultMapJson.get("Avg_Logons");
					summaryObj.put(intlmap.getTextDescription("reporter.common.Total Pool(s)"),(String)resultMapJson.get("Total_Pools")+"#iconUniquePools");
					summaryObj.put(intlmap.getTextDescription("reporter.common.Total Logons"),(String)resultMapJson.get("Total_Logons")+"#iconWebLogIn");
					summaryObj.put(intlmap.getTextDescription("reporter.common.Avg Logon Duration (secs)"), erUtils.round((Double.parseDouble(Avg_Logons)),2)+"#iconSessionHighIdleTime");
					summaryObj.put(intlmap.getTextDescription("reporter.common.Unique Users"),resultMapJson.get("Unique_User")+"#iconLogonUser");
					summaryObj.put(intlmap.getTextDescription("reporter.common.Unique Servers/Desktops"), resultMapJson.get("Desktop_Server_Count")+"#iconClientName");
					rootJson.put("summaryObj",summaryObj);
					JSONArray summaryTableColumns = (JSONArray)resultMapJson.get("summaryTableColumns");
					JSONArray summaryTableDataList = (JSONArray)resultMapJson.get("summaryTableDataList");
					JSONObject logonDistributionGrpah = (JSONObject)resultMapJson.get("logonDistributionGrpah");
					JSONObject DistributionGraph = (JSONObject)resultMapJson.get("DistributionGraph");
					JSONObject columns = (JSONObject)resultMapJson.get("columns");
					JSONArray gridData = (JSONArray)resultMapJson.get("gridData");
					JSONObject gbObj = (JSONObject)resultMapJson.get("GROUP_DATA_GP_DATA");
					if(gbObj != null && gbObj.size() == 0)
					{
						gbObj = null;
					}
					
					
					rootJson.put("summaryTableColumns",summaryTableColumns);
					rootJson.put("summaryTableDataList",summaryTableDataList);
					rootJson.put("logonDistributionGrpah",logonDistributionGrpah);
					rootJson.put("DistributionGraph",DistributionGraph);
					rootJson.put("mainGridCol",columns);
					rootJson.put("mainGriddata",gridData);

					// form Csv data
					lst_dat1 = new LinkedList();
					vec1 = new Vector();
					sen1 = new Hashtable();
					vec1.add(intlmap.getTextDescription("reporter.common.Total Pool(s)"));
					vec1.add(intlmap.getTextDescription("reporter.common.Total Logons"));
					vec1.add(intlmap.getTextDescription("reporter.common.Avg Logon Duration(secs)"));
					vec1.add(intlmap.getTextDescription("reporter.common.Unique Users"));
					vec1.add(intlmap.getTextDescription("reporter.common.Unique Servers/Desktops"));

					lst_dat1.add((String)resultMapJson.get("Total_Pools"));
					lst_dat1.add((String)resultMapJson.get("Total_Logons"));
					lst_dat1.add(erUtils.round((Double.parseDouble(Avg_Logons)),2));
					lst_dat1.add((String)resultMapJson.get("Unique_User"));
					lst_dat1.add((String)resultMapJson.get("Desktop_Server_Count"));

					s_tit1 = "Overview";
					sen1.put(vec1,lst_dat1);
					ht1=new Hashtable();
					ht1.put(s_tit1,sen1);
					//lst.add(ht1);
					// Pool's Summary
					lst_dat1 = new LinkedList();
					vec1 = new Vector();
					sen1 = new Hashtable();
					for(int i=0;i<summaryTableColumns.size();i++)
					{
						String cols = (String)summaryTableColumns.get(i);
						if(cols!=null && cols.indexOf("<br/>")>-1)
						{
							cols = com.egurkha.util.StringUtils.replace(cols,"<br/>"," ");
						}
						vec1.add(cols);
					}
					for(int i=0;i<summaryTableDataList.size();i++)
					{
						JSONArray tempAry = (JSONArray)summaryTableDataList.get(i);
						for(int u=0;u<tempAry.size();u++)
						{
							lst_dat1.add((String)tempAry.get(u));
						}
					}
					s_tit1 = "Summarize by pools";
					sen1.put(vec1,lst_dat1);
					ht1=new Hashtable();
					ht1.put(s_tit1,sen1);
					lst.add(ht1);
					
					// Main table
					lst_dat1 = new LinkedList();
					vec1 = new Vector();
					sen1 = new Hashtable();
					Iterator itrs = columns.keySet().iterator();
					while(itrs.hasNext())
					{
						key = (String)itrs.next();
						String vals = (String)columns.get(key);
						if(vals!=null && vals.indexOf("<br/>")>-1)
						{
							vals = com.egurkha.util.StringUtils.replace(vals,"<br/>"," ");
						}
						vec1.add(vals);
					}
					for(int i=0;i<gridData.size();i++)
					{
						JSONObject tempAry = (JSONObject)gridData.get(i);
						String compKey = "";
						String stDate = (String)tempAry.get("MSMT_TIME_DB");
						String host = (String)tempAry.get("TRGT_HOST");
						String user = (String)tempAry.get("USERNAME");
						String des_compType = (String)tempAry.get("DESKTOP_COMPTYPE");
						if(user!=null && user.indexOf("\\")>-1)
						{
							//user = com.egurkha.util.StringUtils.replace(user,"\\","\\\\");
						}
						String desktop = (String)tempAry.get("DESKTOP");
						if(gbObj!=null)
						{
							String gpDurationData = reportInfo.getValue("USER_LOGON_REPORT",des_compType+"_newTable_GPDuration_Splitup");
							String gpData="";
							if(gpDurationData != null && gpDurationData.indexOf("$") > -1)
								gpData=gpDurationData.substring(gpDurationData.indexOf("$")+1);
							ArrayList gpLst = ErUtils.egTokenizer(gpData, ",");
							if(stDate != null && host != null && desktop != null && user!=null)
							{
								compKey=stDate.trim()+"#"+host.trim()+"#+"+user.trim()+"_on_"+desktop;
							}
							else if(stDate!=null)
							{
								compKey=stDate;
							}
							if(gbObj.containsKey(compKey))
							{
								JSONArray jdnnn = (JSONArray)gbObj.get(compKey);
								JSONArray gpHeader = null;
								JSONArray gpDetailsArr = new JSONArray();
								for(int z=0;z < jdnnn.size();z++)
								{
									JSONObject jsnnnn = (JSONObject)jdnnn.get(z);
									JSONObject objGp=new JSONObject();
									if(gpLst != null)
									{
										for(int k=0;k<gpLst.size();k++)
										{
											String str1=(String)gpLst.get(k);
											String strVal1=str1;
											if(str1 != null && str1.indexOf("#") > -1){
												strVal1=str1.substring(str1.indexOf("#")+1);
												str1=str1.substring(0,str1.indexOf("#"));
											}
											if(gpHeader == null)
											{
												gpHeader=new JSONArray();
												gpHeader.add(strVal1);
											}
											String str2 = (String)jsnnnn.get(str1);
											try
											{
												if(str2 != null)
												{
													double dd = Double.parseDouble(str2);
													if(dd < 0)
													{
														str2="-";
													}
												}
											}
											catch(Exception ee){}
											objGp.put(strVal1,str2);
										}
									}
									gpDetailsArr.add(objGp);
								}

								if(tempAry != null && tempAry.size() > 0){
									gpHeader=new JSONArray();
									for(int k=0;k<gpLst.size();k++){
										String str1=(String)gpLst.get(k);
										if(str1 != null && str1.indexOf("#") > -1)
										{
											str1=str1.substring(str1.indexOf("#")+1);
										}
										gpHeader.add(str1);
									}
									JSONObject objGp=new JSONObject();
									objGp.put("Header",gpHeader);
									objGp.put("Datas",gpDetailsArr);
									tempAry.put("GPDetails",objGp);
								}
							}
						}
						itrs = tempAry.keySet().iterator();
						while(itrs.hasNext())
						{
							key = (String)itrs.next();
							Object vals = (Object)tempAry.get(key);
							if(vals instanceof JSONObject)
							{
								JSONObject arr1 = (JSONObject)tempAry.get("logonBreakup");
								Iterator itr1 = arr1.keySet().iterator();
								while(itr1.hasNext())
								{
									String key1 = (String)itr1.next();
									String value_data = (String)arr1.get(key1);
									if(i==0)
									{
										vec1.add(key1);
									}
									lst_dat1.add(value_data);
								}
								arr1 = (JSONObject)tempAry.get("logonBreakup");
								itr1 = arr1.keySet().iterator();
								while(itr1.hasNext())
								{
									String key1 = (String)itr1.next();
									String value_data = (String)arr1.get(key1);
									if(i==0)
									{
										vec1.add(key1);
									}
									lst_dat1.add(value_data);
								}
							}
							else if(!key.equalsIgnoreCase("GPDetails")&&!key.equalsIgnoreCase("logonBreakup"))
							{
								if(!columns.containsKey(key))
								{
									continue;
								}
								String valsStr = (String)vals;
								if(valsStr != null && valsStr.indexOf("$$") > -1)
								{
									valsStr=valsStr.substring(0,valsStr.indexOf("$$"));
								}
								lst_dat1.add(valsStr);
							}
						}
						JSONObject vals = (JSONObject)tempAry.get("GPDetails");
						if(vals!=null)
						{
							// process for CSV
							lst_dat1.add(" ");
							lst_dat1.add(" ");
							lst_dat1.add(" ");
							lst_dat1.add("Details of client side extensions");
							for(int uv=0;uv<vec1.size()-4;uv++)
							{
								lst_dat1.add(" ");
							}
							JSONArray gpHeader = (JSONArray)vals.get("Header");
							JSONArray gpDetailsArr = (JSONArray)vals.get("Datas");
							lst_dat1.add(" ");
							for(int uv=0;uv<gpHeader.size();uv++)
							{
								lst_dat1.add(gpHeader.get(uv));
							}
							for(int uv=0;uv<vec1.size()-gpHeader.size()-1;uv++)
							{
								lst_dat1.add(" ");
							}
							for(int y=0;y<gpDetailsArr.size();y++)
							{
								lst_dat1.add(" ");
								JSONObject gObj = (JSONObject)gpDetailsArr.get(y);
								for(int uv=0;uv<gpHeader.size();uv++)
								{
									lst_dat1.add(gObj.get((String)gpHeader.get(uv)));
								}
								for(int uv=0;uv<vec1.size()-gpHeader.size()-1;uv++)
								{
									lst_dat1.add(" ");
								}
							}
						}
					}
					s_tit1 = "Logon Duration - Details";
				}
				else
				{
					
					rootJson.put("NO_DATA",true);
				}
			}
			else
			{
				rootJson.put("NO_DATA",true);
			}
		}
		else
		{
			JSONObject publicGridData = new JSONObject();
			JSONArray headerObject = new JSONArray();
			JSONArray dirHeader = new JSONArray();
			List alHeader = new ArrayList();
			int headCount=0;
			String dirHeading = "";
			String dirTestName="CtxXcXAEuemTest";
			String testName ="";
			boolean isSummary=false;
			if(er_aggregateValue==null || er_aggregateValue.equalsIgnoreCase("Details"))
			{
				isSummary=false;
				er_aggregateValue="Details";
			}
			else
			{
				isSummary=true;
			}
			rootJson.put("isSummaryResult",isSummary);
			if(er_aggregateValue!=null && er_aggregateValue.equals("Summary"))
			{
				dirHeading = reportInfo.getValue("USER_LOGON_REPORT","Summary_Dir:"+dirTestName);
			}
			else if(er_aggregateValue!=null && er_aggregateValue.equals("Details"))
			{
				dirHeading = reportInfo.getValue("USER_LOGON_REPORT","Details_Dir:"+dirTestName);
				dirHeading = "trgt_host,"+dirHeading;
			}
			String usrLogons = reportInfo.getValue("USER_LOGON_REPORT","CtxXcXAEuemTest:User Logons");
			String serverCol = reportInfo.getValue("USER_LOGON_REPORT","CtxXcXAEuemTest:Server Start-up");
			String clientCol = reportInfo.getValue("USER_LOGON_REPORT","CtxXcXAEuemTest:Client Start-up");
			String header = reportInfo.getValue("USER_LOGON_REPORT","CtxXcXAEuemTest:Header");
			String usrLogonsArr [] = (usrLogons!=null) ? usrLogons.split(",") : null;
			String serverColArr [] = (serverCol!=null) ? serverCol.split(",") : null;
			String clientColArr [] = (clientCol!=null) ? clientCol.split(",") : null;
			String headerArr [] = (header!=null) ? header.split(",") : null;
			StringTokenizer strs = new StringTokenizer(dirHeading,",");
			while(strs.hasMoreTokens())
			{
				String separateHead = strs.nextToken();
				alHeader.add(separateHead);
				separateHead = intlmap.getMeasureDescription(dirTestName,separateHead);
				if(separateHead.equalsIgnoreCase("trgt host"))
				{
					separateHead = "XenApp Server";
				}
				dirHeader.add(separateHead);
				chHeader.add(separateHead);
			}
			String testKey=er_aggregateValue;
			if (resultMap != null && resultMap.containsKey("USER_LOGON_TEST_NAME"))
			{
				testName=(String)resultMap.get("USER_LOGON_TEST_NAME");
			}
			if (resultMap != null && resultMap.containsKey("USER_LOGON_KEY"))
			{
				testKey=(String)resultMap.get("USER_LOGON_KEY");
			}
			String measures = reportInfo.getValue("USER_LOGON_REPORT",testKey+":"+testName);
			int index=0;
			int indexVal=0;
			boolean isFirstMeasure = true;
			StringTokenizer stk = new StringTokenizer(measures,",");
			while (stk.hasMoreTokens())
			{
				String measure = stk.nextToken();
				String measureUnit = tablesInfo.getUnitForMeasure(testName,measure);
				String dispname=null;
				if(measure.indexOf("#")>-1)
				{
					dispname=measure.substring(measure.indexOf("#")+1);
					measure=measure.substring(0,measure.indexOf("#"));
					if(measure.equalsIgnoreCase("Avg_logon_duration") || measure.equalsIgnoreCase("Logon") || measure.equalsIgnoreCase("Logon_duration"))
						indexVal=index;
				
					if(dispname!=null && dispname.equalsIgnoreCase("Start time"))
					{
						if(selectedCompType!=null && (selectedCompType.equalsIgnoreCase("Citrix_XcXenDesktop_Director") || selectedCompType.equalsIgnoreCase("Citrix_XcXenDesktop_Site")||selectedCompType.equalsIgnoreCase("Citrix_Cloud_Site")))
							dispname = "Logon time";
						else
						{
							dispname = "Session Startup time";
						}
					}
					if(index==0 && isSummary)
					{
						headerObject.add(dispname);
						vec1.add(dispname);
					}
					else
					{
					
						if(isSummary)
						{
							headerObject.add(dispname+" (Avg)");
							vec1.add(dispname+" (Avg)");
						}
						else
						{
							headerObject.add(dispname);
							vec1.add(dispname);
						}
					}
					headCount++;
				}
				else
				{
					if(measure.equalsIgnoreCase("Avg_logon_duration") || measure.equalsIgnoreCase("Logon") || measure.equalsIgnoreCase("Logon_duration"))
						indexVal=index;
			
					if (measure.equalsIgnoreCase("INFO"))
					{
						measure = "User Name";
						measure=intlmap.getMeasureDescription(testName,measure);
						headerObject.add(intlmap.getMeasureDescription(testName,measure));
						vec1.add(intlmap.getMeasureDescription(testName,measure));
						rootJson.put("User_Name",testName);
					} 
					else
					{
						if (!StringUtils.isNull(measure))
						{
							if(measure.equalsIgnoreCase("msmt_time"))
							{
								if(selectedCompType!=null && (selectedCompType.equalsIgnoreCase("Citrix_XcXenDesktop_Director") || selectedCompType.equalsIgnoreCase("Citrix_XcXenDesktop_Site")||selectedCompType.equalsIgnoreCase("Citrix_Cloud_Site")))
									measure="Logon Time";
								else
								{
									measure = "Session Startup time";
								}
							}
							else if(measure.equalsIgnoreCase("Desktop_Name"))
								measure="Desktop Name";
							else
								measure=intlmap.getMeasureDescription(testName,measure);
						}
						if(selectedCompType!=null && !(selectedCompType.equalsIgnoreCase("Citrix_XcXenDesktop_Director") || selectedCompType.equalsIgnoreCase("Citrix_XcXenDesktop_Site")||selectedCompType.equalsIgnoreCase("Citrix_Cloud_Site")) && measure.equalsIgnoreCase("Logon duration") )
						{
							measure="Session Startup duration";
						}
						if(isSummary)
						{
							headerObject.add(measure+" (Avg)");
							vec1.add(measure+" (Avg)");
						}
						else
						{
							headerObject.add(measure);
							vec1.add(measure);
						}
					}
				}
				index++;
				if(index==1 && isSummary)
				{
					headerObject.add("No of Logons");
					vec1.add("No of Logons");
				}
				if (isFirstMeasure && !isSummary){
					index++;
					headerObject.add("Server");
					vec1.add("Server");
					isFirstMeasure = false;
				}
			}
			publicGridData.put("sortIndex",""+indexVal);
			publicGridData.put("title","User Logon Details for "+er_option+"");
			s_tit1="User Logon Analysis";
			if(strSelectedCompType!=null)
				s_tit1+=" for "+intlmap.getComponentTypeDescription(strSelectedCompType);
		
			if(headerObject!=null)
				pageWidthProces=(headerObject.size() * 75);
		
			pageWidthProces=1024;
			if(er_componentType != null && (er_componentType.equalsIgnoreCase("Citrix_XcXenDesktop_Director") || er_componentType.equalsIgnoreCase("Citrix_XcXenDesktop_Site")||er_componentType.equalsIgnoreCase("Citrix_Cloud_Site"))){
				if(er_aggregateValue != null && er_aggregateValue.equalsIgnoreCase("Details"))
					pageWidthProces=2000;
				else
					pageWidthProces=1300;
			}
			JSONObject DetailedlogonObj=new JSONObject();
			boolean noDataFound=false;
			if(resultMap != null && resultMap.containsKey("NO_DATA_FOUND")){
				noDataFound=((Boolean)resultMap.get("NO_DATA_FOUND")).booleanValue();
			}
			if(noDataFound)
			{
				ErUserLogonDetailsReportBean userBean=new ErUserLogonDetailsReportBean();
				String averageLogonVal="";
				if(resultMap != null && resultMap.containsKey("SummaryDataForLogon")){
					JSONArray detailsArr=(JSONArray)resultMap.get("SummaryDataForLogon");
					JSONObject detailsObj=null;
					if(er_componentType != null && er_componentType.equalsIgnoreCase("Citrix_XcXenApp_server"))
						detailsObj=userBean.getLogonDetails(detailsArr,threshObj,includeReconnects,intlmap);
					else
						detailsObj=userBean.getLogonDetails(detailsArr,threshObj,null,intlmap);

					if(detailsObj != null && detailsObj.containsKey("logonDetailsData")){
						JSONArray detailedData=(JSONArray)detailsObj.get("logonDetailsData");
						publicGridData.put("LogonDetails",detailedData);
						String overviewTitle="Overview";
						if(s_application != null && s_application.length == 1 && !s_application[0].equalsIgnoreCase("--All--") && !s_application[0].equalsIgnoreCase("*"))
							overviewTitle="Logon Performance for "+s_application[0];

						publicGridData.put("LogonDetailsTitle",overviewTitle);
					}
					if(detailsObj != null && detailsObj.containsKey("logonDistributionGrpah")){
						JSONObject graphData=(JSONObject)detailsObj.get("logonDistributionGrpah");
						publicGridData.put("logOnDistributionGraph",graphData);
					}
					if(detailsObj != null && detailsObj.containsKey("sessionreconnectGraph")){
						JSONObject donutData=(JSONObject)detailsObj.get("sessionreconnectGraph");
						publicGridData.put("sessionReconnectGraph",donutData);
					}
					if(detailsObj != null && detailsObj.containsKey("UniqueUsersList")){
						JSONArray uniqUsrData=(JSONArray)detailsObj.get("UniqueUsersList");
						session.setAttribute("drillDownData",uniqUsrData);
					}
					if(detailsObj != null && detailsObj.containsKey("avgSlowLogonDuration")){
						averageLogonVal=(String)detailsObj.get("avgSlowLogonDuration");
					}
				}
				if(resultMap != null && resultMap.containsKey("SummaryDataForTrendGrph")){
					JSONArray detailsArr=(JSONArray)resultMap.get("SummaryDataForTrendGrph");
					SimpleDateFormat sdfrmt=new SimpleDateFormat(currentDateFormat);
					long daysCnt=0;
					try{
						java.util.Date dte1=sdfrmt.parse(startDateJSON);
						java.util.Date dte2=sdfrmt.parse(endDateJSON);
						long diff = dte2.getTime() - dte1.getTime();
						daysCnt=(diff/(1000 * 60 * 60 * 24));
					}
					catch(Exception ee){}
					JSONObject distData=userBean.getDistributionGraphData(detailsArr,daysCnt,currentDateFormat);
					publicGridData.put("DistributionGraph",distData);
				}
				publicGridData.put("columns",headerObject);
				publicGridData.put("dirColumns",dirHeader);
				List username = new ArrayList();
				JSONArray gridDataArray=new JSONArray();
				JSONArray dirGridDataArray=new JSONArray();

				if(er_option!=null && !er_option.equalsIgnoreCase("component"))
					lst.add("User Logon Details for "+er_option+" : "+request.getParameter("select_farm"));
				lst.add(s_tit1);

				List mainGrid = new ArrayList();
				int rowCnt=10;
				String colCnt=reportInfo.getValue("MISC","RowsperPageinGrid");
				if(colCnt != null )
					rowCnt=Integer.parseInt(colCnt);
				if(selectedCompType!=null && (selectedCompType.equalsIgnoreCase("Citrix_XcXenDesktop_Director")||selectedCompType.equalsIgnoreCase("Citrix_XcXenDesktop_Site")||selectedCompType.equalsIgnoreCase("Citrix_Cloud_Site")))
				{
					session.setAttribute("USER_LOGON_Query_String",qstringForGraph);
					publicGridData.put("isTimeperiodQuery","/final/servlet/com.eg.ErCitrixSessionLogonServletC;jsessionid="+session.getId()+"?"+qstringForGraph+"&isTimeReport=true");
					JSONObject pieChartData=(JSONObject)resultMap.get("PIE_CHART_DATA");
					if(pieChartData!=null)
					{
					//	JSONObject graphData=(JSONObject)pieChartData.get("graphData");
						JSONObject graphData=(JSONObject)pieChartData.get("graphDataNew");
						String donutTitle="<div align='center'><div style='font-size:28px;font-family:Roboto;font-weight:400'>"+averageLogonVal+"</div><div style='margin-top: -5px;font-size:12px;font-family:Roboto;font-weight:400'>Secs</div></div>";
						graphData.put("title",donutTitle);
						publicGridData.put("isBreakDownQuery",graphData);
					}
					if (resultMap != null && resultMap.containsKey("USER_LOGON_DATA_NEW")){
						JSONArray valuesArr = (JSONArray)resultMap.get("USER_LOGON_DATA_NEW");
						if(valuesArr != null && valuesArr.size() > 0){
							JSONObject dirData=null;
							JSONObject gbSplitup=null;
							JSONObject dirDataFrmVmg=null;
							JSONObject gbSplitupFrmVmg=null;
							if(enableDetailedDataCHECK != null && enableDetailedDataCHECK.equalsIgnoreCase("Yes") && er_aggregateValue  != null && er_aggregateValue.equalsIgnoreCase("Details")){
								if(resultMap.containsKey("Slow_Logon_Dir_Data")){//for slow logon Details grid 
									dirData=(JSONObject)resultMap.get("Slow_Logon_Dir_Data");
								}
								if(resultMap.containsKey("slowlogonGPDurationSplitup")){
									gbSplitup=(JSONObject)resultMap.get("slowlogonGPDurationSplitup");
								}
								if(resultMap.containsKey("Slow_Logon_Dir_DataForVMG")){//for slow logon Details grid (From VMG Test)
									dirDataFrmVmg=(JSONObject)resultMap.get("Slow_Logon_Dir_DataForVMG");
								}
								if(resultMap.containsKey("slowlogonGPDurationSplitupForVMG")){//for slow logon Details grid (From VMG Test)
									gbSplitupFrmVmg=(JSONObject)resultMap.get("slowlogonGPDurationSplitupForVMG");
								}
							}
							JSONObject detailedGridObj=userBean.getSlowLogonGridDetailedDatas(valuesArr,dirData,gbSplitup,dirDataFrmVmg,gbSplitupFrmVmg,er_componentType,intlmap,currentDateFormat,isSummary,enableAggregation,threshObj,er_aggregateValue,lst);
							detailedGridObj.put("gridRowSize",rowCnt);
							publicGridData.put("NewGridObj",detailedGridObj);//
						}
					}
					rootJson.put("GridObj",publicGridData);
				}
				else
				{
					session.setAttribute("USER_LOGON_Query_String",qstringForGraph);
					publicGridData.put("isTimeperiodQuery","/final/servlet/com.eg.ErCitrixSessionLogonServletC;jsessionid="+session.getId()+"?"+qstringForGraph+"&isTimeReport=true");
					JSONObject pieChartData=(JSONObject)resultMap.get("PIE_CHART_DATA");
					if(pieChartData!=null)
					{
					//	JSONObject graphData=(JSONObject)pieChartData.get("graphData");
						JSONObject graphData=(JSONObject)pieChartData.get("graphDataNew");
						String donutTitle="<div align='center'><div style='font-size:28px;font-family:Roboto;font-weight:400'>"+averageLogonVal+"</div><div style='margin-top: -5px;font-size:12px;font-family:Roboto;font-weight:400'>Secs</div></div>";
						graphData.put("title",donutTitle);
						publicGridData.put("isBreakDownQuery",graphData);
					}
					String compTable=selectedCompType;
	//				if(selectedCompType != null && selectedCompType.equalsIgnoreCase("VmVdi_i_server") && er_brokeringFrom != null && er_brokeringFrom.equalsIgnoreCase("Others")){
					if(selectedCompType != null && reportInfo.isVmComponent(selectedCompType) && er_brokeringFrom != null && er_brokeringFrom.equalsIgnoreCase("Others")){
						compTable+="_newTable";
					}
					if (resultMap != null && resultMap.containsKey("USER_LOGON_DATA_NEW")){
						JSONArray valuesArr = (JSONArray)resultMap.get("USER_LOGON_DATA_NEW");
						if(valuesArr != null && valuesArr.size() > 0){
							JSONObject gpObject=null;
							if(resultMap != null && resultMap.containsKey("GROUP_DATA_GP_DATA"))
								gpObject=(JSONObject)resultMap.get("GROUP_DATA_GP_DATA");
							//vec1,lst_dat1,lst
							vec1=new Vector();
							JSONObject gridDataNew=userBean.getLogonDetailsGridData(valuesArr,gpObject,compTable,intlmap,currentDateFormat,isSummary,enableAggregation,threshObj,lst,thisuser);
							if(gridDataNew != null && gridDataNew.size() > 0){
								gridDataNew.put("gridRowSize",rowCnt);
								publicGridData.put("NewGridObj",gridDataNew);//
							}
						}
					}
					rootJson.put("GridObj",publicGridData);
				}
			}
		}
	} 
	else//Graph View start here
	{
		int heightForapplet = 0;
		HashMap distributionGraph = (HashMap) request.getAttribute("distributionGraph");
		
		HashMap topGraph = null;
		if (resultMap != null)
		{
			topGraph = (HashMap) resultMap.get("XMLMAP");
		}
		String cTest = reportInfo.getValue("USER_LOGON_REPORT","Components");
		String strmeasDisplay="";
		String testName="";
		if(er_componentType!=null && er_componentType.length()>0)
		{
			String[]comp_testArray=StringUtils.getTokens(cTest,",");
			for(int i=0;i<comp_testArray.length;i++)
			{
				String compTestPair=comp_testArray[i];
				String[]compTestPairArray=StringUtils.getTokens(compTestPair,"::");
				if(compTestPairArray.length>=4)
				{
					String componentName=compTestPairArray[0];
					String testNameee=compTestPairArray[1];
					String measure=compTestPairArray[2];
					String userMeasureName=compTestPairArray[3];

					if(er_componentType.equalsIgnoreCase(componentName))
					{
						testName=testNameee;
						break;
					}
				}
			}
			strmeasDisplay = reportInfo.getValue("USER_LOGON_REPORT",testName);
		}
		if(distributionGraph != null)
		{
			JSONObject distObj = new JSONObject();
			if(!distributionGraph.isEmpty())
			{
				String title = "";
				String strstrtestDisplay=testName+":"+strmeasDisplay;
				rootJson.put("TITLE", intlmap.getTestDescription(testName)+"/"+intlmap.getMeasureDescription(testName, strmeasDisplay));
				if(selectedCompType!=null && selectedCompType.equalsIgnoreCase("Citrix_XcXenApp_server"))
				{
					 title = "Distribution of Users by Session Startup Duration (Secs)";
				}
				else
				{
					 title = (String)distributionGraph.get("chartTitle");
				}
				distObj.put("TITLE", title);
				String pieRadius = "";
				if(er_mode != null && er_mode.equalsIgnoreCase("3D")){

					pieRadius = "130";
				}
				else
					pieRadius = "97";

				String labels = (String)distributionGraph.get("sampleLabels");
				String colors = (String)distributionGraph.get("sampleColors");
				String urlstr = "";
				ArrayList pieLabels = new ArrayList();
				ArrayList pieColors = new ArrayList();
				ArrayList colrlist = new ArrayList();
				ArrayList pieLinks = new ArrayList();
				ArrayList pieurllist = new ArrayList();
				int cntvalues = 0;
				StringTokenizer stColor =  new StringTokenizer(colors,",");
				String col="";
				while(stColor.hasMoreTokens())
				{
					col = stColor.nextToken();
					colrlist.add(col.substring(col.indexOf("#")+1,col.length()));
				}
				StringTokenizer stlabels=new StringTokenizer(labels,",");
				String lab="";
				while(stlabels.hasMoreTokens())
				{
					lab = stlabels.nextToken();
					pieLabels.add(lab);
					pieurllist.add("purl_"+cntvalues);
					urlstr = (String)distributionGraph.get("url_"+cntvalues);
					pieLinks.add(urlstr);
					pieColors.add(colrlist.get(cntvalues));
					
					cntvalues++;
				}
				String legendLabel = "";
				String legendColors = "";
				String legendLinks = "";
				String urlLink = "";
				String xmlStringForFusionPieChart = chartbean.getXmlDataforfusionpiechartforURL(distributionGraph,pieRadius,true);
				String dimension = "Pie"+(er_mode != null && er_mode.equalsIgnoreCase("2D") ? "2" : "3" ) + "D";
				String swfpath = "/final/FusionCharts/swf/Pie" +  (er_mode != null && er_mode.equalsIgnoreCase("2D") ? "2" : "3" ) + "D.swf";
				distObj.put("SWF_PATH", swfpath);
				distObj.put("XMLDATA", xmlStringForFusionPieChart);
				JSONArray jarr = new JSONArray();
				JSONObject obj = new JSONObject();
				obj.put("data",chartbean.getPieDataSet());
				jarr.add(obj);
				distObj.put("DataSet",jarr);
				distObj.put("showInLegend",new Boolean(false));
				distObj.put("title","");
				distObj.put("chartType","pie");
				distObj.put("colorMode",new Boolean(true));
				distObj.put("drildown","newtab");
			    distObj.put("chartHeight",chartbean.getPieChartHeight());
			    distObj.put("chartWidth",chartbean.getPieChartWidth());
			    distObj.put("height","350");
				JSONObject legends = new JSONObject();
				JSONArray legendKeyArr = new JSONArray();
				JSONObject legendKeyObj = new JSONObject();
				for (int p=0;p <pieurllist.size();p++)
				{
					String strKey=(String)pieurllist.get(p);
					String strValue = (String)pieLinks.get(p);
					strValue = strValue.substring(strValue.indexOf("(")+1,strValue.length()-1);
					legendKeyObj.put(strKey, strValue);
					legendKeyArr.add(legendKeyObj);
				}
				legends.put("LEGEND_KEYS", legendKeyObj);
				JSONArray legendLinkArr = new JSONArray();
				for (int k=0; k <pieLabels.size();k++)
				{
					JSONObject legendLinkObj = new JSONObject();
					legendLabel = (String)pieLabels.get(k);
					legendColors = (String)pieColors.get(k);
					legendLinks = (String)pieLinks.get(k);
					urlLink = (String)pieurllist.get(k);
					legendLinkObj.put("COLOR", legendColors);
					legendLinkObj.put("LABEL", legendLabel);
					String strValue = (String)pieLinks.get(k);
					strValue = strValue.substring(strValue.indexOf("(")+1,strValue.length()-1);
					legendLinkObj.put("LINK", strValue);
					legendLinkArr.add(legendLinkObj);
				}
				legends.put("LEGEND_LINKS", legendLinkArr);
				distObj.put("HIDDENS", legendKeyObj);
				distObj.put("LEGENDS", legends);
			}
			else
			{
				String strstrtestDisplay = testName+":"+strmeasDisplay;
				distObj.put("TITLE", intlmap.getTestDescription(testName)+"/"+intlmap.getMeasureDescription(testName, strmeasDisplay));
			}
			rootJson.put("DISTRIBUTION_CHART_RESULTS", distObj);
		}
		if(topGraph != null)
		{
			JSONObject topObj = new JSONObject();
			if(topGraph != null && topGraph.size() > 0)
			{
				String strLabelsCount = (String)topGraph.get("LabelsCount");
				int countlabels = 0;
				try
				{
					countlabels = Integer.parseInt(strLabelsCount);
				}
				catch(Exception e)
				{
					e.printStackTrace();
				}
				heightForapplet = chartbean.getbarHeightforCount(countlabels);
			}
			if(topGraph.size() > 0)
			{
				String xmlStringForFusionBarChart = (String)topGraph.get("XMLDATA");
				String dimension = "StackedBar"+(er_mode != null && er_mode.equalsIgnoreCase("2D") ? "2" : "3" ) + "D";
				String swfpath = "/final/FusionCharts/swf/MSBar" +  (er_mode != null && er_mode.equalsIgnoreCase("2D") ? "2" : "3" ) + "D.swf";
				String chartTitle = (String)topGraph.get("chartTitle");

				topObj.put("TITLE", chartTitle);
				topObj.put("HEIGHT", heightForapplet+"");
				topObj.put("SWF_PATH", swfpath);
				topObj.put("XMLDATA", xmlStringForFusionBarChart);
				topGraph.put("yAxisLabel", "Avg (Secs)");
				topObj.put("topGraph", topGraph);
				
				rootJson.put("TOP_CHART_RESULTS", topObj);
			}
		}
	}
	session.setAttribute("htdat",htt);
	sen1 = new Hashtable();
	if(lst_dat1!=null && !lst_dat1.isEmpty())
	{
		if(er_option!=null && !er_option.equalsIgnoreCase("component"))
			lst.add("User Logon Details for "+er_option+" : "+request.getParameter("select_farm"));
		sen1.put(vec1,lst_dat1);
		ht1=new Hashtable();
		ht1.put(s_tit1,sen1);
		lst.add(ht1);
		sen1 = new Hashtable();
		ht1 = new Hashtable();
		session.setAttribute("list",lst);
	}else{
		session.setAttribute("list",lst);
	}

	String processVal="";
	if(rtype!=null && rtype.equals("Yes")&& testmes != null)
	{
		processVal="&printGraph=yes&opt=chart&uid="+EgURLEncoder.encode(loginid,"UTF-8")+ "&select_testmes=" +EgURLEncoder.encode(testmes,"UTF-8")+"&er_type=yes&er_sortby=-1";
	} 
	else
	{
		processVal="&er_view=PRINT&";
	}
	String strer_glduration="";
	if(er_glduration != null)
	   strer_glduration = EgURLEncoder.encode(er_glduration,"UTF-8");
	String strEncodeselect_farm = request.getParameter("select_farm");
	String strTime = request.getParameter("startdate");
	String enTime = request.getParameter("enddate");
	if(request.getParameter("select_farm") != null)
		strEncodeselect_farm = EgURLEncoder.encode(request.getParameter("select_farm"),"UTF-8");
	String strEncodetimeline = timeline;
	if(timeline != null)
		strEncodetimeline = EgURLEncoder.encode(timeline,"UTF-8");
	String strEncodestrTime = strTime;
	if(strTime != null)
		strEncodestrTime = EgURLEncoder.encode(strTime,"UTF-8");
	String strEncodeenTime = enTime;
	if(enTime != null)
		strEncodeenTime = EgURLEncoder.encode(enTime,"UTF-8");
	String strEncodeer_server = request.getParameter("er_server");
	if(request.getParameter("er_server") != null)
		strEncodeer_server = EgURLEncoder.encode(request.getParameter("er_server"),"UTF-8");
	String strEncodesel_mes = "";
	if(request.getParameter("select_testmes") != null)
		strEncodesel_mes = EgURLEncoder.encode(request.getParameter("select_testmes"),"UTF-8");

	if(strTime !=null && enTime !=null)
	{
		if(er_glduration==null)
			er_glduration="g";
		String dataProcess = mngrIProc+"/final/reporter/ErUserLogonDetailsReportPrint.jsp;jsessionid="+session.getId()+"?er_rtype=LogonCtxUserActivity&er_gtype=LogonCtxUserActivity&er_trgttype="+EgURLEncoder.encode("User Logon Report","UTF-8")+"&select_farm="+strEncodeselect_farm+"&er_server="+strEncodeer_server+"&er_application="+request.getParameter("er_application")+"&er_timeline="+strEncodetimeline+"&startdate="+strEncodestrTime+"&enddate="+strEncodeenTime+"&timefrom="+request.getParameter("timefrom")+"&timeto="+request.getParameter("timeto")+"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&startmin="+strmin+"&endmin="+enmin+"&er_secs=00&er_excwe="+excludeweekend+"&minfrom="+request.getParameter("minfrom")+"&minto="+request.getParameter("minto")+"&currTime="+request.getParameter("currTime")+"&er_perserver="+request.getParameter("er_perserver")+"&sel_mes="+strEncodesel_mes+"&er_mode="+request.getParameter("er_mode")+processVal+"&er_zone="+s_farmserver+"&er_type="+rtype+"&er_comptype="+strSelectedCompType+"&glduration="+com.eg.EgURLEncoder.encode(er_glduration, "UTF-8")+"&duration="+er_duration+"&duraSelect="+er_duraSelect+"&inidate="+com.eg.EgURLEncoder.encode(currentDateFormat, "UTF-8")+"&eruserid="+loginid+"&er_componentType="+er_componentType+"&uppermajor="+majorValue+"&upperminor="+minorValue+"&upperCritical="+criticalValue;
	
		String strEncodeusrtime = "";
		if(strUsrTimeline!=null)
			strEncodeusrtime = EgURLEncoder.encode(strUsrTimeline,"UTF-8");
		String strEncodegphtype = "";
		if(strGraphViewType!=null)
			strEncodegphtype = EgURLEncoder.encode(strGraphViewType,"UTF-8");
		String strEncodecmpType = "";
		if(strSelectedCompType!=null)
			strEncodecmpType = EgURLEncoder.encode(strSelectedCompType,"UTF-8");
		//commented for inline mail 
		//if(pageWidthProces == 2000)
		//	pageWidthProces = 9999;
		dataProcess+="&opt=chart&option=Citrix&&graphViewtype="+strEncodegphtype+"&userID="+EgURLEncoder.encode(loginid,"UTF-8")+"&er_comptype="+strEncodecmpType+"&userTimeline="+strEncodeusrtime+"&pageWidthProces="+pageWidthProces+"&pageWidth="+pageWidthProces+"&er_aggregateValue="+er_aggregateValue;
		session.setAttribute("MAIL_URL",dataProcess);
	}
	Map parameters = new HashMap();
	parameters= request.getParameterMap();
	String queryString =(String)ErUtils.prepareQueryString(request.getParameterMap());
	String Qstring="";
	if(queryString!=null)
	{
		StringTokenizer strtok = new StringTokenizer(queryString,"&");
		while(strtok.hasMoreTokens())
		{
			String param = strtok.nextToken();
			int ind = param.indexOf("=");
			if (ind < 0 || param.indexOf("responseType")>-1)
				continue;
			String reqparam =param.substring(0,ind);
			String value = param.substring(ind+1);
			if(reqparam!=null&&reqparam.equals("select_farm"))
			{
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			}
			if(reqparam!=null&&reqparam.equals("er_userid"))
			{
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			}
			/*if(reqparam!=null&&reqparam.equals("er_user"))
			{
				//value=com.egurkha.util.StringUtils.replace(value,"\\", "\\\\");
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			}*/
			if(reqparam!=null&&reqparam.equals("er_application"))
			{
				value=com.egurkha.util.StringUtils.replace(value,"\\", "\\\\");
			}
			if(reqparam!=null&&reqparam.equals("uid"))
			{
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			}
			if(reqparam!=null&&reqparam.equals("glduration"))
			{
				continue;
			}
			if(reqparam!=null && ( reqparam.equals("startdate") || reqparam.equals("enddate") || reqparam.equals("inidate") || reqparam.equals("pdfTime") || reqparam.equals("select_testmes") ) )
			{
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			}
			Qstring=Qstring+reqparam+"="+value+"&";		
				
		}
		HashMap hmQry = ErUtils.parseQueryString(Qstring);
		String targetType = "";
		if(hmQry != null && hmQry.get("er_trgttype") instanceof String)
		{
			targetType = (String)hmQry.get("er_trgttype");
		}
		else if(hmQry != null && hmQry.get("er_trgttype") instanceof String[])
		{
			targetType = ((String[])hmQry.get("er_trgttype"))[0];
		}
		hmQry.remove("er_application");
		hmQry.remove("er_component");
		hmQry.remove("er_user");
		String qString = ErUtils.prepareQueryString(hmQry);
		rootJson.put("saveQString",qString);
	}
	session.setAttribute("PDF_URL", mngrIProc+"/final/reporter/ErUserLogonDetailsReportPrint.jsp");

	//Back button - Start
	ArrayList listbackvar = new  ArrayList();
	if(request.getParameter("isSubmit")!=null)
	{
		listbackvar.add("ErUserLogonDetailsReport.jsp");
		listbackvar.add("status="+status+"&bggroundStr="+bggroundStr+"&"+queryString);
		session.setAttribute("favSchBackDisplay","Yes");
	}
	else
	{
		listbackvar.add("ErUserLogonDetailsReport.jsp");
		listbackvar.add(queryString);
		session.setAttribute("favSchBackDisplay","No");
	}
	if(request.getParameter("enableBack")==null)
	{
		session.setAttribute("reportLastAccessedURL","/final/reporter/ErUserLogonDetailsReport.jsp?"+Qstring);
		String backadded = erhelputils.getBackID();
		backreqMap = erhelputils.setBackQueryMap(backreqMap,backadded,listbackvar);
		session.setAttribute("backQuery",backreqMap);
	}
	hiddenfieldsJson.put("pageWidth",""+pageWidthProces);	
	hiddenfieldsJson.put("pageWidthProces",""+pageWidthProces);
	//Back button - End
	Hashtable RangeServerPair = (Hashtable)request.getAttribute("RangeServerPair");
	session.setAttribute("RangeServerPair",RangeServerPair);
	//method for removing the VM name form username
	rootJson.put("hiddenfields",hiddenfieldsJson);
	rootJson.put("screenLabels",screenLabelJson);
	out.println(rootJson.toString());

}
catch(Throwable t)
{
	t.printStackTrace();
}
%>
<%!
public JSONArray getAggregateSessionComboValue(EgMappingInfo intlmap)
{
	JSONArray comboArray=new JSONArray();
	JSONObject obj=new JSONObject();
	obj.put("displayField",intlmap.getTextDescription("reporter.common.Details"));
	obj.put("valueField","Details");
	comboArray.add(obj);
	obj=new JSONObject();
	obj.put("displayField",intlmap.getTextDescription("reporter.common.Summary"));
	obj.put("valueField","Summary");
	comboArray.add(obj);
	return comboArray;
}


public  boolean isArraycontains(String [] array,String val)
{
	if(array!=null)
	{
		for(int i=0;i<array.length;i++)
		{
			if(val.equalsIgnoreCase(array[i]))
			{
				return true;
			}
		}
	}
	return false;
}


%>