<%@ 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.EgExternalInfo" %>
<%@ 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 ="com.eg.MappingNameSorter"%>
<%@ page import = "com.eg.EgName"%>
<%@ 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.EgExternalInfo" %>
<%@ page import = "com.eg.EgFormatInfo" %>

<%
	String titleToDisplay=request.getParameter("er_RmDispName");
	String forChannel=request.getParameter("forChannel");

	int pageWidthProces=1024;
	int totColumns=1;
	response.setContentType("application/json");
	JSONObject rootJson = new JSONObject();
	JSONObject screenLabelJson = new JSONObject();
	JSONObject hiddenfieldsJson=new JSONObject();
	JSONObject loopJsonObj = new JSONObject();
	boolean isEnglishLanguage=false;
	if(trackerLanguage!=null && trackerLanguage.equals("en_US"))
	{
		isEnglishLanguage=true;
	}

	String bggroundStr = (String)request.getAttribute("bggroundStr");
	String status = (String)request.getAttribute("status");
	
	//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();
rootJson.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
	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

try
{
	String mngrIProc = new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
	
	String s_tit1= "";
	Hashtable ht1 = new Hashtable();
	List lst_dat1 = new LinkedList();
	Hashtable sen1 = new Hashtable();
	Vector vec1 = new Vector();
	List lst_dat2 = new LinkedList();
	Vector v_val1 = new Vector();
	List lst = new LinkedList();

	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;

	EgMappingInfo intlmap=new EgMappingInfo(thisuser.getLanguage());
	ErComponentsUtils compUtils = new ErComponentsUtils(thisuser.getLoginID());
	MappingNameSorter sorter = new MappingNameSorter(thisuser.getLanguage());
	ErUtils erUtils = new ErUtils();
	ErInfo erInfo = new ErInfo();
	EgReportInfo reportInfo=new EgReportInfo("manager");
	EgDbInfo dbInfo=new EgDbInfo("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");
	EgExternalInfo externalInfo = new EgExternalInfo("manager");
	String s_user = request.getParameter("er_user");
	String strGraphViewType = request.getParameter("graphViewtype");
	String strSelectedCompType = request.getParameter("er_comptype");
	boolean getMoreUsers = false;
	int countForUser = reportInfo.getMoreUsers("CITRIX_CHANNEL_RESOURCE");

	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 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 dsktp_searchTxt = request.getParameter("dsktp_searchTxt");
	//
	String measureName= request.getParameter("select_testmes");
	String isFromDrillDown= request.getParameter("isFromDrillDown");
	String user_name= request.getParameter("user_name");
	if(user_name != null && user_name.contains("|slash|"))
		user_name=com.egurkha.util.StringUtils.replace(user_name,"|slash|", "\\");
	String erTest= request.getParameter("ertest");
	if(erTest == null || erTest.length()>0)
		erTest= request.getParameter("er_test");

	if(dsktp_searchTxt==null)
		dsktp_searchTxt="";
			rootJson.put("dsktp_searchTxt",dsktp_searchTxt);
	String cType=request.getParameter("er_comptype");
	String cName=request.getParameter("select_server");
	String uid=request.getParameter("uid");
	String er_option =request.getParameter("er_option");
	String onAnalysisChange = request.getParameter("onAnalysisChange");
	String highlightedSummary = request.getParameter("highlightedSummary");
	if(er_option == null || (er_option!=null && er_option.isEmpty()))
	{
		 er_option = "Zone";
	}	
	
	//  for - reports by segment,Service default loading setup
			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;
				}
			}
			//for - reports by Component default loading setup
			else if(er_dataFrom!=null && er_dataFrom.equalsIgnoreCase("Component"))
			{
				er_option=er_dataFrom;
			}
	//
	String srcForImg="";
	if(divStatus==null)
	{
	divStatus="none";
	}
	if(divStatus.equals("none"))
	{
		srcForImg="/final/images/moreoption.png";
	}
	else if(divStatus.equals("block"))
	{
		srcForImg="/final/images/lessoption.png";
	}
	ArrayList aListSupportedComponentType = reportInfo.getComponentsList("CITRIX_CHANNEL_RESOURCE",false);
	ArrayList aListAlltype = new ArrayList();

	for(int kk=0;kk<aListSupportedComponentType.size();kk++)
	{
		aListAlltype.add("All "+aListSupportedComponentType.get(kk));
	}

	if (rtype==null)
	{
		rtype="Yes";
	}
	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");
	v_show.add("LAST  - " +maxInfo);
	v_show.add("LAST  - " +maxInfo/2);
	v_show.add("LAST  - " +maxInfo/4);

	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");
	

	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("CITRIX_CHANNEL_RESOURCE");
	String numTopUsers = reportInfo.getTop("CITRIX_CHANNEL_RESOURCE");

	String s_variable="";
	StringTokenizer tok1=null;
	String type="";
	String mes="";
	
	String s_sort=request.getParameter("er_sortby");
	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("CITRIX_CHANNEL_RESOURCE","FROM");
	toTime = reportInfo.getTimeFrame("CITRIX_CHANNEL_RESOURCE","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("CITRIX_CHANNEL_RESOURCE");
	String NoofServers = reportInfo.getNoOfBars("CITRIX_CHANNEL_RESOURCE","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.getParameter("er_application");
	if(s_application!=null)
	{
		s_application = erUtils.specialCharDecode(s_application);
	}
	String s_server = request.getParameter("er_server");
	String[] s_serverArr=(String[]) request.getParameterValues("er_server");
	ArrayList serverLst=new ArrayList();
	
	if(s_serverArr!=null && s_serverArr.length>0)
	{
		for(int i=0;i<s_serverArr.length;i++)
		{
			String strVal=(String) s_serverArr[i];
			serverLst.add(strVal);
		}
	}
	
	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.equals("-1") && !s_application.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";
	//String value1 = inifile.getValue(sub,var);
	Vector 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 l=0;l<atemp.size();l++)
	{
		zones[l] = (String)atemp.get(l);
	}
	
	ArrayList aListSelectedList = null;
	
	
%>
<%
	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 obj=null;
		if(v_option!=null && v_option.size()>0)
		{
		 rootJson.put("selectedAnalysisByCombo",er_option);	
		
		for(int i=0; i<v_option.size(); i++)
		{
			obj = new JSONObject();
			obj.put("displayField", intlmap.getTextDescription("reporter.common."+v_option.get(i)));
			obj.put("valueField",v_option.get(i));
			arr.add(obj);
			}
		}
		else
		{
			obj = new JSONObject();

				obj.put("displayField", intlmap.getTextDescription("reporter.common.Not Applicable"));
				obj.put("valueField","-1");
				arr.add(obj);
				
		}
		rootJson.put("analysisByCombo",arr);
			
%>		
<%	
	
	List v_site = new ArrayList();
	//Vector vecComponent=null;
	if(er_option!=null)
	{
		List aListComponentTemp=null;
		v_site = erEsxUtils.getGroupsName(htAllGroups,er_option);
		if(v_site!=null){
		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();
		}
	}

	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);
					/*
					Integer count = (Integer)htComponentcount.get(tempcomptype);
					if(count!=null)
					{
						if(vecAll!=null && !vecAll.contains("All "+tempcomptype))
						vecAll.add("All "+tempcomptype);
					}else
					{
						htComponentcount.put(tempcomptype,(new Integer(1)));
					}*/
				}
				/*if(tempcomptype.equalsIgnoreCase("Citrix_server") || tempcomptype.equalsIgnoreCase("Agg_Citrix_server"))
				{
					countCt++;
					if(countCt>1)
						presentCt=true;
				}
				if(tempcomptype.equalsIgnoreCase("Citrix_MF_XP") || tempcomptype.equalsIgnoreCase("Agg_Citrix_MF_XP") || tempcomptype.equalsIgnoreCase("2X_APP_Server"))
				{
					countCtMf++;
					if(countCtMf>1)
						presentCtMf=true;
				}
				if(tempcomptype.equalsIgnoreCase("Terminal_server"))
				{
					countTer++;
					if(countTer>1)
						presentTer=true;
				}*/
			}
		}
	}
	v_components=vecAll;
	/*
	if(vecAll!=null && vecAll.size()>0)
	{
		for(int i=0;i<vecAll.size();i++)
		{
			String strTemp = (String)vecAll.get(i);
			v_components.insertElementAt(strTemp,i);
		}
	}*/

	//if(v_componentSize>0)
	if(v_components !=null && v_components.size()>0)
	{
		/*
		if(countCitrix>0 && countTerminal>0)
			allServerPresent=true;
		*/
		
		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.equals("No") && s_server!=null && !v_components.contains(s_server)))
		s_server = "-1";
	
	if(s_server!=null && !s_server.equals(""))
	{
		v_application=new Vector();
		Vector v_app=new Vector();

		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("CITRIX_CHANNEL_RESOURCE",strTempComponentType1,false);
				if(reportInfo.isVmComponent(server))
				{
					v_app.addAll(reportInfo.getUserNameAlonefromVM(strTest,server));
				}
				else
					v_app.addAll(erInfo.getInfosForTest("NULL",strTest,server));

				if(v_app!=null)
				{
					int userSize=v_app.size();
					if(userSize > countForUser)
						getMoreUsers = true;
					if(getMoreUsers)
						break;
				}
			}
		}
		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 = reportInfo.getTestName("CITRIX_CHANNEL_RESOURCE",strComponentType,false);
					if(reportInfo.isVmComponent(server))
					{
						v_app.addAll(reportInfo.getUserNameAlonefromVM(strTest,server));
					}
					else
					{
						v_app.addAll(erInfo.getInfosForTest("NULL",strTest,server));
					}
				}
				if(v_app!=null)
				{

					int userSize=v_app.size();
					if(userSize > countForUser)
						getMoreUsers = true;
					if(getMoreUsers)
						break;
				}
			}
		}
		else // Get list fo application for specfic components
		{
			if((s_serverArr==null || s_serverArr.length==0) )
			{
				s_serverArr = new String[1];
				s_serverArr[0] = s_server;
			}
//
	if(s_serverArr!=null && s_serverArr.length>0)
	{
		for(int i=0;i<s_serverArr.length;i++)
		{
			String strVal=(String) s_serverArr[i];
			String strTempComponentType1 = strVal.substring(strVal.lastIndexOf(":")+1);
			String strTest = reportInfo.getTestName("CITRIX_CHANNEL_RESOURCE",strTempComponentType1,false);
			if(reportInfo.isVmComponent(strVal))
			{
				v_app.addAll(reportInfo.getUserNameAlonefromVM(strTest,strVal));
			}
			else
				v_app.addAll(erInfo.getInfosForTest("NULL",strTest,strVal));

				if(v_app!=null)
				{

					int userSize=v_app.size();
					if(userSize > countForUser)
						getMoreUsers = true;
					if(getMoreUsers)
						break;
				}
		}
	}
//

		}

		v_app = ErUtils.formatString(v_app,"$0+$1","$1");
		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;

	if(getMoreUsers){
		if(request.getParameter("er_tapplication") != null)
			s_application = request.getParameter("er_tapplication");
	}

	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 displaynameforUI="";
		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();
				displaynameforUI=intlmap.getTextDescription("reporter.thin."+displayname);
			}
			else{
				displaynameforUI=val2+"#"+intlmap.getMeasureDescription(s_test,val2);
				displayname=val2;
			}
			if (!v_testmes.contains(s_test+"/"+mes))
				v_testmes.add(s_test+"/"+mes);
			if(highlightedSummary!=null && s_variable.startsWith(strSelectedCompType+":"+highlightedSummary))
			{
				String hi_value=reportInfo.getValue("CITRIX_CHANNEL_RESOURCE",s_variable);
				if(hi_value.indexOf(",")>-1)
				{
					hi_value = hi_value.substring(0,hi_value.indexOf(","));
				}
				highlightedSummary = displayname+"#"+hi_value;
			}
		}
		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("CITRIX_CHANNEL_RESOURCE",s_variable);
					StringTokenizer cols=new StringTokenizer(st_value,",");
					while (cols.hasMoreTokens())
					{
						v_sort.add(displaynameforUI+"_"+cols.nextToken());
//						v_sort.add(displayname+"_"+cols.nextToken());
					}
				}
			}
		}
	}
	int totalspan=1;
	if(v_sort!=null && v_sort.size()>0)
		totalspan +=v_sort.size();
	//v_testmes.add("Number of unique users");
	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);
	String currentDateFormat = strUserDateFormat;
	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 start_date   = request.getParameter("startdate");
	String end_date     = request.getParameter("enddate");

	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.DATE,-1);
				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;
		}
	}
	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";
