<%
/*******************************************************************************
*	File name		:	ErCtxUserSessionComboJson.jsp
*	Purpose			:	Displays the duration of user logins in the servers
*	Version			:	1.0
*	Author			:	Gowtham G
*	Creation Date	:	23/2/15
*******************************************************************************/
%>

<%@ include file = "ErReporterTracker.jsp" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.text.SimpleDateFormat" %>
<%@ page import = "com.eg.EgDbInfo" %>
<%@ page import = "com.eg.EgAgentInfo" %>
<%@ page import = "com.eg.EgDateInfo" %>
<%@ page import = "com.eg.EgGroupInfo" %>
<%@ page import = "com.eg.EgReportInfo"%>
<%@ page import = "com.eg.EgSpecsInfo"%>
<%@ page import="com.eg.EgTablesInfo" %>
<%@ page import = "egurkha.*" %>
<%@ page import = "com.egurkha.ini.*" %>
<%@ page import = "egurkha.reporter.*" %>
<%@ page import = "com.egurkha.*" %>
<%@ page import = "java.net.URLEncoder" %>
<%@ page import = "java.net.URLDecoder" %>
<%@ page import = "com.egurkha.util.DateTimeTokenizer" %>
<%@ page import = "com.egurkha.util.DateUtil" %>
<%@ page import = "java.text.*" %>
<%@ page import ="com.eg.EgInstallInfo"%>
<%@ page import ="com.eg.MappingNameSorter"%>
<%@ page import ="com.eg.EgMappingInfo"%>
<%@ page import ="com.eg.EgURLEncoder"%>
<%@ page import ="com.eg.IniFile"%>
<%@ page import = "com.eg.EgTesterInfo" %>
<%@ page import = "com.eg.EgTestInfo" %>
<%@ page import = "com.eg.EgConfigInfo"%>
<%@ page import = "com.eg.EgName"%>
<%@ 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.*" %>

<%
response.setContentType("application/json");
JSONObject rootJson = new JSONObject();
JSONObject screenLabelJson = new JSONObject();
JSONObject hiddenfieldsJson=new JSONObject();
JSONObject loopJsonObj = new JSONObject();
String er_showResourceUsage = request.getParameter("er_showResourceUsage");

