<%
/*******************************************************************************
*	File name			:	ErCtxSessionReport.jsp
*	Purpose				:	Displays the session Details
*	Author				:	Chitra.R
*	Creation Date		:	7/12/05
*	Notes					: PLEASR PREPARE DOCUMENT FOR YOUR CODE AND ALIGN CODE PROPER
*******************************************************************************/
%>

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

<%
	JSONObject json = new JSONObject();
	String bggroundStr = (String)request.getAttribute("bggroundStr");
	String status = (String)request.getAttribute("status");
	String titleToDisplay=request.getParameter("er_RmDispName");

	//Back Button - Start

	HashMap backreqMap = (HashMap)session.getAttribute("backQuery");
	String backQnumber = request.getParameter("backQnumber");
	String servlet2 = request.getParameter("backServletName");
	String er_comptype = request.getParameter("er_comptype");
	String qryString = request.getQueryString();
	ErHelperUtils erhelputils = null;
	ErEsxVMutils erEsxUtils = new ErEsxVMutils();
	erEsxUtils.setNeedGroupTire(true);
	if( servlet2!=null && !servlet2.equals(""))
		erhelputils = new ErHelperUtils(backreqMap,backQnumber,servlet2);
	else
		erhelputils = new ErHelperUtils(backreqMap,backQnumber);

	boolean enableBack=erhelputils.isBackButtonEnable();

	String backButtonEnable = request.getParameter("back");
	json.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
	if(backButtonEnable != null && backButtonEnable.equalsIgnoreCase("True"))
	{
		status = (String)request.getParameter("status");
		request.setAttribute("Report_data",null);
		request.setAttribute("chartParam",null);
		request.setAttribute("sessionchartdata",null);
		bggroundStr = (String)request.getParameter("bggroundStr");
	}
	//Back Button - End