%>

<%
	hiddenfieldsJson.put("er_RmDispName",titleToDisplay);
	hiddenfieldsJson.put("option","Citrix");
	hiddenfieldsJson.put("inidate",currentDateFormat);
	hiddenfieldsJson.put("currTime","");
		hiddenfieldsJson.put("er_rtype","CtxChannelResource");
	if((fromScheduleModify!=null && fromScheduleModify.equalsIgnoreCase("yes")) || (fromFavoriteModify!=null && fromFavoriteModify.equalsIgnoreCase("yes")) )
		hiddenfieldsJson.put("er_trgttype","User Channel Report");
	else
		hiddenfieldsJson.put("er_trgttype",EgURLEncoder.encode("User Channel Report","UTF-8"));
	hiddenfieldsJson.put("er_gtype","Citrix");
	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","no");

	if(fromFavoriteModify!=null)
		hiddenfieldsJson.put("fromFavoriteModify",fromFavoriteModify);
	else
		hiddenfieldsJson.put("fromFavoriteModify","null");
	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","ErThinClientUserReport.jsp");
	hiddenfieldsJson.put("getMaxDaysInMonth",String.valueOf(ErUtils.getMaxDaysInMonth()));
	hiddenfieldsJson.put("forwardto","ErCtxChannelReportJson");
	hiddenfieldsJson.put("er_bgreportfrom","Thin_Client_User_Channel");
	hiddenfieldsJson.put("bgenabled",strbgrepportName);
	hiddenfieldsJson.put("limitforbg",limitforbg);
	hiddenfieldsJson.put("savereport","save");
	hiddenfieldsJson.put("servletName","com.eg.ErCtxServerReportC");
	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 &&  enableBack && request.getParameter("enableBack")!=null && request.getParameter("enableBack").equalsIgnoreCase("true") && (fromFavSch!=null && fromFavSch.equalsIgnoreCase("true")))
					{
						rootJson.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
					}
		rootJson.put("reportTitle",intlmap.getTextDescription("reporter.thin.THIN CLIENT REPORTS")+" - "+intlmap.getTextDescription("reporter.thin.USER Channel"));
	if (!StringUtils.isNull(titleToDisplay)){ 
		lst.add(titleToDisplay);
	}
	else
	{
		lst.add(intlmap.getTextDescription("reporter.thin.THIN CLIENT REPORTS")+" - "+intlmap.getTextDescription("reporter.common.USER Channel"));
	}


%>

<%
	if (dispzone != null)
	Collections.sort(dispzone,String.CASE_INSENSITIVE_ORDER);
    if("-1".equals(er_option))er_option="Zone";
	screenLabelJson.put("reporter.consolidated.Zone",intlmap.getTextDescription("reporter.consolidated."+er_option));
	JSONArray zoneArray = new JSONArray();

	if(rtype == null || (rtype!=null && rtype.equals("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);

	}
	String selectedComTyp="";
	screenLabelJson.put("reporter.thin.Component Type",intlmap.getTextDescription("reporter.thin.Component Type"));
	JSONArray comptypeArray = new JSONArray();
	if(aListCompType!=null && aListCompType.size()>0)
	{
		ArrayList sortedNameList1 = new ArrayList();
		sortedNameList1 = sorter.getSortedCompTypeList(aListCompType);
		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<sortedNameList1.size();n++)
		{
			EgName nameObj =(EgName) sortedNameList1.get(n);
			String dispValue = nameObj.getLocalName();
			String sCompType = nameObj.getActualName();

			if(strSelectedCompType!=null && strSelectedCompType.equals(sCompType)&& ! strSelectedCompType.equals("-1"))
			{
				rootJson.put("selectedCompType",sCompType);
				selectedComTyp=sCompType;
			}
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",dispValue);
			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);
	}
		String isDeskTpPresent="false";
	if(selectedComTyp!=null && selectedComTyp.length()>0)
	{
		if(reportInfo.isVmComponent(selectedComTyp))
		{
			isDeskTpPresent="true";
		}
	}
	
	rootJson.put("enableDesktop",isDeskTpPresent);
	rootJson.put("compTypeCombo",comptypeArray);
	if(rtype == null || (rtype!=null && rtype.equals("No")))
	{
		JSONArray serverArray =  new JSONArray();
			
		if(v_components !=null && !v_components.isEmpty())
		{
			JSONArray selectedCompServer = new JSONArray();			
			

			 ArrayList sortedNameList1 = new ArrayList();
			 sortedNameList1 = sorter.getSortedCompTypeList(v_components);
			 for(int n=0;n<sortedNameList1.size();n++)
			 {

				EgName nameObj =(EgName) sortedNameList1.get(n);
				String dispValue = nameObj.getLocalName();
				String s = nameObj.getActualName();
				String displayField2 = dispValue.substring(0, dispValue.lastIndexOf(":"));
			
				String s1 = s;
				if(s1.indexOf(":NULL")>-1)
					s1 = s1.substring(0,s1.indexOf(":NULL"))+s1.substring(s1.indexOf(":NULL")+5);
				
				if(serverLst!=null && serverLst.size()>0 && serverLst.contains(s))
					selectedCompServer.add(s);
				else if(s_server==null || !v_components.contains(s_server))
				  selectedCompServer.add(s);
				if(s.indexOf(":")>-1 || s.indexOf("All ")>-1)
				{
					String strTemp="";
					String strTemp1="";
					if(s.indexOf(":")>-1)
					{
						strTemp = s1.substring(0,s1.lastIndexOf(":"));
						strTemp1 = s.substring(s.lastIndexOf(":")+1);
					}
					if(s.indexOf("All ")>-1)
					{
						strTemp = s.substring(0,s.lastIndexOf("All ")+("All ".length()));
						strTemp1 = s.substring(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);
				}
			 }
			 rootJson.put("selectedServer",selectedCompServer);
		}
		else
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "-1");
			serverArray.add(loopJsonObj);
		}
%>
<%
		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.Graph"));
		loopJsonObj.put("valueField", "Yes");
		reporttypeArray.add(loopJsonObj);

		loopJsonObj = new JSONObject();
		loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.thin.Data"));
		loopJsonObj.put("valueField", "No");
		reporttypeArray.add(loopJsonObj);	

		rootJson.put("reportTypeCombo",reporttypeArray);
		rootJson.put("selectedreportType",rtype);

%>
<%

	rootJson.put("getMoreUsers",String.valueOf(getMoreUsers));

	if(rtype==null || (rtype!=null && rtype.equals("No")) || (strGraphViewType!=null && strGraphViewType.equalsIgnoreCase("Timeline")))
	{
%>
<%		JSONArray userArray = new JSONArray();
		screenLabelJson.put("reporter.thin.User",intlmap.getTextDescription("reporter.thin.User"));

		if(s_application!=null && s_application.equalsIgnoreCase("--All--"))
		{
			rootJson.put("selectedUser","--All--");
		}
		if(strGraphViewType!=null && strGraphViewType.equalsIgnoreCase("Timeline"))
		{
			String str_select="";
			if(v_application!=null && v_application.size()>0)
			{
				if(s_application==null || s_application.equals("-1"))
				{
					str_select="selected"; 
				}
				if(rtype!=null&&rtype.equals("No"))
				{
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.All Users"));
					loopJsonObj.put("valueField", "--All--");
					userArray.add(loopJsonObj);
				}
				for(int n=0;n<v_application.size();n++)
				{
					String s=(String)v_application.get(n);
					if(s_application!=null && s_application.equalsIgnoreCase(s))
					{
						rootJson.put("selectedUser",s);
					}
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",s);
					loopJsonObj.put("valueField",s);
					userArray.add(loopJsonObj);
				}
			}
			else
			{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "Not Applicable");
			userArray.add(loopJsonObj);
			rootJson.put("selectedUser","Not Applicable");
			}
		}
		else
		{
			if(!getMoreUsers)
			{
				String str_select="";
				if(v_application!=null && v_application.size()>0)
				{
					if(s_application==null || s_application.equals("-1"))
					{
						str_select="selected";

				}
				if(rtype!=null&&rtype.equals("No"))
				{
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.All Users"));
					loopJsonObj.put("valueField", "--All--");
					userArray.add(loopJsonObj);
				}
				for(int n=0;n<v_application.size();n++)
				{
					String s=(String)v_application.get(n);
					if(s_application!=null && s_application.equalsIgnoreCase(s))
					{
						rootJson.put("selectedUser",s);
					}
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",s);
					loopJsonObj.put("valueField",s);
					userArray.add(loopJsonObj);
				}
			}
			else
			{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "Not Applicable");
			userArray.add(loopJsonObj);
			rootJson.put("selectedUser","Not Applicable");
			}
		}
		else
		{
			userArray=null;
			String strDisp = searchUser;
			if(strDisp == null || strDisp.equals("") || strDisp.equalsIgnoreCase("null") )
				strDisp = "";
			rootJson.put("userTextVal",strDisp);
		}
		}
		
		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.Criteria",intlmap.getTextDescription("reporter.thin.Criteria"));
				JSONArray measureArray = new JSONArray();
				if(v_testmes!=null && v_testmes.size()>0)
				{
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Criteria"));
					loopJsonObj.put("valueField", "-1");
					measureArray.add(loopJsonObj);
				}else
				{
					loopJsonObj = new JSONObject();
					loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
					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.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);
				}
			}
		/*	loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField","MEASURE_"+n);
			loopJsonObj.put("valueField","measure_"+n);
			measureArray.add(loopJsonObj);*/
		}
%>
<%
	rootJson.put("measureCombo",measureArray);
	}
	}
%>

<%
	if(rtype == null || (rtype!=null && rtype.equals("No")))
	{
		JSONArray s_sortby  =  new JSONArray();
		if (v_sort.isEmpty())
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "Not Applicable");
			s_sortby.add(loopJsonObj);
			rootJson.put("selectedSortbyCombo","Not Applicable");
		}
		else
		{
			if(s_sort ==  null || s_sort.equals("") || s_sort.equals("null"))
			{
				s_sort = (String)v_sort.get(0);
				if(s_sort != null && s_sort.indexOf("#") > -1)
					s_sort=s_sort.substring(0,s_sort.indexOf("#"));
			}
			else
			{
				if(s_sort!=null && v_sort!=null && v_sort.size()>0 && v_sort.contains(s_sort))
				{
					for (int j=0;j<v_sort.size();j++)
					{
						String basedOn = (String)v_sort.get(j); 
						if(s_sort.equals(basedOn))
							s_sort = basedOn;
					}
				}
				else
				{
					s_sort=(String)v_sort.get(0);
				}
				if(s_sort != null && s_sort.indexOf("#") > -1)
					s_sort=s_sort.substring(0,s_sort.indexOf("#"));
			}
			for (int i =0;i<v_sort.size();i++)
			{
				String strsort=(String)v_sort.get(i); 
				String uiMeasr=strsort;
				if(strsort != null && strsort.indexOf("#") > -1){
					uiMeasr=strsort.substring(strsort.indexOf("#")+1);
					strsort=strsort.substring(0,strsort.indexOf("#"));
				}
				if(uiMeasr != null && uiMeasr.indexOf("_") > -1)
					uiMeasr=uiMeasr.substring(0,uiMeasr.lastIndexOf("_"));
					loopJsonObj = new JSONObject();
				loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common."+uiMeasr));
					loopJsonObj.put("valueField",strsort);

					s_sortby.add(loopJsonObj);
			}
			
		}
		if (!v_sort.isEmpty())
			rootJson.put("selectedSortbyCombo",s_sort);
		rootJson.put("sortbycombo",s_sortby);
	
%>
<%
	screenLabelJson.put("reporter.comparison.Show Top",intlmap.getTextDescription("reporter.comparison.Show Top"));	
	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);
	screenLabelJson.put("MappedExcludeDays", intlmap.getTextDescription("reporter.common.Excludes")+" "+Days);
		screenLabelJson.put("reporter.comparison.Weighted Average",intlmap.getTextDescription("reporter.comparison.Weighted Average"));
		JSONArray weightedArray =  new JSONArray();

		loopJsonObj = new JSONObject();
		loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Yes"));
		loopJsonObj.put("valueField", "Yes");
		weightedArray.add(loopJsonObj);

		loopJsonObj = new JSONObject();
		loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.No"));
		loopJsonObj.put("valueField", "No");
		weightedArray.add(loopJsonObj);	

		rootJson.put("weightedAvgCombo",weightedArray);
	if(rtype!=null&&rtype.equals("No") || rtype== null)
	{
		screenLabelJson.put("reporter.thin.Aggregate across servers on",intlmap.getTextDescription("reporter.thin.Aggregate across servers"));
		JSONArray aggbasedon  =  new JSONArray();
		loopJsonObj = new JSONObject();
		loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.thin.Yes"));
		loopJsonObj.put("valueField", "Yes");
		aggbasedon.add(loopJsonObj);
		loopJsonObj = new JSONObject();
		loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.thin.No"));
		loopJsonObj.put("valueField", "No");
		aggbasedon.add(loopJsonObj);
		rootJson.put("aggAcrossServer",aggbasedon);
		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"));
	}