//Back Button - Start
	String bggroundStr = (String)request.getAttribute("bggroundStr");
	String status = (String)request.getAttribute("status");
	HashMap backreqMap = (HashMap)session.getAttribute("backQuery");
	String backQnumber = request.getParameter("backQnumber");
	String servlet2 = request.getParameter("backServletName");
	String client_Version=request.getParameter("client_Version");

	
	String mngrIProc = new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
	String s_tit= "";
	String s_tit1= "";
	Vector vec = new Vector();
	Vector vec2 = new Vector();
	Vector vec1 = new Vector();
	Vector vec3 = new Vector();
	Vector v_val1 = new Vector();
	ErInfo erInfo = new ErInfo();
	EgGroupInfo gpinfo = new EgGroupInfo();
	ErUtils erUtils = new ErUtils();
	ErHelperUtils erhelputils = null;
	EgReportInfo reportInfo = new EgReportInfo("manager");
	EgMappingInfo intlmp=new EgMappingInfo(thisuser.getLanguage());
	MappingNameSorter sorter = new MappingNameSorter(thisuser.getLanguage());
	ErComponentsUtils compUtils = new ErComponentsUtils(thisuser.getLoginID());
	EgSpecsInfo egSpecsInfo = new EgSpecsInfo("manager");	
	EgTesterInfo testInfo = new EgTesterInfo("manager");
	EgTestInfo tokInfo = new EgTestInfo("manager");
	EgDbInfo dbInfo = new EgDbInfo("manager");
	ErReqData erd = new ErReqData(request);
	EgTablesInfo tablesInfo = new EgTablesInfo("manager");
	EgUserRole loginUserRole = EgUserRole.getRoleObject(thisuser.getLoginType());
	
	String showFrom=request.getParameter("showFrom");
	if(showFrom==null)
	{
		showFrom = reportInfo.getValue("CITRIX_USER_REPORT","showFrom");
	}
	if(showFrom==null || showFrom.length()==0)
	{
		showFrom = "Outside view";
	}
	String INI_SUBJECT = "CITRIX_USER_REPORT";
	if(showFrom.equalsIgnoreCase("Inside view"))
	{
		INI_SUBJECT = "CITRIX_USER_REPORT_INSIDE";
	}
	
	String showUserWorkGroup = reportInfo.getValue("MISC","ShowUserWorkGroup");

	boolean enableBack=false;
	String strDipServer="";
	String backButtonEnable = request.getParameter("back");
	String confrimation = reportInfo.getValue("BACKGROUND_PROCESS","NeedConfirmation");
	String strbgrepportName = reportInfo.getValue("BACKGROUND_PROCESS","EnableBackgroundReport");
	String limitforbg = reportInfo.getValue("BACKGROUND_PROCESS","MinDurationForReport");
	String strShowAppNames = reportInfo.getValue(INI_SUBJECT,"ShowApplicationDeatils");
	if( servlet2!=null && !servlet2.equals(""))
		erhelputils = new ErHelperUtils(backreqMap,backQnumber,servlet2);
	else
		erhelputils = new ErHelperUtils(backreqMap,backQnumber);
	
	if(backButtonEnable != null && backButtonEnable.equalsIgnoreCase("True"))
	{
		status = (String)request.getParameter("status");
		request.setAttribute("Report_data",null);
		request.setAttribute("Summary_Report_data",null);
		bggroundStr = (String)request.getParameter("bggroundStr");
	}
	rootJson.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
	
	IniUI ui = IniUI.getInstance();
	IniFile inifile_service = new IniFile(EgInstallInfo.getInstallDir()+"/manager/config/eg_services.ini");
	EgDateInfo egDt = new EgDateInfo();
	
	StringTokenizer st;
	
	int tableCount = 2;
	int countForUser = reportInfo.getMoreUsers(INI_SUBJECT);	
	int pageWidthProces=1024;

	boolean showAllUsers = false;
	boolean summaryExists = false;
	boolean sessionExists = false;
	boolean likeAllUsers = false;
	boolean onlyThisUser = false;
	boolean getMoreUsers = false;
	boolean isAdDiscoverEnabled = false;
	boolean showMeasure = false;
	boolean showDuration = false;
	boolean isSummary=false;
	boolean isVm = false;
	
	List lst = new LinkedList();
	List lst_dat = new LinkedList();
	List lst_dat1 = new LinkedList();
	List lst_dat2 = new LinkedList();
	
	Hashtable avgPerForMeasures=new Hashtable();	
	Hashtable sen = new Hashtable();
	Hashtable ht = new Hashtable();	
	Hashtable ht1 = new Hashtable();
	Hashtable sen1 = new Hashtable();
	HashMap Report_data=null;
	
	Vector v_temp = new Vector();
	Vector v_time = new Vector();
	Vector v_min=new Vector();
	Vector v_compType=new Vector();
	Vector v_u = new Vector();
	Vector v_adddata=new Vector();
	Vector v_users = new Vector();
	Vector colZoneComps = new Vector();
	Vector v_sortBy=new Vector();
	Vector v_summary = new Vector();
	Vector v_session = new Vector();
	Vector v_comp = compUtils.getAllUserComponents1();
	
	String tmpComponent="";
	String backQueryForServer="";
	String queryForUserReport ="";
	String queryForServer ="";
	String queryForGraph ="";
	String queryForMaxAvgPer="";
	String queryForVirualMachineDetails="";
	String summaryTitle = "";
	String sessionTitle = "";
	String sessionField = "";
	String sessionFieldDisp = "";
	String fieldDisplay="$F{title},-,-,-";
	String AddfieldDisplay="Logintime,Server,Duration of Access";
	String Fields="title,Logintime,Server,Duration";
	//String Addmapping="Logintime#Logintime,Server#Server,Duration#Duration";	
	String strGroup = request.getParameter("er_organize");
	String gType = request.getParameter("er_gtype");
	String rType = request.getParameter("er_rtype");
	String er_Type = request.getParameter("er_type");
	String tType = request.getParameter("er_trgttype");
	String tbound = request.getParameter("er_tbound");
	String s_user = request.getParameter("er_user");
	s_user = erUtils.specialCharDecode(s_user);
	String t_user = request.getParameter("t_user");
	String searchUser = request.getParameter("er_tuser");
	String s_sort = request.getParameter("er_sort");
	String menuForVM = request.getParameter("menuForVM");
	String isUserVmReport = request.getParameter("isUserVmReport");
	String isVmReports = request.getParameter("isVmReport");
	if(menuForVM!=null && (menuForVM.equalsIgnoreCase("yes")||menuForVM.equalsIgnoreCase("true")))
	{
		isVmReports = "Yes";
		isUserVmReport = "yes";
	}
	String s_UIsortby = request.getParameter("er_sortBy");
	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 s_compType=request.getParameter("er_compType");
	String er_guestname = request.getParameter("er_guestname");
	String strDiscValue = inifile_service.getValue("AD_XENUSER_REPORT","DiscoverUsersforADXenUserReport");
	String[] selectedCompArrays = request.getParameterValues("er_componentserver");	
	String er_poolType[]=request.getParameterValues("er_poolType");
	String triggeredfrom = request.getParameter("triggeredfrom");
	if(triggeredfrom!=null && triggeredfrom.equalsIgnoreCase("CompType"))
	{
		selectedCompArrays = null;
	}
	String er_option =request.getParameter("er_option");
	String onAnalysisChange = request.getParameter("onAnalysisChange");
	String er_dataFrom =request.getParameter("er_dataFrom");
	String er_service = request.getParameter("er_service");
	String s_farmserver = request.getParameter("select_farm");
	String isSubmitted =request.getParameter("isSubmit");
	String needLogonSplitUp=request.getParameter("needLogonSplitUp");
	String loginid = thisuser.getLoginID();
	String[] zones = getZoneArr(compUtils);
	String strVmComp = reportInfo.getValue("MISC","VMWareComponent");
	String user = "";
	String edate ="";
	String sdate ="";
	String startDate = request.getParameter("er_stdate");
	String endDate = request.getParameter("er_enddate");
	String stHr = request.getParameter("er_sthr");
	String endHr = request.getParameter("er_endhr");
	String timeline = request.getParameter("er_timeline");
	String cTime = request.getParameter("currTime");
	String timeTo = request.getParameter("timeto");
	String timeFrom = request.getParameter("timefrom");
	String minFrom = request.getParameter("minfrom");
	String minTo = request.getParameter("minto");
	String compType = request.getParameter("er_compType");
	String sSearch = request.getParameter("showSearch");
	String colSeparator = testInfo.getDDSeparator1();
	String rowSeparator = testInfo.getDDSeparator2();
	String discontest="";
	String s_totalConnectiontime="";
	String s_pctConnectiontime="";
	String sessionQs_user = (String)session.getAttribute("topBackQuery");
	String er_aggregateValue = request.getParameter("er_aggregateValue");
	ArrayList selectedServerLst=new ArrayList();
	String adGroupFns=request.getParameter("adGroupFns");
	String adGroupForPrint=request.getParameter("adGroupForPrint");
	if(needLogonSplitUp==null)
	{
		needLogonSplitUp = reportInfo.getValue(INI_SUBJECT,"needLogonSplitUp");
	}
	if(needLogonSplitUp==null || needLogonSplitUp.trim().length()==0)
	{
		needLogonSplitUp = "no";
	}
	boolean hasAllComponentAccess = loginUserRole.hasAllComponentAccess();
	List a_userVMs = new LinkedList();
	boolean hasVMs = false;
	String vmType = "";
	List tmp_VMlist = null;
	HashMap vmByCompType = new HashMap();
	if(er_guestname==null)
	{
		er_guestname = "*";
	}
	if(!hasAllComponentAccess)
	{
		//a_userVMs = thisuser.getOnlyVMs();
		List a_userVMs_temp = thisuser.getAlluserDesktopVms();
		if(a_userVMs_temp!=null && a_userVMs_temp.size() > 0)
		{
			for(int i=0;i<a_userVMs_temp.size();i++)
			{
				String VM = (String)a_userVMs_temp.get(i);
				if(VM!=null && VM.indexOf("_on_")>-1)
				{
					VM = VM.substring(VM.indexOf("_on_")+4);
				}
				if(!a_userVMs.contains(VM))
				{
					a_userVMs.add(VM);
				}
			}
			vmType = thisuser.getVMType();
			hasVMs = true;
		}
	}
	if(s_farmserver!=null && (s_farmserver.equals("null") ))
	{
		s_farmserver=null;
	}
	if(s_compType!=null && (s_compType.equals("null") || s_compType.equals("-1")))
	{
		s_compType=null;
	}
	if(er_option!=null && (er_option.equals("null")||er_option.equals("-1")))
	{
		er_option=null;
	}
	er_aggregateValue =request.getParameter("er_aggregateValue");	
	if(er_aggregateValue==null && (isSubmitted!=null && isSubmitted.equalsIgnoreCase("true")))		
			er_aggregateValue="Details";
	else if(er_aggregateValue==null && (isSubmitted==null || (isSubmitted!=null && !isSubmitted.equalsIgnoreCase("true"))))		
			er_aggregateValue="Summary";		
		if(er_aggregateValue!=null && er_aggregateValue.equalsIgnoreCase("Details"))
		{
			isSummary=false;
			er_aggregateValue="Details";
		}else
		{
			isSummary=true;
		
		}
		if(strGroup!=null && strGroup.equalsIgnoreCase("AD"))
		{
			isSummary=false;
			er_aggregateValue="Details";
		}
	IniFile inifile=null;
	inifile = new IniFile(EgInstallInfo.getInstallDir()+"/manager/config/eg_format.ini");
	if(s_compType!=null && s_compType.equals("Terminal_server"))
		discontest=inifile.getValue("FORMAT","TermDisconnectsTest:New_disconnects");
	else if(s_compType!=null && s_compType.equals("Citrix_server"))
	{
		discontest=inifile.getValue("FORMAT","CtxDisconnectsTest:New_disconnects");
		
		if(discontest.indexOf("ClientType")>-1)					//For BugId 15474
		{
			discontest = discontest.replace(" ClientType", "");
		}
	}		
	else if(s_compType!=null && s_compType.equals("Citrix_XcXenApp_server"))
	{
		discontest=inifile.getValue("FORMAT","CtxXcXADisconnTest:New_disconnects");
		if(discontest.indexOf("Client_type")>-1)					//For BugId 15474
		{
			discontest = discontest.replace(" Client_type", "");
		}
	}
	if(erd.s_tbound != null && erd.s_tbound.equalsIgnoreCase("Fixed") && erd.s_timeline != null && erd.s_timeline.length() > 0)
	{
		startDate = sdate;
		endDate = edate;
		stHr =erd.s_sthr;
		endHr =erd.s_endhr;
	}
	
	ArrayList aListVmComponentType = new ArrayList();
	ArrayList aListSupportComponentType =reportInfo.getComponentsList(INI_SUBJECT,false);
	if(aListSupportComponentType!=null)
	{
		aListSupportComponentType.add("Horizon_Pod");
	}
	ArrayList aListApplicationComponentType = reportInfo.getCtxUserApplicationEnabledCompType(INI_SUBJECT);
	
		String clientIp_ = request.getParameter("clientIp");

	enableBack=erhelputils.isBackButtonEnable();
	v_sortBy.add("Session Start Time");
	v_sortBy.add("Logout/Disconnect Time");
	v_sortBy.add("Server");
	if(strGroup!=null && strGroup.equalsIgnoreCase("AD"))
	{
		v_sortBy.add("% Connected Time");
		v_sortBy.add("Total Connected Time");
		v_sortBy.add("Total Elapsed Time");
	}	
	v_adddata.add(searchUser);
	if(s_sort==null)
		s_sort=(String)v_sortBy.get(0);	
	if(s_UIsortby == null || s_UIsortby.equals(""))
		s_UIsortby = s_sort;

	if(searchUser!=null && !searchUser.equals(""))
	{
		if(searchUser.indexOf("*") > -1)
		{
			likeAllUsers = true;
			tableCount = 1;
			fieldDisplay="$F{title},-,-,-,-";
			AddfieldDisplay="User,Logintime,Server,Duration of Access";
			Fields="title,User,Logintime,Server,Duration";
			//Addmapping="User#User,Logintime#Logintime,Server#Server,Duration#Duration";
		}
		else
		{
			onlyThisUser = true;
			tableCount = 1;
		}
		s_user = request.getParameter("er_tuser");
	}
	v_adddata.add(s_user);
	if(s_user == null)
		s_user = "";
	if(s_user!=null && s_user.equalsIgnoreCase("-- All --"))
	{
		v_sortBy.add("User");
		showAllUsers = true;
		tableCount = 1;
	}
	if(t_user!=null && t_user.equalsIgnoreCase("-- All --"))
	{
		v_sortBy.add("User");
		showAllUsers = true;
		tableCount = 1;
	}
	
	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.contains(s_compType) && !hasVMs)
	{
		showFrom = "Outside view"; 
		INI_SUBJECT = "CITRIX_USER_REPORT";
	}

	if(	aListVmComponentType !=null)
	{
		if(aListVmComponentType.contains(s_compType))
			isVm = true;
	}
	if(strDiscValue!=null && (strDiscValue.equalsIgnoreCase("Yes") || strDiscValue.equalsIgnoreCase("True")))
		isAdDiscoverEnabled = true;

	if(er_option == null || (er_option!=null && er_option.isEmpty()))
	{
		if(hasVMs)
		{
			er_option = "Component";
		}
		else
		{
		 er_option = "Zone";
		}
	}	
	
	
	if(er_dataFrom!=null && (er_dataFrom.equalsIgnoreCase("Segment")||er_dataFrom.equalsIgnoreCase("Service")||er_dataFrom.equalsIgnoreCase("Zone")))
	{
		if(er_service!=null)
		{
			er_option=er_dataFrom;
		}
	}
	else if(er_dataFrom!=null && er_dataFrom.equalsIgnoreCase("Component"))
	{
		er_option=er_dataFrom;
	}
	
	
	ErEsxVMutils erEsxUtils = new ErEsxVMutils();
	erEsxUtils.setNeedGroupTire(true);
	List v_option = new ArrayList();
	Hashtable htAllGroups =new Hashtable();
	htAllGroups = erEsxUtils.getGroups(null, aListSupportComponentType, 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(hasVMs)
	{
		v_option = new ArrayList();
		v_option.add("Component");
	}
	
	if(v_option!=null && v_option.size()>0)
	{
		for(int i=0; i<v_option.size(); i++)
		{
			obj = getLoopObjInfo(intlmp.getTextDescription("reporter.common."+v_option.get(i)),(String)v_option.get(i));
			arr.add(obj);
		}
		rootJson.put("selectedAnalysisByCombo",er_option);
	}
	else
	{
		obj = getLoopObjInfo(intlmp.getTextDescription("reporter.common.Not Applicable"),"-1");
		arr.add(obj);
		rootJson.put("selectedAnalysisByCombo","-1");
	}
	rootJson.put("analysisByCombo",arr);
	///
	arr = new JSONArray();
	obj = getLoopObjInfo("Outside view","Outside view");
	arr.add(obj);
	obj = getLoopObjInfo("Inside view","Inside view");
	arr.add(obj);
	rootJson.put("showFromCombo",arr);
	rootJson.put("selectedShowFromCombo",showFrom);
	///
	rootJson.put("selectedAggregateSessionValue",er_aggregateValue);
	
%>		
<%	
	Object[] objArr =null;
	List v_site = new ArrayList();
	Vector vecComponent=null;
	if(er_option!=null)
	{
		List aListComponentTemp=null;
		LinkedHashSet vmSupportedCompType = new LinkedHashSet(); 
		v_site = erEsxUtils.getGroupsName(htAllGroups,er_option);
		
		if(v_site!=null && v_site.size()>0 )
		Collections.sort(v_site,String.CASE_INSENSITIVE_ORDER);
		
		 if(!er_option.equalsIgnoreCase("Component"))
		 {
			 if(v_site!=null && v_site.size()>0 )
			v_temp.addAll(v_site);
			if((s_farmserver==null && v_site!=null && v_site.size()>0) || (s_farmserver!=null && v_site!=null && !v_site.contains(s_farmserver) && v_site.size()>0 ))
			{
				
				s_farmserver=(String)v_site.get(0);
			}
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,s_farmserver);
		 }
		 else 
		 {
			 aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,null);
			if(hasVMs)
			{
				if(a_userVMs!=null && a_userVMs.size() > 0)
				{
					aListComponentTemp = new ArrayList();
					TreeSet selectedCompArraysVm = new TreeSet();
					if(selectedCompArrays!=null && selectedCompArrays.length>0)
					{
						if(selectedCompArrays[0].equalsIgnoreCase("All"))
						{
							tmp_VMlist = new ArrayList(a_userVMs);
						}
						else
						{
							tmp_VMlist = Arrays.asList(selectedCompArrays);
						}
					}
					for(int i=0;i<a_userVMs.size();i++)
					{
						String comps = (String)a_userVMs.get(i);
						ArrayList hosts = (ArrayList)thisuser.getVMHostHistory(comps);
						if(hosts!=null && hosts.size()>0)
						{
							for(int j=0;j<hosts.size();j++)
							{
								String hostName = (String)hosts.get(j);
								String vmCompType = hostName.substring(hostName.lastIndexOf(":")+1);
								vmSupportedCompType.add(vmCompType);
								if(!aListComponentTemp.contains(hostName))
								{
									aListComponentTemp.add(hostName);
								}
								if(tmp_VMlist!=null && ((selectedCompArrays!=null && selectedCompArrays.length>0 && selectedCompArrays[0].equalsIgnoreCase("All"))||tmp_VMlist.contains(comps)))
								{
									selectedCompArraysVm.add(hostName);
								}
								if(vmByCompType.get(vmCompType)==null)
								{
									TreeSet loopSet = new TreeSet();
									loopSet.add(comps);
									vmByCompType.put(vmCompType,loopSet);
								}
								else
								{
									TreeSet loopSet = (TreeSet)vmByCompType.get(vmCompType);
									loopSet.add(comps);
								}
							}
						}
					}
					if(v_comp!=null && v_comp.size()>0)
					{
						for(int j=0;j<v_comp.size();j++)
						{
							String hostName = (String)v_comp.get(j);
							String vmCompType = hostName.substring(hostName.lastIndexOf(":")+1);
							if(!aListSupportComponentType.contains(vmCompType))
							{
								continue;
							}
							vmSupportedCompType.add(vmCompType);
							if(!aListComponentTemp.contains(hostName))
							{
								aListComponentTemp.add(hostName);
							}
							if(tmp_VMlist!=null && ((selectedCompArrays!=null && selectedCompArrays.length>0 && selectedCompArrays[0].equalsIgnoreCase("All"))||tmp_VMlist.contains(hostName)))
							{
								if(!tmp_VMlist.contains(hostName))
								{
									tmp_VMlist.add(hostName);
								}
								selectedCompArraysVm.add(hostName);
							}
							if(vmByCompType.get(vmCompType)==null)
							{
								TreeSet loopSet = new TreeSet();
								loopSet.add(hostName);
								vmByCompType.put(vmCompType,loopSet);
							}
							else
							{
								TreeSet loopSet = (TreeSet)vmByCompType.get(vmCompType);
								loopSet.add(hostName);
							}
						}
					}
					if(selectedCompArraysVm.size()>0)
					{
						selectedCompArrays = new String[selectedCompArraysVm.size()];
						Iterator iterator = selectedCompArraysVm.iterator();
						int i=0;
						while (iterator.hasNext()) 
						{
							 selectedCompArrays[i] = (String)iterator.next();
							 i++;
						}
					}
				}
			 }
		 }
		
		if(selectedCompArrays!=null)
		{
			for(int j=0;j<selectedCompArrays.length;j++)
			{
				selectedServerLst.add(selectedCompArrays[j]);
			}
		}
		if(aListComponentTemp!=null && aListComponentTemp.size()>0)
		{
			vecComponent = new Vector();
			vecComponent.addAll(aListComponentTemp);
		}
		
		if(aListComponentTemp!=null && aListComponentTemp.size()>0)
		{
			v_compType = new Vector();
			for(int i=0; i<aListComponentTemp.size(); i++) 
			{
				String loopComponent = (String) aListComponentTemp.get(i);
				if(loopComponent.lastIndexOf(":")>-1){
					String loopComp = loopComponent.substring(0,loopComponent.lastIndexOf(":"));
					String  loopType = loopComponent.substring(loopComponent.lastIndexOf(":")+1);

						if(v_compType!=null && !v_compType.contains(loopType))
							v_compType.add(loopType);											
				}
			}
		}
		if(er_option.equalsIgnoreCase("Component"))
		{
			if(aListComponentTemp!=null && aListComponentTemp.size()>0)
			{
				vecComponent = new Vector();
				vecComponent.addAll(aListComponentTemp);
			}
			List compTypes = compUtils.getAllComponentType(); 
			if(hasVMs)
			{
				compTypes = new ArrayList(vmSupportedCompType);
			}
			if(compTypes!=null && compTypes.size()>0)
			{
				for(int aa=0;aa<compTypes.size();aa++)
				{
					if(aListSupportComponentType.contains(compTypes.get(aa)))
					{
						if(v_compType!=null && !v_compType.contains(compTypes.get(aa)))
							v_compType.add(compTypes.get(aa));
					}
				}
			}
		}
	
		if(v_compType != null && !v_compType.isEmpty() && s_compType == null)
		{
			ArrayList sortedNameList1 = new ArrayList();
			sortedNameList1 = sorter.getSortedCompTypeList(v_compType);
			EgName obj_name1 = (EgName) sortedNameList1.get(0); 
			s_compType = obj_name1.getActualName();
		}

		if(aListVmComponentType !=null)
		{
			if(aListVmComponentType.contains(s_compType))
				isVm = true;
		}
		
		if(er_option.equalsIgnoreCase("zone"))
		{
			if(s_farmserver!=null)
 			objArr = erUtils.getAllUsersForComponentsToUserSession(s_compType,selectedServerLst,s_farmserver,aListSupportComponentType,zones,v_temp,v_comp,countForUser);
		}
		else
		{	
			ArrayList userAlList=new ArrayList(aListComponentTemp);
			boolean fl=false;
			if(selectedServerLst!=null &&aListComponentTemp!=null)
			{
				
				for(int i=0;i<selectedServerLst.size();i++)
				{
					String strVal=(String) selectedServerLst.get(i);
					if(aListComponentTemp.contains(strVal))
						fl=true;
				}			
			}		
			if(fl)
			{
				userAlList=new ArrayList();
				userAlList.addAll(selectedServerLst);
			}
	
			if(s_compType!=null && aListComponentTemp!=null)
			{
				if(hasVMs)
				{
					TreeSet VMsList = (TreeSet)vmByCompType.get(s_compType);
					//List VMlistForQuery = new ArrayList(a_userVMs);
					List VMlistForQuery = new ArrayList(VMsList);
					if(tmp_VMlist!=null && tmp_VMlist.size()>0)
					{
						VMlistForQuery = tmp_VMlist;
					}					
					objArr = erUtils.getAllUsersForComponentsToUserSession(s_compType,aListSupportComponentType,userAlList,countForUser,VMlistForQuery);
				}
				else
				{
					objArr = erUtils.getAllUsersForComponentsToUserSession(s_compType,aListSupportComponentType,userAlList,countForUser);		
				}
			}
		}
	}
	if(objArr!=null && objArr.length==2 )
	{
		v_u=(Vector)objArr[0];
		getMoreUsers=(Boolean)objArr[1];
	}
	
	if(v_temp!=null && v_temp.size() > 1)
	{
		Collections.sort(v_temp);
	}
	if(v_u!=null && v_u.size() > 1)
	{
		Collections.sort(v_u);
	}
	int cntUserForFarm = 0;

	if(v_u!=null && v_u.size()>=2)
	{
		v_u.add(0,"-- All --");
	}
	if(v_u!=null && !v_u.isEmpty() && s_user.equals(""))
	{
		if(v_u.contains("-- All --") && isAdDiscoverEnabled)
		{
			s_user = "-- All --";
			showAllUsers = true;
		}
		else if(v_u.size() > 1)
			s_user = (String)v_u.get(0);
	}
	

	if(s_user!=null && s_user.equals("-1"))
		s_user = "";
	
	String strWorkgrpName = request.getParameter("er_workgrpname");
	String strServergroupQs = "";
	ArrayList v_Workgroupcomponents = new ArrayList();
	ArrayList aListworkGrp = new ArrayList();
	ArrayList lst_wrkgrp = new ArrayList();
	boolean wrkGrouper = false;
	lst_wrkgrp.add("Citrix_server");
	lst_wrkgrp.add("Citrix_XcXenApp_server");
	if(lst_wrkgrp.size()>0)
	{
		String temp_wgrp=(String)lst_wrkgrp.get(0);
		if(s_compType!=null && s_compType.equalsIgnoreCase(temp_wgrp))
		{
			wrkGrouper=true;
		}
	}
	if(s_compType!=null && s_compType.length()>0)
	{
		String strTest = reportInfo.getTestName(INI_SUBJECT,s_compType,false);
		String strTestName = strTest;
		strTest= strTest+"_DDD";
		EgAgentInfo agentInfo = new EgAgentInfo("manager");
		if(wrkGrouper && vecComponent!=null && vecComponent.size()>0)
		{
			boolean found = false;
			if(showUserWorkGroup!=null && "yes".equalsIgnoreCase(showUserWorkGroup))
			{
				for(int aa=0;aa<vecComponent.size();aa++){
					String compont="";
					String loopComponent = (String) vecComponent.get(aa);
					if(loopComponent.lastIndexOf(":")>-1)
						 compont = loopComponent.substring(0,loopComponent.lastIndexOf(":"));
					else
						compont=(String)vecComponent.get(aa);

					
					String strVar =  agentInfo.getValueForVar(strTestName+"::"+compont);				
					if(strVar!=null && strVar.length()>0)
					{
					int srt=strVar.indexOf("Show_worker_groups");
					if(srt ==-1)
						srt=strVar.indexOf("show_worker_groups");
					int end=strVar.indexOf("-",srt)+1;
					strVar=strVar.substring(srt,end);
					if(strVar!=null && strVar.length()>0)
					{
					strVar=strVar.substring(strVar.indexOf(" "),strVar.indexOf("-"));
					if(strVar!=null && strVar.length()>0)
					{
						strVar=strVar.trim();
						if(strVar.equalsIgnoreCase("true"))
						{
						found=true;
						break;
						}
					}
					}
					}
					
				}
			}
			if(!found)
				wrkGrouper = false;
		}else
			wrkGrouper = false;

		
		ArrayList aListGrupNames = null;
		try {
			if(wrkGrouper)
			{
				aListGrupNames=erInfo.getAllCtirixWorkGroup(strTest,"ProcName");
			}
			//erInfo.getAllCtirixWorkGroup(strTest,"ProcName");
		} catch(Throwable t) {
			aListGrupNames = new ArrayList();
		}
		if(aListGrupNames!=null)
			aListworkGrp.addAll(aListGrupNames);
	}
	Collections.sort(aListworkGrp,String.CASE_INSENSITIVE_ORDER);
	if(aListworkGrp!=null && aListworkGrp.size()>0)
		aListworkGrp.add(0,"Any");
		
	if(strWorkgrpName == null || strWorkgrpName.equals(""))
	{
		if(aListworkGrp!=null && aListworkGrp.size()>0)
			strWorkgrpName = "Any";
	}
	if(strWorkgrpName != null && !strWorkgrpName.equalsIgnoreCase("Any"))
	{
		ArrayList aListCompGrp = new ArrayList();
		if(s_compType!=null && s_compType.length()>0)
		{
			String strTest = reportInfo.getTestName(INI_SUBJECT,s_compType,false);
			strTest= strTest+"_DDD";
			aListCompGrp = erInfo.getServersForWorkGroup(strTest,strWorkgrpName,"ProcName",true);
		}
		if(aListCompGrp!=null && aListCompGrp.size()>0)
		{
			for(int i=0; i<vecComponent.size(); i++) 
			{
				String loopComponent = (String) vecComponent.get(i);
				String strComp = loopComponent;
				if(aListCompGrp.contains(strComp))
					v_Workgroupcomponents.add(strComp);
			}
			if(v_Workgroupcomponents!=null && v_Workgroupcomponents.size()>0)
			{
				vecComponent = new Vector();
				vecComponent.addAll(v_Workgroupcomponents);
			}
		}
		if(v_Workgroupcomponents!=null && v_Workgroupcomponents.size()==0)
		{
			vecComponent = new Vector();
		}
	}
	
	ArrayList selectedCompAl=new ArrayList();

	if((vecComponent!=null && vecComponent.size()>0) && 
		(selectedCompArrays!=null && selectedCompArrays.length>0)){
		for(int j=0;j<selectedCompArrays.length;j++){
			if(vecComponent.contains(selectedCompArrays[j]))
			{
				
				selectedCompAl.add(selectedCompArrays[j]);
			}
		}
	}


	if(selectedCompArrays!=null && selectedCompArrays.length>0)
	{
		for (int i=0;i<selectedCompArrays.length;i++)
		{
			try{
				if(hasVMs && tmp_VMlist!=null && tmp_VMlist.size()>0)
				{
					strServergroupQs += "&er_componentserver="+EgURLEncoder.encode((String)tmp_VMlist.get(i),"UTF-8");
				}
				else
				{
				strServergroupQs += "&er_componentserver="+EgURLEncoder.encode(selectedCompArrays[i],"UTF-8");
				}
			}catch(Exception e){}
		}
	}