try
{
	String mngrIProc = new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
	String s_tit= "";
	String s_tit1= "";
	List lst = new LinkedList();
	List lst_dat = new LinkedList();
	Hashtable sen = new Hashtable();
	Hashtable ht = new Hashtable();
	Vector vec = new Vector();
	Hashtable ht1 = new Hashtable();
	List lst_dat1 = new LinkedList();
	Hashtable sen1 = new Hashtable();
	Vector vec2 = new Vector();
	Vector vec1 = new Vector();
	Vector vec3 = new Vector();
	List lst_dat2 = new LinkedList();
	Vector v_val1 = new Vector();
	EgDateInfo egDt = new EgDateInfo();
	EgMappingInfo intlmp=new EgMappingInfo(thisuser.getLanguage());
	ErComponentsUtils compUtils = new ErComponentsUtils(thisuser.getLoginID());
	IniUI ui = IniUI.getInstance();
	EgDateInfo egDate = new EgDateInfo();
	EgTablesInfo tablesInfo = new EgTablesInfo("manager");
	ErUtils erUtils = new ErUtils();
	ErReqData erd = new ErReqData(request);
	EgDbInfo dbInfo = new EgDbInfo("manager");
	EgGroupInfo gpinfo = new EgGroupInfo();
	ErReportHelper erHelp = new ErReportHelper();
	EgReportInfo reportInfo = new EgReportInfo("manager");
	String confrimation = reportInfo.getValue("BACKGROUND_PROCESS","NeedConfirmation");
	String strbgrepportName = reportInfo.getValue("BACKGROUND_PROCESS","EnableBackgroundReport");
	String limitforbg = reportInfo.getValue("BACKGROUND_PROCESS","MinDurationForReport");
	EgThresholdInfo hreshholdInfo = new EgThresholdInfo("manager");
	Hashtable dataMeasu=new Hashtable();
	Hashtable pdfHashtable=new Hashtable();
	StringBuffer printQS = new StringBuffer();
	String compType="";
	String Hourfrom="";
	String Minfrom="";
	String Hourto="";
	String Minto="";
	String fromTime,toTime;
	String installDir;
	StringTokenizer st;
	String variable;
	String timefrom="";
	String timeto="";
	String queryforuserlink="";
	String s_qryString="";
	String tmpComponent="";
	String SessionQs="";
	long msecsPerHour = (long) 1000 * 60 * 60;

	boolean storeLastAccessedUrl = false;

	String s_farmserver = request.getParameter("select_farm");
	String tfrom = request.getParameter("timefrom");
	String tto = request.getParameter("timeto");
	String stdate = request.getParameter("startdate");
	String enddate = request.getParameter("enddate");
	String sthr = request.getParameter("starthr");
	String cTime = request.getParameter("currTime");
	String endhr = request.getParameter("endhr");
	String excludeweekend = request.getParameter("er_excwe");
	String timefrom2 = request.getParameter("timefrom");
	String minfrom2 = request.getParameter("minfrom");
	String timeto2 = request.getParameter("timeto");
	String minto2 = request.getParameter("minto");
	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 topSession = request.getParameter("topsession");
	String topusers = request.getParameter("topusers");
	String allTypeUniqueUsrSummary = (String)session.getAttribute("allTypeUniqueUsrSummary");
	String userListStr = (String)session.getAttribute("userListStr");

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

	ErReportHelper erh = new ErReportHelper();

	Vector v_components = new Vector();
	Vector v_temp = new Vector();

	Vector v_testmes = new Vector();
	List v_site = new ArrayList();

	String NoofServers = reportInfo.getNoOfBars("CITRIX SESSION REPORT","top");
	String subject ="CITRIX SESSION REPORT";
	ArrayList listCompTypes = new ArrayList();
	ArrayList aListCompType = new ArrayList();
	listCompTypes = reportInfo.getComponentsList(subject,false);
	

	String testmes = request.getParameter("select_testmes");
	String s_server = request.getParameter("er_select_server");
	
	if(s_server==null)
		s_server="All Types";

	if(s_server == null || s_server.equalsIgnoreCase(""))
	{
		s_server="Citrix_MF_XP";
	}
	

	String strEncodeSelectServer = request.getParameter("er_select_server");
	if(strEncodeSelectServer!=null)
		strEncodeSelectServer = URLEncoder.encode(strEncodeSelectServer);
	List v_serverName=new ArrayList();
	String datatype = request.getParameter("er_trenddata");
	IniFile inifile=null;
	installDir = EgInstallInfo.getInstallDir();
	String sub = "LIST_OF_ZONES";
	inifile = new IniFile(installDir +"/manager/config/eg_group.ini");

	ArrayList aListSupportedComponentType = reportInfo.getComponentsList("CITRIX SESSION REPORT",false);
        ArrayList aListAlltype = new ArrayList();

        for(int kk=0;kk<aListSupportedComponentType.size();kk++)
        {
                aListAlltype.add(aListSupportedComponentType.get(kk));
        }
		String er_option =request.getParameter("er_option");
		String er_site = request.getParameter("er_site");
		String headerKeyName="";
			if(er_option!=null && er_option.equalsIgnoreCase("Segment"))
			{
				headerKeyName=intlmp.getTextDescription("reporter.common."+er_option)+" : "+er_site;
			}
			else if(er_option!=null && er_option.equalsIgnoreCase("Service"))
			{
				headerKeyName=intlmp.getTextDescription("reporter.common."+er_option)+" : "+er_site;
			}
			else if(er_option!=null && er_option.equalsIgnoreCase("Group"))
			{
				headerKeyName=intlmp.getTextDescription("reporter.common."+er_option)+" : "+er_site;
			}
			else if(er_option!=null && er_option.equalsIgnoreCase("Component"))
			{
				if(request.getParameter("er_compType")!=null)
					headerKeyName=intlmp.getTextDescription("reporter.common."+er_option)+" : "+request.getParameter("er_compType");
				else if(request.getParameter("er_select_server")!=null)
				{
					String compServr=request.getParameter("er_select_server");
					if(!compServr.equalsIgnoreCase("All Types"))
					{
						compServr=intlmp.getComponentTypeDescription(compServr);
					}
					else
					{
						compServr = intlmp.getTextDescription("reporter.common."+compServr);
					}
					headerKeyName=intlmp.getTextDescription("reporter.common."+er_option)+" : "+compServr;
				}
				else
					headerKeyName=intlmp.getTextDescription("reporter.common."+er_option);
			}
			else
			{
				if(s_farmserver!=null && s_farmserver.equalsIgnoreCase("--Default--"))
				{
					headerKeyName=intlmp.getTextDescription("reporter.common.Zone")+" : "+intlmp.getTextDescription("reporter.common."+s_farmserver);
				}
				else
				{
					headerKeyName=intlmp.getTextDescription("reporter.common.Zone")+" : "+s_farmserver;
				}
				
			}
	String rtype = request.getParameter("er_type");
	if (rtype==null)
		rtype="Yes";

	String startDate="";
	String endDate="";
	String key="";
	String timefrm="";
	String time2="";
	String timeline  = erd.s_timeline;
	String start_date="";
	String end_date="";
	fromTime = reportInfo.getTimeFrame("CITRIX SESSION REPORT","FROM");
	toTime = reportInfo.getTimeFrame("CITRIX SESSION REPORT","TO");
	st = new StringTokenizer(fromTime,":");
	if(st.hasMoreTokens())
	{
		Hourfrom = st.nextToken();
		Minfrom = st.nextToken();
	}
	st=new StringTokenizer(toTime,":");
	if(st.hasMoreTokens())
	{
		Hourto = st.nextToken();
		Minto = st.nextToken();
	}

	String Days = reportInfo.getExcludeWeekend("CITRIX SESSION REPORT");
	String top=reportInfo.getTop("CITRIX SESSION REPORT");
	Vector v_time=new Vector();
	v_time.add("00");
	v_time.add("01");
	v_time.add("02");
	v_time.add("03");
	v_time.add("04");
	v_time.add("05");
	v_time.add("06");
	v_time.add("07");
	v_time.add("08");
	v_time.add("09");
	v_time.add("10");
	v_time.add("11");
	v_time.add("12");
	v_time.add("13");
	v_time.add("14");
	v_time.add("15");
	v_time.add("16");
	v_time.add("17");
	v_time.add("18");
	v_time.add("19");
	v_time.add("20");
	v_time.add("21");
	v_time.add("22");
	v_time.add("23");

	Vector v_min=new Vector();
	v_min.add("00");
	v_min.add("05");
	v_min.add("10");
	v_min.add("15");
	v_min.add("20");
	v_min.add("25");
	v_min.add("30");
	v_min.add("35");
	v_min.add("40");
	v_min.add("45");
	v_min.add("50");
	v_min.add("55");
	v_min.add("59");

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

	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;
					er_site=er_service;
				}
			}
			//for - reports by Component default loading setup
			else if(er_dataFrom!=null && er_dataFrom.equalsIgnoreCase("Component"))
			{
				er_option=er_dataFrom;
				er_site=null;
			}

	User this_user = UserRegistry.getInstance().getUser(session.getId());
	String loginid = this_user.getLoginID();
	List v_option = new ArrayList();
	Hashtable htAllGroups = erEsxUtils.getGroups(null,aListSupportedComponentType, thisuser, loginid, "Yes",true);
	ArrayList aListOption = erEsxUtils.getOptions(htAllGroups);
		if(aListOption!=null && aListOption.size()>0)
			v_option.addAll(aListOption);
		JSONArray arr = new JSONArray();
		JSONObject obj=null;
		
		if(v_option!=null && v_option.size()>0)
		{
			json.put("selectedAnalysisByCombo",er_option);
			for(int i=0; i<v_option.size(); i++)
			{
				obj = new JSONObject();
				obj.put("displayField", intlmp.getTextDescription("reporter.common."+v_option.get(i)));
				obj.put("valueField",v_option.get(i));
					arr.add(obj);
			}
		}
		else
		{
			obj = new JSONObject();
			obj.put("displayField", intlmp.getTextDescription("reporter.common.Not Applicable"));
			obj.put("valueField","-1");
			arr.add(obj);
		}
		json.put("analysisByCombo",arr);

	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 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 opt = request.getParameter("er_trenddata");
	start_date = request.getParameter("startdate");
	end_date = request.getParameter("enddate");
	String startDateTime="";
	String endDateTime="";
	String dispDate = null;
	String comFormat = null;

	if(opt==null)
		opt="No";

	if(er_timeline==null  || er_timeline.equals(" "))
	{
		er_timeline="1 day";
	}
	//Date calculation according to time select
	String[] options=null;
	if(opt!=null && opt.equals("No"))
	{
		options = new String[]{"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"};
	}
	else
	{
		if(er_timeline!=null && !er_timeline.equals("Any"))
		{
			String tmp=er_timeline.substring(er_timeline.indexOf(" ")+1,er_timeline.length());
			if(tmp.startsWith("h"))
			{
				er_timeline="1 day";
			}
		}
		options =new String[]{"Any","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"};
	}
	

	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();
			if(opt!=null && opt.equals("No"))
			{
				endDateTime = sdf.format(today);
			}
			else
			{
				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"))
			{
				if(unit.endsWith("last")){
					//last week
					int weekCount = (int) value;
					SimpleDateFormat simpledf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
					java.util.Date currDateTime = egDt.egetRealDate();
					String currentDateTime = simpledf.format(currDateTime);
					String currentDate = currentDateTime.substring(0, currentDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE));
					String currentHr = currentDateTime.substring(currentDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE)+1, currentDateTime.indexOf(":"));
					String currentMin = currentDateTime.substring(currentDateTime.indexOf(":")+1, currentDateTime.lastIndexOf(":"));
					String userFormat = thisuser.getUserDateFormat();
					String curFormatDate = DateUtil.changeDateFormat(currentDate,"MM/dd/yyyy", userFormat); 
					EgTimeZoneConverter realDateTime = new EgTimeZoneConverter(curFormatDate+" "+currentHr+":"+currentMin,thisuser);
					java.util.Date realDate=new SimpleDateFormat(userFormat).parse((String) realDateTime.getDate(false));
					Calendar c = Calendar.getInstance();
					c.setTime(realDate);
					int i = c.get(Calendar.DAY_OF_WEEK) - c.getFirstDayOfWeek() * weekCount;
					int startDayCount = 7 * weekCount + (1 * (weekCount - 1));
					int lastDayCount = 6 * weekCount + (1 * (weekCount - 1));
					c.add(Calendar.DATE, - i - startDayCount);
					c.set(Calendar.HOUR, 00);
					c.set(Calendar.MINUTE, 00);
					java.util.Date start = c.getTime();
					startDateTime = new SimpleDateFormat(userFormat).format(start);
					c.add(Calendar.DATE, lastDayCount);	
					c.set(Calendar.HOUR, 23);
					c.set(Calendar.MINUTE, 00);
					java.util.Date end = c.getTime();
					endDateTime = new SimpleDateFormat(userFormat).format(end);
					System.out.println("ErCtxSessionReportJson Last Week Start Date-->"+startDateTime+ "    End Time-->"+endDateTime);
				}else{
					//weeks
					value *= (7 * 24 * 3600);
				}
			}
			else if (unit.startsWith("mo"))
			{
				if(unit.endsWith("last"))
				{//last month
					int monthCount = (int) value;
					SimpleDateFormat simpledf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
					java.util.Date currDateTime = egDt.egetRealDate();
					String currentDateTime = simpledf.format(currDateTime);
					String currentDate = currentDateTime.substring(0, currentDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE));
					String currentHr = currentDateTime.substring(currentDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE)+1, currentDateTime.indexOf(":"));
					String currentMin = currentDateTime.substring(currentDateTime.indexOf(":")+1, currentDateTime.lastIndexOf(":"));
					String userFormat = thisuser.getUserDateFormat();
					String curFormatDate = DateUtil.changeDateFormat(currentDate,"MM/dd/yyyy", userFormat); 
					EgTimeZoneConverter realDateTime = new EgTimeZoneConverter(curFormatDate+" "+currentHr+":"+currentMin,thisuser);
					java.util.Date realDate=new SimpleDateFormat(userFormat).parse((String) realDateTime.getDate(false));
					Calendar c = Calendar.getInstance();
					c.setTime(realDate);
					c.add(Calendar.MONTH, -monthCount);
					c.set(Calendar.DATE, 1);
					c.set(Calendar.HOUR, 00);
					c.set(Calendar.MINUTE, 00);
					java.util.Date start = c.getTime();
					startDateTime = new SimpleDateFormat(userFormat).format(start);
					Calendar c1 = Calendar.getInstance();
					c1.setTime(realDate);
					c1.add(Calendar.MONTH, -1);
					c1.set(Calendar.DAY_OF_MONTH, c1.getActualMaximum(Calendar.DAY_OF_MONTH));
					c1.set(Calendar.HOUR, 23);
					c1.set(Calendar.MINUTE, 59);
					java.util.Date end = c1.getTime();
					endDateTime = new SimpleDateFormat(userFormat).format(end);
					System.out.println("ErCtxSessionReportJson Last Month Start Date-->"+startDateTime+ "    End Time-->"+endDateTime);
				}else{
					//months
					if(opt!=null && opt.equals("No"))
					{
						java.util.Date dt_temp = new java.util.Date(egDt.egetUTCDate());
						Calendar cal_temp = new GregorianCalendar();
						cal_temp.setTime(dt_temp);
						cal_temp.add(Calendar.HOUR_OF_DAY,0);
						java.util.Date dt_temp1 = cal_temp.getTime();
						long l_temp = dt_temp1.getTime();
						int  totalDays=24*(ErUtils.getMaxDaysInMonth());
						startDateTime = egDt.egetDate(l_temp -(long)( (value*totalDays * msecsPerHour)));
						startDateTime = DateUtil.changeDateFormat(startDateTime,
						"dd/MM/yyyy HH:mm","MM/dd/yyyy HH:mm");
					}
					else
					{
						java.util.Date dt_temp = new java.util.Date(endDateTime);
						Calendar cal_temp = new GregorianCalendar();
						cal_temp.setTime(dt_temp);
						cal_temp.add(Calendar.HOUR_OF_DAY,0);
						java.util.Date dt_temp1 = cal_temp.getTime();
						long l_temp = dt_temp1.getTime();
						int  totalDays=24*(ErUtils.getMaxDaysInMonth());
						startDateTime = egDt.egetDate(l_temp -(long)( (value*totalDays * msecsPerHour)));
						startDateTime = DateUtil.changeDateFormat(startDateTime,
						"dd/MM/yyyy HH:mm","MM/dd/yyyy HH:mm");
					}
				}
			}
			if (unit!=null&&!unit.startsWith("mo")&& !unit.endsWith("last"))
			{
				java.util.Date start1 = egDt.egetRealDate();
				java.util.Date startTmp=new java.util.Date(endDateTime);
				start1.setTime(startTmp.getTime() - (value * 1000));
				startDateTime = sdf.format(start1);
			}else if (unit.endsWith("last")){
				String usrStartDateTime = startDateTime +" 00:00";
				String usrEndDateTime = endDateTime +" 23:59";
				System.out.println("ErCtxSessionReportJson User Start Date-->"+usrStartDateTime+ "    End Time-->"+usrEndDateTime);
				EgTimeZoneConverter timeZoneConverterStart = new EgTimeZoneConverter(usrStartDateTime, thisuser, true);
				startDateTime = DateUtil.changeDateFormat((String) timeZoneConverterStart.getDate(false), thisuser.getUserDateFormat(), "MM/dd/yyyy");
				startDateTime = startDateTime+" "+(String) timeZoneConverterStart.getHour()+":"+(String) timeZoneConverterStart.getMinute();
				EgTimeZoneConverter timeZoneConverterEnd = new EgTimeZoneConverter(usrEndDateTime, thisuser, true);
				endDateTime = DateUtil.changeDateFormat((String) timeZoneConverterEnd.getDate(false), thisuser.getUserDateFormat(), "MM/dd/yyyy");
				endDateTime = endDateTime +" "+(String) timeZoneConverterEnd.getHour()+":"+(String) timeZoneConverterEnd.getMinute();
				System.out.println("ErCtxSessionReportJson Manager Start Date-->"+startDateTime+ "    End Time-->"+endDateTime);
			}
		}
		if ((startDateTime != null) && (endDateTime != null))
		{
			String shr = startDateTime.substring(startDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE)+1, startDateTime.indexOf(":"));
			strmin=startDateTime.substring(startDateTime.indexOf(":")+1);
			String en_hr = 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));

			if(opt!=null && opt.equals("No"))
			{
				s_st_hr = shr;
				s_en_hr = 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;
		}
	}
	%>
		<%@  include file ="ErTimeFormatJSON.jsp"%>
	<%

		String usr_startTime=startDateForDisplay+" "+startHourForDisplay+":"+startMinForDisplay;
		String	usr_endTime=endDateForDisplay+" "+endHourForDisplay+":"+endMinForDisplay;
		String pdfTime = "From  "+usr_startTime+" "+"To "+usr_endTime;	
		Vector sessionPdfData = new Vector();
		sessionPdfData = (Vector)request.getAttribute("sessionPdfData");

		String pdfTitle = "Thin Client Session Report  "+ pdfTime;
		if(sessionPdfData!=null && !sessionPdfData.isEmpty())
		{
			Vector forTime = (Vector)sessionPdfData.get(1);
			forTime.removeElementAt(0);
			forTime.insertElementAt(pdfTitle,0);
			sessionPdfData.removeElementAt(1);
			sessionPdfData.insertElementAt(forTime,1);
		}
	inifile = new IniFile(installDir +"/manager/config/eg_report.ini");
	String detailval= inifile.getValue("MISC","DetailedTime");
	String tbound =request.getParameter("er_tbound");
	printQS.append("&er_tbound=" + tbound);
	printQS.append("&startdate=" + request.getParameter("startdate"));
	printQS.append("&enddate=" +	request.getParameter("enddate"));
	printQS.append("&starthr=" + request.getParameter("starthr"));
	printQS.append("&endhr="	+ request.getParameter("endhr"));
	printQS.append("&timefrom="+Hourfrom);
	printQS.append("&timeto="+Hourto);
	printQS.append("&minfrom="+Minfrom);
	printQS.append("&minto="+Minto);
	printQS.append("&er_excwe="+excludeweekend);
	printQS.append("&er_select_server="+s_server);
	printQS.append("&select_compType="+"Terminal_server");

	session.setAttribute("PDF_URL", mngrIProc+"/final/servlet/com.eg.ErCtxServerReportC");

	if (excludeweekend==null ||	excludeweekend.equals(""))
		excludeweekend="No";

	JSONObject screenLabels = new JSONObject();
	JSONObject hiddenParams = new JSONObject();
	JSONObject pageParams = new JSONObject();

	hiddenParams.put("option","Citrix");
	hiddenParams.put("currTime","");
	hiddenParams.put("er_rtype","Session");
	hiddenParams.put("er_trgttype","Session Report");
	hiddenParams.put("er_gtype","Citrix");
	if(!StringUtils.isNull(pdfTime))
	{
		hiddenParams.put("pdfTime",pdfTime);
	}
	if(!StringUtils.isNull(loginid))
	{
		hiddenParams.put("uid",loginid);
		hiddenParams.put("userID",loginid);
	}
	hiddenParams.put("getMaxDaysInMonth",String.valueOf(ErUtils.getMaxDaysInMonth()));
	hiddenParams.put("detailtime",detailval);
	hiddenParams.put("inidate",currentDateFormat);
	hiddenParams.put("fromSchedule",reqFromSchedule);
	if(fromScheduleModify!=null)
		hiddenParams.put("fromScheduleModify",fromScheduleModify);
	else
		hiddenParams.put("fromScheduleModify","null");		
	if(fromFavoriteModify!=null)
		hiddenParams.put("fromFavoriteModify",fromFavoriteModify);
	else
		hiddenParams.put("fromFavoriteModify","null");
	hiddenParams.put("favorite_id", favorite_id);
	hiddenParams.put("er_favorite", er_favorite);
	hiddenParams.put("er_ViewName","ErCtxSessionReport.jsp");
	hiddenParams.put("er_bgreportfrom","Thin_Client_Session");
	hiddenParams.put("bgenabled",strbgrepportName);
	hiddenParams.put("limitforbg",limitforbg);
	hiddenParams.put("savereport","save");
	hiddenParams.put("servletName","com.eg.ErCtxServerReportC");
	hiddenParams.put("divStatus",divStatus);

	if(!StringUtils.isNull(schedule_id))
	{
		hiddenParams.put("schedule_id",schedule_id);
	}

	if(!StringUtils.isNull(rtype))
	{
		pageParams.put("rtype",rtype);
	}

	String StrServer =request.getParameter("select_server1");
	String StrChartfor =request.getParameter("daychartfor");
	String sel_comptyp = request.getParameter("select_compType");

	if(StrChartfor!=null&&StrChartfor.equals("uniqueuser"))
	{
		session.setAttribute("uniqueUserCompType",sel_comptyp);

		hiddenParams.put("daychartfor",StrChartfor);
		hiddenParams.put("select_server",StrServer);

		if(StrServer!=null)
		{
			hiddenParams.put("select_server1",StrServer);
		}
	}
	else if(StrServer!=null&&!StrServer.equals(""))
	{
		hiddenParams.put("select_server",StrServer);
		hiddenParams.put("select_server1",StrServer);
	}
	else
	{
		hiddenParams.put("daychartfor","");
		if(!StringUtils.isNull(StrServer))
		{
			hiddenParams.put("select_server",StrServer);
			hiddenParams.put("select_server1",StrServer);
		}
	}

	if(!StringUtils.isNull(sel_comptyp))
	{
		hiddenParams.put("select_compType",sel_comptyp);
		hiddenParams.put("er_sel_comp",StrServer);
	}

	if(!StringUtils.isNull(topSession))
		hiddenParams.put("topSession",topSession);

	if(!StringUtils.isNull(topusers))
		hiddenParams.put("topusers",topusers);
	
	EgServicesInfo si = new EgServicesInfo("manager");
	boolean computsum=si.getAvgSumTrends();

	String graphmode = request.getParameter("er_mode");
	if(graphmode==null || graphmode.equals(""))
	{
		if(ui.use3DGraphs(IniUI.REPORTER))
			graphmode="3D";
		else
			graphmode="2D";
	}

	pageParams.put("graphmode",graphmode);

	if (!StringUtils.isNull(titleToDisplay)){ 
		lst.add(titleToDisplay);
	}
	else
	{
		lst.add(intlmp.getTextDescription("reporter.thin.THIN CLIENT REPORTS")+" - "+intlmp.getTextDescription("reporter.common.SESSION"));
	}
	 if(excludeweekend!=null && 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"));
	 }
	Vector dvec = new Vector();
	String stimefmt = "Start Date : "+usr_startTime+" Hrs";
	String etimefmt = "End Date : "+usr_endTime+" Hrs";
	dvec.add('"'+stimefmt+'"');
	dvec.add('"'+etimefmt+'"');
	lst.add(dvec);
	String action = request.getParameter("thinClientSessionAction");
	if(action!=null && action.equals("defaultLoad"))
	{
		screenLabels.put("reporter.common.Graph",intlmp.getTextDescription("reporter.common.Graph"));

		JSONArray graphModeJsonArr = new JSONArray();

		JSONObject graphOpt = new JSONObject();
		graphOpt.put("displayField",intlmp.getTextDescription("reporter.common.3D"));
		graphOpt.put("valueField","3D");

		graphModeJsonArr.add(graphOpt);

		graphOpt = new JSONObject();
		graphOpt.put("displayField",intlmp.getTextDescription("reporter.common.2D"));
		graphOpt.put("valueField","2D");

		graphModeJsonArr.add(graphOpt);

		json.put("graphModeJsonArr",graphModeJsonArr);

		String var[] = inifile.getVariables(sub);
		for(int i=0;i<var.length;i++)
		{
			variable = var[i];
			v_components.add(variable);
		}

		List zonelist = compUtils.getUserZones();
		if(zonelist != null && zonelist.contains("--Default--"))
			zonelist.remove("--Default--");
		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);
		}
		Vector v_comp = compUtils.getAllUserComponents1();
		v_temp = erUtils.getAllThinClientZones(zones,v_zonelist,v_comp,listCompTypes);
		if(v_temp != null && !v_temp.isEmpty() && (s_farmserver == null|| s_farmserver.equalsIgnoreCase("undefined")||s_farmserver.equalsIgnoreCase("null")))
		{
			// by karthikeyan- to find component types  to corresponding zone(used for reports by component tab)		
			HashMap comp_zoneMap=new HashMap();	
			for(int i=0;i<v_zonelist.size();i++)
			{
				String zoneName = (String)v_zonelist.get(i);
				ArrayList al=new ArrayList();
				if(zoneName!=null)
				{
					al = compUtils.getTypeModifyComponents(compUtils.getZoneComponents(zoneName,true),2);
					for(int k=0;k<al.size();k++)
					{
						String comp = (String)al.get(k);
						StringTokenizer token1 = new StringTokenizer(comp,":");
						while(token1.hasMoreTokens())
						{
							String comptype=token1.nextToken();
							if(!comp_zoneMap.containsKey(comptype))
								comp_zoneMap.put(comptype,zoneName);
						}
					}
				}
			}
			if(comp_zoneMap.containsKey(s_server))
			{
				s_farmserver=(String)	comp_zoneMap.get(s_server);
			}
			else if (v_temp.contains("--Default--"))
			{
				s_farmserver ="--Default--";
			}
			else
			{
				s_farmserver =(String) v_temp.get(0);
			}
		}
		v_serverName = erEsxUtils.getComponentForGroup(htAllGroups,er_option,s_farmserver);
		if(v_temp!=null && v_temp.size() > 1)
		{
			Collections.sort(v_temp,String.CASE_INSENSITIVE_ORDER);
		}
		if(v_serverName!=null && s_farmserver!=null && v_serverName.size()>=2 && !s_farmserver.equals("-1") && request.getParameter("er_type")!=null && !request.getParameter("er_type").equalsIgnoreCase("Yes"))
		{
			v_serverName.add("All Types");
		}
		if(v_serverName!=null && v_serverName.size()>0 && (s_server == null || !v_serverName.contains(s_server)))
		{
			s_server = (String)v_serverName.get(0);
		}
		v_testmes = erUtils.getMeasureForComponentType(s_server,"CITRIX SESSION REPORT");

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

		screenLabels.put("pageTitle",intlmp.getTextDescription("reporter.thin.THIN CLIENT REPORTS")+" - "+intlmp.getTextDescription("reporter.thin.SESSION"));
		screenLabels.put("reporter.thin.THIN CLIENT REPORTS",intlmp.getTextDescription("reporter.thin.THIN CLIENT REPORTS"));
		screenLabels.put("reporter.common.Back",intlmp.getTextDescription("reporter.common.Back"));
		screenLabels.put("reporter.common.SAVE",intlmp.getTextDescription("reporter.common.SAVE"));
		screenLabels.put("reporter.common.PRINT",intlmp.getTextDescription("reporter.common.PRINT"));
		screenLabels.put("reporter.common.MAIL",intlmp.getTextDescription("reporter.common.MAIL"));
		screenLabels.put("reporter.common.CSV",intlmp.getTextDescription("reporter.common.CSV"));
		screenLabels.put("reporter.common.ADD TO FAVORITES",intlmp.getTextDescription("reporter.common.ADD TO FAVORITES"));
		screenLabels.put("reporter.common.ADD TO SCHEDULES",intlmp.getTextDescription("reporter.common.ADD TO SCHEDULES"));
		screenLabels.put("reporter.thin.Zone",intlmp.getTextDescription("reporter.thin.Zone"));

		String fromFavSch = request.getParameter("fromFavSch");
		if(backreqMap != null && backreqMap.size() > 0 &&  enableBack && request.getParameter("enableBack")!=null && request.getParameter("enableBack").equalsIgnoreCase("true"))
		{
			json.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
		}
		else if(fromFavSch!=null && fromFavSch.equalsIgnoreCase("true"))
		{
			json.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
		}
	String cType=request.getParameter("er_compType");
	if(cType==null||cType.length()==0)
		cType= request.getParameter("er_select_server");
	if(er_comptype==null||er_comptype.length()==0)
	er_comptype=cType;
		JSONArray zoneListJson = new JSONArray();

		if(v_temp != null && v_temp.size() >0)
		{
			JSONObject defaultOpt = new JSONObject();
			if(StringUtils.isNull(s_farmserver))
				pageParams.put("selectedZone","-1");

		}
		else
		{
			JSONObject defaultOpt = new JSONObject();
			defaultOpt.put("displayField",intlmp.getTextDescription("reporter.common.Not Applicable"));
			defaultOpt.put("valueField","-1");
			zoneListJson.add(defaultOpt);

			pageParams.put("selectedZone","-1");
		}
		for(int n=0;n<v_temp.size();n++)
		{
			String s=(String)v_temp.get(n);
			if(!s.equalsIgnoreCase("--Default--"))
			{
				JSONObject jOpt = new JSONObject();
				jOpt.put("displayField",s);
				jOpt.put("valueField",s);
				zoneListJson.add(jOpt);
				if(s_farmserver!=null && s_farmserver.equalsIgnoreCase(s))
				{
					pageParams.put("selectedZone",s);
				}
			}
			else
			{
				JSONObject jOpt = new JSONObject();
				jOpt.put("displayField","--"+intlmp.getTextDescription("reporter.common.Default")+"-- ");
				jOpt.put("valueField",s);
				zoneListJson.add(jOpt);
				if(s_farmserver!=null && s_farmserver.equalsIgnoreCase(s))
				{
					pageParams.put("selectedZone",s);
				}
			}
		}
		ArrayList aListComponentTemp=new ArrayList();
		boolean isNeedMeasure=true;
		if(er_option!=null && er_option.equalsIgnoreCase("Zone") )
		{
			v_site = erEsxUtils.getGroupsName(htAllGroups,er_option);
			if(v_site!=null && v_site.size()>0)
			{
				v_zonelist.addAll(v_site);
				if(s_farmserver==null )
				{
					s_farmserver=(String)v_site.get(0);
				}
			}
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,s_farmserver);
			json.put("zoneListJson",zoneListJson);
			pageParams.put("selectedZone",s_farmserver);

			if(er_comptype!=null)
			{
				v_testmes = erUtils.getMeasureForComponentType(er_comptype,"CITRIX SESSION REPORT");
				if(v_testmes!=null && v_testmes.size()>0 && testmes == null)
					testmes = (String)v_testmes.get(0);
				isNeedMeasure=false;
			}
		}
		else if(er_option!=null && er_option.equalsIgnoreCase("Group") || er_option.equalsIgnoreCase("Segment") || er_option.equalsIgnoreCase("Service"))
		{
			v_site = erEsxUtils.getGroupsName(htAllGroups,er_option);
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,er_site);
			json.put("siteCombo",getJSONComboFromList(v_site,"",intlmp));
			pageParams.put("selectedSiteCombo",er_site);
			if(er_comptype!=null)
			{
				v_testmes = erUtils.getMeasureForComponentType(er_comptype,"CITRIX SESSION REPORT");
				if(v_testmes!=null && v_testmes.size()>0 && testmes == null)
					testmes = (String)v_testmes.get(0);
				isNeedMeasure=false;
			}
		}
		else if(er_option!=null && er_option.equalsIgnoreCase("Component"))
		{
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,null);
			if(er_comptype!=null)
			{
			v_testmes = erUtils.getMeasureForComponentType(er_comptype,"CITRIX SESSION REPORT");
			if(v_testmes!=null && v_testmes.size()>0 && testmes == null)
					testmes = (String)v_testmes.get(0);
			isNeedMeasure=false;
			}
		}
		else
		{
			  aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,"Zone",s_farmserver);
			json.put("zoneListJson",zoneListJson);
		}
		if(aListComponentTemp!=null && aListComponentTemp.size()>0)
		{
			v_serverName = new ArrayList();
			for(int i=0; i<aListComponentTemp.size(); i++) 
			{
				String loopComponent = (String) aListComponentTemp.get(i);
				if(loopComponent.lastIndexOf(":")>-1){
					String loopComp = loopComponent.substring(0,loopComponent.lastIndexOf(":"));
					String  loopType = loopComponent.substring(loopComponent.lastIndexOf(":")+1);
						if(v_serverName!=null && !v_serverName.contains(loopType))
							v_serverName.add(loopType);
				}
			}
		}
		screenLabels.put("reporter.thin.Component Type",intlmp.getTextDescription("reporter.thin.Component Type"));

		JSONArray compTypeJson = new JSONArray();
		if (v_serverName==null || v_serverName.size()==0)
		{
			JSONObject defaultOpt = new JSONObject();
			defaultOpt.put("displayField",intlmp.getTextDescription("reporter.consolidated.Not Applicable"));
			defaultOpt.put("valueField","-1");
			compTypeJson.add(defaultOpt);

			json.put("compTypeJson",compTypeJson);
			pageParams.put("selectedCompType","-1");
		}
		else if (v_serverName.size()==1)
		{
			String s_compTyp = (String)v_serverName.get(0);
			JSONObject jOpt = new JSONObject();
			jOpt.put("displayField",intlmp.getComponentTypeDescription(s_compTyp));
			jOpt.put("valueField",s_compTyp);
			compTypeJson.add(jOpt);
			pageParams.put("selectedCompType",s_compTyp);
			json.put("compTypeJson",compTypeJson);

			if(isNeedMeasure)
			{
				v_testmes = erUtils.getMeasureForComponentType(s_compTyp,"CITRIX SESSION REPORT");
				if(v_testmes!=null && v_testmes.size()>0 && testmes == null)
					testmes = (String)v_testmes.get(0);
			}
		}
		else
		{
			JSONObject jOpt = new JSONObject();
			ArrayList aSortedList = new ArrayList();
			for(int m=0;m<v_serverName.size();m++)
			{
				String s=(String)v_serverName.get(m);
				String component = intlmp.getComponentTypeDescription(s);
				if(component!=null && !component.equalsIgnoreCase("All Types"))
				aSortedList.add(component);
				Collections.sort(aSortedList,String.CASE_INSENSITIVE_ORDER);
			}
			if(s_farmserver!=null && v_serverName.size()>=2 && !s_farmserver.equals("-1") && request.getParameter("er_type")!=null && !request.getParameter("er_type").equalsIgnoreCase("Yes"))
			{
				aSortedList.add(aSortedList.size(),"All Types");
			}
			for(int n=0;n<aSortedList.size();n++)
			{
				String dispValue=(String)aSortedList.get(n);
				String s = dispValue;
				if(dispValue!=null && !dispValue.equalsIgnoreCase("All Types"))
					s = intlmp.getReverseComponentTypeDescription(dispValue);
				else
					dispValue = intlmp.getTextDescription("reporter.consolidated."+dispValue);

				jOpt = new JSONObject();
				jOpt.put("displayField",dispValue);
				jOpt.put("valueField",s);
				compTypeJson.add(jOpt);

				if(er_comptype!=null && er_comptype.length()>0)
				{
					pageParams.put("selectedCompType",er_comptype);
					if(isNeedMeasure)
					{
						v_testmes = erUtils.getMeasureForComponentType(er_comptype,"CITRIX SESSION REPORT");
						if(v_testmes!=null && v_testmes.size()>0 && testmes == null)
							testmes = (String)v_testmes.get(0);
					}
				}
				else if(n==0)
				{
					pageParams.put("selectedCompType",s);

					if(isNeedMeasure)
					{
						v_testmes = erUtils.getMeasureForComponentType(s,"CITRIX SESSION REPORT");
						if(v_testmes!=null && v_testmes.size()>0 && testmes == null)
							testmes = (String)v_testmes.get(0);
					}
				}
			}
		json.put("compTypeJson",compTypeJson);
		}
		String data="";
		String graph="";
		if (rtype==null )
			rtype="No";

		screenLabels.put("reporter.common.Report Type",intlmp.getTextDescription("reporter.common.Report Type"));

		JSONArray repTypeJson = new JSONArray();

		JSONObject rOpt = new JSONObject();
		rOpt.put("displayField",intlmp.getTextDescription("reporter.thin.Graph"));
		rOpt.put("valueField","Yes");

		repTypeJson.add(rOpt);

		rOpt = new JSONObject();
		rOpt.put("displayField",intlmp.getTextDescription("reporter.thin.Data"));
		rOpt.put("valueField","No");
		repTypeJson.add(rOpt);

		json.put("repTypeJson",repTypeJson);
		pageParams.put("selectedReportType",rtype);

		screenLabels.put("reporter.thin.Criteria",intlmp.getTextDescription("reporter.thin.Criteria"));

		JSONArray measureOpts = new JSONArray();
		
		
		if(v_serverName==null || v_serverName.isEmpty())
		{
			JSONObject jObj = new JSONObject();
			jObj.put("displayField",intlmp.getTextDescription("reporter.common.NotApplicable"));
			jObj.put("valueField","-1");

			measureOpts.add(jObj);
			pageParams.put("selectedMeasure","-1");
		}
		else
		{
			JSONObject jObj = new JSONObject();
			jObj.put("displayField",intlmp.getTextDescription("reporter.common.Please choose a Criteria"));
			jObj.put("valueField","-1");

			measureOpts.add(jObj);

			if(StringUtils.isNull(testmes))
				pageParams.put("selectedMeasure","-1");

			for (int i=0;i<v_testmes.size();i++)
			{
				String s=(String)v_testmes.get(i);
				String testdisp="";//s.substring(0,s.indexOf("/"));
				String mesdisp="";//s.substring(s.indexOf("/")+1);
				if(s.indexOf("/")>-1)
				{
					testdisp=s.substring(0,s.indexOf("/"));
					mesdisp=s.substring(s.indexOf("/")+1);

					String reqMeasure=intlmp.getMeasureDescription(testdisp,mesdisp);
					
					if (reqMeasure.equalsIgnoreCase("USERNAME"))
						reqMeasure = "No of Unique users";
					else if (reqMeasure.equalsIgnoreCase("Active_sessions"))
						reqMeasure = "Active session";
					else if (reqMeasure.trim().equalsIgnoreCase("DURATION"))
						reqMeasure = "Session duration";
					else
						reqMeasure = ""+reqMeasure;
					jObj = new JSONObject();
					jObj.put("displayField",reqMeasure);
					jObj.put("valueField",s);

					measureOpts.add(jObj);

					if(testmes!=null && testmes.equalsIgnoreCase(s))
					{
						pageParams.put("selectedMeasure",s);
					}
					else if(i==0)
					{
						pageParams.put("selectedMeasure",s);
					}
				}
				else
				{
					jObj = new JSONObject();
					jObj.put("displayField",intlmp.getTextDescription("reporter.common."+s));
					jObj.put("valueField",s);

					measureOpts.add(jObj);

					if(testmes!=null && testmes.equalsIgnoreCase(s))
					{
						pageParams.put("selectedMeasure",s);
					}
					else if(i==0)
					{
						pageParams.put("selectedMeasure",s);
					}
				}
			}
		}
		json.put("measureOpts",measureOpts);
	//	}
		
			String detailed="",trend="";
			String trenddata=reportInfo.getValue("CITRIX SESSION REPORT","TrendData");

			//String datatype=request.getParameter("er_trenddata");
			if (datatype==null)
				datatype=trenddata;

			if(datatype !=null)
			{
				if(datatype.equalsIgnoreCase("Yes"))
					trend = "checked";
				else
					detailed = "checked";
			}

			JSONArray showDataOptJson = new JSONArray();

			JSONObject detailedJsonOpt = new JSONObject();
			

			detailedJsonOpt.put("displayField",intlmp.getTextDescription("reporter.common.Detailed"));
			detailedJsonOpt.put("valueField","No");

			showDataOptJson.add(detailedJsonOpt);
			if (computsum)
			{
			JSONObject trendJsonOpt = new JSONObject();
			trendJsonOpt.put("displayField",intlmp.getTextDescription("reporter.common.Trend"));
			trendJsonOpt.put("valueField","Yes");

			showDataOptJson.add(trendJsonOpt);
			}
			json.put("showDataOptJson",showDataOptJson);

			if(StringUtils.isNull(datatype))
				datatype ="No";

			pageParams.put("selectedShowDataOption",datatype);
		
		hiddenParams.put("trendenable",String.valueOf(computsum));
		screenLabels.put("reporter.common.Time period",intlmp.getTextDescription("reporter.common.Time period"));
		screenLabels.put("reporter.common.From",intlmp.getTextDescription("reporter.common.From"));
		screenLabels.put("reporter.common.Hrs",intlmp.getTextDescription("reporter.common.Hrs"));
		screenLabels.put("reporter.common.Mins",intlmp.getTextDescription("reporter.common.Mins"));
		screenLabels.put("reporter.common.To",intlmp.getTextDescription("reporter.common.To"));
		screenLabels.put("reporter.common.Exclude weekends",intlmp.getTextDescription("reporter.common.Exclude weekends"));
		screenLabels.put("reporter.common.Excludes",intlmp.getTextDescription("reporter.common.Excludes")+" "+Days);

		if(!StringUtils.isNull(Hourfrom))
			pageParams.put("selectedFromTime",Hourfrom);

		if(!StringUtils.isNull(Minfrom))
			pageParams.put("selectedFromMin",Minfrom);

		if(!StringUtils.isNull(Hourfrom))
			pageParams.put("selectedToTime",Hourto);

		if(!StringUtils.isNull(Hourfrom))
			pageParams.put("selectedToMin",Minto);

		JSONArray excludeWeekDaysOpt = new  JSONArray();
		JSONObject excludeOpts =new JSONObject();
		excludeOpts.put("displayField",intlmp.getTextDescription("reporter.common.Yes")+" ("+Days+") ");
		excludeOpts.put("valueField","Yes");
		excludeWeekDaysOpt.add(excludeOpts);

		excludeOpts =new JSONObject();
		excludeOpts.put("displayField",intlmp.getTextDescription("reporter.common.No"));
		excludeOpts.put("valueField","No");
		excludeWeekDaysOpt.add(excludeOpts);

		if(excludeweekend.equalsIgnoreCase("Yes"))
		{
			pageParams.put("selectedExcludeWeekEndOption",excludeweekend);
		}
		else
		{
			pageParams.put("selectedExcludeWeekEndOption","No");
		}

		json.put("excludeWeekDaysOpt",excludeWeekDaysOpt);

		screenLabels.put("reporter.common.Timeline",intlmp.getTextDescription("reporter.common.Timeline"));
	
		hiddenParams.put("er_usertimeline",strUsrTimeline);
		json.put("timelineJSONArray",timelineComboArray);
		pageParams.put("selectedTimeline",er_timeline);

		pageParams.put("startDate",startDateJSON);
		pageParams.put("endDate",endDateJSON);
		pageParams.put("startHour",startHourJSON);
		pageParams.put("endHour",endHourJSON);
		pageParams.put("startmin",startMin);
		
		pageParams.put("endmin",endMin);

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




		String buttonLbl = "";

		if(reqFromSchedule!=null && reqFromSchedule.equalsIgnoreCase("Yes"))
		{
			buttonLbl = intlmp.getTextDescription("repoerter.common.SAVE");
		}
		else
		{
			buttonLbl = intlmp.getTextDescription("repoerter.common.SUBMIT");
		}

		screenLabels.put("submitBtnLbl",buttonLbl);
		screenLabels.put("reporter.common.Show Data",intlmp.getTextDescription("reporter.common.Show Data"));
		pageParams.put("er_reportgenration","foreground");

		storeLastAccessedUrl = true;
	}
	else if(action!=null && action.equals("zoneOnChange"))
	{
		List aListComponentTemp=null;
		v_site = erEsxUtils.getGroupsName(htAllGroups,er_option);
		Collections.sort(v_site,String.CASE_INSENSITIVE_ORDER);
		String var[] = inifile.getVariables(sub);
		for(int i=0;i<var.length;i++)
		{
			variable = var[i];
			v_components.add(variable);
		}

		
		List zonelist = compUtils.getUserZones();
		if(zonelist != null && zonelist.contains("--Default--"))
			zonelist.remove("--Default--");
		Vector v_zonelist = new Vector();
		v_zonelist.addAll(zonelist);
		//
		if(er_option!=null && er_option.equals("Zone"))
		{
			v_zonelist.addAll(v_site);
			if(s_farmserver==null && v_site!=null && v_site.size()>0)
			{
				s_farmserver=(String)v_site.get(0);
			}
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,s_farmserver);
		}
		else if(er_option.equals("Group") || er_option.equals("Segment") || er_option.equals("Service"))
		{
			if(er_site==null && v_site!=null && v_site.size()>0)
			{
				er_site=(String)v_site.get(0);
			}
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,er_site);
		}
		else if(er_option.equals("Component"))
		{
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,null);
		}
		if(aListComponentTemp!=null && aListComponentTemp.size()>0)
		{
			v_serverName = new ArrayList();
			for(int i=0; i<aListComponentTemp.size(); i++) 
			{
				String loopComponent = (String) aListComponentTemp.get(i);
				if(loopComponent.lastIndexOf(":")>-1){
					String loopComp = loopComponent.substring(0,loopComponent.lastIndexOf(":"));
					String  loopType = loopComponent.substring(loopComponent.lastIndexOf(":")+1);
						if(v_serverName!=null && !v_serverName.contains(loopType))
							v_serverName.add(loopType);
				}
			}
		}
		
		JSONArray compTypeJson = new JSONArray();
		if (v_serverName.size()==0)
		{
			JSONObject defaultOpt = new JSONObject();
			defaultOpt.put("displayField",intlmp.getTextDescription("reporter.consolidated.NotApplicable"));
			defaultOpt.put("valueField","NotApplicable");
			compTypeJson.add(defaultOpt);

			pageParams.put("selectedCompType","NotApplicable");
		}
		else if (v_serverName.size()==1)
		{
			String s_compTyp = (String)v_serverName.get(0);
			pageParams.put("selectedCompType",s_compTyp);
			JSONObject jOpt = new JSONObject();
			jOpt.put("displayField",intlmp.getComponentTypeDescription(s_compTyp));
			jOpt.put("valueField",s_compTyp);
			compTypeJson.add(jOpt);
			s_server = s_compTyp;
		}
		else
		{
			JSONObject jOpt = new JSONObject();
			compTypeJson.add(jOpt);
			ArrayList aSortedList = new ArrayList();
			for(int m=0;m<v_serverName.size();m++)
			{
				String s=(String)v_serverName.get(m);
				String component = intlmp.getComponentTypeDescription(s);
				if(component!=null && !component.equalsIgnoreCase("All Types"))
				aSortedList.add(component);
				Collections.sort(aSortedList,String.CASE_INSENSITIVE_ORDER);
			}
			if(s_farmserver!=null && v_serverName.size()>=2 && !s_farmserver.equals("-1") && request.getParameter("er_type")!=null && !request.getParameter("er_type").equalsIgnoreCase("Yes"))
			{
				aSortedList.add(aSortedList.size(),"All Types");
			}

			else if(request.getParameter("er_type")!=null && !request.getParameter("er_type").equalsIgnoreCase("Yes"))
			{
				aSortedList.add(aSortedList.size(),"All Types");
			}

			for(int n=0;n<aSortedList.size();n++)
			{
				String dispValue=(String)aSortedList.get(n);
				String s = dispValue;
				if(dispValue!=null && !dispValue.equalsIgnoreCase("All Types"))
					s = intlmp.getReverseComponentTypeDescription(dispValue);
				else
					dispValue = intlmp.getTextDescription("reporter.consolidated."+dispValue);

				jOpt = new JSONObject();
				jOpt.put("displayField",dispValue);
				jOpt.put("valueField",s);
				compTypeJson.add(jOpt);
				if(n==0)
				{
					pageParams.put("selectedCompType",s);
					s_server = s;
				}
			}
		}
		json.put("compTypeJson",compTypeJson);

		v_testmes = erUtils.getMeasureForComponentType(s_server,"CITRIX SESSION REPORT");
		if(v_testmes != null && !v_testmes.isEmpty() && testmes == null)
		{
			testmes = (String)v_testmes.get(0);
		}
		JSONArray measureOpts = new JSONArray();
			
		if(v_serverName.isEmpty())
		{
			JSONObject jObj = new JSONObject();
			jObj.put("displayField",intlmp.getTextDescription("reporter.common.NotApplicable"));
			jObj.put("valueField","NotApplicable");

			measureOpts.add(jObj);
			pageParams.put("selectedMeasure","NotApplicable");
		}
		else
		{
			JSONObject jObj = new JSONObject();
			jObj.put("displayField",intlmp.getTextDescription("reporter.common.Please choose a Criteria"));
			jObj.put("valueField","-1");

			measureOpts.add(jObj);

			if(StringUtils.isNull(testmes))
				pageParams.put("selectedMeasure","-1");
			for (int i=0;i<v_testmes.size();i++)
			{
				String s=(String)v_testmes.get(i);
				String testdisp="";
				String mesdisp="";
				if(s.indexOf("/")>-1)
				{
					testdisp=s.substring(0,s.indexOf("/"));
					mesdisp=s.substring(s.indexOf("/")+1);
					String reqMeasure=intlmp.getMeasureDescription(testdisp,mesdisp);
					if (reqMeasure.equalsIgnoreCase("USERNAME"))
						reqMeasure = "No of Unique users";
					else if (reqMeasure.equalsIgnoreCase("Active_sessions"))
						reqMeasure = "Active session";
					else if (reqMeasure.trim().equalsIgnoreCase("DURATION"))
						reqMeasure = "Session duration";
					else
						reqMeasure = ""+reqMeasure;
					jObj = new JSONObject();
					jObj.put("displayField",reqMeasure);
					jObj.put("valueField",s);

					measureOpts.add(jObj);

					if(testmes!=null && testmes.equalsIgnoreCase(s))
					{
						pageParams.put("selectedMeasure",s);
					}
				}
				else
				{
					jObj = new JSONObject();
					jObj.put("displayField",intlmp.getTextDescription("reporter.common."+s));
					jObj.put("valueField",s);

					measureOpts.add(jObj);

					if(testmes!=null && testmes.equalsIgnoreCase(s))
					{
						pageParams.put("selectedMeasure",s);
					}
				}
			}
		}
		json.put("measureOpts",measureOpts);
		
		json.put("siteComboLabel",er_option);
		if(er_site==null||er_site.length()==0)
		{
			json.put("zoneListJson",getJSONComboFromList(v_site,"",intlmp));
			pageParams.put("selectedZone",s_farmserver);
		}
		else
		{
			json.put("siteCombo",getJSONComboFromList(v_site,"",intlmp));
		json.put("selectedSiteCombo",er_site);
		}
	}
	else if(action!=null && action.equals("compTypeOnChange"))
	{
		v_testmes = erUtils.getMeasureForComponentType(s_server,"CITRIX SESSION REPORT");
		if(v_testmes != null && !v_testmes.isEmpty() && testmes == null)
		{
			testmes = (String)v_testmes.get(0);
		}

		JSONArray measureOpts = new JSONArray();
		
		JSONObject jObj = new JSONObject();
		jObj.put("displayField",intlmp.getTextDescription("reporter.common.Please choose a Criteria"));
		jObj.put("valueField","-1");

		measureOpts.add(jObj);

		if(StringUtils.isNull(testmes))
			pageParams.put("selectedMeasure","-1");

		for (int i=0;i<v_testmes.size();i++)
		{
			String s=(String)v_testmes.get(i);
			String testdisp="";
			String mesdisp="";
			if(s.indexOf("/")>-1)
			{
				testdisp=s.substring(0,s.indexOf("/"));
				mesdisp=s.substring(s.indexOf("/")+1);
				String reqMeasure=intlmp.getMeasureDescription(testdisp,mesdisp);
				if (reqMeasure.equalsIgnoreCase("USERNAME"))
					reqMeasure = "No of Unique users";
				else if (reqMeasure.equalsIgnoreCase("Active_sessions"))
					reqMeasure = "Active session";
				else if (reqMeasure.trim().equalsIgnoreCase("DURATION"))
					reqMeasure = "Session duration";
				else
					reqMeasure = ""+reqMeasure;
				jObj = new JSONObject();
				jObj.put("displayField",reqMeasure);
				jObj.put("valueField",s);

				measureOpts.add(jObj);

				if(testmes!=null && testmes.equalsIgnoreCase(s))
				{
					pageParams.put("selectedMeasure",s);
				}
			}
			else
			{
				jObj = new JSONObject();
				jObj.put("displayField",intlmp.getTextDescription("reporter.common."+s));
				jObj.put("valueField",s);

				measureOpts.add(jObj);

				if(testmes!=null && testmes.equalsIgnoreCase(s))
				{
					pageParams.put("selectedMeasure",s);
				}
			}
		}
		json.put("measureOpts",measureOpts);
	}
	else if(action!=null && action.equals("reportTypeChange"))
	{
		List aListComponentTemp=new ArrayList();
		v_site = erEsxUtils.getGroupsName(htAllGroups,er_option);
		Collections.sort(v_site,String.CASE_INSENSITIVE_ORDER);
		String var[] = inifile.getVariables(sub);
		for(int i=0;i<var.length;i++)
		{
			variable = var[i];
			v_components.add(variable);
		}
		List zonelist = compUtils.getUserZones();
		if(zonelist != null && zonelist.contains("--Default--"))
			zonelist.remove("--Default--");
		Vector v_zonelist = new Vector();
		v_zonelist.addAll(zonelist);
		if(er_option.equals("Zone")&& er_option!=null)
		{
			v_zonelist.addAll(v_site);
			if(s_farmserver==null && v_site!=null && v_site.size()>0)
			{
				s_farmserver=(String)v_site.get(0);
			}
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,s_farmserver);
		}
		else if(er_option.equals("Group") || er_option.equals("Segment") || er_option.equals("Service"))
		{
			if(er_site==null && v_site!=null && v_site.size()>0)
			{
				er_site=(String)v_site.get(0);
			}
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,er_site);
		}
		else if(er_option.equals("Component"))
		{
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,null);
		}
		if(aListComponentTemp!=null && aListComponentTemp.size()>0)
		{
			v_serverName = new ArrayList();
			for(int i=0; i<aListComponentTemp.size(); i++) 
			{
				String loopComponent = (String) aListComponentTemp.get(i);
				if(loopComponent.lastIndexOf(":")>-1){
					String loopComp = loopComponent.substring(0,loopComponent.lastIndexOf(":"));
					String  loopType = loopComponent.substring(loopComponent.lastIndexOf(":")+1);
					if(v_serverName!=null && !v_serverName.contains(loopType))
						v_serverName.add(loopType);
				}
				
			}
		}
		if(v_temp!=null && v_temp.size() > 1)
		{
			Collections.sort(v_temp,String.CASE_INSENSITIVE_ORDER);
		}
		
		JSONArray compTypeJson = new JSONArray();
		if (v_serverName==null || v_serverName.size()==0)
		{
			JSONObject defaultOpt = new JSONObject();
			defaultOpt.put("displayField",intlmp.getTextDescription("reporter.consolidated.NotApplicable"));
			defaultOpt.put("valueField","NotApplicable");
			compTypeJson.add(defaultOpt);

			pageParams.put("selectedCompType","NotApplicable");
		}
		else if (v_serverName.size()==1)
		{
			String s_compTyp = (String)v_serverName.get(0);
			if(s_server!=null && s_server.equalsIgnoreCase((String)v_serverName.get(0)))
			{
				pageParams.put("selectedCompType",s_compTyp);
			}
			else
			{
				JSONObject jOpt = new JSONObject();
				compTypeJson.add(jOpt);

				pageParams.put("selectedCompType",s_compTyp);
			}

			JSONObject jOpt = new JSONObject();
			jOpt.put("displayField",intlmp.getComponentTypeDescription(s_compTyp));
			jOpt.put("valueField",s_compTyp);
			compTypeJson.add(jOpt);
		}
		if (v_serverName!=null && v_serverName.size()>0)
		{
			JSONObject jOpt = new JSONObject();
			compTypeJson.add(jOpt);

			ArrayList aSortedList = new ArrayList();
			for(int m=0;m<v_serverName.size();m++)
			{
				String s=(String)v_serverName.get(m);
				String component = intlmp.getComponentTypeDescription(s);
				if(component!=null && !component.equalsIgnoreCase("All Types"))
				aSortedList.add(component);
				Collections.sort(aSortedList,String.CASE_INSENSITIVE_ORDER);
			}
		if(s_farmserver!=null && v_serverName.size()>=2 && !s_farmserver.equals("-1") && request.getParameter("er_type")!=null && !request.getParameter("er_type").equalsIgnoreCase("Yes"))
		{
			aSortedList.add("All Types");
				
		}
		else if(request.getParameter("er_type")!=null && request.getParameter("er_type").equalsIgnoreCase("No") && v_serverName.size()>=2)
			{
				aSortedList.add("All Types");
			}
			for(int n=0;n<aSortedList.size();n++)
			{
				String dispValue=(String)aSortedList.get(n);
				String s = dispValue;
				if(dispValue!=null && !dispValue.equalsIgnoreCase("All Types"))
					s = intlmp.getReverseComponentTypeDescription(dispValue);
				else
					dispValue = intlmp.getTextDescription("reporter.consolidated."+dispValue);

				jOpt = new JSONObject();
				jOpt.put("displayField",dispValue);
				jOpt.put("valueField",s);
				compTypeJson.add(jOpt);
				if(n==0)
				{
					pageParams.put("selectedCompType",s);
					s_server = s;
					v_testmes = erUtils.getMeasureForComponentType(s_server,"CITRIX SESSION REPORT");
					String testMes = (String)v_testmes.get(0);
					if(request.getParameter("er_type")!=null && request.getParameter("er_type").equalsIgnoreCase("Yes"))
					{
						JSONArray measureOpts = new JSONArray();
						JSONObject jObjs = new JSONObject();
						jObjs.put("displayField",intlmp.getTextDescription("reporter.common.Please choose a Criteria"));
						jObjs.put("valueField","-1");

						measureOpts.add(jObjs);
						String testdisp="";
						String mesdisp="";
						String vTestMeasure_temp="";
						
						for(int ii=0;ii<v_testmes.size();ii++)
						{	
							String vTestMeasure = (String)v_testmes.get(ii);
								System.out.println("vTestMeasure --->>> "+vTestMeasure);
							if(vTestMeasure!=null && vTestMeasure.indexOf("/") > -1)
							{
								testdisp=vTestMeasure.substring(0,vTestMeasure.indexOf("/"));
								mesdisp=vTestMeasure.substring(vTestMeasure.indexOf("/")+1);
								vTestMeasure_temp=intlmp.getMeasureDescription(testdisp,mesdisp);
								if (vTestMeasure_temp.equalsIgnoreCase("USERNAME"))
									vTestMeasure_temp = "No of Unique users";
								else if (vTestMeasure_temp.equalsIgnoreCase("Active_sessions"))
									vTestMeasure_temp = "Active session";
								else if (vTestMeasure_temp.trim().equalsIgnoreCase("DURATION"))
									vTestMeasure_temp = "Session duration";
								else
									vTestMeasure_temp = ""+vTestMeasure_temp;
							}
							else if(s_server!=null && !s_server.equalsIgnoreCase("All Types") &&  !s_server.equalsIgnoreCase("Vmware_esx_server"))
							{
								vTestMeasure_temp = "No of Sessions Completed";
							}
								
							jObjs = new JSONObject();
							jObjs.put("displayField",vTestMeasure_temp);
							jObjs.put("valueField",vTestMeasure);

							measureOpts.add(jObjs);
							if(testMes == vTestMeasure)
								pageParams.put("selectedMeasure",vTestMeasure);
						}
						json.put("measureOpts",measureOpts);
						
					}
					
							
				}
			}
		}
		json.put("compTypeJson",compTypeJson);
	}
		String er_uniqueUser = (String)request.getParameter("er_uniqueUser");
		boolean er_uniqueUserVal = false;
		if(er_uniqueUser==null || er_uniqueUser.length()==0)
		{
			er_uniqueUser = reportInfo.getValue("CITRIX SESSION REPORT","ShowUniqueUser");
		}
		if(er_uniqueUser!=null &&(er_uniqueUser.equalsIgnoreCase("true") || er_uniqueUser.equalsIgnoreCase("yes")))
		{
			er_uniqueUserVal = true;
		}
		json.put("er_uniqueUser",er_uniqueUserVal);

		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 = "";
			json.put("reportGeneration","background");
		}
		else if (er_reportgenration != null && er_reportgenration.equals("background-csv"))
		{
			er_background = "selected";
			er_foreground = "";
			json.put("reportGeneration","background-csv");
		}
		else
		{
			er_background = "";
			er_foreground = "selected";
			json.put("reportGeneration","foreground");
		}
		String bg_reportname = request.getParameter("bg_reportname");
		if(bg_reportname == null)
		{
			bg_reportname = "";
		}
		screenLabels.put("reporter.consolidated.Report Generation",intlmp.getTextDescription("reporter.consolidated.Report Generation"));

		JSONArray repGenOptJson = new JSONArray();
		JSONObject repGenOpt = new JSONObject();

		repGenOpt.put("displayField",strforeground);
		repGenOpt.put("valueField","foreground");
		repGenOptJson.add(repGenOpt);

		repGenOpt.put("displayField",strbackground);
		repGenOpt.put("valueField","background");
		repGenOptJson.add(repGenOpt);
		if(rtype!=null && rtype.equals("No"))
		{
			repGenOpt.put("displayField",intlmp.getTextDescription("reporter.consolidated.Background Save - CSV"));
			repGenOpt.put("valueField","background-csv");
			repGenOptJson.add(repGenOpt);
		}
		
		json.put("repGenOptJson",repGenOptJson);
		
		screenLabels.put("reporter.consolidated.Report Name",intlmp.getTextDescription("reporter.consolidated.Report Name"));

		if(!StringUtils.isNull(bg_reportname))
			pageParams.put("selectedReportName",bg_reportname);

	String isSubmit = request.getParameter("isSubmit");
	if(isSubmit!=null && isSubmit.equals("true"))
	{
		if(bggroundStr != null && !bggroundStr.equals(""))
		{
			storeLastAccessedUrl = true;
			String strreportName ="Thin_Client_Session";
			if(status != null && (status.equalsIgnoreCase("duplicate") || status.equalsIgnoreCase("exceedLimit")))
			{
				strreportName ="All Report Types";
			}
			if(strreportName!=null && strreportName.indexOf(" ") > -1)
			{
				strreportName = EgURLEncoder.encode(strreportName, "UTF-8");
			}
			pageParams.put("backgroundReportStatus",status);
			if(status != null && !status.equalsIgnoreCase("exceedLimit"))
			{
				pageParams.put("langSupportMsg",erbgreport.getlangsupportedString(bggroundStr,bgString,urs));
			}
			else
			{
				pageParams.put("langSupportMsg",bggroundStr);
			}
			pageParams.put("bgrdUrl","/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");

			screenLabels.put("linkMsg",intlmp.getTextDescription("reporter.common.Click here to see a list of generated and processing reports"));
		}
		Vector v_forpdf = new Vector();
		ArrayList Report_data=new ArrayList();
		ArrayList arr_data1=new ArrayList();
		
		Vector v_data1= new Vector();
		Hashtable ht_data = new Hashtable();

		String qs = (String)session.getAttribute("SessionQry");
		ht_data = (Hashtable)request.getAttribute("Report_data");
		Hashtable Daywisechart = (Hashtable)request.getAttribute("chartParam");
		Hashtable DaywiseUserData = (Hashtable)request.getAttribute("userChartData");
		Vector v_qry_string = (Vector)request.getAttribute("sessionchartdata");
		Vector sessionpdfdata = (Vector)request.getAttribute("sessionpdfdata");
		
		v_data1 = (Vector)request.getAttribute("Report_data1");
		arr_data1 = (ArrayList)request.getAttribute("Report_data2");

		session.removeAttribute("SessionQry");

		if(Daywisechart!=null&&!Daywisechart.isEmpty())
		{
			ht_data = new Hashtable();
		}

		session.setAttribute("sessionDatatop",arr_data1);

		screenLabels.put("selectionDetailsTitle",intlmp.getTextDescription("reporter.common.Selection Details for a Zone")+" "+intlmp.getComponentTypeDescription(s_farmserver));

		if( (ht_data!=null && ht_data.size()>0) || (v_qry_string!=null && v_qry_string.size()>0) || (Daywisechart!=null && Daywisechart.size()>0) )
		{
			String s_reportType="";
			if(rtype!=null && rtype.equals("Yes")) {
				s_reportType="Graph";
			} else {
				s_reportType="Data";
			}

			JSONObject selDetailsJson = new JSONObject();
			selDetailsJson.put(intlmp.getTextDescription("reporter.common.Report Type"),intlmp.getTextDescription("reporter.common."+s_reportType));
			selDetailsJson.put(intlmp.getTextDescription("reporter.common.Component Type"),intlmp.getComponentTypeDescription(s_server));
			if(testmes!=null)
			{
				String disptestmes=testmes;
				if(disptestmes.indexOf("/") >-1)
				{
					disptestmes=disptestmes.substring(disptestmes.indexOf("/")+1);
				}
				if (disptestmes.equalsIgnoreCase("USERNAME"))
					disptestmes = "No of Unique users";
				else if (disptestmes.equalsIgnoreCase("Active_sessions"))
					disptestmes = "Active session";
				else if (disptestmes.trim().equalsIgnoreCase("DURATION"))
					disptestmes = "Session duration";
				else
					disptestmes = ""+disptestmes;
			
				selDetailsJson.put(intlmp.getTextDescription("reporter.common.Criteria"),intlmp.getTextDescription("reporter.common." +disptestmes));
			}
			if (computsum)
			{
				String s_reportFor="";
				if(opt != null && opt.equals("Yes"))
				{
					s_reportFor = "Trend";
				}
				else
				{
					s_reportFor= "Detailed";
				}
				selDetailsJson.put(intlmp.getTextDescription("reporter.common.Show Data"),intlmp.getTextDescription("reporter.common."+s_reportFor));
			}

			selDetailsJson.put(intlmp.getTextDescription("reporter.common.Exclude weekends"),intlmp.getTextDescription("reporter.common."+excludeweekend));

			String fromLbl = intlmp.getTextDescription("reporter.common.From");
			String toLbl = intlmp.getTextDescription("reporter.common.to");

			String timePeriodVal = "<span class='font_bold'></span> "+Hourfrom+":"+Minfrom +"<span class='font_bold'>  "+toLbl+"</span> "+Hourto+":"+Minto;

			selDetailsJson.put(intlmp.getTextDescription("reporter.common.Time Period"),timePeriodVal);

			String timelineVal ="<span class='font_bold'>"+"</span>"+usr_startTime+" "+intlmp.getTextDescription("reporter.common.hrs")+"<span class='font_bold'> "+intlmp.getTextDescription("reporter.common.to")+"</span> "+usr_endTime+" "+intlmp.getTextDescription("reporter.common.hrs");

			selDetailsJson.put(intlmp.getTextDescription("reporter.common.Timeline"),timelineVal);

			json.put("selDetailsJson",selDetailsJson);
		}
		if(rtype!=null&&rtype.equals("No")) //For data view
		{
			String s_qryStringses1 = "../servlet/com.eg.ErCtxServerReportC?er_type=No&select_farm="+EgURLEncoder.encode(s_farmserver,"UTF-8")+"&topsession=yes&select_server1=no&er_gtype=Citrix&er_rtype=Session&isSubmit=true&er_excwe="+excludeweekend+"&er_trgttype="+EgURLEncoder.encode("Session Report","UTF-8")+"&er_tbound="+tbound+"&pdfTime="+URLEncoder.encode(pdfTime)+"&er_timeline="+EgURLEncoder.encode(erd.s_timeline,"UTF-8")+"&startdate="+URLEncoder.encode(request.getParameter("startdate"))+"&minfrom="+minfrom2+"&minto="+minto2+"&enddate="+URLEncoder.encode(request.getParameter("enddate"))+"&timefrom="+tfrom+"&timeto="+tto+"&starthr="+request.getParameter("starthr")+"&endhr="+request.getParameter("endhr")+"&uid=" +EgURLEncoder.encode(loginid,"UTF-8")+"&er_trenddata="+request.getParameter("er_trenddata")+"&er_select_server="+EgURLEncoder.encode(s_server,"UTF-8")+"&select_compType="+EgURLEncoder.encode(s_server,"UTF-8")+"&startmin="+strmin+"&endmin="+enmin+"&inidate="+URLEncoder.encode(currentDateFormat)+"&er_option="+er_option+"&er_site="+er_site;

			String s_qryStringses = "../servlet/com.eg.ErCtxServerReportC?er_type=No&select_farm="+EgURLEncoder.encode(s_farmserver,"UTF-8")+"&topusers=users&select_server1=no&er_gtype=Citrix&er_rtype=Session&isSubmit=true&er_excwe="+excludeweekend+"&er_trgttype="+EgURLEncoder.encode("Session Report","UTF-8")+"&er_tbound="+tbound+"&pdfTime="+URLEncoder.encode(pdfTime)+"&er_timeline="+EgURLEncoder.encode(erd.s_timeline,"UTF-8")+"&startdate="+URLEncoder.encode(request.getParameter("startdate"))+"&minfrom="+minfrom2+"&minto="+minto2+"&enddate="+URLEncoder.encode(request.getParameter("enddate"))+"&timefrom="+tfrom+"&timeto="+tto+"&starthr="+request.getParameter("starthr")+"&endhr="+request.getParameter("endhr")+"&uid=" +  EgURLEncoder.encode(loginid,"UTF-8")+"&er_trenddata="+request.getParameter("er_trenddata")+"&er_select_server="+s_server+"&select_compType="+EgURLEncoder.encode(s_server,"UTF-8")+"&startmin="+strmin+"&endmin="+enmin+"&inidate="+URLEncoder.encode(currentDateFormat)+"&er_option="+er_option+"&er_site="+er_site;

			Vector v_in  = new Vector();
			String FieldsTb2forDis = "$F{title}";
			String FieldsTb2="title";
			String AddFields ="";
			int fieldsizefortb2=2;
			String ClassTypesfortb2 = "";
			String addMapping="";
			String serverName="";
			int serverCount=0;
			ArrayList variables=reportInfo.getVariables("CITRIX SESSION REPORT");
			ArrayList availableServers =listCompTypes;
			String variable1="";
			StringTokenizer tok1;
			if(ht_data!=null && ht_data.size()>0)
			{
				
				String skey1="";
				Iterator itr1 =(ht_data.keySet()).iterator();
				skey1= (String)itr1.next();
				StringTokenizer serverToken=new StringTokenizer(skey1,"~");
				serverToken.nextToken();
				serverName=serverToken.nextToken();
				Report_data= (ArrayList)ht_data.get(skey1);
				ArrayList tempVariables=null;
				if(Report_data.size()!=0 && Report_data!=null)
				{
					json.put("dataAvailable","true");
					variable1 = "";
					String value1;
					variables=reportInfo.getVariables("CITRIX SESSION REPORT");
					int varsize = variables.size();
					for(int i=0;i<varsize;i++)
					{
						variable1 = (String)variables.get(i);
						tok1 = new StringTokenizer(variable1,":");
						while(tok1.hasMoreTokens())
						{
							tok1.nextToken();
							String testname=tok1.nextToken();
							String val2=tok1.nextToken();
							StringTokenizer meas=new StringTokenizer(val2,"#");
							String mes="";
							String displayname="";
							if(meas.hasMoreTokens())
								mes=meas.nextToken();
							else
							mes=val2;
							String units=tablesInfo.getUnitForMeasure(testname,mes);
							if(meas.hasMoreTokens() )
								displayname=meas.nextToken();
							else
								displayname=val2;
							v_in.add(displayname);
						}
					}
					String s_QSGraph="";
					String congigtop = "Top "+top;
					Vector v_pdf1 = new Vector();
					if(s_farmserver!=null || !s_farmserver.equals(""))
					{
						SessionQs="../servlet/com.eg.ErCtxServerReportC";
						session.setAttribute("SessionQry",SessionQs);
					}
					String FieldsTb1forDis = "$F{title},Total_number_of_sessions,Average_duration ,Maximum_duration";
					String FieldsTb1= "title,Total_number_of_sessions,Average_duration,Maximum_duration";
					String classtype1 = "java.lang.String.class,java.lang.String.class,java.lang.String.class,java.lang.String.class";

					JSONObject summaryTableJson = new JSONObject();
					s_tit = intlmp.getTextDescription("reporter.common.Summary for")+"  "+headerKeyName;
					json.put("summaryTableTitle",s_tit);

					if(arr_data1==null || arr_data1.size()<0 || arr_data1.isEmpty())
					{
						session.setAttribute("sessionData",new Hashtable(ht_data));
						if(s_server!=null && !s_server.equalsIgnoreCase("All Types"))
						{
							session.setAttribute("sessionData1",v_data1);
							v_pdf1.add("Total_number_of_sessions");
							
							vec.add(intlmp.getTextDescription("reporter.thin.Criteria"));
							vec.add(intlmp.getTextDescription("reporter.thin.Average"));

							lst_dat.add(intlmp.getTextDescription("reporter.thin.Sessions completed")+"("+intlmp.getTextDescription("reporter.thin.Number")+")");
							
							
							String avgdu0=(String)v_data1.get(0);
							if(avgdu0.equals("")||avgdu0==null)
								avgdu0="-";
							avgdu0 = (avgdu0 == null || avgdu0.equals("-"))? "-" : erUtils.round(Float.parseFloat(avgdu0),2);

							JSONObject jObj = new JSONObject();
							jObj.put("val",avgdu0);
							jObj.put("hrefUrl","-");

							summaryTableJson.put(intlmp.getTextDescription("reporter.thin.Sessions completed")+" ("+intlmp.getTextDescription("reporter.thin.Number")+")",jObj);

							v_pdf1.add(avgdu0);
							lst_dat.add(avgdu0);

							v_pdf1.add("Average_duration");	
							
							lst_dat.add(intlmp.getTextDescription("reporter.thin.Average duration")+"("+intlmp.getTextDescription("reporter.thin.Mins")+")");	

							String avgdu=(String)v_data1.get(1);
							if(avgdu.equals("")||avgdu==null)
								avgdu="-";
							avgdu = (avgdu == null || avgdu.equals("-"))? "-" : erUtils.round(Float.parseFloat(avgdu),2);
							jObj = new JSONObject();
							jObj.put("val",avgdu);
							jObj.put("hrefUrl","-");
							summaryTableJson.put(intlmp.getTextDescription("reporter.thin.Average duration")+" ("+intlmp.getTextDescription("reporter.thin.Mins")+")",jObj);

							v_pdf1.add(avgdu);
							lst_dat.add(avgdu);
							v_pdf1.add("Maximum_duration");

							lst_dat.add(intlmp.getTextDescription("reporter.thin.Maximum duration")+"("+intlmp.getTextDescription("reporter.thin.Mins")+")");
							String avgdu1=(String)v_data1.get(2);
							if(avgdu1.equals("")||avgdu1==null)
								avgdu1="-";
							avgdu1 = (avgdu1 == null || avgdu1.equals("-"))? "-" : erUtils.round(Float.parseFloat(avgdu1),2);
							v_pdf1.add(avgdu1);
							lst_dat.add(avgdu1);

							jObj = new JSONObject();
							jObj.put("val",avgdu1);
							jObj.put("hrefUrl","-");
							summaryTableJson.put(intlmp.getTextDescription("reporter.thin.Maximum duration")+" ("+intlmp.getTextDescription("reporter.thin.Mins")+")",jObj);

							String strval=(String)v_data1.get(0);
							String strchk="0";
							if(strval == null || strval.equals("") || strval.equals(strchk))
							{
								s_qryStringses1="-";
								s_qryStringses="-";

								JSONObject jObj1 = new JSONObject();
								jObj.put("val",avgdu1);
								jObj.put("hrefUrl",s_qryStringses1);
								summaryTableJson.put(congigtop+" "+intlmp.getTextDescription("reporter.thin.longest sessions"),jObj1);
								jObj1 = new JSONObject();
								jObj.put("val",avgdu1);
								jObj.put("hrefUrl",s_qryStringses);
								summaryTableJson.put(intlmp.getTextDescription("reporter.thin."+congigtop)+" "+intlmp.getTextDescription("reporter.thin.users")+" "+intlmp.getTextDescription("reporter.thin.by duration of usage"),jObj1);
							}
							else
							{
								jObj = new JSONObject();
								jObj.put("val","top.gif");
								jObj.put("hrefUrl",s_qryStringses1+"&responseType=json&thinClientSessionAction=submit");
								summaryTableJson.put(congigtop+" "+intlmp.getTextDescription("reporter.thin.longest sessions"),jObj);
								jObj = new JSONObject();
								jObj.put("val","top.gif");
								jObj.put("hrefUrl",s_qryStringses+"&responseType=json&thinClientSessionAction=submit");
								summaryTableJson.put(congigtop+" "+intlmp.getTextDescription("reporter.thin.users")+" "+intlmp.getTextDescription("reporter.thin.by duration of usage"),jObj);
							}
							lst_dat.add(intlmp.getTextDescription("reporter.thin.Unique users"));
							String Qsuserfarm="../servlet/com.eg.ErCtxServerReportC?select_farm="+EgURLEncoder.encode(s_farmserver,"UTF-8")+"&er_type=No&isSubmit=true&er_excwe="+excludeweekend+"&pdfTime="+URLEncoder.encode(pdfTime)+"&er_gtype=Citrix&er_rtype=Session&er_trgttype="+EgURLEncoder.encode("Session Report","UTF-8")+"&er_tbound="+tbound+"&er_timeline="+EgURLEncoder.encode(erd.s_timeline,"UTF-8")+"&startdate="+URLEncoder.encode(request.getParameter("startdate"))+"&minfrom="+minfrom2+"&minto="+minto2+"&enddate="+URLEncoder.encode(request.getParameter("enddate"))+"&timefrom="+tfrom+"&timeto="+tto+"&starthr="+request.getParameter("starthr")+"&endhr="+request.getParameter("endhr")+"&startmin="+strmin+"&endmin="+enmin+"&uid=" + EgURLEncoder.encode(loginid,"UTF-8")+"&er_trenddata="+request.getParameter("er_trenddata")+"&daychartfor=uniqueuser&select_compType="+EgURLEncoder.encode(s_server,"UTF-8")+"&er_select_server="+EgURLEncoder.encode(s_server,"UTF-8")+"&inidate="+URLEncoder.encode(currentDateFormat)+"&er_option="+er_option+"&er_site="+er_site;
							String Strfarmuser = (String)v_data1.get(3);
							if(Strfarmuser!=null&&Strfarmuser.equals("-"))
							{
								jObj = new JSONObject();
								jObj.put("val",Strfarmuser);
								jObj.put("hrefUrl","-");
								summaryTableJson.put(intlmp.getTextDescription("reporter.thin.Unique users")+" "+intlmp.getTextDescription("reporter.thin.by duration of usage"),jObj);
								lst_dat.add(Strfarmuser);
							}
							else
							{
								jObj = new JSONObject();
								jObj.put("val",Strfarmuser);
								jObj.put("hrefUrl",Qsuserfarm+"&responseType=json&thinClientSessionAction=submit");
								summaryTableJson.put(intlmp.getTextDescription("reporter.thin.Unique users"),jObj);
								lst_dat.add(Strfarmuser);
							}
							
						}else{
							String allTypeUniqueUsrSummaryTmp[] = allTypeUniqueUsrSummary.split(":");
							vec.add(intlmp.getTextDescription("reporter.thin.Criteria"));
							vec.add(intlmp.getTextDescription("reporter.thin.Average"));
							lst_dat.add(intlmp.getTextDescription("reporter.thin.Sessions completed")+"("+intlmp.getTextDescription("reporter.thin.Number")+")");
							
							lst_dat.add(allTypeUniqueUsrSummaryTmp[0]);
							
							lst_dat.add(intlmp.getTextDescription("reporter.thin.Average duration")+"("+intlmp.getTextDescription("reporter.thin.Mins")+")");

							lst_dat.add(allTypeUniqueUsrSummaryTmp[1]);

							lst_dat.add(intlmp.getTextDescription("reporter.thin.Maximum duration")+"("+intlmp.getTextDescription("reporter.thin.Mins")+")");

							lst_dat.add(allTypeUniqueUsrSummaryTmp[2]);
						   
						    lst_dat.add(intlmp.getTextDescription("reporter.thin.Unique users"));
							lst_dat.add(allTypeUniqueUsrSummaryTmp[3]);
							//prakash
							/*String first_temp = allTypeUniqueUsrSummaryTmp[0];
								System.out.println("first_temp --->>> "+first_temp);
							if(first_temp==null && first_temp.equals(""))
								first_temp = "-";
							first_temp = (first_temp == null || first_temp.equals("-"))? "-" : erUtils.round(Float.parseFloat(first_temp),2);
								System.out.println("first_temp123 --->>> "+first_temp);
							JSONObject jObj = new JSONObject();	  
							jObj.put("val",first_temp);
							jObj.put("hrefUrl","-");
							summaryTableJson.put(intlmp.getTextDescription("reporter.thin.Sessions completed")+" ("+intlmp.getTextDescription("reporter.thin.Number")+")",jObj);

							String sec_temp = allTypeUniqueUsrSummaryTmp[1];
							if(sec_temp == null && sec_temp.equals(""))
								sec_temp = "-";
							sec_temp = (sec_temp == null || sec_temp.equals("-"))? "-" : erUtils.round(Float.parseFloat(sec_temp),2);
							jObj = new JSONObject();
							jObj.put("val",sec_temp);
							jObj.put("hrefUrl", "-");
							summaryTableJson.put(intlmp.getTextDescription("reporter.thin.Average duration")+" ("+intlmp.getTextDescription("reporter.thin.Mins")+")",jObj);

							String third_temp = allTypeUniqueUsrSummaryTmp[2];
							if(third_temp == null && third_temp.equals(""))
								third_temp = "-";
							jObj = new JSONObject();
							jObj.put("val",third_temp);
							jObj.put("hrefUrl", "-");
							summaryTableJson.put(intlmp.getTextDescription("reporter.thin.Maximum duration")+" ("+intlmp.getTextDescription("reporter.thin.Mins")+")",jObj);
							String strval=allTypeUniqueUsrSummaryTmp[0];
							String strchk="0";
							if(strval == null || strval.equals("") || strval.equals(strchk))
							{
								s_qryStringses1="-";
								s_qryStringses="-";

								JSONObject jObj1 = new JSONObject();
								jObj.put("val",third_temp);
								jObj.put("hrefUrl",s_qryStringses1);
								summaryTableJson.put(congigtop+" "+intlmp.getTextDescription("reporter.thin.longest sessions"),jObj1);
								jObj1 = new JSONObject();
								jObj.put("val",third_temp);
								jObj.put("hrefUrl",s_qryStringses);
								summaryTableJson.put(intlmp.getTextDescription("reporter.thin."+congigtop)+" "+intlmp.getTextDescription("reporter.thin.users")+" "+intlmp.getTextDescription("reporter.thin.by duration of usage"),jObj1);
							}
							else
							{
								jObj = new JSONObject();
								jObj.put("val","top.gif");
								jObj.put("hrefUrl",s_qryStringses1+"&responseType=json&thinClientSessionAction=submit");
								summaryTableJson.put(congigtop+" "+intlmp.getTextDescription("reporter.thin.longest sessions"),jObj);
								jObj = new JSONObject();
								jObj.put("val","top.gif");
								jObj.put("hrefUrl",s_qryStringses+"&responseType=json&thinClientSessionAction=submit");
								summaryTableJson.put(congigtop+" "+intlmp.getTextDescription("reporter.thin.users")+" "+intlmp.getTextDescription("reporter.thin.by duration of usage"),jObj);
							}
							String Qsuserfarm="../servlet/com.eg.ErCtxServerReportC?select_farm="+EgURLEncoder.encode(s_farmserver,"UTF-8")+"&er_type=No&isSubmit=true&er_excwe="+excludeweekend+"&pdfTime="+URLEncoder.encode(pdfTime)+"&er_gtype=Citrix&er_rtype=Session&er_trgttype="+EgURLEncoder.encode("Session Report","UTF-8")+"&er_tbound="+tbound+"&er_timeline="+EgURLEncoder.encode(erd.s_timeline,"UTF-8")+"&startdate="+URLEncoder.encode(request.getParameter("startdate"))+"&minfrom="+minfrom2+"&minto="+minto2+"&enddate="+URLEncoder.encode(request.getParameter("enddate"))+"&timefrom="+tfrom+"&timeto="+tto+"&starthr="+request.getParameter("starthr")+"&endhr="+request.getParameter("endhr")+"&startmin="+strmin+"&endmin="+enmin+"&uid=" + EgURLEncoder.encode(loginid,"UTF-8")+"&er_trenddata="+request.getParameter("er_trenddata")+"&daychartfor=uniqueuser&select_compType="+EgURLEncoder.encode(s_server,"UTF-8")+"&er_select_server="+EgURLEncoder.encode(s_server,"UTF-8")+"&inidate="+URLEncoder.encode(currentDateFormat)+"&er_option="+er_option+"&er_site="+er_site;
							String Strfarmuser_temp = allTypeUniqueUsrSummaryTmp[3];
							if(Strfarmuser_temp!=null&&Strfarmuser_temp.equals("-"))
							{
								jObj = new JSONObject();
								jObj.put("val",Strfarmuser_temp);
								jObj.put("hrefUrl","-");
								summaryTableJson.put(intlmp.getTextDescription("reporter.thin.Unique users")+" "+intlmp.getTextDescription("reporter.thin.by duration of usage"),jObj);
							}
							else
							{
								jObj = new JSONObject();
								jObj.put("val",Strfarmuser_temp);
								//jObj.put("hrefUrl",Qsuserfarm+"&responseType=json&thinClientSessionAction=submit");
								jObj.put("hrefUrl","-");
								summaryTableJson.put(intlmp.getTextDescription("reporter.thin.Unique users"),jObj);

							} */
							//
						}
						json.put("summaryTableJson",summaryTableJson);
						JSONArray sessionDetailsTableArr = new JSONArray();
						for(serverCount=0;serverCount<availableServers.size();serverCount++)
						{
							TreeMap dispHash=new TreeMap();
							if(ht_data.size()>0)
							{
								String skey="";
								String tempVar="";
								Iterator itr = ht_data.keySet().iterator();
								while(itr.hasNext())
								{
									skey = (String)itr.next();
									serverToken=new StringTokenizer(skey,"~");
									tempVar=serverToken.nextToken();
									serverName=serverToken.nextToken();
									String str_temp=skey.substring(skey.indexOf("~"));

									if(str_temp.indexOf((String)availableServers.get(serverCount))!=-1)
										dispHash.put(skey,ht_data.get(skey));
								}

								JSONObject sessionDetaileTableJson = new JSONObject();
								int totalColumnCount=0;
								int havingSingleColumn=0;
								if(!dispHash.isEmpty())
								{
									int cnt = 0;
									if (s_farmserver!=null)
									{
										if(s_farmserver!=null && s_farmserver.equalsIgnoreCase("--Default--"))
										{
											if(headerKeyName.contains(intlmp.getComponentTypeDescription((String)availableServers.get(serverCount))))
												s_tit1 = intlmp.getTextDescription("reporter.thin.Session Details For")+" "+headerKeyName;
											else
											s_tit1 = intlmp.getTextDescription("reporter.thin.Session Details For") +" "+headerKeyName+", "+intlmp.getTextDescription("reporter.thin.Type:")+" " + intlmp.getComponentTypeDescription((String)availableServers.get(serverCount));
											vec2.add(s_tit1);
										}
										else
										{
											if(headerKeyName.contains(intlmp.getComponentTypeDescription((String)availableServers.get(serverCount))))
												s_tit1 = intlmp.getTextDescription("reporter.thin.Session Details For")+" "+headerKeyName;
											else
												s_tit1 = intlmp.getTextDescription("reporter.thin.Session Details For")+" "+headerKeyName+", "+intlmp.getTextDescription("reporter.thin.Type:")+" " +intlmp.getComponentTypeDescription((String)availableServers.get(serverCount));
											vec2.add(s_tit1);
										}
									}
										// Removing comma from title
									if(s_tit1.indexOf(",")>-1)
										s_tit1 = s_tit1.replace(',',' ');

									sessionDetaileTableJson.put("tableTitle",s_tit1);
									JSONObject sessionDetailsCols = new JSONObject();
									JSONObject unitForMeasure = new JSONObject();
									sessionDetailsCols.put(intlmp.getTextDescription("reporter.thin.Server"),new JSONArray());
									vec1.add(intlmp.getTextDescription("reporter.common.Server"));
									AddFields="Server";
									if (addMapping.equals(""))
										addMapping="Server#Server";
									else
										addMapping+=",Server#Server";
									if(FieldsTb2forDis.equals(""))
										FieldsTb2forDis="-";
									else
										FieldsTb2forDis=FieldsTb2forDis+",-";
									if (FieldsTb2.equals(""))
										FieldsTb2="Server";
									else
										FieldsTb2+=",Server";
									String s_var = "";
									String s_measure = "";
									String s_test = "";
									String st_value="";
									String unit="";

									Vector v_val = new Vector();
									Vector v_tb1 = new Vector();
									ArrayList a_measunit = new ArrayList();
									tempVariables=new ArrayList();
									for(int j=0;j<variables.size();j++)
									{
										variable1 = (String)variables.get(j);
										tok1 = new StringTokenizer(variable1,":");
										while(tok1.hasMoreTokens())
										{
											serverName=tok1.nextToken();
											if(serverName.equals((String)availableServers.get(serverCount)))
												tempVariables.add(variable1);
											tok1.nextToken();
											tok1.nextToken();
										}
									}
									for(int m=0;m<tempVariables.size();m++)
									{
										s_var =(String) tempVariables.get(m);
										StringTokenizer tokens = new StringTokenizer(s_var,":");
										while(tokens.hasMoreTokens())
										{
											tokens.nextToken();
											s_test = tokens.nextToken();
											s_measure = tokens.nextToken();
										}
										String mes="";
										String displayname="";
										StringTokenizer meas=new StringTokenizer(s_measure,"#");
										if(meas.hasMoreTokens() )
											mes=meas.nextToken();
										else
											mes=s_measure;
										if(meas.hasMoreTokens() )
											displayname=meas.nextToken();
										else
											displayname=s_measure;

										if(displayname.equalsIgnoreCase("Session duration"))
										{
											displayname=displayname;
										}
										st_value = reportInfo.getValue("CITRIX SESSION REPORT",s_var);
										v_val.add(st_value);
										StringTokenizer st_val=new StringTokenizer(st_value,",");
										int countTokens=st_val.countTokens();
										String unitmeasure="";
										if(s_measure!=null && s_measure.indexOf("(")>0)
										{
											unitmeasure = s_measure.substring(s_measure.indexOf("(")+1,s_measure.lastIndexOf(")"));
										}
										else
										{
											unitmeasure = tablesInfo.getUnitForMeasure(s_test,mes);
										}
										String colHeader1 = intlmp.getTextDescription("reporter.common."+displayname);
										String dispmeasure = "";
										if(st_value.indexOf("Avg")>-1 && st_value.indexOf("Max")>-1 && st_value.indexOf("Pct")>-1)
										{
											if(AddFields.equals(""))
											AddFields=displayname;
											else
											AddFields=AddFields+","+displayname;

											if(FieldsTb2forDis.equals(""))
												FieldsTb2forDis=st_value;
											else
												FieldsTb2forDis+=","+st_value;
											for (int l=0;l<countTokens;l++)
											{
												if(FieldsTb2.equals(""))
													FieldsTb2=mes+(l+1);
												else
													FieldsTb2+=","+mes+(l+1);
											}
											if(addMapping.equals(""))
											{
												addMapping=mes+"1#"+mes+countTokens;
											}
											else
											{
												addMapping+=","+mes+"1#"+mes+countTokens;
											}
											a_measunit.add(unitmeasure+"="+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 tmpTok = st_tok.nextToken();
													String measureUnit=(String)a_measunit.get(cnt);
													StringTokenizer unitValue=new StringTokenizer(measureUnit,"=");
													String measUnitDisp = unitValue.nextToken();
													vec1.add(intlmp.getTextDescription("reporter.common."+displayname)+"("+measUnitDisp+")"+"-"+"("+intlmp.getTextDescription("reporter.common."+tmpTok)+")");
													if (tmpTok!=null && tmpTok.equalsIgnoreCase("count"))
													{
													}
													else if(str!=null)
													{
														subHeaders.add(intlmp.getTextDescription("reporter.common."+tmpTok));
													}
													totalColumnCount++;
												}
											}
											if(!StringUtils.isNull(unitmeasure))
											{
												unitForMeasure.put(colHeader1,unitmeasure);
											}
											sessionDetailsCols.put(colHeader1,subHeaders);
											cnt++;
										}
										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) )
										{
											String adds =displayname;
											if(AddFields.equals(""))
												AddFields=displayname;
											else
												AddFields=AddFields+","+displayname;

											if(FieldsTb2forDis.equals(""))
												FieldsTb2forDis=st_value;
											else
												FieldsTb2forDis+=","+st_value;

											for (int l=0;l<countTokens;l++)
											{
												if(FieldsTb2.equals(""))
													FieldsTb2=mes+(l+1);
												else
													FieldsTb2+=","+mes+(l+1);
											}
											if(addMapping.equals(""))
											{
												addMapping=mes+"1#"+mes+countTokens;
											}
											else
											{
												addMapping+=","+mes+"1#"+mes+countTokens;
											}
											if(unitmeasure!=null && !unitmeasure.equals(""))
											{
												a_measunit.add(unitmeasure+"="+countTokens);
											}
											else
											{
												if(displayname.indexOf("(")>-1)
													a_measunit.add(displayname.substring(displayname.indexOf("(")+1,displayname.length()-1)+"="+countTokens);
												else
													a_measunit.add("-="+countTokens);
											}
											if(displayname.indexOf("(")>-1)
												displayname=displayname.substring(0,displayname.indexOf("("));
											JSONArray subHeaders = new JSONArray();
											String colHeader = intlmp.getTextDescription("reporter.common."+displayname);
											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 tmpTok = st_tok.nextToken();
													String measureUnit=(String)a_measunit.get(cnt);
													StringTokenizer unitValue=new StringTokenizer(measureUnit,"=");
													String measUnitDisp = unitValue.nextToken();
													vec1.add(intlmp.getTextDescription("reporter.common."+displayname)+"("+measUnitDisp+")"+"-"+"("+intlmp.getTextDescription("reporter.common."+tmpTok)+")");
													if (tmpTok!=null && tmpTok.equalsIgnoreCase("count"))
													{
													}
													else if(str!=null)
													{
														subHeaders.add(intlmp.getTextDescription("reporter.common."+tmpTok));
													}
													totalColumnCount++;
												}
											}
											if(!StringUtils.isNull(unitmeasure) && !unitmeasure.equals("Number"))
											{
												unitForMeasure.put(colHeader,unitmeasure);
											}
											sessionDetailsCols.put(colHeader,subHeaders);
											cnt++;
										}
										else if(st_value.indexOf("Count")>-1 || st_value.indexOf("Avg")>-1 || st_value.indexOf("Max")>-1||st_value.equals("")||st_value.indexOf("Pct")>-1)
										{
											if(AddFields.equals(""))
												AddFields=displayname;
											else
												AddFields=AddFields+","+displayname;

											if(FieldsTb2forDis.equals(""))
												FieldsTb2forDis=st_value;
											else
												FieldsTb2forDis+=","+st_value;

											for (int l=0;l<countTokens;l++)
											{
												if(FieldsTb2.equals(""))
													FieldsTb2=mes+(l+1);
												else
													FieldsTb2+=","+mes+(l+1);
											}
											if(addMapping.equals(""))
											{
												addMapping=mes+"1#"+mes+countTokens;
											}
											else
											{
												addMapping+=","+mes+"1#"+mes+countTokens;
											}
											if(unitmeasure.equalsIgnoreCase(""))
												a_measunit.add("-=1");
											else
												a_measunit.add(unitmeasure+"=1");

											JSONArray subHeaders = new JSONArray();
											String colHeader = intlmp.getTextDescription("reporter.common."+displayname);
											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 tmpTok = st_tok.nextToken();
													vec1.add(intlmp.getTextDescription("reporter.common."+displayname)+"-"+"("+intlmp.getTextDescription("reporter.common."+tmpTok)+")");
													if (tmpTok!=null && tmpTok.equalsIgnoreCase("count"))
													{
													}
													else if(str!=null)
													{
														subHeaders.add(intlmp.getTextDescription("reporter.common."+tmpTok));
													}
													totalColumnCount++;
												}
											}
											if(!StringUtils.isNull(unitmeasure))
											{
												unitForMeasure.put(colHeader,unitmeasure);
											}
											sessionDetailsCols.put(colHeader,subHeaders);
											cnt++;
										}
										for(int x=0;x< v_val.size();x++)
										{
											v_val1.add(v_val.get(x));
										}
										v_val = new Vector();
									}
									AddFields=AddFields+",No_of_sessions_completed";
									if(addMapping.equals(""))
										addMapping="No_of_sessions_completed#No_of_sessions_completed";
									else
										addMapping+=",No_of_sessions_completed#No_of_sessions_completed";
									if(FieldsTb2forDis.equals(""))
										FieldsTb2forDis="-";
									else
										FieldsTb2forDis=FieldsTb2forDis+",-";

									if(FieldsTb2.equals(""))
										FieldsTb2="No_of_sessions_completed";
									else
										FieldsTb2+=",No_of_sessions_completed";

									String noOfSessionsCompleted = intlmp.getTextDescription("reporter.thin.session.Sessions completed");
									String topUniqueUsers = congigtop+" "+intlmp.getTextDescription("reporter.thin.reporter.thin.session.users")+" "+intlmp.getTextDescription("reporter.thin.by usage");
									String longestSessions =congigtop+" "+intlmp.getTextDescription("reporter.thin.session.longest sessions");
									sessionDetailsCols.put(noOfSessionsCompleted,new JSONArray());
									sessionDetailsCols.put(longestSessions,new JSONArray());
									sessionDetailsCols.put(topUniqueUsers,new JSONArray());
									vec1.add(intlmp.getTextDescription("reporter.thin.session.Sessions completed"));
									sessionDetaileTableJson.put("unitForMeasure",unitForMeasure);
									sessionDetaileTableJson.put("columns",sessionDetailsCols);
									v_val1 = new Vector();
									JSONArray measureData = new JSONArray();
									if(dispHash!=null && dispHash.size()>0)
									{
										String tempskey1="";
										Iterator tempitr1 =(dispHash.keySet()).iterator();
										while(tempitr1.hasNext())
										{
											JSONArray tmp = new JSONArray();
											tempskey1 = (String)tempitr1.next();
											serverToken=new StringTokenizer(tempskey1,"~");
											tempVar=serverToken.nextToken();
											serverName=serverToken.nextToken();
											String dispTempVar = tempVar;
											if(tempVar!=null && tempVar.endsWith(":NULL"))
												dispTempVar = tempVar.substring(0,tempVar.indexOf(":NULL"));
											v_forpdf.add(tempVar);

											if(serverName.equals((String)availableServers.get(serverCount)))
											{
												Report_data= (ArrayList)dispHash.get(tempskey1);
												String s_qryStringses2="";
												String s_qryStringses3="";
												s_qryStringses2 = "../servlet/com.eg.ErCtxServerReportC?er_type=No&select_farm="+s_farmserver+"&select_server1="+tempVar+"&topusers=no&er_excwe="+excludeweekend+"&pdfTime="+pdfTime+"&er_gtype=Citrix&er_rtype=Session&isSubmit=true&er_trgttype=Session Report&er_tbound="+tbound+"&er_timeline="+erd.s_timeline+"&startdate="+request.getParameter("startdate")+"&minfrom="+minfrom2+"&minto="+minto2+"&enddate="+request.getParameter("enddate")+"&timefrom="+tfrom+"&timeto="+tto+"&starthr="+request.getParameter("starthr")+"&endhr="+request.getParameter("endhr")+"&startmin="+strmin+"&endmin="+enmin+"&uid=" + loginid+"&er_trenddata="+request.getParameter("er_trenddata")+"&er_select_server="+s_server+"&select_compType="+((String)availableServers.get(serverCount))+"&inidate="+currentDateFormat+"&er_option="+er_option+"&er_site="+er_site;
												s_qryStringses3 = "../servlet/com.eg.ErCtxServerReportC?er_type=No&select_farm="+s_farmserver+"&select_server1="+tempVar+"&topusers=users&isSubmit=true&er_excwe="+excludeweekend+"&pdfTime="+pdfTime+"&er_gtype=Citrix&er_rtype=Session&er_trgttype=Session Report&er_tbound="+tbound+"&er_timeline="+erd.s_timeline+"&startdate="+request.getParameter("startdate")+"&minfrom="+minfrom2+"&minto="+minto2+"&enddate="+request.getParameter("enddate")+"&timefrom="+tfrom+"&timeto="+tto+"&starthr="+request.getParameter("starthr")+"&endhr="+request.getParameter("endhr")+"&startmin="+strmin+"&endmin="+enmin+"&uid=" + loginid+"&er_trenddata="+request.getParameter("er_trenddata")+"&er_select_server="+s_server+"&select_compType="+((String)availableServers.get(serverCount))+"&inidate="+currentDateFormat+"&er_option="+er_option+"&er_site="+er_site;

												JSONObject jObj1 = new JSONObject();
												jObj1.put("dispVal",dispTempVar);
												jObj1.put("hrefUrl","-");
												tmp.add(dispTempVar);
												if(tempVar.indexOf(":NULL")>-1)
													lst_dat1.add(tempVar.substring(0,tempVar.indexOf(":NULL")));
												else
													lst_dat1.add(tempVar);

												String Qsforuserchart ="../servlet/com.eg.ErCtxServerReportC?select_farm="+s_farmserver+"&er_type=No&isSubmit=true&select_server1="+tempVar+"&er_excwe="+excludeweekend+"&pdfTime="+pdfTime+"&er_gtype=Citrix&er_rtype=Session&er_trgttype=Session Report&er_tbound="+tbound+"&er_timeline="+erd.s_timeline+"&startdate="+request.getParameter("startdate")+"&minfrom="+minfrom2+"&minto="+minto2+"&enddate="+request.getParameter("enddate")+"&timefrom="+tfrom+"&timeto="+tto+"&starthr="+request.getParameter("starthr")+"&endhr="+request.getParameter("endhr")+"&startmin="+strmin+"&endmin="+enmin+"&uid=" + loginid+"&er_trenddata="+request.getParameter("er_trenddata")+"&daychartfor=uniqueuser"+"&er_select_server="+s_server+"&select_compType="+((String)availableServers.get(serverCount))+"&inidate="+currentDateFormat+"&er_option="+er_option+"&er_site="+er_site;
												boolean isUnwantedData = false;
												isUnwantedData = getDataChange(Report_data);		// for bugId : 10811
												if(isUnwantedData)
													continue;
												for(int i=0;i<Report_data.size();i++)
												{
													v_forpdf.add((String)Report_data.get(i));
													String s_avgmax="";
													if(i==0)
													{
														String Struser = (String)Report_data.get(i);
														if(!Struser.equals("-"))
														{
															JSONObject jObj = new JSONObject();
															jObj.put("dispVal",Struser);
															jObj.put("hrefUrl",Qsforuserchart+"&select_server="+tempVar+"&responseType=json&thinClientSessionAction=submit");
															tmp.add(jObj);
															lst_dat1.add((String)Report_data.get(i));
														}
														else
														{
															
															s_avgmax=(String)Report_data.get(i);
															if(s_avgmax.equals("-1"))
																	s_avgmax="-";
															JSONObject jObj = new JSONObject();
															jObj.put("dispVal",Struser);
															jObj.put("hrefUrl","-");
															tmp.add(Struser);
															lst_dat1.add((String)Report_data.get(i));
														}
													}
													else
													{
														s_avgmax=(String)Report_data.get(i);
														if(s_avgmax!=null && s_avgmax.equals("-1"))
														{
															s_avgmax="-";
														}
														if(s_avgmax!=null && (s_avgmax.trim()).length()==0)
														{
															s_avgmax="-";
														}
														if(s_avgmax!=null && !s_avgmax.equals("-"))
														{
															s_avgmax=String.valueOf(Math.round(Float.parseFloat(s_avgmax)));
														}
														JSONObject jObj = new JSONObject();
														jObj.put("dispVal",s_avgmax);
														jObj.put("hrefUrl","-");
														tmp.add(s_avgmax);

														lst_dat1.add(s_avgmax);
													}
													pdfHashtable.put(tempskey1,v_forpdf);
													
												}
												String check = "0";
												String rptdata ="";
												String session_cmd="";
												Object ob_chk=(Object)check;
												rptdata =(String)Report_data.get(Report_data.size()-1);
												if(v_data1!=null && !v_data1.isEmpty())
													session_cmd=(String)v_data1.get(0);
												if(session_cmd ==null || session_cmd.equals("") || session_cmd.equals(check) || rptdata.equals("-"))
												{
													s_qryStringses2="-";
													s_qryStringses3="-";

													JSONObject jObj = new JSONObject();
													jObj.put("dispVal","-");
													jObj.put("hrefUrl",s_qryStringses2);
													tmp.add(s_qryStringses2);

													jObj = new JSONObject();
													jObj.put("dispVal","-");
													jObj.put("hrefUrl",s_qryStringses3);
													tmp.add(s_qryStringses3);
												}
												else
												{
													JSONObject jObj = new JSONObject();
													jObj.put("dispVal","top.gif");
													jObj.put("hrefUrl",s_qryStringses2+"&responseType=json&thinClientSessionAction=submit");
													tmp.add(jObj);

													jObj = new JSONObject();
													jObj.put("dispVal","top.gif");
													jObj.put("hrefUrl",s_qryStringses3+"&responseType=json&thinClientSessionAction=submit");
													tmp.add(jObj);
												}
												measureData.add(tmp);
											}
										}
									}
									sessionDetaileTableJson.put("measureData",measureData);
									lst_dat2.add(lst_dat1);
									lst_dat1 = new LinkedList();
									vec3.add(vec1);
									vec1 = new Vector();
									sessionDetaileTableJson.put("TOTAL_COLUMN_COUNT",String.valueOf(totalColumnCount));
									sessionDetaileTableJson.put("SINGLE_SUBCOLUMN_COUNT",String.valueOf(havingSingleColumn));
									sessionDetailsTableArr.add(sessionDetaileTableJson);
								}
							}
						}
						json.put("sessionDetailsTableArr",sessionDetailsTableArr);

						String table1 = intlmp.getTextDescription("reporter.common.SUMMARY FOR")+" "+headerKeyName;
						String table2 = intlmp.getTextDescription("reporter.common.SESSION DETAILS FOR")+" "+headerKeyName;
						HashMap PdfData = new HashMap();
						PdfData.put(table1, v_pdf1);
						PdfData.put(table2, v_forpdf);
						StringTokenizer st_fields=new StringTokenizer(FieldsTb2,",");
						int dtlXCoor[]=new int[st_fields.countTokens()];
						int dtlFieldwidth[]=new int[st_fields.countTokens()];
						int noofcols=st_fields.countTokens();
						int colsize=752/noofcols;
						for (int i=0;i<noofcols;i++)
						{
							if( i==0)
							{
								dtlFieldwidth[i]=752;
								dtlXCoor[i]=0;
							}
							else
							{
								if (i==1)
								{
									dtlXCoor[i]=5;
									dtlFieldwidth[i]=colsize;
								}
								else
								{
									dtlXCoor[i]=dtlXCoor[i-1]+colsize;
									dtlFieldwidth[i]=colsize;
								}
							}
						}
						int [][] xCoor = new int [][] {{0, 200, 450, 600},dtlXCoor};
						int [][] fieldWidth = new int [][] {{752, 100, 100, 100},dtlFieldwidth};
						int [][] fieldHeight= new int [][] {{10, 10, 10, 10},{10, 10, 10, 10, 10,10}};
						boolean fieldWidthInPercentage = false;
						int [][] lineXCoor = new int [][] {{0, 0, 0},{0, 0, 0}};
						int [][] lineYCoor = new int [][] {{10, 28, 0},{10, 28, 0}};
						if(FieldsTb2forDis.equalsIgnoreCase("$F{title},-,Count,Avg,Avg,-"))
						{
							xCoor = new int [][] {{100, 75, 250, 325},{100, 10, 50,100,150,280,350}};
							fieldWidth = new int [][] {{100, 30, 30, 20},{100,12,15,16,20,15,15}};
						}
						TreeMap Map_param = new TreeMap();
						Map_param.put("pageLayout", "Landscape");
						Map_param.put("fields", new String []{"title,Measures,Values",FieldsTb2});
						Map_param.put("fieldTitleMapping", table1+"#"+table2);
						Map_param.put("display", new String []{"$F{title},Measures,Values",FieldsTb2forDis});
						Map_param.put("fieldWidth", fieldWidth);
						Map_param.put("dataBag", PdfData);
						Map_param.put("fieldWidthInPercentage", new Boolean(fieldWidthInPercentage));
						Map_param.put("xCoor", xCoor);
						Map_param.put("addDisplay", new String []{"",AddFields});
						Map_param.put("addMapping", new String []{"",addMapping});
						if (excludeweekend!=null && !excludeweekend.equalsIgnoreCase("No"))
						Map_param.put("subreportTitle", "Excludes "+Days);
						Vector vtforexparam=new Vector();
						vtforexparam.add("Thin Client Session Report");
						vtforexparam.add("From "+erd.s_stdate+" hrs "+""+" To "+erd.s_enddate+"  hrs");
						Vector vdata=new Vector();
						vdata.add(Map_param);
						vdata.add(vtforexparam);
						Hashtable htforpdfdata=new Hashtable();
						htforpdfdata.put("commandName","DynamicTest");
						htforpdfdata.put("pdfFileName", "Thin Client-Session");
						
						htforpdfdata.put("pdfData",sessionPdfData);
						session.setAttribute("sessionVal", htforpdfdata);
						HashMap param1 =new HashMap();
						param1.put("REPORT_PARAM",ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap())));
						param1.put("REPORT_DATA",sessionPdfData);
						param1.put("fileName","Session-report");
						session.setAttribute("parameters", param1);
					}
					else
					{
						json.put("DataType","SessionAndUserData");
						if(arr_data1!=null && !arr_data1.isEmpty())
						{
							Vector v_pdfdata = new Vector();
							HashMap ht_table1 = (HashMap)arr_data1.get(0);
							String server1 = request.getParameter("select_server1");
							session.setAttribute("sessionDatatop",arr_data1);
							String reqser=request.getParameter("select_server1");
							String reqses=request.getParameter("topsession");
							String requser=request.getParameter("topusers");
							String reqfarm=request.getParameter("select_farm");
							String titleforlink="";
							if(reqser!=null&&reqser.equals("no")&&reqses!=null&&reqses.equals("yes"))
							{
								titleforlink = "Longest sessions in "+intlmp.getTextDescription("reporter.thin.session."+headerKeyName);
								s_tit = intlmp.getTextDescription("reporter.thin.session.Longest sessions in")+" "+intlmp.getTextDescription("reporter.thin.session."+headerKeyName);
							}
							else if(reqser!=null&&!reqser.equals("no")&&requser!=null&&requser.equals("no"))
							{
								String dispServerName = server1;
								if(server1!=null && server1.endsWith(":NULL"))
									dispServerName = server1.substring(0,server1.indexOf(":NULL"));
								titleforlink = intlmp.getTextDescription("reporter.thin.session.Longest sessions in")+" "+intlmp.getTextDescription("reporter.thin.session."+headerKeyName);
								s_tit = intlmp.getTextDescription("reporter.thin.session.Longest sessions in")+"  "+intlmp.getTextDescription("reporter.thin.session."+headerKeyName);
							}
							else if(reqser!=null&&!reqser.equals("no")&&requser!=null&&requser.equals("users"))
							{
								String dispServerName = server1;
								if(server1!=null && server1.endsWith(":NULL"))
									dispServerName = server1.substring(0,server1.indexOf(":NULL"));
								titleforlink = "users in "+dispServerName;

								s_tit = intlmp.getTextDescription("reporter.thin.Top")+" "+intlmp.getTextDescription("reporter.thin.users in")+" "+dispServerName;
							}
							else
							{
								titleforlink = "Top users in "+intlmp.getTextDescription("reporter.thin.session."+headerKeyName);
								s_tit = intlmp.getTextDescription("reporter.thin.session.Top users in")+" "+intlmp.getTextDescription("reporter.thin.session."+headerKeyName);
							}

							json.put("summaryTableTitle",s_tit);
							session.setAttribute("title",titleforlink);

							if (qs!=null && !qs.equals(""))
							{
								pageParams.put("showBackButton","true");
								pageParams.put("backBtnUrl",qs+"?isSubmit=true");
							}
							else
							{
								pageParams.put("showBackButton","false");
							}

							HashMap ht_map = (HashMap)arr_data1.get(0);
							String totfields ="title";
							String fieldstodisp="$F{title}";
							JSONObject colDetails = new JSONObject();
							if(ht_map.containsKey("trgt_host"))
							{
								if(totfields.equals(""))
								{
									totfields="Server";
								}
								else
								{
									totfields+=",Server";
								}
								if(fieldstodisp.equals(""))
								{
									fieldstodisp="Server";
								}
								else
								{
									fieldstodisp+=",Server";
								}

								colDetails.put(intlmp.getTextDescription("reporter.thin.Server"),new JSONArray());
								vec.add(intlmp.getTextDescription("reporter.thin.Server"));
							}
							if(totfields.equals(""))
							{
								totfields="Username";
							}
							else
							{
								totfields+=",Username";
							}
							if(fieldstodisp.equals(""))
							{
								fieldstodisp="Username";
							}
							else
							{
								fieldstodisp+=",Username";
							}
							colDetails.put(intlmp.getTextDescription("reporter.thin.Username"),new JSONArray());
							vec.add(intlmp.getTextDescription("reporter.thin.Username"));
							if(ht_map.containsKey("login_time"))
							{
								if(totfields.equals(""))
								{
									totfields="Logintime";
								}
								else
								{
									totfields+=",Logintime";
								}
								if(fieldstodisp.equals(""))
								{
									fieldstodisp="Logintime";
								}
								else
								{
									fieldstodisp+=",Logintime";
								}
								colDetails.put(intlmp.getTextDescription("reporter.thin.Logintime"),new JSONArray());
								vec.add(intlmp.getTextDescription("reporter.thin.Logintime"));
							}
							if(totfields.equals(""))
							{
								totfields="Duration_of_access";
							}else
							{
								totfields+=",Duration_of_access";
							}
							if(fieldstodisp.equals(""))
							{
								fieldstodisp="Duration_of_ access";
							}
							else
							{
								fieldstodisp+=",Duration_of_access";
							}
							colDetails.put(intlmp.getTextDescription("reporter.thin.Duration of access")+" ("+intlmp.getTextDescription("reporter.thin.Mins")+")",new JSONArray());

							vec.add(intlmp.getTextDescription("reporter.thin.Duration of access ")+"("+intlmp.getTextDescription("reporter.thin.Mins")+")");
							HashMap ht_table=null;
							String server="";
							String LoginTime="";
							String s_duration="";
							String user="";
							String userTemp="";

							JSONArray measureData = new JSONArray();

							for(int j=0;j<arr_data1.size();j++)
							{
								JSONArray tmp = new JSONArray();
								Object v1 = (Object)arr_data1.get(j);
								if(v1 instanceof Hashtable)
								{
									continue;
								}
								ht_table = (HashMap)arr_data1.get(j);
								server = (String)ht_table.get("trgt_host");
								userTemp = (String)ht_table.get("username");
								String s_compType="";
								if(userTemp.indexOf(":")>0)
								{
									user=userTemp.substring(0,userTemp.indexOf(":"));
									s_compType=userTemp.substring(userTemp.indexOf(":")+1,userTemp.length());
								}
								else
									user=userTemp;

								LoginTime = (String)ht_table.get("login_time");
								s_duration = (String)ht_table.get("duration");

								queryforuserlink="../servlet/com.eg.ErCtxServerReportC?er_rtype=User&er_gtype=Citrix&er_timeline="+erd.s_timeline+"&select_server1=no&isSubmit=true&er_trgttype=User Report&timefrom=" + tfrom + "&timeto=" + tto + "&minfrom=" + minfrom2 + "&minto=" + minto2 + "&startdate=" +URLEncoder.encode(request.getParameter("startdate")) + "&enddate=" +URLEncoder.encode(request.getParameter("enddate"))+ "&starthr="+URLEncoder.encode(request.getParameter("starthr"))+ "&pdfTime="+URLEncoder.encode(pdfTime)+"&endhr=" +request.getParameter("endhr") +"&startmin="+strmin+"&endmin="+enmin+ "&currTime=" + cTime + "&er_tbound="+tbound+"&select_farm=" + s_farmserver + "&er_excwe=" + excludeweekend + "&showAll=false &er_compType="+request.getParameter("select_compType")+"&showSearch=false&likeAllUsers=false&onlyThisUser=false&&er_user=" + EgURLEncoder.encode(user,"UTF-8")+"&uid="+loginid+"&inidate="+URLEncoder.encode(currentDateFormat)+"&forwardTo=ErCtxUserReportJson&enableBack=true"+"&er_option="+er_option+"&er_site="+er_site;

								String queryforuserlink1="../servlet/com.eg.ErCtxServerReportC?er_rtype=User&er_gtype=Citrix&er_timeline="+erd.s_timeline+"&er_trgttype=User Report&isSubmit=true&timefrom=" + tfrom + "&timeto=" + tto + "&minfrom=" + minfrom2 + "&minto=" + minto2 + "&startdate=" +URLEncoder.encode(request.getParameter("startdate")) + "&enddate=" +URLEncoder.encode(request.getParameter("enddate"))+ "&starthr="+request.getParameter("starthr") + "&pdfTime="+URLEncoder.encode(pdfTime)+"&endhr=" +request.getParameter("endhr")+"&startmin="+strmin+"&endmin="+enmin+ "&currTime=" + cTime + "&er_tbound="+tbound+"&select_farm=" + s_farmserver + "&er_excwe=" + excludeweekend + "&showAll=false &er_compType="+request.getParameter("select_compType")+"&showSearch=false&likeAllUsers=false&onlyThisUser=false&&er_user="+EgURLEncoder.encode(user,"UTF-8")+ "&uid="+loginid+"&inidate="+URLEncoder.encode(currentDateFormat)+"&forwardTo=ErCtxUserReportJson&enableBack=true"+"&er_option="+er_option+"&er_site="+er_site;

								String backQuery="../servlet/com.eg.ErCtxServerReportC?er_type=No&topusers=users&select_server1=no&er_user="+EgURLEncoder.encode(user,"UTF-8")+"&showSearch=false&isSubmit=true&er_trenddata="+request.getParameter("er_trenddata")+"&er_select_server="+s_server+"&select_compType="+request.getParameter("select_compType")+"&select_farm=" + s_farmserver+"&er_option="+er_option+"&er_site="+er_site;//availableServers[server

								session.setAttribute("backQueryForsesion",backQuery);

								String backQuery_server="../servlet/com.eg.ErCtxServerReportC?er_type=No&isSubmit=true&topusers=users&select_server1="+EgURLEncoder.encode(server1,"UTF-8")+"&er_user="+EgURLEncoder.encode(user,"UTF-8")+"&showSearch=false&uid="+loginid+"&er_trenddata="+request.getParameter("er_trenddata")+"&er_select_server="+EgURLEncoder.encode(s_server,"UTF-8")+"&select_compType="+request.getParameter("select_compType")+"&er_option="+er_option+"&er_site="+er_site;

								session.setAttribute("backQSsessionserver",backQuery_server);

								if(server!=null&&server.endsWith(":NULL"))
								{
									server = server.substring(0,server.indexOf(":"));
								}
								if(ht_table.containsKey("trgt_host"))
								{
									v_pdfdata.add(server);

									JSONObject jObj = new JSONObject();
									jObj.put("dispVal",server);
									jObj.put("hrefUrl","-");
									tmp.add(jObj);
									lst_dat.add(server);
								}
								v_pdfdata.add(user);
								if (reqser!=null&&reqser.equals("no")&&requser!=null&&requser.equals("users")&&reqfarm!=null&&reqfarm.equals(s_farmserver))
								{
									JSONObject jObj = new JSONObject();
									jObj.put("dispVal",user);
									jObj.put("hrefUrl",queryforuserlink);
									tmp.add(jObj);
									lst_dat.add(user);
								}
								else if(reqser!=null&&!reqser.equals("no")&&requser!=null&&requser.equals("users"))
								{
									queryforuserlink1+="&select_server1="+EgURLEncoder.encode(server1,"UTF-8");

									JSONObject jObj = new JSONObject();
									jObj.put("dispVal",user);
									jObj.put("hrefUrl",queryforuserlink1);
									tmp.add(jObj);
									lst_dat.add(user);
								}
								else
								{
									JSONObject jObj = new JSONObject();
									jObj.put("dispVal",user);
									jObj.put("hrefUrl","-");
									tmp.add(jObj);
									lst_dat.add(user);
								}
								if(ht_table.containsKey("login_time"))
								{
									v_pdfdata.add(LoginTime);
									String logintimedisp=LoginTime.substring(0,LoginTime.indexOf(" "));
									JSONObject jObj = new JSONObject();
									jObj.put("dispVal",logintimedisp+" "+LoginTime.substring(LoginTime.indexOf(" ")));
									jObj.put("hrefUrl","-");
									tmp.add(jObj);
									lst_dat.add(logintimedisp+" "+LoginTime.substring(LoginTime.indexOf(" ")));
								}
								v_pdfdata.add(s_duration);
								JSONObject jObj = new JSONObject();
								jObj.put("dispVal",s_duration);
								jObj.put("hrefUrl","-");
								tmp.add(jObj);
								lst_dat.add(s_duration);
								measureData.add(tmp);
							}

							json.put("summaryTableJson",summaryTableJson);

							JSONObject sessionDetaileTableJson = new JSONObject();
							sessionDetaileTableJson.put("columns",colDetails);
							sessionDetaileTableJson.put("measureData",measureData);

							JSONArray sessionDetailsTableArr = new JSONArray(); 

							sessionDetailsTableArr.add(sessionDetaileTableJson);

							json.put("sessionDetailsTableArr",sessionDetailsTableArr);

							HashMap PdfData = new HashMap();
							PdfData.put(titleforlink,v_pdfdata);
						
							int [] xCoor=null;
							int [] fieldWidth=null;
							if(totfields.equals("title,Username,Duration_of_access"))
							{
								xCoor = new int []{0, 130,300};
								fieldWidth = new int [] {525,100, 100};

							}
							else if(totfields.equals("title,Username,Logintime,Duration_of_access"))
							{
								xCoor = new int []{0, 90,210,330};
								fieldWidth = new int [] {525,100, 100, 100};
							}
							else
							{
								xCoor = new int []{0, 15,130,250,370};
								fieldWidth = new int [] {525, 100, 100, 100,100};
							}
							int [] yCoor = new int []{0, 15, 15, 15,15};
							int []fieldHeight= new int []{10, 10, 10, 10, 30};
							boolean fieldWidthInPercentage = false;
							int [] lineXCoor = new int [] {0, 0, 0,0};
							int [] lineYCoor = new int [] {10, 28, 0,0};
							TreeMap Map_param = new TreeMap();
							Map_param.put("pageLayout", "portrait");
							Map_param.put("fields",totfields);
							Map_param.put("display",fieldstodisp);
							Map_param.put("dataBag",PdfData);
							Map_param.put("fieldWidthInPercentage", new Boolean(fieldWidthInPercentage));
							Map_param.put("xCoor", xCoor);
							Map_param.put("yCoor", yCoor);
							Map_param.put("fieldWidth", fieldWidth);
							if (excludeweekend!=null && !excludeweekend.equalsIgnoreCase("No"))
							{
								Map_param.put("subreportTitle", "Excludes"+Days);
							}
							Vector vtforexparam=new Vector();
							vtforexparam.add("Thin Client Session Report");
							vtforexparam.add("From	 "+erd.s_stdate+" hrs "+""+" To "+erd.s_enddate+"  hrs");
							Vector vdata=new Vector();
							vdata.add(Map_param);
							vdata.add(vtforexparam);
							Hashtable htforpdfdata=new Hashtable();
							htforpdfdata.put("commandName","DynamicTest");
							htforpdfdata.put("pdfData",sessionPdfData);
							htforpdfdata.put("pdfFileName","Thin Client Session Report");
							session.setAttribute("sessionVal", htforpdfdata);
							HashMap param1 =new HashMap();
							param1.put("REPORT_PARAM",ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap())));
							param1.put("REPORT_DATA",sessionPdfData);
							param1.put("fileName","Session-report");
							session.setAttribute("parameters", param1);
						}
					}
				}
				serverCount++;
				
				storeLastAccessedUrl = true;
			}
			else if(Daywisechart!=null)
			{
				if(er_uniqueUser!=null &&(er_uniqueUser.equalsIgnoreCase("true") || er_uniqueUser.equalsIgnoreCase("yes")))
				{
					storeLastAccessedUrl = true; // this to avoid invalid last accessed url storage in session 
				}
				else
				{
					storeLastAccessedUrl = false; // this to avoid invalid last accessed url storage in session 
				}

				json.put("DataType","dayWiseAndUserWiseData");

				String Strserver =request.getParameter("select_server1");
				String backQueryfromchart="../servlet/com.eg.ErCtxServerReportC?daychartfor=&isSubmit=true&select_server=";

				JSONArray sessionDetailsTableArr = new JSONArray();

				JSONObject sessionDetaileTableJson =new JSONObject();

				String sessionTableTitle = "";

				if(Strserver!=null&&!Strserver.equals(""))
				{
					String dispServerName = Strserver;
					if(Strserver!=null && Strserver.endsWith(":NULL"))
						dispServerName = Strserver.substring(0,Strserver.indexOf(":NULL"));

					sessionTableTitle = intlmp.getTextDescription("reporter.thin.Unique users")+" - "+dispServerName;
				}
				else
				{
					sessionTableTitle = intlmp.getTextDescription("reporter.thin.Unique users")+""+ headerKeyName;
				}

				json.put("summaryTableTitle",sessionTableTitle);

				if(backQueryfromchart!=null && !backQueryfromchart.equals(""))
				{
					pageParams.put("showBackButton","true");
					pageParams.put("backBtnUrl",backQueryfromchart);
				}
				else
				{
					pageParams.put("showBackButton","false");
				}
				if(Daywisechart==null ||Daywisechart.isEmpty())
				{
					json.put("dataAvailable","false");
					sessionDetaileTableJson.put("reporter.thin.No Measures Available for the current selection Associated",intlmp.getTextDescription("reporter.thin.No Measures Available for the current selection Associated"));
				}
				else
				{
					json.put("dataAvailable","true");
					HashMap ht_Daywisechart = new HashMap(Daywisechart);
					
					Set setofKeys =  new TreeSet();
					setofKeys= (Set)ht_Daywisechart.keySet();
					ArrayList listof_keys = new ArrayList(setofKeys);
					Collections.sort(listof_keys);
					for(int i=0;i<listof_keys.size();i++)
					{
						String url =(String)listof_keys.get(i);
						if(url.indexOf("url_")>-1)
						{
							String url_value = (String)ht_Daywisechart.get(url);
							url_value = url_value.substring(url_value.indexOf("(")+1,url_value.length()-1);
						}
					}
					ErFusionChartBean chartbean = new ErFusionChartBean();
					String xmlStringForFusionColumnChart = chartbean.getXmlDataforfusionbarpopupchartforURL(ht_Daywisechart);
					String er_mode = request.getParameter("er_mode");
					String dimension = "StackedColumn"+(er_mode != null && er_mode.equalsIgnoreCase("2D") ? "2" : "3" ) + "D";
					String swfpath = "/final/FusionCharts/swf/StackedColumn" + (er_mode != null && er_mode.equalsIgnoreCase("2D") ? "2" : "3" ) + "D.swf";
					sessionDetaileTableJson.put("xmlData",xmlStringForFusionColumnChart);
					sessionDetaileTableJson.put("swfpath",swfpath);
					sessionDetaileTableJson.put("er_mode",er_mode);
					sessionDetaileTableJson.put("xAxisLabel",chartbean.getXAxisDataLabel());
					sessionDetaileTableJson.put("yAxisLabel",chartbean.getYAxisLabel());
					sessionDetaileTableJson.put("xAxisLabelText",chartbean.getXAxisLabel());
					JSONArray dataSet = new JSONArray();
					JSONObject s1=new JSONObject();
					s1.put("name","");
					s1.put("data",chartbean.getBarDataSet());
					s1.put("showInLegend",new Boolean(false));
					dataSet.add(s1);
					sessionDetaileTableJson.put("DataSet",dataSet);
					sessionDetaileTableJson.put("title","");
					sessionDetaileTableJson.put("chartType","column");
					int width=100;
					if(chartbean.getXAxisDataLabel().size()<3)
						width=800;
					else
					{
						width+=chartbean.getXAxisDataLabel().size()*30;
						if(width<500)
							width=450;	
					}
					sessionDetaileTableJson.put("chartHeight","300");
					sessionDetaileTableJson.put("chartWidth",width);	
					sessionDetaileTableJson.put("drildown","newtab");
					sessionDetaileTableJson.put("daychartof","uniqueusers");
					sessionDetaileTableJson.put("inside",new Boolean(true));
				}
				json.put("dayWiseChartJson",sessionDetaileTableJson);
				Vector Chartdata =new Vector();
				String pdftitle="";
				String strCompType_1 = request.getParameter("select_compType");
				strCompType_1 = intlmp.getComponentTypeDescription(strCompType_1);
				if(StrServer!=null&&!StrServer.equals(""))
					pdftitle = "Daywise User Details - "+StrServer+" component type:-"+strCompType_1;
				else
					pdftitle = "Daywise User Details - "+s_farmserver+" component type:-"+strCompType_1;
				Chartdata.add(pdftitle);
				String control_servlet_pdf = EgInstallInfo.getUrlPrefix()+"//" + (new EgSpecsInfo("manager")).getEGServer() + ":" + request.getServerPort() + "/final/servlet/com.eg.";
				String pdfQs ="";
				if(StrServer!=null&&!StrServer.equals(""))
				{
					pdfQs = control_servlet_pdf+"ErCtxServerReportC?er_width=450&er_height=300&er_view=imageprint&er_rtype=Session&er_gtype=Citrix&er_tbound="+tbound+"&er_trgttype=Session Report&select_farm="+s_farmserver+"&er_timeline="+timeline+"&er_trenddata=" + datatype + "&er_stdate="+stdate+"&er_excwe= " + excludeweekend + "&er_enddate="+enddate+"&timefrom="+tfrom+"&timeto="+tto+"&er_sthr="+sthr+"&er_endhr="+endhr+"&select_server1="+StrServer+"&uid="+loginid+"&minfrom="+minfrom2+"&minto="+minto2+"&daychartfor="+StrChartfor+"&er_select_server="+s_server+"&select_compType="+request.getParameter("select_compType");
				}
				else
				{
					pdfQs = control_servlet_pdf+"ErCtxServerReportC?er_width=450&er_height=300&er_view=imageprint&er_rtype=Session&er_gtype=Citrix&er_tbound="+tbound+"&er_trgttype=Session Report&select_farm="+s_farmserver+"&er_timeline="+timeline+"&er_trenddata=" + datatype + "&er_stdate="+stdate+"&er_excwe= " + excludeweekend + "&er_enddate="+enddate+"&timefrom="+tfrom+"&timeto="+tto+"&er_sthr="+sthr+"&er_endhr="+endhr+"&select_server1=&uid="+loginid+"&minfrom="+minfrom2+"&minto="+minto2+"&daychartfor="+StrChartfor+"&er_select_server="+s_server+"&select_compType="+request.getParameter("select_compType");
				}
				Chartdata.add(pdfQs);
				boolean serverEnable=false;
				if(Strserver!=null && !Strserver.equals(""))
				{
					serverEnable=true;
					String dispServerName = Strserver;
					StringTokenizer stToken = new StringTokenizer(Strserver,":");
					if(stToken.countTokens() ==3)
					{
						String strComp = stToken.nextToken();
						String port = stToken.nextToken();
						if(port.equalsIgnoreCase("NULL"))
							Strserver = strComp+":"+intlmp.getComponentTypeDescription(stToken.nextToken());
						else
							Strserver = strComp+":"+port+":"+intlmp.getComponentTypeDescription(stToken.nextToken());
					}
					if(Strserver!=null && Strserver.endsWith(":NULL"))
						dispServerName = Strserver.substring(0,Strserver.indexOf(":NULL"));

					s_tit = intlmp.getTextDescription("reporter.thin.User details for Server")+": "+Strserver;
				}
				else
				{
					if(s_farmserver!=null && s_farmserver.equalsIgnoreCase("--Default--"))
					{
						s_tit = intlmp.getTextDescription("reporter.thin.User details for Zone")+": "+intlmp.getTextDescription("reporter.thin.Default");
					}
					else
					{
						s_tit = intlmp.getTextDescription("reporter.thin.User details for Zone")+": "+s_farmserver;
					}
				}

				JSONObject userTable = new JSONObject();
				JSONArray colValues = new JSONArray();
				
				//check
				String srt=s_tit;
				if(srt.lastIndexOf(':')>-1)
				{	
					
					String srt1 = srt.substring(srt.lastIndexOf(":")+1);
					
					if(srt1.equalsIgnoreCase("NULL"))
						srt = srt.substring(0, srt.lastIndexOf(":"));
				}
				s_tit=srt;
				//

				userTable.put("tableTitle",s_tit);

				userTable.put("subTitle",intlmp.getTextDescription("reporter.thin.User"));
				vec.add(intlmp.getTextDescription("reporter.thin.User"));

				session.setAttribute("userData",DaywiseUserData);
				Iterator itr=DaywiseUserData.keySet().iterator();
				int count=0;
				while(itr.hasNext())
				{
					String user=(String)itr.next();
					Vector u_data=(Vector)DaywiseUserData.get(user);

					String queryforuserlink1 = "../servlet/com.eg.ErCtxServerReportC?er_trgttype=User Report&er_rtype=User&er_gtype=Citrix&isSubmit=true&er_timeline="+er_timeline+"&er_trgttype=User Report&timefrom=" + tfrom + "&timeto=" + tto + "&minfrom=" + minfrom2 + "&minto=" + minto2 + "&startdate=" +URLEncoder.encode(stdate) + "&enddate=" + URLEncoder.encode(enddate) + "&starthr=" + sthr + "&pdfTime="+URLEncoder.encode(pdfTime)+"&endhr=" + endhr +"&startmin="+strmin+"&endmin="+enmin+ "&currTime=" + cTime +"&select_farm=" + EgURLEncoder.encode(s_farmserver,"UTF-8") + "&er_excwe=" + excludeweekend + "&showAll=false  &er_compType="+request.getParameter("select_compType")+"&showSearch=false&likeAllUsers=false&onlyThisUser=false&&er_user=" +  EgURLEncoder.encode(user,"UTF-8")  + "&uid=" + EgURLEncoder.encode(loginid,"UTF-8")+"&select_server1=no&inidate="+URLEncoder.encode(currentDateFormat)+"&er_trenddata="+request.getParameter("er_trenddata")+"&er_option="+er_option+"&er_site="+er_site+"&er_RmDispName="+EgURLEncoder.encode("User Session Details","UTF-8");

					String backQuery="../servlet/com.eg.ErCtxServerReportC?select_farm="+EgURLEncoder.encode(s_farmserver,"UTF-8")+"&er_type=No&er_excwe="+excludeweekend+"&pdfTime="+URLEncoder.encode(pdfTime)+"&isSubmit=true&er_gtype=Citrix&er_rtype=Session&er_trgttype=Session Report&er_tbound="+tbound+"&er_timeline="+er_timeline+"&startdate="+URLEncoder.encode(stdate)+"&minfrom="+minfrom2+"&minto="+minto2+"&enddate="+URLEncoder.encode(enddate)+"&timefrom="+tfrom+"&timeto="+tto+"&starthr="+sthr+"&endhr="+endhr+"&startmin="+strmin+"&endmin="+enmin+"&uid=" + loginid+"&er_trenddata="+request.getParameter("er_trenddata")+"&daychartfor=uniqueuser&select_compType="+request.getParameter("select_compType")+"&er_select_server="+EgURLEncoder.encode(s_server,"UTF-8")+"&er_trenddata="+request.getParameter("er_trenddata");

					if(Strserver!=null)
						backQuery+="&select_server1="+EgURLEncoder.encode(Strserver,"UTF-8")+"&select_server="+EgURLEncoder.encode(Strserver,"UTF-8");
					session.setAttribute("backQueryForsesion",backQuery);
					boolean userLink=false;
					for(int i=0;i<(u_data.size()/2);i++)
					{
						String temp_st=(String)u_data.get(i+(i+1));
						if(temp_st!=null && !temp_st.equalsIgnoreCase("Session alive"))
						{
							userLink=true;
							break;
						}
					}
					if(userLink)
					{
						JSONObject userJsonObj = new JSONObject();
						userJsonObj.put("val",user);
						userJsonObj.put("hrefUrl",queryforuserlink1);
						colValues.add(userJsonObj);
						lst_dat.add(user);
					}
					else
					{
						JSONObject userJsonObj = new JSONObject();
						userJsonObj.put("val",user);
						userJsonObj.put("hrefUrl","-");
						colValues.add(userJsonObj);
						lst_dat.add(user);
					}
					if (count == (5-1))
					{
						count = 0;
					}
					else
					{
						count++;
					}
				}
				userTable.put("userTableValues",colValues);
				json.put("userTable",userTable);
				if((count%5)!=0)
				{
					lst_dat.add("-");
				}
				HashMap param =new HashMap();
				param.put("REPORT_PARAM",ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap())));
				Chartdata=(Vector)request.getAttribute("PdfchartParam");
				param.put("REPORT_DATA",Chartdata);
				param.put("fileName","Session-report");
				session.setAttribute("parameters", param);
			}
			else if(v_data1!=null&&!v_data1.isEmpty()&&ht_data!=null&&ht_data.isEmpty())
			{
				json.put("dataAvailable","false");
				screenLabels.put("reporter.thin.No measures available for the current selection",intlmp.getTextDescription("reporter.thin.No measures available for the current selection"));
				storeLastAccessedUrl = true;
			}
		}
		else if(v_qry_string!=null&&v_qry_string.size()>0) //For graph view
		{
			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++;
					}
				}
			}
			if(v_qry_string != null && v_qry_string.size() > 2)
			{
				JSONArray chartJsonData = new JSONArray();
				String st_qryString = "";
				Vector  sqry = new Vector();
				sqry.add("opt");
				sqry.add("rtype");
				sqry.add("chartFor");
				String Str_units="";
				String Str_test="";
				String Str_mes="";
				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('*','%');
					if(s_title!=null&&s_title.equals("CtxSessionTest/Active_sessions"))
						s_title ="Active_sessions (Number)";
					if(s_title!=null&&s_title.equals("CtxLogintest/DURATION"))
						s_title ="Session Duration (Mins)";
					if(s_title!=null&&s_title.equals("CtxSessionTest/USERNAME"))
						s_title ="No of Unique Users (Number)";
					if(s_title!=null&&s_title.equalsIgnoreCase("No Of Sessions Completed"))
						s_title ="No of Sessions Completed (Number)";
					st_qryString = (String)v_qry_string.get(i+1);
					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);
					param.remove("er_select_server");
					Set s_param = param.keySet();
					Iterator i_param = s_param.iterator();
					while(i_param.hasNext())
					{
						String st_key = (String)i_param.next();
						String value="";
						try
						{
							value = (String)param.get(st_key);
						}catch(Exception e)
						{
							value=((String[])param.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_meas"))
						{
							Str_mes=value;
						}

						if(!sqry.contains(st_key))
						{
							queryStringdata+=st_key+ "=" + URLEncoder.encode(value) + "&";
						}
						st_key=st_key.trim();
						if(st_key.equals("inidate"))
							queryString+=st_key+ "="+value+"&";
						else if(st_key.equals("er_dismeas"))
						{
							if(value.indexOf('(')>-1 || value.indexOf('(')>-1)
							{
								queryString+=st_key+ "="+erUtils.specialCharEncode(value)+"&";
							}
							else
							{
								queryString+=st_key+ "="+ URLEncoder.encode(value)+"&";//queryString+=st_key+ "="+erUtils.specialCharEncode(value)+"&";
							}
						}
						else
							queryString+=st_key+ "=" + EgURLEncoder.encode(value,"UTF-8") + "&";
					}
					queryString = controlfile+"?"+queryString;
					queryStringdata = queryStringdata +"&er_sortby=-1&optt=data&dataFor=distribution&er_select_server="+s_server;
					session.setAttribute("QsDistData",queryStringdata);
	//----				//Adding the title and the URL of the image for saving to PDF
					count++;
					String theWidth = "";
					String theHeight = "";
					String isPie = reportInfo.getChartTypeForDist("CITRIX SESSION REPORT");
					Str_units = tablesInfo.getUnitForMeasure(Str_test,Str_mes);
					if(Str_units == null || Str_units.equals(""))
					{
						if (Str_mes!=null&&Str_mes.equals("DURATION"))
						{
							Str_units ="Mins";
						}
						else if (Str_mes!=null&&(Str_mes.equalsIgnoreCase("Active_sessions") || Str_mes.equalsIgnoreCase("USERNAME")))
						{
							Str_units ="Number";
						}
						if (Str_mes!=null&&Str_mes.equalsIgnoreCase("No Of Sessions Completed"))
						{
							Str_units="Number";
						}
					}
					if(isPie!=null && isPie.equalsIgnoreCase("Pie"))
					{
						theWidth = "740";
						theHeight = "250";
					}
					else
					{
						theWidth = "740";
						theHeight = "380";
					}

					JSONObject graphResultObj = new JSONObject();
					String graphTitle = "";
					if(s_title.indexOf("/")>-1)
					{
						String tmpTest = s_title.substring(0,s_title.indexOf("/"));
						String tmpMeas = s_title.substring(s_title.indexOf("/")+1);
						//for uqique users title setting
						if(tmpMeas.equalsIgnoreCase("Unique users") && tmpMeas!=null)
						{
							graphTitle = intlmp.getMeasureDescription(tmpTest,tmpMeas)+" ("+intlmp.getTextDescription("reporter.common."+Str_units)+")";
						}
						else
						{
							graphTitle = intlmp.getTestDescription(tmpTest)+" / "+intlmp.getMeasureDescription(tmpTest,tmpMeas)+" ("+intlmp.getTextDescription("reporter.common."+Str_units)+")";
						}
					}
					else
					{
						graphTitle = s_title;
					}
					json.put("graphMainTitle",graphTitle);
					if(isPie!=null && isPie.equalsIgnoreCase("Pie"))
					{
						graphResultObj.put("chartUrl",queryString +"&er_width=620&er_height=250&er_align=left&er_select_server="+s_server+"&optt=graph&er_view=APPLET");
					}
					else
					{
						graphResultObj.put("chartUrl",queryString +"&er_width="+theWidth+"&er_height="+theHeight+"&er_align=left&er_select_server="+s_server+"&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('*','%');
							if(s_title!=null&&s_title.equals("CtxSessionTest/Active_sessions"))
							s_title ="Active sessions (Number)";
						if(s_title!=null&&s_title.equals("CtxLogintest/DURATION"))
							s_title ="Session Duration (Mins)";
						if(s_title!=null&&s_title.equals("CtxSessionTest/USERNAME"))
							s_title ="No of Unique Users (Number)";
						if(s_title!=null&&s_title.equalsIgnoreCase("No Of Sessions Completed"))
							s_title ="No of Sessions Completed (Number)";
						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);
						param.remove("er_select_server");
						query_String="";
						s_param = param.keySet();
						i_param = s_param.iterator();
						String Tinfos[]=null;
						String er_test="";
						String er_meas="";
						while(i_param.hasNext())
						{
							String st_key = (String)i_param.next();
							String value="";
							try
							{
								value = (String)param.get(st_key);
							}catch(Exception e)
							{
								value=((String[])param.get(st_key))[0];
							}
							if(st_key!=null&&st_key.equals("er_test"))
							{
								er_test = value;
							}
							else if(st_key!=null&&st_key.equals("er_meas"))
							{
								er_meas=value;
							}
							if(!sqry.contains(st_key))
							{
								if(st_key.equals("startdate") || st_key.equals("enddate") || st_key.equals("inidate")|| st_key.equals("select_testmes"))
								{
									query_String+="&"+st_key+ "=" + URLEncoder.encode(value) + "&";
								}
								else if(st_key.equals("er_dismeas"))
								{
									query_String+="&"+st_key+ "=" + erUtils.specialCharEncode(value) + "&";
								}
								else
								{
									if(st_key.equals("select_farm"))
									{
										qrydata+=st_key+ "=" + EgURLEncoder.encode(value,"UTF-8") + "&";
										query_String+="&"+st_key+ "=" + EgURLEncoder.encode(value,"UTF-8") ;
									}else{
									qrydata+=st_key+ "=" + URLEncoder.encode(value) + "&";
									query_String+="&"+st_key+ "=" + URLEncoder.encode(value) ;
									}
								}
							}
							else
							{
								query_String+="&"+st_key+ "=" + URLEncoder.encode(value) + "&";
							}
						}
						query_String = controlfile+"?"+query_String;
						qrydata = qrydata +"&er_sortby=-1&drillDown=yes&optt=data&er_select_server="+EgURLEncoder.encode(s_server,"UTF-8");
						count++;
						session.setAttribute("QsTopData",qrydata);
						String sessionQs="../servlet/com.eg.ErCtxServerReportC?er_type="+rtype+"&isSubmit=true&select_farm="+EgURLEncoder.encode(s_farmserver,"UTF-8")+"&uid="+EgURLEncoder.encode(loginid,"UTF-8")+"&er_trenddata=" + datatype+"&er_select_server="+EgURLEncoder.encode(loginid,"UTF-8")+ "&currTime=" + cTime+"&er_mode="+request.getParameter("er_mode")+"&er_option="+er_option+"&er_site="+er_site;

						session.setAttribute("sessionQs",sessionQs);

						String backsessionQs="../servlet/com.eg.ErCtxServerReportC?er_type="+rtype+"&isSubmit=true&select_farm="+EgURLEncoder.encode(s_farmserver,"UTF-8")+"&uid="+EgURLEncoder.encode(loginid,"UTF-8")+"&select_testmes=" + URLEncoder.encode(testmes) + "&opt=chart&er_select_server="+EgURLEncoder.encode(s_server,"UTF-8")+"&currTime=" + cTime+"&er_mode="+request.getParameter("er_mode")+"&er_option="+er_option+"&er_site="+er_site;

						session.setAttribute("backsessionQs",backsessionQs);

						graphResultObj.put("chartUrl2",query_String + "&er_width="+theWidth+"&er_height=" + theHeight + "&er_align=left&er_select_server="+EgURLEncoder.encode(s_server,"UTF-8")+"&optt=graph&er_view=APPLET");
					}
					graphResultObj.put("graphTitle",graphTitle);
					chartJsonData.add(graphResultObj);
				}
				json.put("chartJsonData",chartJsonData);
				json.put("dataAvailable","true");
			}
			else
			{
				json.put("dataAvailable","false");
			}
			HashMap param =new HashMap();
			param.put("REPORT_PARAM",ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap())));
			param.put("REPORT_DATA",sessionpdfdata);
			param.put("fileName","Session-report");
			session.setAttribute("parameters", param);
			storeLastAccessedUrl = true;
		}
		if(s_server!=null && !s_server.equalsIgnoreCase("All Types"))
		{
			sen = new Hashtable();
			if(lst_dat!=null && !lst_dat.isEmpty())
			{
				sen.put(vec,lst_dat);
				ht=new Hashtable();
				ht.put(s_tit,sen);
				lst.add(ht);
				if(vec2!=null && !vec2.isEmpty())
					{
						for(int i=0;i<vec2.size();i++)
						{
							sen1.put(vec3.get(i),lst_dat2.get(i));
							s_tit1 = (String)vec2.get(i);
							ht1=new Hashtable();
							ht1.put(s_tit1,sen1);
							lst.add(ht1);
							sen1 = new Hashtable();
							ht1 = new Hashtable();
						}
					}
				session.setAttribute("list",lst);
			}
			else 
			{
				session.setAttribute("list",lst);
			}
		}
		else
		{
			sen = new Hashtable();
			sen.put(vec,lst_dat);
			ht=new Hashtable();
			ht.put(s_tit,sen);
			lst.add(ht);
			if(vec2!=null && !vec2.isEmpty())
			{
				for(int i=0;i<vec2.size();i++)
				{
					sen1.put(vec3.get(i),lst_dat2.get(i));
					s_tit1 = (String)vec2.get(i);
					ht1=new Hashtable();
					ht1.put(s_tit1,sen1);
					lst.add(ht1);
					sen1 = new Hashtable();
					ht1 = new Hashtable();
				}
				session.setAttribute("list",lst);
			}
			else
			{
				sen.put(vec,lst_dat);
				ht=new Hashtable();
				ht.put(s_tit,sen);
				lst.add(ht);
				session.setAttribute("list",lst);
			}
		}
	}
	if((action!=null && action.equals("defaultLoad")) || (isSubmit!=null && isSubmit.equals("true")))
	{
		if(StringUtils.isNull(testmes))
			testmes="";
		String processVal="";
		if(rtype!=null && rtype.equals("Yes")) {
			processVal="&opt=chart&printGraph=yes&er_view=IMAGE&uid="+EgURLEncoder.encode(loginid,"UTF-8")+ "&select_testmes=" +EgURLEncoder.encode(testmes,"UTF-8");
		} 
		else
		{
			if(StrChartfor!=null&&StrChartfor.equals("uniqueuser")){
				processVal="&er_view=image&uid="+EgURLEncoder.encode(loginid,"UTF-8");
			}
			else
				processVal="&er_view=PRINT&uid="+EgURLEncoder.encode(loginid,"UTF-8");
		}
		String strEncodeer_trgttype = request.getParameter("er_trgttype");
		if(request.getParameter("er_trgttype")!= null)
			strEncodeer_trgttype = EgURLEncoder.encode(request.getParameter("er_trgttype"),"UTF-8");
		String strEncodes_farmserver = s_farmserver;
		if(s_farmserver != null)
			strEncodes_farmserver = EgURLEncoder.encode(s_farmserver,"UTF-8");
		String strEncodeer_timeline = request.getParameter("er_timeline");
		if(request.getParameter("er_timeline") != null)
			strEncodeer_timeline = EgURLEncoder.encode(request.getParameter("er_timeline"),"UTF-8");
		String strEncodestdate = stdate;
		if(stdate != null)
			strEncodestdate = EgURLEncoder.encode(stdate,"UTF-8");
		String strEncoeenddate = enddate;
		if(enddate != null)
			strEncoeenddate = EgURLEncoder.encode(enddate,"UTF-8");
		String strEncodes_server = s_server;
		if(s_server != null)
			strEncodes_server = URLEncoder.encode(s_server);
		String strEncodeinidate = request.getParameter("inidate");
		if(request.getParameter("inidate") != null)
			strEncodeinidate = EgURLEncoder.encode(request.getParameter("inidate"),"UTF-8");

		String dataProcess = mngrIProc+"/final/servlet/com.eg.ErCtxServerReportC;jsessionid="+session.getId()+"?er_rtype="+request.getParameter("er_rtype")+"&er_gtype="+request.getParameter("er_gtype")+"&er_trgttype="+strEncodeer_trgttype+"&select_farm="+strEncodes_farmserver+"&er_timeline="+strEncodeer_timeline+"&er_trenddata="+datatype+"&startdate="+strEncodestdate+"&er_excwe="+excludeweekend+"&enddate="+strEncoeenddate+"&timefrom="+request.getParameter("timefrom")+"&timeto="+tto+"&minfrom="+Minfrom+"&minto="+Minto+"&starthr="+sthr+"&endhr="+endhr+"&startmin="+request.getParameter("startmin")+"&endmin="+request.getParameter("endmin")+"&daychartfor="+StrChartfor+"&select_server1="+StrServer+"&er_select_comp="+strEncodeSelectServer+"&er_select_server="+strEncodes_server+"&select_server=null&er_mode="+request.getParameter("er_mode")+"&inidate="+strEncodeinidate+processVal+"&er_option="+er_option+"&er_site="+er_site;

		session.setAttribute("MAIL_URL",dataProcess);

		if(storeLastAccessedUrl)
		{
			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)
						continue;
					String reqparam =param.substring(0,ind);

					if(reqparam!=null && reqparam.equalsIgnoreCase("thinClientSessionAction"))
					{
						continue;
					}
					else if(reqparam!=null && reqparam.equalsIgnoreCase("responseType"))
					{
						continue;
					}
					String value = param.substring(ind+1);
					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("enddate"))
					{
						value=com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("startdate"))
					{
						value=com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("select_testmes"))
					{
						value=com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("inidate"))
					{
						value=com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					Qstring=Qstring+reqparam+"="+value+"&";
				}
			}
			//Back button - Start
			ArrayList listbackvar = new  ArrayList();
			if(request.getParameter("isSubmit")!=null)
			{
				session.setAttribute("reportLastAccessedURL","/final/reporter/ErCtxSessionReport.jsp?"+Qstring);
				listbackvar.add("ErCtxSessionReport.jsp");
				listbackvar.add("status="+status+"&bggroundStr="+bggroundStr+"&"+queryString);
				session.setAttribute("favSchBackDisplay","Yes");
			}
			else
			{
				session.setAttribute("reportLastAccessedURL","/final/reporter/ErCtxSessionReport.jsp?"+Qstring);
				listbackvar.add("ErCtxSessionReport.jsp");
				listbackvar.add(queryString);
				session.setAttribute("favSchBackDisplay","No");
			}
				String backadded = erhelputils.getBackID();
				backreqMap = erhelputils.setBackQueryMap(backreqMap,backadded,listbackvar);
				session.setAttribute("backQuery",backreqMap);
			//Back button - End
		}
	}
	if(userListStr!=null && !"".equals(userListStr))
	{
	//Following variables are used for the drilldown csv unique user list
		Vector headerDD          = new Vector();
		List listDataDD          = new LinkedList();	//ColumnData
		Hashtable subtableDD     = new Hashtable();	//SubTable Data
		Hashtable tableDD        = new Hashtable();	//SunTitle with SubTable Data
		List wholeDD             = new LinkedList();

		headerDD.add("S.No");
		headerDD.add("User Name");

		String userListArr[] = userListStr.split(",");
		for(int csvDD =0;csvDD<userListArr.length;csvDD++){
			listDataDD.add((csvDD+1)+"");
			listDataDD.add('"'+ userListArr[csvDD] +'"');
		}
		subtableDD.put(headerDD, listDataDD);
		tableDD.put("Unique user list", subtableDD);
		wholeDD.add(tableDD);

		session.setAttribute("list_drilldown",wholeDD);
	}
	json.put("pageParams",pageParams);
	json.put("hiddenParams",hiddenParams);
	json.put("screenLabels",screenLabels);
	json.put("allTypeUniqueUsrSummary",allTypeUniqueUsrSummary);
	json.put("userListStr",userListStr);
    
	response.setContentType("application/json;charset=UTF-8");
	response.getWriter().write(json.toString());
}
catch(Exception e)
{
	e.printStackTrace();
}
%>
<%!
	public synchronized JSONArray getJSONComboFromList(List list,String infoVal,EgMappingInfo intlmp)
	{
		JSONArray arr=new JSONArray();
		JSONObject obj=null;
		if(list !=null && list.size()>0)
		{
			for (int i=0;i<list.size();i++)
			{
				String text=(String)list.get(i);
				obj=new JSONObject();
				obj.put("displayField",text);
				obj.put("valueField",text);
				arr.add(obj);
			}
		}
		else
		{
			obj=new JSONObject();
			obj.put("displayField", intlmp.getTextDescription("reporter.common.Not Applicable"));
			obj.put("valueField","-1");
			arr.add(obj);
		}
		return arr;
	}
%>
<%!
	private boolean getDataChange(List dataList)			// For Bug Id : 10811
	{
		boolean status = false;
		int dataSize = dataList.size();
		int count = 0;
		for(int i=0;i<dataSize;i++)
		{
			String data = (String)dataList.get(i);
			if(data.equals("-"))
				count++;
		}
		if(count == dataSize)
			status = true;
		return status;
	}
%>