%>


<%
	String select_yes = "";
	String select_no = "";
	if(show_timeinuse != null && show_timeinuse.equalsIgnoreCase("Yes"))
	{
		select_yes = "checked";
		select_no="";
		rootJson.put("weightedAvg","Yes");

	}
	else
	{
		select_yes="";
		select_no = "checked";
		rootJson.put("weightedAvg","No");

	}
%>





									<%@  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"))
	{
		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("timelineHourCombo",timelineHourComboArray);
	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);

	//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"));

	//This set time convertion in selection field
		 pdfStartDate = startDateForDisplay+" "+startHourForDisplay+":"+startMinForDisplay;
		 pdfEndDate = endDateForDisplay+" "+endHourForDisplay+":"+endMinForDisplay;



								
							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);
							
							%>
<%
	JSONArray reportGenerationComboArray =  new JSONArray();
	JSONObject tmpobj=new JSONObject();

	tmpobj.put("displayField", strforeground);
	tmpobj.put("valueField", "foreground");
	reportGenerationComboArray.add(tmpobj);
	if (rtype!=null && rtype.equals("No"))
	{
		tmpobj=new JSONObject();
		tmpobj.put("displayField", "Background Save - CSV");
		tmpobj.put("valueField", "background-csv");
		reportGenerationComboArray.add(tmpobj);
	}
	tmpobj=new JSONObject();
	tmpobj.put("displayField", strbackground);
	tmpobj.put("valueField", "background");
	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 Channel"));
	tmpobj.put("valueField", "user_Channel");
	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_Channel");

	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("reportGeneration","background-csv");
		}
		else
		{
			rootJson.put("reportGeneration","foreground");
%>
<%
		}
%>
 <%
	}
%>
<%
if(bggroundStr != null && !bggroundStr.equals(""))
{
	rootJson.put("backgroundReportStatus",status);
%>
<%
	String strreportName ="Thin_Client_User_Channel";
		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"));

%>

 <%
}

%>

<%
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();
	 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="Graph";
	} else {
		s_reportType="Data";
	}
	selectionDetails.put(intlmap.getTextDescription("reporter.common.Report Type"),s_reportType);
	selectionDetails.put(intlmap.getTextDescription("reporter.common.Report By"),er_option);
	selectionDetails.put(intlmap.getTextDescription("reporter.consolidated.Component Type"),intlmap.getComponentTypeDescription(strSelectedCompType));


%>
<%
	String server = (s_server!=null && s_server.equals("-1")) ? "All Server" : s_server;
	if(server.indexOf(":NULL")>-1)
		server = server.substring(0,server.indexOf(":NULL"))+server.substring(server.indexOf(":NULL")+5);
	if(rtype!=null && rtype.equals("No") && server!=null && !server.equals("-1"))
	{
	selectionDetails.put(intlmap.getTextDescription("reporter.common.Server"),server.substring(0,server.lastIndexOf(":")+1));

%>
<%
	}
	if(testmes!=null && rtype!= null && rtype.equals("Yes") && strGraphViewType!=null && strGraphViewType.equalsIgnoreCase("distribution"))
	{
%>
<%
		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.Criteria"),intlmap.getMeasureDescription(str_test, s_meas));

%>
<%
		} else {
			selectionDetails.put(intlmap.getTextDescription("reporter.common.Criteria"),intlmap.getTextDescription("reporter.common."+testmes));

%>
<%
		}
	}
	String strApp = (s_application!=null && s_application.equals("-1")) ? "All Users" : s_application;

	if(rtype!=null)
	{
		if(rtype.equals("No") && strApp!=null && !strApp.equals("-1") || rtype.equals("Yes") && strGraphViewType!=null && strGraphViewType.equalsIgnoreCase("timeline"))
		{
	
	selectionDetails.put(intlmap.getTextDescription("reporter.common.User"),erUtils.specialCharDecode(strApp));

%>
<%
		}
	}
			selectionDetails.put(intlmap.getTextDescription("reporter.common.Exclude weekends"),excludeweekend);

			selectionDetails.put(intlmap.getTextDescription("reporter.common.Time Period "),
			"<span class='font_bold'></span> "+Hourfrom+":"+Minfrom+
			"<span class='font_bold'> "+intlmap.getTextDescription("reporter.common.to")+" </span>"
			+Hourto+":"+Minto);

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

			rootJson.put("selectionDetails",selectionDetails);


%>