screenLabelJson.put("reporter.consolidated.Zone",intlmp.getTextDescription("reporter.consolidated."+er_option));
JSONArray zoneArray = new JSONArray();

if(v_temp != null && v_temp.size() >0)
{
	loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common.Please choose a "+er_option),"-1");
	zoneArray.add(loopJsonObj);
}else
{
	loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common.Not Applicable"),"-1");
	zoneArray.add(loopJsonObj); 
}

for(int n=0;n<v_temp.size();n++)
{
	String s=(String)v_temp.get(n);
	if(s.indexOf("Default")>-1)
		loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common."+s),s);
	else
		loopJsonObj = getLoopObjInfo(s,s);
	zoneArray.add(loopJsonObj);
	if(s.indexOf("Default")>-1)
	{
		if(s_farmserver!=null && s_farmserver.equalsIgnoreCase(s))
		{
			rootJson.put("selectedZone",s_farmserver);
		}			
	}
	else
	{
		if(s_farmserver!=null && s_farmserver.equalsIgnoreCase(s))
		{
			rootJson.put("selectedZone",s_farmserver);
		}			
	}
}
rootJson.put("zoneCombo",zoneArray);

//
	String groupBy=" Summary Report";

	if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details"))
	{ groupBy=" Details Report";
	}
	if(adGroupForPrint!=null && adGroupForPrint.length()>0)
	{
		groupBy+=" for "+adGroupForPrint;
	}