<%
	}

	ArrayList sublist=(ArrayList)reportInfo.getVariables("CITRIX_CHANNEL_RESOURCE");
	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";
	}
	//Data View starts here
	if(rtype!=null&&rtype.equals("No") || rtype== null)
	{
		JSONObject reportDataJson = new JSONObject();
		if(app_topusers == null || app_topusers.isEmpty() || app_topusers.size() == 0)
		{
			Vector value=new Vector();
			String AddFieldsDisplay="";
			String FieldstoDisplay="$F{title}";
			String Fields="title";
			String addMapping="";
			String pdfKey="";
			String con="yes";
			if (htt!=null )
			{
				Enumeration enum1 = htt.keys();
				if (htt.isEmpty())
				{
%>
<%
				}
				while(enum1.hasMoreElements())
				{
					String key1 = (String)enum1.nextElement();
					value=(Vector)htt.get(key1);

					if(value.isEmpty() && con.equals("yes"))
					{
%>
<%
						con="no";
					}
					if(!value.isEmpty())
					{
						JSONObject gridObj=new JSONObject();
						JSONObject gridColumnsDetails=new JSONObject();
						JSONObject unitForMeasure=new JSONObject();
						JSONArray gridDataArray=new JSONArray();
						JSONArray gridDataArray_temp=new JSONArray();//New Change
						JSONArray summarylst=new JSONArray();
						JSONArray summaryAry=new JSONArray();
						int totalColumnCount=0;
						int havingSingleColumn=0;

						if(s_server.equals("-1") && value.get(0) instanceof Vector)
							totalspan= ((Vector)value.get(0)).size();
%>
<%
						//vec1.add(new String());
						gridColumnsDetails.put(new String(),new JSONArray());
						totalColumnCount++;
						


						if(s_server==null || s_server.equals("-1") || s_server.equals("")|| aListAlltype.contains(s_server))// s_server.equals("All Terminal_Servers")|| s_server.equals("All Citrix_MF_XP Servers")|| s_server.equals("All Citrix_servers"))
						//&&  s_farmserver!=null && !s_farmserver.equals("") )
						{
							pdfKey=s_farmserver;
%>
<%
							if(priority != null && priority.equalsIgnoreCase("All"))
							{
								s_tit1 = intlmap.getTextDescription("reporter.application.ICA Virtual Channel Analytics")+" for "+intlmap.getComponentTypeDescription(key1);
							}
							else
							{
								s_tit1 = priority + " " + intlmap.getTextDescription("reporter.application.ICA Virtual Channel Analytics")+" for "+intlmap.getComponentTypeDescription(key1);
							}
							if(er_option!=null)
							{
								if(!er_option.equals("Component"))
								s_tit1+=" components of "+er_option;
							}
							if(s_farmserver!=null && !s_farmserver.equals("-1"))
							s_tit1+=" "+s_farmserver;

							gridObj.put("gridTitle",s_tit1);
							

							if (s_perserver!=null && s_perserver.equalsIgnoreCase("No"))
							{
								AddFieldsDisplay="Server / User";
%>
<%
							
							vec1.add(intlmap.getTextDescription("reporter.common.Server")+" /"+intlmap.getTextDescription("reporter.common.User"));

							gridColumnsDetails.put(intlmap.getTextDescription("reporter.common.Server")+" /"+intlmap.getTextDescription("reporter.common.User"),new JSONArray());
							summaryAry.add(intlmap.getTextDescription("reporter.common.Server")+" /"+intlmap.getTextDescription("reporter.common.User"));
							totalColumnCount++;
							}
							else
							{
%>
<%
								AddFieldsDisplay="Application";
								vec1.add(intlmap.getTextDescription("reporter.common.User"));
								gridColumnsDetails.put(intlmap.getTextDescription("reporter.common.users"),new JSONArray());
								summaryAry.add(intlmap.getTextDescription("reporter.thin.users"));
								totalColumnCount++;
							}
%>
<%
							FieldstoDisplay+=",-";
						}
						else if ((s_server!=null || !s_server.equals("-1") || !s_server.equals("")) )
						{
							String s_server_sub = s_server;
							if(s_server_sub.indexOf(":NULL")>-1)
								s_server_sub = s_server_sub.substring(0,s_server_sub.indexOf(":NULL"))+s_server_sub.substring(s_server_sub.indexOf(":NULL")+5);
							String t_srv=s_server_sub.substring(0,s_server_sub.lastIndexOf(":"));
							if(t_srv!=null && t_srv.indexOf(",")>0 && strSelectedCompType!=null && strSelectedCompType.trim().length()>0)
								t_srv=intlmap.getComponentTypeDescription(strSelectedCompType);
%>
<%
							pdfKey=s_server_sub.substring(0,s_server_sub.lastIndexOf(":"));
							AddFieldsDisplay="Application";
							FieldstoDisplay+=",-";
							if(priority != null && priority.equalsIgnoreCase("All"))
							{
								s_tit1 = intlmap.getTextDescription("reporter.application.ICA Virtual Channel Analytics")+" for "+intlmap.getComponentTypeDescription(key1);
							}
							else
							{
								s_tit1 = priority + " " + intlmap.getTextDescription("reporter.application.ICA Virtual Channel Analytics")+" for "+intlmap.getComponentTypeDescription(key1);
							}
							if(er_option!=null)
							{
								if(!er_option.equals("Component"))
								s_tit1+=" components of "+er_option;
							}
							if(s_farmserver!=null && !s_farmserver.equals("-1"))
							s_tit1+=" "+s_farmserver;

							vec1.add(intlmap.getTextDescription("reporter.common.User"));
							gridObj.put("gridTitle",s_tit1);					
							gridColumnsDetails.put(intlmap.getTextDescription("reporter.common.User"),new JSONArray());
							summaryAry.add(intlmap.getTextDescription("reporter.thin.users"));
							totalColumnCount++;
						}
						else
						{
							pdfKey=s_application;
							AddFieldsDisplay="Application";
							FieldstoDisplay+=",-";
							s_tit1 = intlmap.getTextDescription("reporter.application.User Channel Report")+" - "+s_application;
							gridObj.put("gridTitle",s_tit1);					
						}

						JSONArray subheader=new JSONArray();
						subheader.add(intlmap.getTextDescription("reporter.common.Mins"));
						vec1.add(intlmap.getTextDescription("reporter.common.Time in Session")+"-"+"("+intlmap.getTextDescription("reporter.common.Mins")+")"); ;
						gridColumnsDetails.put(intlmap.getTextDescription("reporter.common.Time in Session"),subheader);
						for(int v=0;v<subheader.size();v++)
							summaryAry.add(intlmap.getTextDescription("reporter.common.Time in Session")+"#"+subheader.get(v));
						totalColumnCount++;
						if (FieldstoDisplay.equals(""))
						{
							FieldstoDisplay="-,-";
						}
						else
						{
							FieldstoDisplay+=",-,-";
						}
						String s_var = "";
						Vector v_val = new Vector();
						if (Fields.equals(""))
						{
							//Fields="Application,Timeinuse,Users";
							Fields="User";
						}
						else
						{
							//Fields+=",Application,Timeinuse,Users";
							Fields+=",Application";
						}
						if (addMapping.equals(""))
						{
							//addMapping="Application#Application,Timeinuse#Timeinuse,Users#Users";
							addMapping="Users#Users";
						}
						else
						{
							//addMapping+=",Application#Application,Timeinuse#Timeinuse,Users#Users";
							addMapping+=",Users#Users";
						}
						Class [] addFieldClassTypes = new Class[sublist.size()+3] ;

						addFieldClassTypes[0]=java.lang.String.class;
						addFieldClassTypes[1]=java.lang.String.class;
						addFieldClassTypes[2]=java.lang.String.class;
						v_val1=new Vector();
						int sortCount=0;
						int connectionIndeIndex = -1;
						for(int m=0;m<sublist.size();m++)
						{
							s_var = (String)sublist.get(m);
							String st_value="";
							String displayname="";
							String displaynameforUI="";
							String strTempDisplayname="";
							String val2="";
							String testname="";
							String s_unit = "";
							if ((s_server==null || s_server.equals("-1") || s_server.equals("")) &&  s_farmserver!=null && !s_farmserver.equals("") || aListAlltype.contains(s_server))// s_server.equals("All Terminal_Servers")|| s_server.equals("All Citrix_servers") || s_server.equals("All Citrix_MF_XP Servers"))
							{
								if(s_var.startsWith(key1))
								{
									StringTokenizer tok2 = new StringTokenizer(s_var,":");
									while(tok2.hasMoreTokens())
									{
										tok2.nextToken();
										testname=tok2.nextToken();
										val2=tok2.nextToken();
										StringTokenizer meas=new StringTokenizer(val2,"#");
										if(meas.hasMoreTokens() )
										{
											mes=meas.nextToken();
										}
										else
										{
											mes=val2;
										}
										if(meas.hasMoreTokens() )
										{
											displayname=meas.nextToken();
										}
										else
										{
											displayname=val2;
										}
										strTempDisplayname = displayname;
										s_unit=tablesInfo.getUnitForMeasure(testname,mes);
										if(s_unit != null && !s_unit.equals(""))
											//displayname = displayname+" ("+s_unit+")";
											displayname = displayname;
									}
									st_value=reportInfo.getValue("CITRIX_CHANNEL_RESOURCE",s_var);
								}
								v_val.add(st_value);
							}
							else
							{
								String strCompType = null;
								if(s_server.lastIndexOf(":")>-1)
									strCompType = s_server.substring(s_server.lastIndexOf(":")+1);
								if(strCompType!=null && s_var !=null && !s_var.startsWith(strCompType))
									continue;
								StringTokenizer tok2 = new StringTokenizer(s_var,":");
								while(tok2.hasMoreTokens())
								{
									tok2.nextToken();
									testname=tok2.nextToken();
									val2=tok2.nextToken();
									StringTokenizer meas=new StringTokenizer(val2,"#");
									if(meas.hasMoreTokens() )
									{
										mes=meas.nextToken();
									}
									else
									{
										mes=val2;
									}
									if(meas.hasMoreTokens() )
									{
										displayname=meas.nextToken();
										displaynameforUI = intlmap.getTextDescription("reporter.thin."+displayname);
									}
									else
									{
										displayname=val2;
										displaynameforUI = intlmap.getMeasureDescription(testname,mes);
									}
									strTempDisplayname = displayname;
									s_unit=tablesInfo.getUnitForMeasure(testname,mes);
									String strTestname = (testname+":"+mes);
									if(strTestname!=null && strTestname.equalsIgnoreCase("CtxXcXAUserTest:Connection_strength"))
											connectionIndeIndex=m;
									if(s_unit != null && !s_unit.equals(""))
										//displayname = displayname+"("+s_unit+")";
										displayname = displayname;
								}
								st_value=reportInfo.getValue("CITRIX_CHANNEL_RESOURCE",s_var);
								v_val.add(st_value);
							}
							if (st_value.equals(""))
							{
								st_value="Avg";
							}
							StringTokenizer st_val=new StringTokenizer(st_value,",");
							StringTokenizer st_val_temp=new StringTokenizer(st_value,",");
							int countTokens=st_val.countTokens();
							if(displayname != null && displayname.equals("ICA_nwlatency"))
							{
								s_unit = "Secs";
							}
							if(!displayname.equals(""))
							{
								sortCount = sortCount+1;
							}
							String strsort_temp=String.valueOf(sortCount);
							if(st_value.indexOf("Avg")>-1 && st_value.indexOf("Pct")>-1 && st_value.indexOf("Max")  >-1 )
							{
								for (int l=0;l<countTokens;l++)
								{
									if (Fields.equals(""))
									{
										Fields=mes+(l+1);
									}
									else
									{
										Fields+=","+mes+(l+1);
									}
								}
								if(addMapping.equals(""))
								{
									addMapping=mes+"1#"+mes+countTokens;
								}else
								{
									addMapping+=","+mes+"1#"+mes+countTokens;
								}
%>
<%
								JSONArray subheaders=new JSONArray();
	
								for(int k=0;k < v_val.size(); k++)
								{
								
									String str = (String)v_val.get(k);


									if (str.equals(""))
									{
									str="Avg";
									}
									if(str.indexOf(",")== -1)
									havingSingleColumn++;
									StringTokenizer st_tok=new StringTokenizer(str,",");

									while (st_tok.hasMoreTokens())
									{

										String token_val=st_tok.nextToken()+"  ("+s_unit+")";
										subheaders.add(token_val);
										totalColumnCount++;
										vec1.add(intlmap.getTextDescription("reporter.thin."+displaynameforUI)+"-"+"("+intlmap.getTextDescription("reporter.common."+token_val)+")");    //vec1.add(intlmap.getTextDescription("reporter.common."+displayname)+"("+unitmeasure+")"+"-"+"("+intlmap.getTextDescription("reporter.common."+st_tok.nextToken())+")");

									}

								}
								gridColumnsDetails.put(intlmap.getTextDescription("reporter.thin."+displaynameforUI),subheaders);
								for(int v=0;v<subheaders.size();v++)
									summaryAry.add(intlmap.getTextDescription("reporter.thin."+displayname)+"#"+subheaders.get(v));
							}
							else if((st_value.indexOf("Avg")>-1 && st_value.indexOf("Pct")>-1) || (st_value.indexOf("Avg")>-1 && st_value.indexOf("Max")>-1) || (st_value.indexOf("Max")>-1 && st_value.indexOf("Pct")>-1))
							{
								for (int l=0;l<countTokens;l++)
								{
									if (Fields.equals(""))
									{
										Fields=mes+(l+1);
									}
									else
									{
										Fields+=","+mes+(l+1);
									}
								}
								if (addMapping.equals(""))
								{
									addMapping=mes+"1#"+mes+countTokens;
								}
								else
								{
									addMapping+=","+mes+"1#"+mes+countTokens;
								}
								if(!displayname.equals(""))
								{
%>
<%								JSONArray subheaders=new JSONArray();

									for(int k=0;k < v_val.size(); k++)
									{
									
										String str = (String)v_val.get(k);


										if (str.equals(""))
										{
										str="Avg";
										}
									if(str.indexOf(",")== -1)
									havingSingleColumn++;
										StringTokenizer st_tok=new StringTokenizer(str,",");

										while (st_tok.hasMoreTokens())
										{
										String token_val=st_tok.nextToken()+"  ("+s_unit+")";
										subheaders.add(token_val);
										totalColumnCount++;

											vec1.add(intlmap.getTextDescription("reporter.thin."+displaynameforUI)+"-"+"("+intlmap.getTextDescription("reporter.common."+token_val)+")");    //vec1.add(intlmap.getTextDescription("reporter.common."+displayname)+"("+unitmeasure+")"+"-"+"("+intlmap.getTextDescription("reporter.common."+st_tok.nextToken())+")");

										}

									}
								gridColumnsDetails.put(intlmap.getTextDescription("reporter.thin."+displaynameforUI),subheaders);
								for(int v=0;v<subheaders.size();v++)
									summaryAry.add(intlmap.getTextDescription("reporter.thin."+displayname)+"#"+subheaders.get(v));

								}
								
							}
							else
							{
								for (int l=0;l<countTokens;l++)
								{
									if (Fields.equals(""))
									{
										Fields=mes+(l+1);
									}
									else
									{
										Fields+=","+mes+(l+1);
									}
								}
								if (addMapping.equals(""))
								{
									addMapping=mes+"1#"+mes+countTokens;
								}else
								{
									addMapping+=","+mes+"1#"+mes+countTokens;
								}
								if(!displayname.equals(""))
								{
%>
<%								JSONArray subheaders=new JSONArray();

									for(int k=0;k < v_val.size(); k++)
									{
									
										String str = (String)v_val.get(k);


										if (str.equals(""))
										{
										str="Avg";
										}
								if(str.indexOf(",")== -1)
									havingSingleColumn++;
										StringTokenizer st_tok=new StringTokenizer(str,",");

										while (st_tok.hasMoreTokens())
										{
											//for removing Number units in grid column in UI
											String token_val = "";
											if(s_unit.equalsIgnoreCase("Number"))
												token_val=st_tok.nextToken();
											else
												token_val=st_tok.nextToken()+"  ("+s_unit+")";
											subheaders.add(token_val);
											totalColumnCount++;

											vec1.add(intlmap.getTextDescription("reporter.thin."+displaynameforUI)+"-"+"("+intlmap.getTextDescription("reporter.common."+token_val)+")");    //vec1.add(intlmap.getTextDescription("reporter.common."+displayname)+"("+unitmeasure+")"+"-"+"("+intlmap.getTextDescription("reporter.common."+st_tok.nextToken())+")");

										}

									}
								gridColumnsDetails.put(intlmap.getTextDescription("reporter.thin."+displaynameforUI),subheaders);
								for(int v=0;v<subheaders.size();v++)
									summaryAry.add(intlmap.getTextDescription("reporter.thin."+displayname)+"#"+subheaders.get(v));

								}
							
							}
							for(int x=0;x< v_val.size();x++)
							{

								v_val1.add(v_val.get(x));

							}
														
							v_val = new Vector();
						}
%>
<%
						int fieldsize=1;
						for(int v=0;v<v_val1.size();v++)
						{
							String v_value = (String)v_val1.get(v);
							StringTokenizer tokenizer=new StringTokenizer(v_value,",");
							while(tokenizer.hasMoreTokens())
							{
								String str1=tokenizer.nextToken();
								fieldsize=fieldsize+1;
								if (FieldstoDisplay.equals(""))
								{
									FieldstoDisplay=str1;
								}
								else
								{
									FieldstoDisplay+=","+str1;
								}
							}
						}
						Class [] fieldClassTypes = new Class[fieldsize+1];
						for (int z=0;z<fieldClassTypes.length;z++)
						{
							fieldClassTypes[z]=java.lang.String.class;
						}
						Vector v_pdfdata=new Vector();
						String st_app="";
						if (s_server==null || s_server.equals("-1") || s_server.equals("")|| aListAlltype.contains(s_server))//s_server.equals("All Terminal_Servers")|| s_server.equals("All Citrix_MF_XP Servers")|| s_server.equals("All Citrix_servers"))
						{
							app_data=value;
						}
						Map TmpparamMap = new HashMap(request.getParameterMap());
						String backqueryforuserDetails=getEncodedParams(TmpparamMap);
						if(backqueryforuserDetails == null || (backqueryforuserDetails != null && backqueryforuserDetails.length() == 0) )
							backqueryforuserDetails =(String)ErUtils.prepareQueryString(TmpparamMap);
						session.setAttribute("userDetailsBckQuery",backqueryforuserDetails);
						for (int z=0;z<app_data.size();z++)
						{
							Vector v_data=(Vector)app_data.get(z);
							String st_check="-";
							JSONObject rowOfdata=new JSONObject();
							JSONArray summaryDataAry = new JSONArray();

							for (int i=0;i<v_data.size();i++)
							{
								String strdata=v_data.get(i).toString();
								if(i==0)
								{
									st_app =strdata;
								}
								if (i==1)
								{
									strdata = (strdata == null || strdata.equals("")||strdata.equals("-5.0"))? "-" : erUtils.round(Float.parseFloat(strdata),4);
								}
								else if (i==2)
								{
									if(strdata.equals("-5.0"))
										st_check=strdata;
									strdata = (strdata == null ||strdata.equals("-")|| strdata.equals("")||strdata.equals("-5.0"))? "-" : erUtils.round(Float.parseFloat(strdata),4);
								}
								else if(i>2)
								{
									strdata = (strdata == null || strdata.equals("")||strdata.equals("-5.0"))? "-" : erUtils.round(Float.parseFloat(strdata),4);
								}
								if(connectionIndeIndex>-1 && (i==(connectionIndeIndex+2)))
								{
									if(!(strdata == null || strdata.equals("-") || strdata.equals("")))
									{
										try{
											double d = Double.parseDouble(strdata);
											d = Math.floor(d);
											strdata = getConnectionQulityString(d);
											}catch(Exception e){}
									}else
										strdata = "-";
								}
								v_pdfdata.add(strdata);
								String strdata_disp = strdata;
								if(strdata_disp!= null && strdata_disp.indexOf(":NULL")>-1)
									strdata_disp = strdata_disp.substring(0,strdata_disp.indexOf(":NULL"))+strdata_disp.substring(strdata_disp.indexOf(":NULL")+5);
								if (i==0)
								{
%>
<%

								String strFarmVal=s_farmserver;
								if(s_farmserver != null)
									strFarmVal=EgURLEncoder.encode(s_farmserver,"UTF-8");
								String strcomptype=strSelectedCompType;
								if(strSelectedCompType != null)
									strcomptype=EgURLEncoder.encode(strSelectedCompType,"UTF-8");
								String strexecWeek=excludeweekend;
								if(excludeweekend != null)
									strexecWeek=EgURLEncoder.encode(excludeweekend,"UTF-8");
								String strtimeline = timeline;
								if(timeline != null)
									strtimeline = EgURLEncoder.encode(timeline,"UTF-8");
								String struser = strdata_disp;
								String straggregate = request.getParameter("er_perserver");
								if(straggregate!= null && straggregate.equalsIgnoreCase("No")){
									if(struser != null && struser.indexOf("/") > -1)
										struser=struser.substring(struser.indexOf("/")+1).trim();
								}
								if(struser != null)
									struser = EgURLEncoder.encode(struser,"UTF-8");

								String strStTime=request.getParameter("startdate");
								if(strStTime != null)
									strStTime = EgURLEncoder.encode(strStTime,"UTF-8");
								String strenTime =  request.getParameter("enddate");
								if(strenTime != null)
									strenTime = EgURLEncoder.encode(strenTime,"UTF-8");
								String strpdfTime =  pdfTime;
								if(pdfTime != null)
									strpdfTime = EgURLEncoder.encode(pdfTime,"UTF-8");
								String strlimitforbg =  limitforbg;
								if(limitforbg != null)
									strlimitforbg = EgURLEncoder.encode(limitforbg,"UTF-8");
								String strappln =  request.getParameter("er_application");
								if(strappln != null)
									strappln = EgURLEncoder.encode(strappln,"UTF-8");

						String qryyString="";
				qryyString="/final/reporter/ErThinClientUserReport.jsp?select_farm="+strFarmVal+"&er_comptype="+strcomptype+"&er_type=Yes&er_excwe="+strexecWeek+"&graphViewtype=timeline&sh_timeinuse="+request.getParameter("show_timeinuse")+"&er_perserver="+request.getParameter("er_perserver")+"&er_application="+struser+"&er_option="+er_option+"&er_timeline="+strtimeline+"&startdate="+strStTime+"&enddate="+strenTime+"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&startmin="+strmin+"&endmin="+enmin+"&er_secs=00&option=Citrix&er_rtype=CtxChannelResource&er_trgttype="+EgURLEncoder.encode("User Channel Report","UTF-8")+"&er_gtype=Citrix&pdfTime="+strpdfTime+"&uid="+uid+"&userID="+EgURLEncoder.encode(loginid,"UTF-8")+"&er_trenddata="+request.getParameter("er_trenddata")+"&er_ViewName=ErThinClientUserReport.jsp&getMaxDaysInMonth=30&forwardto=ErCtxChannelReportJson&er_bgreportfrom=Thin_Client_User_Channel&bgenabled="+request.getParameter("bgenabled")+"&limitforbg="+strlimitforbg+"&savereport=save&servletName=com.eg.ErCtxServerReportC&showSearch=false&opt=chart&er_uisortby=1&userTimeline=-1&timefrom="+request.getParameter("timefrom")+"&minfrom="+request.getParameter("minfrom")+"&timeto="+request.getParameter("timeto")+"&minto="+request.getParameter("minto")+"&er_RmDispName="+EgURLEncoder.encode("Users Channel Analysis","UTF-8")+"&opt=chart&isSubmit=true&enableBackForUserDetails=true&getBckQuery=yes";
				

								
								// lst_dat1.add("ss");
								 rowOfdata.put(rowOfdata.size(),"ss~"+qryyString);
								 lst_dat1.add(strdata_disp);
								 summaryDataAry.add(strdata_disp);
								 rowOfdata.put(rowOfdata.size(),strdata_disp);
								}
								else if (i==2)
								{
									if(strdata_disp.equals("-"))
									{
%>
<%
									 lst_dat1.add(strdata_disp);
										summaryDataAry.add(strdata_disp);
								 rowOfdata.put(rowOfdata.size(),strdata_disp);

									}
									else
									{
%>
<%
										lst_dat1.add(strdata_disp);
										summaryDataAry.add(strdata_disp);
								 rowOfdata.put(rowOfdata.size(),strdata_disp);

									}
								}
								else
								{
%>
<%
									lst_dat1.add(strdata);
									summaryDataAry.add(strdata);
									rowOfdata.put(rowOfdata.size(),strdata);

								}
							
							}
							totColumns=rowOfdata.size();
								gridDataArray.add(rowOfdata);
							//Here commenting this line because we are getting the summary list from other vector
							//summarylst.add(summaryDataAry);//new change
							String stg_server = st_app;
							if(s_server!=null&&s_server.equals("-1")&&s_perserver.equals("No"))
							{
								st_app=st_app.substring(st_app.indexOf("/")+2,st_app.length());
							}
							String qryback_Allserver ="../servlet/com.eg.ErCtxServerReportC?isSubmit=true";
							String qryback_perserver ="../servlet/com.eg.ErCtxServerReportC?isSubmit=true";
%>
<%
						}
						//new
						Vector app_data_temp = (Vector)request.getAttribute("App_data_temp");
						
						if(app_data_temp!=null && app_data_temp.size()>0)
						{
							session.setAttribute("app_data_temp",app_data_temp);
							for (int z=0;z<app_data_temp.size();z++)
							{
							Vector v_data=(Vector)app_data_temp.get(z);
							String st_check="-";
							JSONObject rowOfdata=new JSONObject();
							JSONArray summaryDataAry = new JSONArray();

							for (int i=0;i<v_data.size();i++)
							{
								String strdata=v_data.get(i).toString();
								if(i==0)
								{
									st_app =strdata;
								}
								if (i==1)
								{
									strdata = (strdata == null || strdata.equals("")||strdata.equals("-5.0"))? "-" : erUtils.round(Float.parseFloat(strdata),4);
								}
								else if (i==2)
								{
									if(strdata.equals("-5.0"))
										st_check=strdata;
									strdata = (strdata == null ||strdata.equals("-")|| strdata.equals("")||strdata.equals("-5.0"))? "-" : erUtils.round(Float.parseFloat(strdata),4);
								}
								else if(i>2)
								{
									strdata = (strdata == null || strdata.equals("")||strdata.equals("-5.0"))? "-" : erUtils.round(Float.parseFloat(strdata),4);
								}
								v_pdfdata.add(strdata);
								String strdata_disp = strdata;
								if(strdata_disp!= null && strdata_disp.indexOf(":NULL")>-1)
									strdata_disp = strdata_disp.substring(0,strdata_disp.indexOf(":NULL"))+strdata_disp.substring(strdata_disp.indexOf(":NULL")+5);
								if(i==0)
								{
									 summaryDataAry.add(strdata_disp);
								 rowOfdata.put(rowOfdata.size(),strdata_disp);
								}
								else if (i==2)
								{
									//System.out.println("strdata_disp _______________ "+strdata_disp);
									if(strdata_disp.equals("-"))
									{
%>
<%
									 //lst_dat1.add(strdata_disp);
										summaryDataAry.add(strdata_disp);
								rowOfdata.put(rowOfdata.size(),strdata_disp);

									}
									else
									{
%>
<%
										//lst_dat1.add(strdata_disp);
										summaryDataAry.add(strdata_disp);
								 rowOfdata.put(rowOfdata.size(),strdata_disp);

									}
								}
								else
								{
									
%>
<%
									//lst_dat1.add(strdata);
									summaryDataAry.add(strdata);
									rowOfdata.put(rowOfdata.size(),strdata);

								}
							
							}
							totColumns=rowOfdata.size();
								gridDataArray_temp.add(rowOfdata);
							
							summarylst.add(summaryDataAry);

						}
					}
						//


						String summaryStr=reportInfo.getValue("CITRIX_CHANNEL_RESOURCE_SUMMARY",strSelectedCompType);
						boolean haveSummary = false;
						JSONObject summaryObj = new JSONObject();
						String highlightedBlock = "";
						if(summaryStr!=null && summaryStr.length()>0 )
						{
							ArrayList dispSummaryLst = new ArrayList(Arrays.asList(summaryStr.split(","))); // From INI value
							JSONArray indexAry = new JSONArray(); // Filter the Required index for Summary panel
							for(int v=0;v<summaryAry.size();v++)
							{
								String summaryCol = (String)summaryAry.get(v);
								if(summaryCol!=null && summaryCol.indexOf("(")>-1)
								{
									summaryCol = summaryCol.substring(0,summaryCol.indexOf("("));
									summaryCol = summaryCol.trim();// Remove the unit
								}
								if(summaryCol!=null && dispSummaryLst.contains(summaryCol))
								{
									indexAry.add(v);
								}
							}
							if(indexAry.size()>0)
							{
								LinkedHashMap SummaryMp = new LinkedHashMap();
								JSONArray dividerAry = new JSONArray();
								for(int u=0;u<summarylst.size();u++)
								{
									JSONArray summaryDataAry = (JSONArray)summarylst.get(u);
									JSONObject gridDataObj = (JSONObject)gridDataArray_temp.get(u);//new gridDataArray changed to gridDataArray_temp 
									for(int c=0;c<indexAry.size();c++)
									{
										int indexVal = indexAry.getInt(c);
										String columnValue = (String)summaryAry.get(indexVal);
										String data_val = null;
										if(summaryDataAry.size()>indexVal)
											data_val = (String)summaryDataAry.get(indexVal);
										// column highlighting block
										if(highlightedSummary!=null && columnValue.startsWith(highlightedSummary))
										{
											if(data_val!=null)
											{
												// 1 is added for skiping graph column
												// custom-column is CSS class
												gridDataObj.put((indexVal+1)+"",data_val+"$custom-column");
											}
										}
										//end
										ArrayList dataLst = null;
										if(SummaryMp.get(columnValue)==null)
										{
											dataLst = new ArrayList();
										}
										else
										{
											dataLst = (ArrayList)SummaryMp.get(columnValue);
										}
										boolean needIncrement = false;
										if(dividerAry.size()==c)
										{
											dividerAry.add(1);
										}
										else
										{
											needIncrement = true;
										}
										if(data_val!=null && !data_val.equals("-"))
										{
											int oldIndex = dividerAry.getInt(c);
											if(needIncrement)
											{
												dividerAry.set(c,oldIndex+1);
											}
											try
											{
												if(dataLst.size()>0)
												{
													String oldValStr = (String)dataLst.get(dataLst.size()-1);
													double oldVal = Double.parseDouble(oldValStr);
													double oldVal_new = Double.parseDouble(data_val);
													dataLst.set(dataLst.size()-1,(oldVal+oldVal_new)+"");
												}
												else
												{
													dataLst.add(data_val);
												}
											}
											catch (Exception e)
											{
												if(!dataLst.contains(data_val))
													dataLst.add(data_val);
											}
										}
										SummaryMp.put(columnValue,dataLst);
									}
								}
								if(SummaryMp!=null && SummaryMp.size()>0)
								{
									Set SummaryMp_set = SummaryMp.keySet();
									Iterator SummaryMp_itr = SummaryMp_set.iterator();
									int count = 0;
									while(SummaryMp_itr.hasNext())
									{
										String summaryKey = (String)SummaryMp_itr.next();
										ArrayList dataLst = (ArrayList)SummaryMp.get(summaryKey);
										boolean ishighlight = false;
										if(highlightedSummary!=null && summaryKey.startsWith(highlightedSummary))
											ishighlight = true;
//										summaryKey = summaryKey.replace("#","-");
										String prefixStr = summaryKey;
										String sufixStr = "";
										if(summaryKey.indexOf("#")>-1)
										{
											prefixStr = summaryKey.substring(0,summaryKey.indexOf("#"));
											if(summaryKey.indexOf("(")>-1)
												 sufixStr = summaryKey.substring(summaryKey.indexOf("("),summaryKey.length());
											summaryKey = prefixStr+" "+sufixStr;
										}
										if(ishighlight)
										{
											highlightedBlock = summaryKey;
										}
										if(dataLst.size()==1)
										{
											String valStr = (String)dataLst.get(0);
											try
											{
												double summaryVal = (Double.parseDouble(valStr))/(dividerAry.getInt(count));
												summaryObj.put(summaryKey,erUtils.round(Float.parseFloat(summaryVal+""),2)+"");
											}
											catch (Exception e)
											{
												System.out.println("Error in Summary panel USER ACTIVITY ANALYSIS");
											}
										}
										else
										{
											summaryObj.put("Unique "+summaryKey,dataLst.size()+"");	
										}
										haveSummary = true;
										count++;
									}
								}
							}
						}
						TreeMap paramMap = new TreeMap();
						TreeMap pdfData=new TreeMap();
						pdfData.put(pdfKey,v_pdfdata);

						boolean fieldWidthInPercentage = false;
						boolean addFieldWidthInPercentage =true;
						StringTokenizer stfields=new StringTokenizer(Fields,",");
						int [] xCoor = new int [stfields.countTokens()] ;
						int [] yCoor = new int [stfields.countTokens()] ;
						int coorsize=762/stfields.countTokens();
						for (int k=0;k<xCoor.length;k++)
						{
							if (k==0)
							{
								xCoor[k]=0;
								yCoor[k]=5;
							}
							else
							{
								if (k==1)
								{
									xCoor[k]=0;
									yCoor[k]=35;
								}
								else if (k==2)
								{
									xCoor[k]=120;
									yCoor[k]=35;
								}
								else
								{
									xCoor[k]=xCoor[k-1]+coorsize;
									yCoor[k]=35;
								}
							}
						}
						int size=752/(stfields.countTokens());
						int [] fieldWidth = new int [stfields.countTokens()] ;
						int [] fieldHeight= new int [stfields.countTokens()];

						for (int l=0;l<fieldWidth.length;l++)
						{
							if (l==0)
							{
								fieldWidth[l]=752;
								fieldHeight[l]=10;
							}else
							{
								fieldWidth[l]=size;
								fieldHeight[l]=10;
							}
						}

						StringTokenizer staddfields=new StringTokenizer(AddFieldsDisplay,",");
						int [] addFieldWidth = new int [staddfields.countTokens()] ;
						int [] addFieldHeight= new int [staddfields.countTokens()];
						int [] addXCoor = new int [staddfields.countTokens()] ;
						int [] addYCoor = new int [staddfields.countTokens()] ;
						int addwidth=0;
						int addcoorsize=762/staddfields.countTokens();
						if(staddfields.countTokens()>0)
						{
							addwidth=100/staddfields.countTokens();
						}
						else
						{
							addwidth=10;
						}

						for(int k=0;k<addFieldWidth.length;k++)
						{
							addFieldWidth[k]=addwidth;
							addFieldHeight[k]=10;
						}
						int [] lineXCoor = new int [] {0, 0, 0};
						int [] lineYCoor = new int [] {15, 48, 10};
						int [] bandHeight = new int [] {49, 20, 35};
						paramMap.put("fields", Fields);
						paramMap.put("display", FieldstoDisplay);
						paramMap.put("addDisplay", AddFieldsDisplay);
						paramMap.put("addMapping", addMapping); //must
						paramMap.put("dataBag", pdfData);
						paramMap.put("pageLayout", "Landscape");
						paramMap.put("rowSize", new Integer(xCoor.length-1));//must
						paramMap.put("xCoor", xCoor);
						paramMap.put("lineXCoor", lineXCoor);
						paramMap.put("lineYCoor", lineYCoor);
						paramMap.put("bandHeight", bandHeight);
						paramMap.put("fieldWidth", fieldWidth);//must
						paramMap.put("fieldHeight", fieldHeight);
						paramMap.put("fieldClassTypes", fieldClassTypes);
						paramMap.put("addFieldClassTypes", addFieldClassTypes);
						paramMap.put("fieldWidthInPercentage", new Boolean(fieldWidthInPercentage));
						paramMap.put("addFieldWidthInPercentage", new Boolean(addFieldWidthInPercentage));

						Vector vdata=new Vector();
						Vector extraparam=new Vector();
						extraparam.add("Application Report");
						extraparam.add("From	 "+erd.s_stdate+" hrs "+""+" To "+erd.s_enddate+"  hrs");
						vdata.add(paramMap);
						vdata.add(extraparam);
						Hashtable ht_pdfdata=new Hashtable();
						ht_pdfdata.put("commandName","DynamicTest");
						ht_pdfdata.put("pdfData",applnPdfData);
						ht_pdfdata.put("pdfFileName","CITRIX_USER_Channel_REPORT");
						session.setAttribute("sessionVal", ht_pdfdata);
						HashMap param =new HashMap();
						param.put("REPORT_PARAM",ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap())));
						param.put("REPORT_DATA",applnPdfData);
						session.setAttribute("parameters", param);
						//gridObj.put("units",unitForMeasure);
						gridObj.put("haveSummary",haveSummary);
						gridObj.put("summaryObj",summaryObj);
						gridObj.put("highlightedBlock",highlightedBlock);
						gridObj.put("columns",gridColumnsDetails);
						gridObj.put("dataArray",gridDataArray);
						gridObj.put("TOTAL_COLUMN_COUNT",String.valueOf(totalColumnCount));
						gridObj.put("SINGLE_SUBCOLUMN_COUNT",String.valueOf(havingSingleColumn));
						reportDataJson.put("GridObj",gridObj);
						rootJson.put("reportData",reportDataJson);

					}
				}
			}
		}
		
		pageWidthProces=(totColumns * 155)+250;
		if(pageWidthProces<1024)
			pageWidthProces=1024;
		
		hiddenfieldsJson.put("pageWidth",""+pageWidthProces);
		//--start-- For bug ID 9515
		hiddenfieldsJson.put("pageWidthProces",""+pageWidthProces);
		//--End--
	} //Graph View start here
	else if(strGraphViewType!=null && strGraphViewType.equalsIgnoreCase("Timeline") && v_qry_string!=null&&v_qry_string.size()>0)
	{
		JSONObject reportDataJson = new JSONObject();
		JSONArray chartUrls = new JSONArray();
		String strApp = (s_application!=null && s_application.equals("-1")) ? "All Users" : s_application;
		String timelin_title = intlmap.getTextDescription("reporter.application.User Channel Report") + " - " +intlmap.getTextDescription("reporter.application."+strApp)+ " : "+ s_farmserver;
		reportDataJson.put("title",timelin_title);
		
//

	String componentName=null,portNo=null;
		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(cType))
				{
			
				StringTokenizer strtok = new StringTokenizer(server,":");
					int k=0;
					while(strtok.hasMoreTokens())
					{
						String param = strtok.nextToken();
						if(k==0)
							componentName=param;
						else if(k==1)
							portNo=param;
						k++;
					}
					break;
				}
				
			}
		
		
				String ddMeasure="No_of_sessions";
				if(cType!=null && (cType.equalsIgnoreCase("Vmware_vdi_server") || cType.equals("VmVdi_i_server")))
					ddMeasure="Current_sessions";
				else
					ddMeasure = reportInfo.getCtxUserDDMeasure("CITRIX_USER_REPORT",cType);
			if(v_components!=null && v_components.size()>0)
			{
				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(cType))
					{
						String strTest = reportInfo.getTestName("CITRIX_CHANNEL_RESOURCE",strTempComponentType1,false);
						Vector vecTemp = new Vector();
						if(reportInfo.isVmComponent(server))
						{
							vecTemp =reportInfo.getUserNameAlonefromVM(strTest,server);
						}
						else
							vecTemp = (erInfo.getInfosForTest("NULL",strTest,server));
						if(vecTemp!=null && (vecTemp.contains(user_name) || vecTemp.contains("+"+user_name)))
						{
							StringTokenizer strtok = new StringTokenizer(server,":");
							if(strtok.countTokens()>=2)
							{
								componentName = strtok.nextToken();
								portNo = strtok.nextToken();
							}
							break;
						}
					}
				}
			}

		for(int i=0;i<v_qry_string.size();i+=4)
		{
			JSONObject chartObj=new JSONObject();
				String s_title = (String)v_qry_string.get(i);
			
				String s_title_org=s_title;
				s_qryString = (String)v_qry_string.get(i+1);
			
				String Str_test="";
				String Str_mes="";
				String Str_units="";

				//s_temp = s_qryString;
				String Qstring = "";
				String valuestr = "";
				if(s_qryString!=null)
				{
					StringTokenizer strtok = new StringTokenizer(s_qryString,"&");
					while(strtok.hasMoreTokens())
					{
						String param = strtok.nextToken();
						String reqparam = param.substring(0,param.indexOf("="));
						valuestr = param.substring(param.indexOf("=")+1, param.length());
						if(reqparam!=null && reqparam.equalsIgnoreCase("option"))
							continue;
						if(reqparam!=null && (reqparam.equalsIgnoreCase("er_user") || reqparam.equalsIgnoreCase("er_application")  || reqparam.equalsIgnoreCase("user_name")))
							valuestr = com.egurkha.util.StringUtils.replace(valuestr,"\\", "|slash|");

						if(reqparam!=null && reqparam.equalsIgnoreCase("er_RmDispName"))
						{
							valuestr = valuestr;
						}
						else
						{
							valuestr = EgURLEncoder.encode(valuestr,"UTF-8");
						}
						Qstring = Qstring + reqparam + "=" + valuestr+"&";
					}
				}
		//To get Unit for Measures
				String queryString = s_qryString.substring(s_qryString.indexOf("?")+1);
				HashMap parame  = ErUtils.parseQueryString(queryString);			
				Set s_param = parame.keySet();
				Iterator i_param = s_param.iterator();
				
				while(i_param.hasNext())
				{
					String st_key = (String)i_param.next();
					
					String value="";
					//
					if(parame != null && parame.get(st_key) instanceof String)
					{
						value = (String)parame.get(st_key);
					}
					else if(parame != null && parame.get(st_key) instanceof String[])
					{
					value = ((String[])parame.get(st_key))[0];
					}
			     	//
					if(st_key!=null&&st_key.equals("er_test"))
					{
						Str_test = value;
					}
					else if(st_key!=null&&st_key.equals("er_measure"))
					{
						Str_mes=value;
					}
					
				}
			Str_units = tablesInfo.getUnitForMeasure(Str_test,Str_mes);
		




				String s_temp=Qstring;
				String strImgWidth="400";
				String strGraphWidth="400";
				String strGraphHeight="200";
				String strTempTDwidth = "50%";
				String height_px = "215px";
				if(screenWidth>1200)
				{
					try{
						strImgWidth = (Integer.parseInt(strImgWidth)+150)+"";
					}catch(Exception e){}
					try{
						strGraphWidth = (Integer.parseInt(strGraphWidth)+150)+"";
					}catch(Exception e){}
				}
%>
<%
								String strTest = s_title.substring(0,s_title.indexOf("/"));
								String strMeasure = s_title.substring(s_title.indexOf("/")+1);
								s_title = intlmap.getMeasureDescription(strTest,strMeasure);
								if(s_title.length() > 43  && !(screenWidth>1200))
								{	
									 s_title=StringUtils.egSubString(s_title,isEnglishLanguage,43,38);
								}
s_title = s_title + " ("+Str_units+")";

chartObj.put("chartTitle",s_title);
chartObj.put("chartWidth",strImgWidth);
chartObj.put("chartHeight",strGraphHeight);


//
String ddUrl="/final/monitor/componentMeasureTabSet.jsp?";
Vector vec_infos= null;
String strVmComp = reportInfo.getValue("MISC","VMWareComponent");
ArrayList aListVmComponentType = new ArrayList();
if(strVmComp!=null && strVmComp.length()>0)
{
	StringTokenizer stToken = new StringTokenizer(strVmComp,",");
	while (stToken.hasMoreTokens())
	{
		String str = stToken.nextToken();
		str = str.trim();
		//str = str.toUpperCase();
		aListVmComponentType.add(str);
	}
}
	if(aListVmComponentType!=null && aListVmComponentType.contains(cType))
	{
		vec_infos=erInfo.getInfosForUser(erTest);
	}
String ss="";

			if(user_name==null)
			{
			user_name=request.getParameter("er_application");
			}

if(user_name!=null && user_name.length()>0)
{
	String encuser_dd=user_name;
	String strinfo_DD=encuser_dd;//com.egurkha.util.StringUtils.replace(encuser_dd,"\\", "\\\\");;
	if(vec_infos!=null && vec_infos.size()>0)
	{
		for(int ddi=0;ddi<vec_infos.size();ddi++)
		{
			String strInfo = (String) vec_infos.get(ddi);
			if(strInfo!=null && (strInfo.toLowerCase().startsWith(("+"+encuser_dd.toLowerCase())) || strInfo.toLowerCase().startsWith(encuser_dd.toLowerCase())))
			{
				strinfo_DD = strInfo;
				break;
			}
		}
	}
	List mHostList = externalInfo.getAgentsForHost(componentName);
	EgFormatInfo formatInfo = new EgFormatInfo("manager");
	String strMeas = request.getParameter("er_measure");

	if(strMeas==null && testmes!=null && testmes.indexOf("/") >-1)
	{
		strMeas = testmes.substring(testmes.indexOf("/")+1);
	}
	boolean ddenable = formatInfo.isDdEnabled(erTest,strMeas);


	if(ddenable)
	chartObj.put("isddEnabled","true");
	else
	chartObj.put("isddEnabled","false");

	String strMhost= "";
	if(mHostList!=null && mHostList.size()>0)
		strMhost = (String)mHostList.get(0);
	if(strinfo_DD!=null && strinfo_DD.startsWith("+"))
		strinfo_DD = strinfo_DD.substring(1);
	strinfo_DD = com.egurkha.util.StringUtils.replace(strinfo_DD,"\\\\", "\\");

	String link="&type="+cType
	    +"&site=NULL"
	    +"&host="+componentName
	    +"&port="+portNo
		+"&info=*"+com.eg.EgURLEncoder.encode(strinfo_DD, "UTF-8")
	    +"&state="
		//+"&messy=No_of_sessions"
		+"&messy="+strMeas
		
	   +"&msmt_host="+strMhost
	   +"&userID="+uid
	   +"&test="+erTest
	   +"&comptype="+cType
	  // +"&measureDisp=No_of_sessions"
	    +"&measureDisp="+strMeas
		+"&starttime="+request.getParameter("startdate")+"&endtime="+request.getParameter("enddate")+"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&startmin="+request.getParameter("startmin")+"&endmin="+request.getParameter("endmin")
	   + "&from=measurespage"
	   +"&dd=yes"
	   +"&clicked=dd"
	   +"&newWindow=true"
	   +"&fromReporterHis=true"
	   +"&popup=true"
	   +"&fromPage=eveHist"
	   +"&er_RmDispName=testing";
ddUrl+=link;


chartObj.put("ddQstring",ddUrl);
ss="&componentNamee="+EgURLEncoder.encode(componentName,"UTF-8")+"&portt="+portNo;

}
//

Qstring=Qstring+ss;
chartObj.put("drillDownQstring",Qstring);

String drillQstring = Qstring.substring(Qstring.indexOf("?"));
drillQstring="/final/reporter/ErCtxApplicationGraph.jsp"+drillQstring;
chartObj.put("drillDownQstring1",drillQstring);

			
				if(isFromDrillDown!=null && isFromDrillDown.equalsIgnoreCase("true")&& s_title_org!=null && s_title_org.length()>0)
				{
					if(measureName!=null && measureName.equalsIgnoreCase(s_title_org))
					{
						strGraphWidth="900";
					chartObj.put("queryString",Qstring+"&option=Citrix&er_width="+strGraphWidth+"&er_height="+strGraphHeight+"&er_align=left&option=graph");
					chartUrls.add(chartObj);
					
					}
					
				}
				else
				{
					chartObj.put("queryString",Qstring+"&option=Citrix&er_width="+strGraphWidth+"&er_height="+strGraphHeight+"&er_align=left&option=graph");
					chartUrls.add(chartObj);
			
				}


%>
<%
				if(v_qry_string.size() == (i + 2))
				{
%>
<%
				}
				else
				{
					s_title = (String)v_qry_string.elementAt(i+2);
					s_title_org=s_title;
					s_qryString = (String)v_qry_string.elementAt(i+3);
					//s_temp = s_qryString;
					String csvQueryString = s_qryString.substring(s_qryString.indexOf("?")+1);
					String Qstring1="";
					if(s_qryString!=null)
					{
						StringTokenizer strtok = new StringTokenizer(s_qryString,"&");
						while(strtok.hasMoreTokens())
						{
							String param = strtok.nextToken();
							String reqparam = param.substring(0,param.indexOf("="));
							valuestr = param.substring(param.indexOf("=")+1,param.length());
							if(reqparam!=null && reqparam.equalsIgnoreCase("option"))
								continue;
							if(reqparam!=null && (reqparam.equalsIgnoreCase("er_user") || reqparam.equalsIgnoreCase("er_application") ))
								valuestr = com.egurkha.util.StringUtils.replace(valuestr,"\\", "|slash|");

							if(reqparam!=null && reqparam.equalsIgnoreCase("er_RmDispName"))
							{
								valuestr = valuestr;
							}
							else
							{
								valuestr = EgURLEncoder.encode(valuestr,"UTF-8");
							}
							Qstring1 = Qstring1 + reqparam + "=" + valuestr+"&";
						}
					}
					s_temp=Qstring1;
					 ss="&componentNamee="+EgURLEncoder.encode(componentName,"UTF-8")+"&portt="+portNo;

					Qstring1=Qstring1+ss;

					String strtitlein = (String)v_qry_string.elementAt(i+2);
					strTest = strtitlein.substring(0,strtitlein.indexOf("/"));
					strMeasure = s_title.substring(s_title.indexOf("/")+1);
					//unitFortoolTip=s_title.substring(s_title.lastIndexOf("("));
//					s_title = intlmap.getTestDescription(strTest) + " / " 
	//						+ intlmap.getMeasureDescription(strTest,strMeasure);
					s_title = intlmap.getMeasureDescription(strTest,strMeasure);
					Str_units = tablesInfo.getUnitForMeasure(strTest,strMeasure);
		
							//+s_title.substring(s_title.indexOf(" ("));
					if(s_title.length()>43  && !(screenWidth>1200))
					{
						s_title=StringUtils.egSubString(s_title,isEnglishLanguage,43,38);
					}
					s_title = s_title + " ("+Str_units+")";

					chartObj.put("chartTitle",s_title);
					chartObj.put("chartWidth",strImgWidth);
					chartObj.put("chartHeight",strGraphHeight);
					chartObj.put("drillDownQstring",Qstring1);
					String drillQstring1 = Qstring1.substring(Qstring.indexOf("?"));
					drillQstring1="/final/reporter/ErCtxApplicationGraph.jsp"+drillQstring1;

					chartObj.put("drillDownQstring1",drillQstring1);
					//
						EgFormatInfo formatInfo = new EgFormatInfo("manager");

						String strMeas = request.getParameter("er_measure");

	if(strMeas==null && testmes!=null && testmes.indexOf("/") >-1)
	{
		strMeas = testmes.substring(testmes.indexOf("/")+1);
	}
	boolean ddenable = formatInfo.isDdEnabled(erTest,strMeas);

					String ddUrl_1="/final/monitor/componentMeasureTabSet.jsp?";
					if(user_name!=null && user_name.length()>0)
						{
						String encuser_dd_1=com.egurkha.util.StringUtils.replace(user_name,"\\", "\\\\");
						String link_1="&type="+cType
								+"&site=NULL"
								+"&host="+componentName
								+"&port="+portNo
								+"&info=*"+com.eg.EgURLEncoder.encode(encuser_dd_1, "UTF-8")
								+"&state="
								//+"&messy=No_of_sessions"
								+"&messy="+strMeas
							   +"&msmt_host="
							   +"&userID="+uid
							   +"&test="+erTest
							   +"&comptype="+cType
							  // +"&measureDisp=No_of_sessions"
							    +"&measureDisp="+strMeas
								+"&starttime="+request.getParameter("startdate")+"&endtime="+request.getParameter("enddate")+"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&startmin="+request.getParameter("startmin")+"&endmin="+request.getParameter("endmin")
							   + "&from=measurespage"
							   +"&dd=yes"
							   +"&clicked=dd"
							   +"&newWindow=true"
							   +"&fromReporterHis=true"
							   +"&popup=true"
							   +"&fromPage=eveHist"
							   +"&er_RmDispName=testing";
						ddUrl_1+=link_1;
						chartObj.put("ddQstring",ddUrl_1);
							if(ddenable)
								chartObj.put("isddEnabled","true");
							else
								chartObj.put("isddEnabled","false");
						}



					//chartObj.put("queryString",Qstring1+"&option=Citrix&er_width="+strGraphWidth+"&er_height="+strGraphHeight+"&er_align=left&option=graph");
					//	chartUrls.add(chartObj);

					//
					if(isFromDrillDown!=null && isFromDrillDown.equalsIgnoreCase("true")&& s_title_org!=null && s_title_org.length()>0)
					{
						if(measureName!=null && measureName.equalsIgnoreCase(s_title_org))
						{
					
						strGraphWidth="900";
						chartObj.put("queryString",Qstring1+"&option=Citrix&er_width="+strGraphWidth+"&er_height="+strGraphHeight+"&er_align=left&option=graph");
						chartUrls.add(chartObj);
						
						}
					}
					else
					{
						chartObj.put("queryString",Qstring1+"&option=Citrix&er_width="+strGraphWidth+"&er_height="+strGraphHeight+"&er_align=left&option=graph");
					
						chartUrls.add(chartObj);
					}

				}
%>
<%
		}
		reportDataJson.put("chartUrls",chartUrls);

		rootJson.put("reportData",reportDataJson);
	}
	else if(v_qry_string!=null&&v_qry_string.size()>0)
	{
		JSONObject reportDataJson = new JSONObject();
		JSONArray chartUrls = new JSONArray();

		int count = 0;
		String s_title="";
		int flag=0;
		if(v_qry_string !=null)
		{
			for(int k=0;k<v_qry_string.size();k+=2) //New Fix
			{
				s_title = (String)v_qry_string.get(k);
				if(s_title.length() > 44)
				{
					flag++;
				}
			}
		}
		String Str_test ="";
		String Str_mes ="";
		String Str_units="";
		if(v_qry_string != null && v_qry_string.size() > 2)
		{

			String st_qryString = "";
			Vector  sqry = new Vector();
			sqry.add("opt");
			sqry.add("rtype");
			sqry.add("chartFor");
			for(int i=0;i<v_qry_string.size();i+=4)
			{
				s_title= (String)v_qry_string.get(i);
				if(s_title.indexOf("*")>-1)
					s_title = s_title.replace('*','%');
				st_qryString = (String)v_qry_string.get(i+1);
				//Adding the title and the URL of the image for saving to PDF
				count++;
				String theWidth = "";
				String theHeight = "";

				String isPie = reportInfo.getChartTypeForDist("APPLICATION_REPORT");
				if(isPie!=null && isPie.equalsIgnoreCase("Pie"))
				{
					theWidth = "740";
					theHeight = "250";
				}
				else
				{
					theWidth = "740";
					theHeight = "380";
				}
%>

<%
				st_qryString = st_qryString;
				String queryString = "";
				String 	queryStringdata="";
				String controlfile = st_qryString.substring(0,st_qryString.indexOf("?"));
				st_qryString = st_qryString.substring(st_qryString.indexOf("?")+1);
				HashMap param  = ErUtils.parseQueryString(st_qryString);
				Set s_param = param.keySet();
				Iterator i_param = s_param.iterator();
				while(i_param.hasNext())
				{
					String st_key = (String)i_param.next();
					String value="";
					if(st_key.equals("er_application"))		
					{
						Object obj1 =param.get(st_key);
						if(obj1 instanceof String)
						{
							value = (String)obj1;
						}
						else if(obj1 instanceof String[])
						{
							String kvalue[] = (String[])obj1;
							if(kvalue!=null)
							{
								value=kvalue[0];
							}
						}
						
					}
					else
					{
						//value = (String)param.get(st_key);
					
						//
						Object obj2 =(Object) param.get(st_key); 
						if(obj2 instanceof String[])
						{
							value = ((String[])obj2)[0];
						}else
							value = (String)obj2;
						//
					}					
					if(st_key!=null&&st_key.equals("er_test"))
					{
						Str_test = value;
					}
					else if(st_key!=null&&st_key.equals("er_meas"))
					{
						Str_mes=value;
					}
					if(!sqry.contains(st_key))
					{
						queryStringdata+=st_key+ "=" + URLEncoder.encode(value) + "&";
					}
					if(st_key!=null&&st_key.equals("select_farm"))
					{
						queryString+=st_key+ "=" + EgURLEncoder.encode(value,"UTF-8") + "&";
					}
					else
					{
						queryString+=st_key+ "=" + URLEncoder.encode(value) + "&";
					}
				}

				Str_units = tablesInfo.getUnitForMeasure(Str_test,Str_mes);
				if(s_title!=null && s_title.equals("Number of unique users"))
				{
					s_title = intlmap.getTextDescription("reporter.common."+s_title) + " (Number)";
				}
				else
				{
					s_title = s_title + " ("+Str_units+")";
					//s_title =intlmap.getTestDescription(s_title.substring(0,s_title.indexOf("/")))+"/"+intlmap.getMeasureDescription(s_title.substring(0,s_title.indexOf("/")),s_title.substring(s_title.indexOf("/")+1,s_title.indexOf("(")));
				}
				queryString = controlfile+"?"+queryString+"&startmin="+strmin+"&endmin="+enmin;
				queryStringdata = queryStringdata+"&startmin="+strmin+"&endmin="+enmin +"er_sortby=-1&optt=data&dataFor=distribution";

				session.setAttribute("distQryData",queryStringdata);
				reportDataJson.put("title",s_title);

%>
<%
														
				queryString=queryString+"&startdate="+s_st_time+"&enddate="+s_en_time+"&starthr="+s_st_hr+"&endhr="+s_en_hr;
				chartUrls.add(queryString+"&er_width=620&er_height=250&er_align=left&optt=graph&er_view=APPLET");

%>
<%
				if(v_qry_string.size() == (i + 2))
				{
%>
<%
				}
				else
				{
					theWidth = "740";
					theHeight = "380";
					s_title=(String)v_qry_string.elementAt(i+2);
					if(s_title.indexOf("*")>-1)
					s_title = s_title.replace('*','%');
					s_qryString = (String)v_qry_string.elementAt(i+3);
					String ertest = request.getParameter("er_test");
					String ermeas = request.getParameter("er_meas");
					String 	query_String="";
					controlfile = s_qryString.substring(0,s_qryString.indexOf("?"));
					query_String = s_qryString.substring(s_qryString.indexOf("?")+1);
					String qrydata = "";
					param  = ErUtils.parseQueryString(query_String);
					HashMap param1  = ErUtils.parseQueryString(query_String);
					String strSelectFarm = (String)param1.get("select_farm");
					param1.put("select_farm", EgURLEncoder.encode(strSelectFarm,"UTF-8"));
					Set s_param1=param1.keySet();
					Iterator i_param1=s_param1.iterator();
					String value11="";
					String st_key1 ="";
					String	qrydata1="";

					while(i_param1.hasNext())
					{

						
						st_key1 = (String)i_param1.next();
					//	value11 = (String)param1.get(st_key1);

						if(st_key1.equals("er_application"))		
					{
						Object obj1 =param1.get(st_key1);
						if(obj1 instanceof String)
						{
							value11 = (String)obj1;
						}
						else if(obj1 instanceof String[])
						{
							String kvalue[] = (String[])obj1;
							if(kvalue!=null)
							{
								value11=kvalue[0];
							}
						}
								
						}
						else
						{
							//value11 = (String)param1.get(st_key1);
							Object obj3 =(Object) param.get(st_key1); 
							if(obj3 instanceof String[])
							{
								value11 = ((String[])obj3)[0];
							}else
								value11 = (String)obj3;
						}	
						qrydata1+=st_key1+ "=" + URLEncoder.encode(value11) + "&";

					}
					query_String  = ErUtils.prepareQueryString(param1);
					s_param = param.keySet();
					i_param = s_param.iterator();
					String Tinfos[]=null;
					String er_test="";
					String er_meas="";

					while(i_param.hasNext())
					{
						String value="";
						String st_key = (String)i_param.next();
				//		value = (String)param.get(st_key);

							if(st_key.equals("er_application"))		
					{
						Object obj1 =param.get(st_key);
						if(obj1 instanceof String)
						{
							value = (String)obj1;
						}
						else if(obj1 instanceof String[])
						{
							String kvalue[] = (String[])obj1;
							if(kvalue!=null)
							{
								value=kvalue[0];
							}
						}
								
						}
						else
						{
							//value = (String)param.get(st_key);
							Object obj4 =(Object) param.get(st_key); 
							if(obj4 instanceof String[])
							{
								value = ((String[])obj4)[0];
							}else
								value = (String)obj4;
						}	
						if(st_key.equals("er_test"))
							er_test = value;

						if(st_key.equals("er_meas"))
							er_meas = value;

						if(!sqry.contains(st_key))
						{
							qrydata+=st_key+ "=" + URLEncoder.encode(value) + "&";
						}
					}

					Str_units = tablesInfo.getUnitForMeasure(er_test,er_meas);
					if(s_title!=null && s_title.equals("Number of unique users"))
					{
						s_title = s_title + " (Number)";
					}
					else
					{
						s_title = s_title + " ("+Str_units+")";
					}

					query_String = controlfile+"?"+qrydata1;
					qrydata = qrydata +"er_sortby=-1&optt=data";
					//Adding the title and the URL of the image for saving to PDF
					count++;
					session.setAttribute("topQryData",qrydata);
					chartUrls.add(query_String+"&startmin="+strmin+"&endmin="+enmin + "&er_width=" + theWidth + "&er_height=" + theHeight + "&er_align=center&optt=graph&er_view=APPLET");

%>
<%
				}
%>
<%
			}
%>

<%
		}
		HashMap param =new HashMap();
		param.put("REPORT_PARAM",ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap())));
		param.put("REPORT_DATA",pdfQuery);
		param.put("fileName","UserChannelReport");
		session.setAttribute("parameters", param);
		reportDataJson.put("chartUrls",chartUrls);
		rootJson.put("reportData",reportDataJson);

	}
	session.setAttribute("htdat",htt);
%>
<%
	sen1 = new Hashtable();
	if(lst_dat1!=null && !lst_dat1.isEmpty())
	{
	
			
			sen1.put(vec1,lst_dat1);
			
			
			ht1=new Hashtable();
			ht1.put(s_tit1,sen1);
			
			lst.add(ht1);
			
			//lst.add(lst_dat3.get(i));
			sen1 = new Hashtable();
		//	ht1 = new Hashtable();
		
		
	
		session.setAttribute("list",lst);
	}
	else 
	{
		session.setAttribute("list",lst);
	}

	String processVal="";
	String strtestmes =testmes;
	if(testmes!=null && testmes.length()>0)
		strtestmes = EgURLEncoder.encode(testmes,"UTF-8");
	if(rtype!=null && rtype.equals("Yes")) {
		processVal="&printGraph=yes&opt=chart&uid="+EgURLEncoder.encode(loginid,"UTF-8")+ "&select_testmes=" +strtestmes+"&er_type=yes&er_sortby=-1";
	} else {
		processVal="&er_view=PRINT&";
	}
	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){

		String er_apps=request.getParameter("er_application");
		if(er_apps==null)
			er_apps="";
		String dataProcess = mngrIProc+"/final/servlet/com.eg.ErCtxServerReportC;jsessionid="+session.getId()+"?er_rtype=CtxChannelResource&er_gtype=Citrix&er_trgttype="+EgURLEncoder.encode("User Channel Report","UTF-8")+"&select_farm="+strEncodeselect_farm+"&er_server="+strEncodeer_server+"&er_application="+EgURLEncoder.encode(er_apps,"UTF-8")+"&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;
		String strEncodeerUser = "";
		if(er_apps!=null)
			strEncodeerUser = EgURLEncoder.encode(er_apps,"UTF-8");
		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");
		if(isFromDrillDown!=null && isFromDrillDown.equalsIgnoreCase("true"))
		{// for send mail from drill down
		dataProcess+="&opt=chart&option=Citrix&er_user="+strEncodeerUser+"&graphViewtype="+strEncodegphtype+"&userID="+EgURLEncoder.encode(loginid,"UTF-8")+"&er_comptype="+strEncodecmpType+"&userTimeline="+strEncodeusrtime+"&isFromDrillDown=true";

		}
		else
		{
		dataProcess+="&opt=chart&option=Citrix&er_user="+strEncodeerUser+"&graphViewtype="+strEncodegphtype+"&userID="+EgURLEncoder.encode(loginid,"UTF-8")+"&er_comptype="+strEncodecmpType+"&userTimeline="+strEncodeusrtime;
		}
		
		dataProcess+="&er_RmDispName="+titleToDisplay+"&er_option="+er_option+"&dsktp_searchTxt="+EgURLEncoder.encode(dsktp_searchTxt,"UTF-8");
		
		if(rtype!=null&&!rtype.equals("Yes"))
		{
			dataProcess+="&pageWidthProces="+pageWidthProces;
		}

		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("dsktp_searchTxt"))
		{
			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") || reqparam.equals("user_name")))
		{
			if(value != null){
				if(value.indexOf("\\") > -1)
					value=com.egurkha.util.StringUtils.replace(value, "\\","|slash|");
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			}
		}
		if(reqparam!=null&&reqparam.equals("er_application"))
		{
			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("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.equals("showLegend"))
		{
			rootJson.put("showLegend",value);
		}
		if(reqparam!=null&&reqparam.equals("er_sortby"))
		{
			value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			value=com.eg.EgURLEncoder.encode(value, "UTF-8");
		}
		Qstring=Qstring+reqparam+"="+value+"&";
	}
	rootJson.put("saveQString",Qstring);
}
session.setAttribute("PDF_URL", mngrIProc+"/final/servlet/com.eg.ErCtxServerReportC");
//Back button - Start
ArrayList listbackvar = new  ArrayList();
//	String forUserDetails=request.getParameter("enableBackForUserDetails");
if(request.getParameter("isSubmit")!=null)
{
	session.setAttribute("favSchBackDisplay","Yes");
	/*if(forUserDetails != null && forUserDetails.equalsIgnoreCase("true")){
		listbackvar.add("ErThinClientUserReport.jsp");
		listbackvar.add("status="+status+"&bggroundStr="+bggroundStr+"&"+queryString);
	}
	else{*/
		listbackvar.add("/servlet/com.eg.ErCtxServerReportC?");
		listbackvar.add("status="+status+"&bggroundStr="+bggroundStr+"&"+queryString);

	//}

}
else
{
	listbackvar.add("ErThinClientUserReport.jsp");
	listbackvar.add(queryString);
	session.setAttribute("favSchBackDisplay","No");
}
	session.setAttribute("reportLastAccessedURL","/final/reporter/ErThinClientUserReport.jsp?"+Qstring);
	String backadded = erhelputils.getBackID();
	backreqMap = erhelputils.setBackQueryMap(backreqMap,backadded,listbackvar);
	session.setAttribute("backQuery",backreqMap);

//Back button - End

//method for removing the VM name form username
	rootJson.put("hiddenfields",hiddenfieldsJson);
	rootJson.put("screenLabels",screenLabelJson);
	//
	String isMainSearch=request.getParameter("main_search");
	if(isMainSearch!=null && isMainSearch.equalsIgnoreCase("true"))
	{
	session.setAttribute("backData",rootJson);
	}

	out.println(rootJson.toString());
	

}catch(Throwable t)
{t.printStackTrace();}