if(adGroupFns!=null && (adGroupFns.equalsIgnoreCase("Details")||adGroupFns.equalsIgnoreCase("Summary")))
	{
lst.add(intlmp.getTextDescription("reporter.common.Thin Client")+" "+intlmp.getTextDescription("reporter.thin.AD Group ")+groupBy);
	}
	else
	{
//
					lst.add(intlmp.getTextDescription("reporter.thin.THIN CLIENT REPORTS")+" - "+intlmp.getTextDescription("reporter.common.USER"));
	}

screenLabelJson.put("reporter.common.Component Type",intlmp.getTextDescription("reporter.common.Component Type"));
JSONArray comptypeArray = new JSONArray();

if (v_compType.size()==0)
{
	loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common.Not Applicable"),"-1");
	comptypeArray.add(loopJsonObj);
}
else
{
	loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common.Please choose a Component Type"), "-1");
	comptypeArray.add(loopJsonObj);
	ArrayList sortedNameList1 = new ArrayList();
	sortedNameList1 = sorter.getSortedCompTypeList(v_compType);
	for(int n=0;n<sortedNameList1.size();n++)
	{
		EgName nameObj =(EgName) sortedNameList1.get(n);
		String dispValue = nameObj.getLocalName();
		String strTempComptype = nameObj.getActualName();
		loopJsonObj = getLoopObjInfo(dispValue,strTempComptype);
		comptypeArray.add(loopJsonObj);

		if(s_compType!=null && s_compType.equalsIgnoreCase(strTempComptype))
		{
			rootJson.put("selectedCompType",s_compType);
			lst.add("Component Type: "+intlmp.getComponentTypeDescription(strTempComptype));
		}
	}
}
rootJson.put("compTypeCombo",comptypeArray);
rootJson.put("er_guestname",er_guestname);
rootJson.put("getMoreUsers",String.valueOf(getMoreUsers));
if(strShowAppNames!=null && (strShowAppNames.equalsIgnoreCase("Yes") || strShowAppNames.equalsIgnoreCase("True")))
	rootJson.put("ShowAppNames","Yes");
else
	rootJson.put("ShowAppNames","No");
screenLabelJson.put("reporter.thin.Worker Group",intlmp.getTextDescription("reporter.thin.Worker Group"));
JSONArray wrkrGroupArray = new JSONArray();
if(aListworkGrp!=null && aListworkGrp.size()>0 )
{
	for(int n=0;n<aListworkGrp.size();n++)
	{
		String sCompType = (String)aListworkGrp.get(n);
		if(strWorkgrpName!=null && strWorkgrpName.equals(sCompType))
		{
			rootJson.put("selectedWorkerGroup",sCompType);
		}
		loopJsonObj = getLoopObjInfo(sCompType,sCompType);
		wrkrGroupArray.add(loopJsonObj);
	}
}
else{
	loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common.Not Applicable"),"notapplicable");
	wrkrGroupArray.add(loopJsonObj);
}
rootJson.put("WorkerGroupArray",wrkrGroupArray);
screenLabelJson.put("reporter.thin.Components",intlmp.getTextDescription("reporter.thin.Components"));
JSONArray compServerArray = new JSONArray();
JSONArray selectedCompServer = new JSONArray();
String selectedComponents="";
String fromReportBuilder=request.getParameter("fromReportBuilder");
String temp_erComp = request.getParameter("er_componentserver");
if(hasVMs)
{
	TreeSet VMsList = (TreeSet)vmByCompType.get(s_compType);
	selectedCompAl=new ArrayList();
	if(VMsList!=null && VMsList.size()>0)
	{
		Iterator itr = VMsList.iterator();
		loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common.--All VMs/Desktops--"),"All");
		compServerArray.add(loopJsonObj);
		while (itr.hasNext()) 
		{
			 String s = (String)itr.next();
			if(tmp_VMlist==null || tmp_VMlist.contains(s))
			{
				selectedCompServer.add(s);
				selectedComponents+=s+",";
				selectedCompAl.add(s);
			}
			String s1 = s;
			if(s1.indexOf(":")>-1)
				s1 = s1.substring(0,s1.indexOf(":"));
			loopJsonObj = getLoopObjInfo(s1,s);
			compServerArray.add(loopJsonObj);
		}
		if(selectedComponents.endsWith(","))
			selectedComponents=selectedComponents.substring(0,selectedComponents.length()-1);
	}
	if(temp_erComp==null || temp_erComp.equalsIgnoreCase("All"))
	{
		rootJson.put("selectedComps","All");
		selectedComponents="All Components"; //added this line for selection details - swami
	}
	else
	{
		rootJson.put("selectedComps",selectedCompServer);
	}
}
else if(vecComponent !=null && !vecComponent.isEmpty())
{
	loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common.--All Components--"),"All");
	compServerArray.add(loopJsonObj);
	List tempList=getComponent(vecComponent,loopJsonObj,compServerArray,selectedComponents,selectedCompServer,selectedServerLst,fromReportBuilder,isSubmitted,selectedCompAl,strDipServer,s_compType);
	if(tempList.size()>1)
	{
		selectedComponents=(String)tempList.get(0);
		strDipServer=(String)tempList.get(1);
	}
	if(selectedComponents.endsWith(","))
	selectedComponents=selectedComponents.substring(0,selectedComponents.length()-1);	
	if(temp_erComp==null || temp_erComp.equalsIgnoreCase("All"))
	{
		rootJson.put("selectedComps","All");
		selectedComponents="All Components"; //added this line for selection details - swami
	}
	else
	{
		rootJson.put("selectedComps",selectedCompServer);
	}
}
if(compServerArray.size()==0)
{
	loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common.Not Applicable"),"notapplicable");
	compServerArray.add(loopJsonObj);
}
rootJson.put("ComponentServerArray",compServerArray);	
screenLabelJson.put("reporter.common.User",intlmp.getTextDescription("reporter.common.User"));
JSONArray userArray = new JSONArray();
getPodComponentInfo(selectedCompServer,compServerArray,erInfo,rootJson,screenLabelJson,intlmp,er_poolType,s_compType);
if(!getMoreUsers)
{
	if(v_u.size()!=0)
	{
		loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common.Please choose a User"), "-1");
		userArray.add(loopJsonObj);
		for(int n=0;n<v_u.size();n++)
		{
			String s=(String)v_u.get(n);
			if(!s.equalsIgnoreCase("-- All --"))
				loopJsonObj = getLoopObjInfo(s,s);
			else
				loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common."+s),s);
			userArray.add(loopJsonObj);
			if(!s.equalsIgnoreCase("-- All --"))
			{
				if(s_user!=null && s_user.equalsIgnoreCase(s))
				{
					rootJson.put("selectedUser",s);
				}
			}
			else
			{
				if(s_user!=null && s_user.equalsIgnoreCase(s))
				{
					rootJson.put("selectedUser",s);
				}
			}
		}
	}
	else
	{
		loopJsonObj = getLoopObjInfo(intlmp.getTextDescription("reporter.common.Not Applicable"),"-1");
		userArray.add(loopJsonObj);
	}
	rootJson.put("userCombo",userArray);
}
else
{
	if(s_user.equalsIgnoreCase("-- All --"))
	{
		s_user = "*";
	}
	rootJson.put("selectedUser",s_user);
	String strDisp = searchUser;
	if(strDisp == null || strDisp.equals("") || strDisp.equalsIgnoreCase("null") )
		strDisp = "";
}
rootJson.put("isAdDiscoverEnabled",String.valueOf(isAdDiscoverEnabled));
rootJson.put("selectedAdGroupFns",adGroupFns);
rootJson.put("enableOragnizeCombo","true");
rootJson.put("organizeCombo",getOrganizeCombo(intlmp));
String strSelectUsergroup = "";
String strSelectADgroup = "";
if(strGroup!=null && strGroup.equalsIgnoreCase("AD")){
	strSelectADgroup = "selected";
	rootJson.put("selectedOrganizeby","AD");
}
else{
	strSelectUsergroup = "selected";
	rootJson.put("selectedOrganizeby","User");
}
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 dispDate = null;
	String comFormat = null;
	String s_st_time=request.getParameter("startdate");
	String s_en_time=request.getParameter("enddate");
	String s_st_hr=request.getParameter("starthr");
	String s_en_hr=request.getParameter("endhr");
	String strmin=request.getParameter("startmin");
	String enmin=request.getParameter("endmin");
	String er_timeline=request.getParameter("er_timeline");
	
	String pdfStartDate=s_st_time+" "+s_st_hr+":"+strmin;
	String pdfEndDate=s_en_time+" "+s_en_hr+":"+enmin;
	String pdfTime =" "+intlmp.getTextDescription("reporter.common.From")+"  "+pdfStartDate+" "+intlmp.getTextDescription("reporter.common.hrs")+"  "+intlmp.getTextDescription("reporter.common.To ")+" "+pdfEndDate+"  "+intlmp.getTextDescription("reporter.common.hrs");

	Vector userPdfData = new Vector();
	userPdfData = (Vector)request.getAttribute("userPdfData");
	String pdfTitle = intlmp.getTextDescription("reporter.common.Thin Client User Report")+" "+ pdfTime;
	
	if(userPdfData!=null && !userPdfData.isEmpty() && userPdfData.size()>1)
	{
		Vector forTime = (Vector)userPdfData.get(1);
		forTime.removeElementAt(0);
		forTime.insertElementAt(pdfTitle,0);
		userPdfData.removeElementAt(1);
		userPdfData.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"};
	long msecsPerHour = (long) 1000 * 60 * 60;
	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 = egDt.egetRealDate();
				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;
		}
		strmin="00";
		enmin="00";
	}
	String selectedArrangeOrder   = request.getParameter("arrangeOrderBy");
	if(selectedArrangeOrder == null || selectedArrangeOrder.trim().length()==0)
		selectedArrangeOrder = "desc";
	String nextOrderBy="asc";
	String imgurl="/final/monitor/eg_images/arrow_down_black_small.gif";
	if(selectedArrangeOrder!=null && selectedArrangeOrder.equals("desc"))
	{
		nextOrderBy="asc";
		imgurl="/final/monitor/eg_images/arrow_down_black_small.gif";
	}
	else if(selectedArrangeOrder!=null && selectedArrangeOrder.equals("asc"))
	{
		nextOrderBy="desc";
		imgurl="/final/monitor/eg_images/arrow_up_black_small.gif";
	}
	// TImeLine
	String excludeweekend=request.getParameter("er_excwe");
	if (excludeweekend==null ||	excludeweekend.equals(""))
		excludeweekend="No";
	String Minto="";
	String Hourto="";
	String Minfrom="";
	String Hourfrom="";
	String fromTime,toTime;
	fromTime = reportInfo.getTimeFrame(INI_SUBJECT,"FROM");
	toTime = reportInfo.getTimeFrame(INI_SUBJECT,"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(INI_SUBJECT);
	String numTopApps = reportInfo.getTop(INI_SUBJECT);
	String displayTopApps = "Top " + numTopApps;
	
	getHours(v_time);

	getMinutes(v_min);

	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;
	
	screenLabelJson.put("reporter.common.Time period", intlmp.getTextDescription("reporter.common.Time period"));
	screenLabelJson.put("reporter.common.Hrs", intlmp.getTextDescription("reporter.common.Hrs"));
	screenLabelJson.put("reporter.common.Mins", intlmp.getTextDescription("reporter.common.Mins"));
	rootJson.put("selectedTimeFrom",Hourfrom);
	rootJson.put("selectedMinsFrom",Minfrom);
	rootJson.put("selectedTimeTo",Hourto);
	rootJson.put("selectedMinsTo",Minto);
	
	rootJson.put("excludeWeekCombo",getExcludeWeekCombo(intlmp,Days));
	rootJson.put("excludeWeek",excludeweekend);
	screenLabelJson.put("MappedExcludeDays", intlmp.getTextDescription("reporter.common.Excludes")+" "+Days);
	screenLabelJson.put("reporter.common.Exclude weekends",intlmp.getTextDescription("reporter.common.Exclude weekends"));
	

if(excludeweekend.equalsIgnoreCase("Yes") )
	{
		lst.add('"'+intlmp.getTextDescription("reporter.common.Time period")+":"+intlmp.getTextDescription("reporter.common.From")+" "+request.getParameter("timefrom")+":"+request.getParameter("minfrom")+intlmp.getTextDescription("reporter.common.Hrs")+" "+intlmp.getTextDescription("reporter.common.To")+" "+request.getParameter("timeto")+":"+request.getParameter("minto")+intlmp.getTextDescription("reporter.common.Hrs")+'"'+","+'"'+intlmp.getTextDescription("reporter.common.Exclude weekends")+":"+Days+'"');

	}
	else
	{

		lst.add(intlmp.getTextDescription("reporter.common.Time period")+":"+intlmp.getTextDescription("reporter.common.From")+" "+request.getParameter("timefrom")+":"+request.getParameter("minfrom")+intlmp.getTextDescription("reporter.common.Hrs")+" "+intlmp.getTextDescription("reporter.common.To")+" "+request.getParameter("timeto")+":"+request.getParameter("minto")+intlmp.getTextDescription("reporter.common.Hrs"));
	}
%>
<%@  include file ="ErTimeFormatJSON.jsp"%>
<%
hiddenfieldsJson.put("userTimeline",strUsrTimeline);
	String clientIps=request.getParameter("clientIp");
		if(clientIps!=null && clientIps.equals("Yes"))
		{
		hiddenfieldsJson.put("clientIp", "Yes");
		}
		else if(clientIps!=null && clientIps.equals("No"))
		{
		hiddenfieldsJson.put("clientIp", "No");
		}
		//
	String	er_aggregateVaalue =request.getParameter("er_aggregateValue");
		if(er_aggregateVaalue!=null &&er_aggregateVaalue.length()>0)
		{
		hiddenfieldsJson.put("er_aggregateVaalue", er_aggregateVaalue);
		}

	screenLabelJson.put("reporter.common.Timeline", intlmp.getTextDescription("reporter.common.Timeline"));
	screenLabelJson.put("reporter.common.From", intlmp.getTextDescription("reporter.common.From"));
	screenLabelJson.put("reporter.common.To", intlmp.getTextDescription("reporter.common.To"));
	screenLabelJson.put("reporter.common.Hr", intlmp.getTextDescription("reporter.common.Hr"));
	screenLabelJson.put("reporter.common.Graph", intlmp.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);

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

	//User TimeZone changes
	rootJson.put("startDateForDisplay",startDateForDisplay);
	rootJson.put("startHourForDisplay",startHourForDisplay);
	rootJson.put("startMinForDisplay",startMinForDisplay);
	rootJson.put("endDateForDisplay",endDateForDisplay);
	rootJson.put("endHourForDisplay",endHourForDisplay);
	rootJson.put("endMinForDisplay",endMinForDisplay);

	String starttimeformat="";
	String endtimeformat="";	
	String stdate = request.getParameter("startdate");	
	String endate = request.getParameter("enddate");	
	String shr = request.getParameter("starthr");	
	String ehr = request.getParameter("endhr");	
	String smin = request.getParameter("startmin");	
	String emin = request.getParameter("endmin");
	starttimeformat = stdate+ " " +shr+":"+smin+" "+"Hrs ";
	endtimeformat   = endate+ " " +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);

	screenLabelJson.put("reporter.common.Report Generation", intlmp.getTextDescription("reporter.common.Report Generation"));
	screenLabelJson.put("reporter.common.SUBMIT", intlmp.getTextDescription("reporter.common.SUBMIT"));
	screenLabelJson.put("reporter.common.Report Name", intlmp.getTextDescription("reporter.common.Report Name"));
	
	rootJson.put("reportTitle",intlmp.getTextDescription("reporter.thin.THIN CLIENT REPORTS")+" - "+intlmp.getTextDescription("reporter.common.USER"));
	rootJson.put("isSubmit",isSubmitted);

	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());
	}

	hiddenfieldsJson.put("option","Citrix");

	hiddenfieldsJson.put("inidate",currentDateFormat);
	hiddenfieldsJson.put("currTime","");
	hiddenfieldsJson.put("er_rtype","User");
	hiddenfieldsJson.put("er_trgttype","User Report");
	hiddenfieldsJson.put("er_gtype","Citrix");
	hiddenfieldsJson.put("pdfTime",pdfTime);
	hiddenfieldsJson.put("showSearch",String.valueOf(getMoreUsers));
	hiddenfieldsJson.put("uid",loginid);
	hiddenfieldsJson.put("userID",loginid);
	if(reqFromSchedule!=null)
		hiddenfieldsJson.put("fromSchedule",reqFromSchedule);
	else
		hiddenfieldsJson.put("fromSchedule","null");

	if(fromScheduleModify!=null)
		hiddenfieldsJson.put("fromScheduleModify",fromScheduleModify);
	else
		hiddenfieldsJson.put("fromScheduleModify","null");
	if(fromFavoriteModify!=null)
		hiddenfieldsJson.put("fromFavoriteModify",fromFavoriteModify);
	else
		hiddenfieldsJson.put("fromFavoriteModify","null");
	hiddenfieldsJson.put("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","ErCtxUserReportJson");
	hiddenfieldsJson.put("er_bgreportfrom","Thin_Client_User");
	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("er_sortBy",s_UIsortby);
	if(er_Type!=null&&er_Type.equals("Yes"))
	{
		hiddenfieldsJson.put("opt","chart");
	}
	else
	{
		hiddenfieldsJson.put("opt","data");
	}

	rootJson.put("hiddenfields",hiddenfieldsJson);
	rootJson.put("screenLabels",screenLabelJson);
	rootJson.put("reportGenerationCombo",getreportGenerationCombo(intlmp,strbackground,strforeground));
	rootJson.put("reportForCombo",getreportForCombo(intlmp));
	rootJson.put("reportFor","user_usage");
	String er_reportgenration = request.getParameter("er_reportgenration");
	String er_background ="";
	String er_foreground ="";
	if (er_reportgenration != null && er_reportgenration.equals("background"))
	{
		er_background = "selected";
		er_foreground = "";
		rootJson.put("reportGeneration","background");
	}
	else
	{
		er_background = "";
		er_foreground = "selected";
		rootJson.put("reportGeneration","foreground");
	}
	String bg_reportname = request.getParameter("bg_reportname");
	if(bg_reportname == null)
	{
		bg_reportname = "";
	}
	

	if(bggroundStr != null && !bggroundStr.equals(""))
	{
		rootJson.put("backgroundReportStatus",status);
		String strreportName ="Thin_Client_User";
		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+"&userID="+com.eg.EgURLEncoder.encode(urs, "UTF-8")+"&savereport=search&er_filterby=Report_Name&forwardto=ErBackGoundProcess");
		rootJson.put("backgroundAnchor", intlmp.getTextDescription("reporter.common.Click here to see a list of generated and processing reports"));

	}

	String test="";
	ArrayList subjects=(ArrayList)reportInfo.getVariables(INI_SUBJECT);
	//Collections.sort(subjects);

	Hashtable ht_colspan=new Hashtable();
	int totalspan=7;
	if(strGroup!=null && strGroup.equalsIgnoreCase("AD"))
		totalspan=7;
	ArrayList allMeasures = new ArrayList();
	int cnntt=0;
	for (int i=0;i<subjects.size();i++)
	{
		String vars=(String)subjects.get(i);
		if(s_compType!=null && !(vars.indexOf(s_compType)>-1))
		{
			if(vars.indexOf("Total:")>-1)
			{
				StringTokenizer colon_st_temp=new StringTokenizer(vars,":");
				colon_st_temp.nextToken();
				colon_st_temp.nextToken();
				String totalMeasure=colon_st_temp.nextToken();
				if(totalMeasure.indexOf("+")>-1)
					totalMeasure = totalMeasure.substring(0,totalMeasure.indexOf("+"));
				if(allMeasures!=null && !allMeasures.contains(totalMeasure))
					continue;
			}else
				continue;
		}
		if(vars.indexOf(":")==-1)
		{
			continue;
		}

		StringTokenizer st_var=new StringTokenizer(vars,":");
		String disname="";
		String displayname="";
		cnntt = 0;
		while(st_var.hasMoreTokens())
		{
			if(cnntt == 0)
				st_var.nextToken();
			st_var.nextToken();
			String mes=st_var.nextToken();
			String mes1="";
			StringTokenizer st_mes=new StringTokenizer(mes,"#");
			
			if(st_mes.hasMoreTokens() )
				mes1=st_mes.nextToken();
			else
				mes1=mes;

			test = getTestNameForType(aListSupportComponentType,s_compType,INI_SUBJECT);
			
			allMeasures.add(mes1);
			disname=dbInfo.getColumnForMeasure(test,mes1);
			if(cnntt == 0){
				if(st_mes.hasMoreTokens() )
					displayname=st_mes.nextToken();
				else
					displayname=mes;
			}
			cnntt++;
		}

		String vals=reportInfo.getValue(INI_SUBJECT,vars);
		StringTokenizer map=new StringTokenizer(vals,",");
		totalspan+=map.countTokens();
		ht_colspan.put(displayname,String.valueOf(map.countTokens()));
	}
	if(( clientIp_!=null && clientIp_.equalsIgnoreCase("Yes")))
		totalspan+=7;
	if(isVm)
		totalspan+=1;
	if(s_compType!=null && aListApplicationComponentType.contains(s_compType))
		totalspan=totalspan+1;
	if(er_showResourceUsage!=null && er_showResourceUsage.equalsIgnoreCase("No"))
		pageWidthProces=1024;
	else 
		pageWidthProces=(totalspan * 92)+150;