%>


<%!
	public String getEncodedParams(Map TmpparamMapVal){
		String qStrimgMap="";
		try{
		Iterator itr = TmpparamMapVal.keySet().iterator();
		while(itr.hasNext()){
			String map_key = (String)itr.next();
			String map_value ="";
			Object obj_val = TmpparamMapVal.get(map_key);
			if(obj_val instanceof String[]){
				String val_arr[] = (String[])TmpparamMapVal.get(map_key);
				for(int k=0;k<val_arr.length;k++)
				{
					map_value = val_arr[k];
					if(map_key != null && (map_key.equalsIgnoreCase("er_user") || map_key.equalsIgnoreCase("er_application") || map_key.equalsIgnoreCase("er_aduser") || map_key.equalsIgnoreCase("er_adGroup"))){
						map_value = com.eg.EgURLEncoder.encode(map_value, "UTF-8");
					}
					qStrimgMap+="&"+map_key+"="+map_value;
				}
			}
			else
			{
				map_value = (String)TmpparamMapVal.get(map_key);
					if(map_key != null && (map_key.equalsIgnoreCase("er_user") || map_key.equalsIgnoreCase("er_application") || map_key.equalsIgnoreCase("er_aduser") || map_key.equalsIgnoreCase("er_adGroup"))){
					map_value = com.eg.EgURLEncoder.encode(map_value, "UTF-8");
				}
				qStrimgMap+="&"+map_key+"="+map_value;
			}
		}
		}catch(Exception ee){
			ee.printStackTrace();
		}
		return qStrimgMap;
	}
%>
<%!
	public String getConnectionQulityString(double dd)
	{
		String strReturn ="";
		if(dd>0 && dd==1.0)
			strReturn = "Poor connection";
		else if(dd>0 && dd==2.0)
			strReturn = "Weak connection";
		else if(dd>0 && dd==3.0)
			strReturn = "Strong connection";
		else
			strReturn = "None";
		return strReturn;

	}

%>