Map parameters = new HashMap();
parameters= request.getParameterMap();
HashMap tmpMap = new HashMap(parameters);
/*prakash for encoding the user before it passes to prepareQueryString method
if it is non english os measns, then username comes in #$39 instead of (');
so before tokenize i encoded the user
Have to verify it before giving to check-in
 */
if(tmpMap!=null && (tmpMap.containsKey("er_user")||tmpMap.containsKey("er_tuser")))
{
	Object values = tmpMap.get("er_user");
	if(values == null)
	{
		values = tmpMap.get("er_tuser");
	}
	if(values instanceof String[])
	{
		String[] temp = (String[])values;
		for(int k=0;k<temp.length;k++){
			temp[k] = erUtils.specialCharEncode(temp[k]);
		}
		tmpMap.put("er_user",temp);
	}
	else
	{
		String strValue = (String)values;
		strValue = erUtils.specialCharEncode(strValue);
		tmpMap.put("er_user",strValue);
	}
}
//String queryString = (String)ErUtils.prepareQueryString(request.getParameterMap());
String queryString = (String)ErUtils.prepareQueryString(tmpMap);
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.equalsIgnoreCase("er_componentserver"))
		{
			continue;
		}
		if(reqparam!=null&&reqparam.equalsIgnoreCase("select_server1"))
		{
			continue;
		}
		
		if(reqparam!=null&&reqparam.equalsIgnoreCase("er_adGroup"))
		{
			continue;
		}
		if(reqparam!=null&&reqparam.equalsIgnoreCase("er_aduser"))
		{
			continue;
		}
		/*if(reqparam!=null&&reqparam.equals("select_farm"))
		{
			value=com.eg.EgURLEncoder.encode(value, "UTF-8");
		}
		if(reqparam!=null && reqparam.equals("er_user"))
		{
			value=com.eg.EgURLEncoder.encode(value, "UTF-8");
		}
		if(reqparam!=null&&reqparam.equals("userID"))
		{
			value=com.eg.EgURLEncoder.encode(value, "UTF-8");
		}
		if(reqparam!=null&&reqparam.equals("uid"))
		{
			value=com.eg.EgURLEncoder.encode(value, "UTF-8");
		}*/
		if(reqparam!=null&&reqparam.equals("er_view"))
		{
			continue;
		}
		if(reqparam!=null && (reqparam.equals("er_user") || reqparam.equals("er_tuser")|| reqparam.equals("t_user") || reqparam.equals("uid") || reqparam.equals("select_farm") || reqparam.equals("userID")))
		{
			value=com.eg.EgURLEncoder.encode(value, "UTF-8");
		}
		Qstring=Qstring+reqparam+"="+value+"&";
	}
	//Qstring=Qstring+"&pageWidthProces="+pageWidthProces;
	queryString=queryString+"&pageWidthProces="+pageWidthProces;
		rootJson.put("saveQString",queryString);

}//client_Version


//Back button - Start
ArrayList listbackvar = new  ArrayList();
if(request.getParameter("isSubmit")!=null)
{
	//session.setAttribute("reportLastAccessedURL","/final/servlet/com.eg.ErCtxServerReportC?"+Qstring);
	listbackvar.add("ErThinClientUserReport.jsp");
	listbackvar.add("status="+status+"&bggroundStr="+bggroundStr+"&"+queryString);
	session.setAttribute("favSchBackDisplay","Yes");
}
else
{
	//session.setAttribute("reportLastAccessedURL","/final/reporter/ErThinClientUserReport.jsp?"+Qstring);
	listbackvar.add("ErThinClientUserReport.jsp");
	listbackvar.add(queryString);
	session.setAttribute("favSchBackDisplay","No");
}
	//if(client_Version == null)
		session.setAttribute("reportLastAccessedURL","/final/reporter/ErThinClientUserReport.jsp?"+Qstring);
	String backadded = erhelputils.getBackID();
	backreqMap = erhelputils.setBackQueryMap(backreqMap,backadded,listbackvar);
	session.setAttribute("backQuery",backreqMap);

%>
<%!
public JSONArray getreportForCombo(EgMappingInfo intlmp)
{
	JSONArray viewApplnCombo =  new JSONArray();
	JSONObject tmpobj=new JSONObject();
	tmpobj=new JSONObject();
	tmpobj.put("displayField", intlmp.getTextDescription("reporter.common.User Activity"));
	tmpobj.put("valueField", "user_activity");
	viewApplnCombo.add(tmpobj);
	tmpobj=new JSONObject();
	tmpobj.put("displayField", intlmp.getTextDescription("reporter.common.User Usage"));
	tmpobj.put("valueField", "user_usage");
	viewApplnCombo.add(tmpobj);
	return viewApplnCombo;
}
public JSONArray getreportGenerationCombo(EgMappingInfo intlmp,String strbackground,String strforeground)
{
	JSONArray reportGenerationComboArray =  new JSONArray();
	JSONObject tmpobj=new JSONObject();
	tmpobj.put("displayField", strbackground);
	tmpobj.put("valueField", "background");
	reportGenerationComboArray.add(tmpobj);
	//
	tmpobj=new JSONObject();
	tmpobj.put("displayField", intlmp.getTextDescription("reporter.common.Background Save - CSV"));
	tmpobj.put("valueField", "background-csv");
	reportGenerationComboArray.add(tmpobj);
	//
	tmpobj=new JSONObject();
	tmpobj.put("displayField", strforeground);
	tmpobj.put("valueField", "foreground");
	reportGenerationComboArray.add(tmpobj);
	return reportGenerationComboArray;
}
public JSONArray getOrganizeCombo(EgMappingInfo intlmp)
{
	JSONArray oragnizeArray = new JSONArray();
	JSONObject loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmp.getTextDescription("reporter.common.User"));
	loopJsonObj.put("valueField","User");
	oragnizeArray.add(loopJsonObj);
	loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmp.getTextDescription("reporter.common.Active Directory Group"));
	loopJsonObj.put("valueField","AD");
	oragnizeArray.add(loopJsonObj);
	return oragnizeArray;
}
public JSONArray getExcludeWeekCombo(EgMappingInfo intlmp,String Days)
{
	JSONObject loopJsonObj = new JSONObject();
	JSONArray exclweekArray  =  new JSONArray();
	loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmp.getTextDescription("reporter.common.Yes")+" ("+Days+") ");
	loopJsonObj.put("valueField", "Yes");
	exclweekArray.add(loopJsonObj);
	loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",intlmp.getTextDescription("reporter.common.No"));
	loopJsonObj.put("valueField", "No");
	exclweekArray.add(loopJsonObj);
	return exclweekArray;
}
public JSONObject getLoopObjInfo(String dispName, String value)
{
	JSONObject loopJsonObj = new JSONObject();
	loopJsonObj.put("displayField",dispName);
	loopJsonObj.put("valueField", value);
	return loopJsonObj;
}
public void getMinutes(Vector mins)
{
	mins.add("00");
	mins.add("05");
	mins.add("10");
	mins.add("15");
	mins.add("20");
	mins.add("25");
	mins.add("30");
	mins.add("35");
	mins.add("40");
	mins.add("45");
	mins.add("50");
	mins.add("55");
	mins.add("59");
}
public void getHours(Vector hrs)
{
	hrs.add("00");
	hrs.add("01");
	hrs.add("02");
	hrs.add("03");
	hrs.add("04");
	hrs.add("05");
	hrs.add("06");
	hrs.add("07");
	hrs.add("08");
	hrs.add("09");
	hrs.add("10");
	hrs.add("11");
	hrs.add("12");
	hrs.add("13");
	hrs.add("14");
	hrs.add("15");
	hrs.add("16");
	hrs.add("17");
	hrs.add("18");
	hrs.add("19");
	hrs.add("20");
	hrs.add("21");
	hrs.add("22");
	hrs.add("23");
}
public List getComponent(Vector vecComponent,JSONObject loopJsonObj,JSONArray compServerArray,String selectedComponents,JSONArray selectedCompServer,ArrayList selectedServerLst,String fromReportBuilder,String isSubmitted,ArrayList selectedCompAl,String strDipServer,String s_compType)
{
	List tempList=new ArrayList();
	for(int n=0;n<vecComponent.size();n++)
	{
		String s=(String)vecComponent.get(n);
		String s1 = s;
		String s2 = s;
		if(s1.indexOf(":")>-1)
			s1 = s1.substring(0,s1.indexOf(":"));
		if(s2.indexOf(":")>-1)
			s2 = s2.substring(s2.lastIndexOf(":")+1);

		
		if(s_compType.equalsIgnoreCase(s2))
		{
			
			strDipServer = s1;
			if(selectedCompAl!=null && selectedCompAl.contains(s))
			{
				selectedCompServer.add(s);
				selectedComponents+=s1+",";
			}
			else if((selectedCompAl==null ||(!selectedCompAl.contains(s) && (isSubmitted==null || !isSubmitted.equalsIgnoreCase("true")))) && (fromReportBuilder == null || selectedServerLst.contains("All")))
			{	
				selectedCompServer.add(s);
				selectedComponents+=s1+",";
			}
			loopJsonObj = getLoopObjInfo(strDipServer,s);
			compServerArray.add(loopJsonObj);
		}
	}
	tempList.add(selectedComponents);
	tempList.add(strDipServer);
	return tempList;
}
public void getPodComponentInfo(JSONArray selectedCompServer,JSONArray compServerArray,ErInfo erInfo,JSONObject rootJson,JSONObject screenLabelJson,EgMappingInfo intlmp,String[] er_poolType,String s_compType)
{
	if(s_compType!=null && !s_compType.equals("-1") && s_compType.equalsIgnoreCase("Horizon_Pod"))
	{
		JSONArray pooTypeAry = new JSONArray();
		List selectedPool = new ArrayList();
		JSONObject loopJsonObj = null;
		if(selectedCompServer.size()==1 && selectedCompServer.contains("-1"))
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmp.getTextDescription("reporter.common.Not Applicable")+"!");
			loopJsonObj.put("valueField", "-1");
			pooTypeAry.add(loopJsonObj);
			selectedPool.add("-1");
		}
		else
		{
			ArrayList testList = new ArrayList();
			testList.add("METATEST");
			String queryComp = "";
			String queryCompType = "";
			if(selectedCompServer.size()==1 && (selectedCompServer.contains("All")||selectedCompServer.contains("all")))
			{
				for(int v=0;v<compServerArray.size();v++)
				{
					JSONObject tempObj = (JSONObject)compServerArray.get(v);
					String temp = (String)tempObj.get("valueField");
					if(temp!=null && temp.indexOf(":")>-1)
					{
						queryCompType = temp.substring(temp.lastIndexOf(":")+1);
						queryComp+="'"+temp.substring(0,temp.lastIndexOf(":"))+"',";
					}
				}
			}
			else
			{
				for(int v=0;v<selectedCompServer.size();v++)
				{
					String temp = (String)selectedCompServer.get(v);
					if(temp!=null && temp.indexOf(":")>-1)
					{
						queryCompType = temp.substring(temp.lastIndexOf(":")+1);
						queryComp+="'"+temp.substring(0,temp.lastIndexOf(":"))+"',";
					}
				}
			}
			if(queryComp.endsWith(","))
			{
				queryComp = queryComp.substring(0,queryComp.length()-1);
			}
			StringBuffer sb_query = new StringBuffer();
			sb_query.append(" comp_name  in (" + queryComp + ") AND ");
			sb_query.append(" comp_type in ('" + queryCompType + "','Host_system') AND ");
			if(queryCompType.equalsIgnoreCase("Horizon_Pod"))
			{
				sb_query.append(" test_name ='HrznPODPoolTest'");
			}
			else
			{
				sb_query.append(" test_name ='CtxXcXDCGroupTest'");
				sb_query.append(" AND INFO LIKE '+Desktop OS Machines%'");
			}
			Vector desktopsList = erInfo.getDistinctDataForReport(testList,"INFO", null, false, 0, sb_query.toString(),null, null, null, null, "No", null);
			if(desktopsList==null || desktopsList.size()==0)
			{
				loopJsonObj = new JSONObject();
				loopJsonObj.put("displayField",intlmp.getTextDescription("reporter.common.Not Applicable"));
				loopJsonObj.put("valueField","-1");
				pooTypeAry.add(loopJsonObj);
				selectedPool.add("-1");
			}
			else
			{
				if(er_poolType!=null&&er_poolType.length>0)
				{
					selectedPool = Arrays.asList(er_poolType);
				}
				else
				{
					selectedPool.add("all");
				}
				loopJsonObj=new JSONObject();
				loopJsonObj.put("displayField",intlmp.getTextDescription("reporter.common.All Desktops pools"));
				loopJsonObj.put("valueField","all");
				pooTypeAry.add(loopJsonObj);
				for(int v=0;v<desktopsList.size();v++)
				{
					String desktopsListStr = (String)desktopsList.get(v);
					if(s_compType.equalsIgnoreCase("Citrix_XcXenDesktop_server") && desktopsListStr.indexOf(":")>-1)
					{
						desktopsListStr = desktopsListStr.substring(desktopsListStr.indexOf(":")+1);
					}
					if(desktopsListStr!=null && (desktopsListStr.equalsIgnoreCase("Total")||desktopsListStr.equalsIgnoreCase("All")))
					{
						continue;
					}
					loopJsonObj=new JSONObject();
					loopJsonObj.put("displayField",desktopsListStr);
					loopJsonObj.put("valueField",desktopsListStr);
					pooTypeAry.add(loopJsonObj);
				}
			}
		}
		rootJson.put("poolTypeCombo",pooTypeAry);
		rootJson.put("poolTypeSelected",selectedPool);
		screenLabelJson.put("reporter.thin.poolTypeLabel",intlmp.getTextDescription("reporter.thin.Desktops pools"));
	}
}
private String[] getZoneArr(ErComponentsUtils compUtils)
{
	List aTemp1 = compUtils.getUserZones();
	if(aTemp1 != null && aTemp1.contains("--Default--"))
		aTemp1.remove("--Default--");
	String zones1[] = new String[aTemp1.size()];
	for(int l=0;l<aTemp1.size();l++)
	{
		zones1[l] = (String)aTemp1.get(l);
	}
	return zones1;
}
%>