<%
/*******************************************************************************
*	File name		:	ErCtxUserReport.jsp
*	Purpose			:	Displays the duration of user logins in the servers
*	Version			:	1.0
*	Author			:	Sri Devi G
*	Creation Date	:	7/12/05 
*	New UI			:	31/12/2005  Vijaykumar
* Last Modified	:	21/03/2009-sakthi-added code disconnected user seesion detail
* Last Modified	:	05/03/2015-Gowtham-added code disconnected user seesion detail
*******************************************************************************/
%>


<%@ include file = "ErCtxUserSessionComboJson.jsp" %>


<%
	JSONArray chkJsonArr=new JSONArray();
	String server,LoginTime,dispLoginTime;
	EgTimeZoneConverter converterStart = null;
	String s_duration="";
	String activeTime="";
	String idleTime="";
	String geoLocation="";
	String source = request.getParameter("source");
	String er_duration = request.getParameter("fromOverviewReport");
	String er_durationValue = request.getParameter("er_duration");
	boolean reqFromOverviewReport=false;
	if(er_duration != null && er_duration.equalsIgnoreCase("true"))
		reqFromOverviewReport=true;
	String sessionQs = null;
	String sessionQs_server = null;
	String avg = "";
	String maximum = "";
	String logon_duration="-";
	String logon_duration_splitup = null;

	int totalnoofcols=0;
	int sess=0;
	boolean isAppsEnabled = false;
	int rwSize=0;


	if(source != null && source.equals("menu"))
	{
		session.removeAttribute("backQueryForsesion");
		session.removeAttribute("backQSsessionserver");
	}
	else
	{
		sessionQs=(String)session.getAttribute("backQueryForsesion");
		sessionQs_server=(String)session.getAttribute("backQSsessionserver");
	}
	String strUserWithDesktop = "";
	if(!isVm)
	{
		isAppsEnabled=true;
	}
	rootJson.put("isVm",isVm);
	rootJson.put("hasVMs",hasVMs);
	if(client_Version != null)
		rootJson.put("selectedClientVersion",client_Version);
	else
		rootJson.put("selectedClientVersion","*");//..

	ArrayList  Rep_data =(ArrayList) request.getAttribute("Report_data");
	HashMap  summarySessionVc =(HashMap) request.getAttribute("summarySessionVc");
	Hashtable  ht_Rep_data =(Hashtable) request.getAttribute("Summary_Report_data");
	Hashtable  aList_Rep_data =(Hashtable) request.getAttribute("Summary_Report_OverAllUserSummary_data");
	ArrayList topAppsDataForFarm = (ArrayList) request.getAttribute("topAppsDataForFarm");
	ArrayList topAppsDataForServer = (ArrayList) request.getAttribute("topAppsDataForServer");
	ArrayList perServerDispMaxAvgPer = (ArrayList) request.getAttribute("perServerDispMaxAvgPer");
	ArrayList disconuser=(ArrayList)request.getAttribute("disconnectuser");
	JSONObject pod_resultMap = (JSONObject)session.getAttribute("USER_SESSION_DETAILS_POD");
	if(pod_resultMap==null)
	{
		pod_resultMap = new JSONObject();
	}
	
	session.setAttribute("hash_summary_data",ht_Rep_data);
	session.setAttribute("OverAllUserSummary_data",aList_Rep_data);
	session.setAttribute("hash_data",Rep_data);
	session.setAttribute("userTopAppsFarm",topAppsDataForFarm);
	session.setAttribute("userTopAppsServ",topAppsDataForServer);
	session.setAttribute("userMaxAvgPer",perServerDispMaxAvgPer);
	session.setAttribute("disconuserdeal",disconuser);
	session.setAttribute("summarySessionVc",summarySessionVc);

	session.setAttribute("sessionUserView",Rep_data);
	if(er_showResourceUsage!=null)
		rootJson.put("er_showResourceUsage",er_showResourceUsage);
	boolean showADShortName = false;
	String strShowEntities = inifile_service.getValue("AD_XENUSER_REPORT","ShowEntities");
	if(strShowEntities!=null && !strShowEntities.equalsIgnoreCase("descriptive"))
	showADShortName = true;

	if(s_user!=null && s_user.equals("*"))
		s_user = "-- All --";

	if((Rep_data!=null && Rep_data.size()>0) || (ht_Rep_data!=null&& ht_Rep_data.size()>0))
	{
		String compDisp=selectedComponents;
		if(compDisp.length()>30)
			compDisp=compDisp.substring(0,29)+"...";
		JSONObject selectionDetails=new JSONObject();
		rootJson.put("reporter.common.SelectionDetailsfor",intlmp.getTextDescription("reporter.common.Selection Details for ")+" "+intlmp.getTextDescription("reporter.common.User")+" "+ s_user);
		selectionDetails.put(intlmp.getTextDescription("reporter.common.Report By"),er_option);
		selectionDetails.put(intlmp.getTextDescription("reporter.common.Component Type"),intlmp.getComponentTypeDescription(s_compType));
		if(hasVMs)
			selectionDetails.put(intlmp.getTextDescription("reporter.thin.VMs/Desktops"),compDisp);
		else
			selectionDetails.put(intlmp.getTextDescription("reporter.thin.Components"),compDisp);
		selectionDetails.put(intlmp.getTextDescription("reporter.common.Exclude weekends"),excludeweekend);
		selectionDetails.put(intlmp.getTextDescription("reporter.common.Time Period "),"<span class='font_bold'></span>"+Hourfrom+":"+Minfrom+" <span class='font_bold'> "+intlmp.getTextDescription("reporter.common.to")+" </span> "+Hourto+":"+Minto);
		selectionDetails.put((String)intlmp.getTextDescription("reporter.common.Timeline"),"<span class='font_bold'></span> "+pdfStartDate+" "+intlmp.getTextDescription("reporter.common.hrs")+" <span class='font_bold'> "+intlmp.getTextDescription("reporter.common.to")+" </span> "+pdfEndDate+" "+intlmp.getTextDescription("reporter.common.hrs"));


		if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details")){
		selectionDetails.put("Show Details","Yes");
		}
		if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Summary")){
		selectionDetails.put("Show Details","No");
		}
		if(adGroupFns!=null&&adGroupForPrint!=null &&(adGroupFns.equalsIgnoreCase("Details")||adGroupFns.equalsIgnoreCase("Summary"))){
			if(!adGroupForPrint.equals("-1"))
				selectionDetails.put("Ad Group",adGroupForPrint);
		}

		rootJson.put("selectionDetails",selectionDetails);

	}
		JSONArray iterateJArray=new JSONArray();
		JSONObject iterateJObject=new JSONObject();
		JSONArray selectedAdGroupArray=new JSONArray();

			List selectedAdgroup = new ArrayList();

		String er_adGroup[] = request.getParameterValues("er_adGroup");

		ErCtxAdGroupDetailsReportBean cusb=new ErCtxAdGroupDetailsReportBean();
		List directoryList=cusb.getADList();
			if(er_adGroup!=null){
				for(int j=0;j<er_adGroup.length;j++){
				selectedAdgroup.add(er_adGroup[j]);
				}
			}
		iterateJArray=new JSONArray();
		if (directoryList.size() > 1)
		{
			 iterateJObject=getLoopObjInfo(intlmp.getTextDescription("reporter.common.All"),"All");
			iterateJArray.add(iterateJObject);
		}
				Collections.sort(directoryList,String.CASE_INSENSITIVE_ORDER);
				StringBuffer str=new StringBuffer();
					for (int i=0; i<directoryList.size(); i++) {
						String dirStr = (String) directoryList.get(i);
						String strdispDirStr = dirStr;
						if(showADShortName)
						{
							if(strdispDirStr!=null && strdispDirStr.indexOf(",")>-1)
							{
								StringTokenizer stToken = new StringTokenizer(strdispDirStr,",");
								if(stToken.countTokens()>1)
								{
									String strAdName = stToken.nextToken();
									if(strAdName!=null && strAdName.indexOf("=")>-1)
									{
										strdispDirStr = strAdName.substring(strAdName.indexOf("=")+1);
									}
								}
							}
						}
						iterateJObject=getLoopObjInfo(strdispDirStr,dirStr);
						iterateJArray.add(iterateJObject);
						if(selectedAdgroup.contains(dirStr))
						{
							selectedAdGroupArray.add(dirStr);
						}
					}

						rootJson.put("selectedAdGroup",selectedAdGroupArray);

					if (er_adGroup == null && directoryList.size() > 1){
						selectedAdGroupArray=new JSONArray();
						selectedAdGroupArray.add("All");
						rootJson.put("selectedAdGroup",selectedAdGroupArray);
						}
						if (selectedAdgroup.contains("All") && directoryList.size() > 1){
						selectedAdGroupArray=new JSONArray();
						selectedAdGroupArray.add("All");
						rootJson.put("selectedAdGroup",selectedAdGroupArray);
						}
						//
						if(iterateJArray==null || iterateJArray.isEmpty())
						{
						iterateJObject=getLoopObjInfo(intlmp.getTextDescription("reporter.common.Not Applicable"), "-1");
						iterateJArray.add(iterateJObject);
						}
						//
						//
						if (directoryList.size()==1)
						{
							selectedAdGroupArray=new JSONArray();
							selectedAdGroupArray.add((String) directoryList.get(0));
							rootJson.put("selectedAdGroup",selectedAdGroupArray);
						}

						rootJson.put("adGroupCombo",iterateJArray);

//
			JSONArray selectedAdGroupUsersArray=new JSONArray();
			List selectedAdgroupUsers = new ArrayList();
			String er_adGroupUsers[] = request.getParameterValues("er_aduser");

			if(er_adGroupUsers!=null){
				for(int j=0;j<er_adGroupUsers.length;j++){
				selectedAdgroupUsers.add(er_adGroupUsers[j]);
				}
			}

			List adGroupUserList=cusb.getADUsers(selectedAdgroup);
			iterateJArray=new JSONArray();
			if (adGroupUserList.size() > 1)
			{
				iterateJObject=getLoopObjInfo(intlmp.getTextDescription("reporter.common.All"),"All");
				iterateJArray.add(iterateJObject);
			}
			Collections.sort(adGroupUserList,String.CASE_INSENSITIVE_ORDER);

			for (int i=0; i<adGroupUserList.size(); i++) {
				String usrStr = (String) adGroupUserList.get(i);
				String disStr=usrStr;
				disStr=com.egurkha.util.StringUtils.replace(disStr,"$", "\\");
				iterateJObject=getLoopObjInfo(disStr,usrStr);
				iterateJArray.add(iterateJObject);
				if(selectedAdgroupUsers.contains(usrStr))
				{
				selectedAdGroupUsersArray.add(usrStr);
				}
			}

				rootJson.put("selectedAdGroupUser",selectedAdGroupUsersArray);
			if (er_adGroupUsers == null && adGroupUserList.size() > 1){
					selectedAdGroupUsersArray=new JSONArray();
					selectedAdGroupUsersArray.add("All");
					rootJson.put("selectedAdGroupUser",selectedAdGroupUsersArray);
			}
			if (selectedAdgroupUsers.contains("All") && adGroupUserList.size() > 1){
					selectedAdGroupUsersArray=new JSONArray();
					selectedAdGroupUsersArray.add("All");
					rootJson.put("selectedAdGroupUser",selectedAdGroupUsersArray);
			}
			//
			if(iterateJArray==null || iterateJArray.isEmpty())
			{
			  iterateJObject=getLoopObjInfo(intlmp.getTextDescription("reporter.common.Not Applicable"), "-1");
			  iterateJArray.add(iterateJObject);
			}
			rootJson.put("adGroupUserCombo",iterateJArray);
//

	String client_details = null;
	String strCompTypeDetailsVal =null;
	if(s_compType!=null)
	{
		client_details = reportInfo.getValue(INI_SUBJECT,"ClientDetails");
		if(isVm)
			client_details = reportInfo.getValue(INI_SUBJECT,"VdiClientDetails");
		if(client_details!=null && client_details.length()>0)
		{
			StringTokenizer stToken = new StringTokenizer(client_details,",");
			while (stToken.hasMoreTokens())
			{
				String strVal = stToken.nextToken();
				if(strVal!=null && strVal.startsWith(s_compType))
				{
					strCompTypeDetailsVal = strVal;
					break;
				}
			}
		}
	}
	ArrayList aListClientDetails =  new ArrayList();
	ArrayList aListClientDetails_ColName =  new ArrayList();
	String geoColumn = reportInfo.getValue(INI_SUBJECT,"GeoColumnDetails_"+s_compType);
	ArrayList geoColumnList = com.egurkha.util.StringUtils.egTokenizer(geoColumn, ",",false,false,true);
	if(strCompTypeDetailsVal!=null)
	rootJson.put("clientDetailsCompType",strCompTypeDetailsVal.substring(0,strCompTypeDetailsVal.indexOf(":")));

		String vdiClientDetails = reportInfo.getValue(INI_SUBJECT,"VdiClientDetails");
		String strVdiCompTypeDetailsVal =null;
		if(s_compType!=null)
		{
		if(vdiClientDetails!=null && vdiClientDetails.length()>0)
			{
			StringTokenizer stToken = new StringTokenizer(vdiClientDetails,",");
			while (stToken.hasMoreTokens())
				{
				String strVal = stToken.nextToken();
				if(strVal!=null && strVal.startsWith(s_compType))
					{
					strVdiCompTypeDetailsVal = strVal;
					break;
					}
				}
			}
		}
			if(strCompTypeDetailsVal!=null && strCompTypeDetailsVal.length()>0)
					{
						StringTokenizer stToken_1 = new StringTokenizer(strCompTypeDetailsVal,":");
						stToken_1.nextToken();//Component Type Token
						if(isVm)
							stToken_1.nextToken();//TestName Token
						while (stToken_1.hasMoreTokens())
						{
							String strVal = stToken_1.nextToken();
							String strColName = strVal;
							if(strVal!=null && strVal.indexOf("#")>-1)
							{
								strVal = strVal.substring(strVal.indexOf("#")+1);
								strColName = strColName.substring(0,strColName.indexOf("#"));
							}
							aListClientDetails_ColName.add(strColName);
							aListClientDetails.add(strVal);
			}
		}
		if(strVdiCompTypeDetailsVal!=null)
			rootJson.put("clientDetailsCompType",strVdiCompTypeDetailsVal.substring(0,strVdiCompTypeDetailsVal.indexOf(":")));
	if(topAppsDataForFarm == null || topAppsDataForFarm.isEmpty() || topAppsDataForFarm.size() == 0)
	{
		Vector vec_infos= null;
		if(s_compType!=null && s_compType.equalsIgnoreCase("Horizon_Pod"))
		{
			pod_resultMap.put("compType",s_compType);
			rootJson.put("reportData",pod_resultMap);
		}
		else if(Rep_data!=null)
		{
			if(isVm)
			{
				String ddTest = reportInfo.getCtxUserDDTest(INI_SUBJECT,s_compType);
				vec_infos=erInfo.getInfosForUser(ddTest);
			}
			JSONObject reportDataJson = new JSONObject();
			JSONArray GridArray = new JSONArray();
			JSONObject summarytableData =  new JSONObject();
			if (Rep_data.size()>0)
			{
				sess = Rep_data.size();
				int  tempsess=sess;
				Object check= (Object)Rep_data.get(sess-1);
				if(check instanceof Hashtable)
				{
					sess=sess-1;
				}
				
				try
				{
					ArrayList data = new ArrayList();
					for(int j=0; j < Rep_data.size(); j++)
					{
						try
						{
							Object v = (Object)Rep_data.get(j);
							if(v instanceof Hashtable)
							{
								avgPerForMeasures = (Hashtable)Rep_data.get(j);
								showMeasure = true;
								continue;
								
							}else if(v instanceof HashMap)
							{
								Report_data = (HashMap)Rep_data.get(j);
								if(likeAllUsers)
								user = (String)Report_data.get("user");
								if(likeAllUsers)
								{
									if(!v_users.contains(user))
									v_users.add(user);
								}
								sessionExists = true;
								if(!showAllUsers)
								{
									data.add((String)Report_data.get("duration"));
									if(onlyThisUser)
									{
										showDuration = true;
									}
									if(v_users!=null && v_users.isEmpty())
									{
										showDuration = true;
									}
								}
							}
						}catch(Exception e)
						{
							e.printStackTrace();
						}
					}
					if(!showAllUsers && v_users!=null && v_users.size() == 1 && likeAllUsers)
					{
						showDuration = true;
						onlyThisUser = true; 
					}
					if(showDuration || showMeasure)
					{
						summaryExists = true;
					}
					if(data!=null && data.size() > 0)
					{
						maximum = erUtils.getMaximum(data);
						maximum = (maximum == null || maximum.equals("-"))? "-" : erUtils.round(Float.parseFloat(maximum),2);
					
						avg = erUtils.calculateAvg(data);
						avg = (avg == null || avg.equals("-"))? "-" : erUtils.round(Float.parseFloat(avg),2);
					}
					
				}catch(Exception e)
				{
					e.printStackTrace();
				}
				boolean showSummay = true;
				if(s_compType!=null && !aListApplicationComponentType.contains(s_compType) && showAllUsers )
						showSummay = false;
				if(showSummay)
				{

					boolean showTop = false;
					if(showAllUsers || likeAllUsers || onlyThisUser)
						showTop = true;
					if(!showAllUsers && (showDuration || showMeasure || showTop))
					{
						summaryTitle = "Summary for User - " + java.net.URLEncoder.encode(s_user) ;
						String select_server = request.getParameter("select_server1");
						s_tit = intlmp.getTextDescription("reporter.common.Summary for User")+" - "+erUtils.specialCharDecode(s_user);
					}
					else if(showAllUsers && showTop)
					{
						s_tit = intlmp.getTextDescription("reporter.common.Summary for User")+" - "+intlmp.getTextDescription("reporter.common.All");
					}
				}
				if(!isSummary)
					reportDataJson.put("summary_title",s_tit);
				String enc_user =s_user;
				String selectServer = request.getParameter("select_server1");
				String queryForTopApps = "../servlet/com.eg.ErCtxServerReportC?er_rtype=User&er_gtype=Citrix&er_timeline=" + timeline + "&er_trgttype=User Report&isSubmit=true&timefrom=" + timeFrom + "&timeto=" + timeTo + "&" + getDateInfoString(s_st_hr,s_en_hr,strmin,enmin,minFrom,minTo) + appendString(request.getParameter("startdate"),request.getParameter("enddate"),stHr,endHr)+ "&currTime=" + cTime + "&pdfTime="+pdfTime+"&select_farm=" + s_farmserver + "&er_excwe=" + excludeweekend + "&showAll=" + showAllUsers + "&er_compType=" + s_compType + "&showSearch=" + sSearch + "&likeAllUsers=" + likeAllUsers + "&onlyThisUser=" + onlyThisUser  + "&showTopApps=true" + "&er_user="  + java.net.URLEncoder.encode(enc_user)  +  "&er_tbound=" + tbound + "&uid=" + loginid+"&startdate="+request.getParameter("startdate")+"&enddate="+request.getParameter("enddate")+"&userID="+urs+"&option=Citrix&er_option="+er_option+"&showFrom="+showFrom;

				if(selectServer!=null && !selectServer.equals("")){
					queryForTopApps+="&select_server1=" + selectServer; 
					if(selectedCompAl!=null && selectedCompAl.size()>0)
					{
						for(int cc=0;cc<selectedCompAl.size();cc++)
						queryForTopApps+="&er_componentserver=" + selectedCompAl.get(cc);; 
					}
				}
				if(showDuration && !showAllUsers)
				{
					summarytableData.put(intlmp.getTextDescription("reporter.common.Total number of sessions completed")+"("+intlmp.getTextDescription("reporter.common.Number")+")",String.valueOf(sess));
					summarytableData.put(intlmp.getTextDescription("reporter.thin.Average duration")+"("+intlmp.getTextDescription("reporter.common.Mins")+")",avg);
					summarytableData.put(intlmp.getTextDescription("reporter.common.Maximum duration")+"("+intlmp.getTextDescription("reporter.common.Mins")+")",maximum);


					vec.add(intlmp.getTextDescription("reporter.thin.Measures"));
					vec.add(intlmp.getTextDescription("reporter.thin.Values"));

					lst_dat.add(intlmp.getTextDescription("reporter.common.Total number of sessions completed")+" ("+intlmp.getTextDescription("reporter.thin.Number")+")");

					Integer sessobj = new Integer(sess);
					lst_dat.add(sessobj.toString());
					
					lst_dat.add(intlmp.getTextDescription("reporter.thin.Average duration")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
					lst_dat.add(avg);

					lst_dat.add(intlmp.getTextDescription("reporter.common.Maximum duration")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
					lst_dat.add(maximum);
					v_summary.add("Total_number_of_sessions");
					v_summary.add(String.valueOf(sess));
					v_summary.add("Average_duration");
					v_summary.add(avg);
					v_summary.add("Maximum_ duration");
					v_summary.add(maximum);
					
				}
				if(showMeasure && !showAllUsers)
				{
					if(avgPerForMeasures!=null && avgPerForMeasures.size() > 0)
					{
						String skey="";
						String units="";
						Iterator itr = avgPerForMeasures.keySet().iterator();
						for (int m=0;m<subjects.size();m++)
						{
							skey=(String)subjects.get(m);
							if (skey.indexOf(s_compType)>-1)
								skey=skey.substring(skey.indexOf(s_compType)+s_compType.length()+1);
							else
								continue;

							if(skey!=null && skey.indexOf(":")>-1 && skey.indexOf("#")>-1) //swami for User Session Details error in this line for some of the skeys
								units=tablesInfo.getUnitForMeasure(skey.substring(0,skey.indexOf(":")),skey.substring((skey.indexOf(":")+1),skey.indexOf("#")));
							String sum_data = (String)avgPerForMeasures.get(skey);
							if(sum_data == null){
								StringTokenizer st_sum = new StringTokenizer(skey,":");
								String dispMear="";
								String tst="";
								String measr="";
								int cntt=0;
								String tmpKey="";
								while(st_sum.hasMoreTokens())
								{
									tst= (String)st_sum.nextToken();
									if(st_sum.hasMoreTokens())
										measr= (String)st_sum.nextToken();
									if(cntt == 0){
										if(measr != null && measr.indexOf("#") > -1){
											dispMear=measr.substring(measr.indexOf("#")+1);
											measr=measr.substring(0,measr.indexOf("#"));
										}else{
											dispMear=measr;
										}
									}
									tmpKey=tst+":"+measr+"#"+dispMear;
									if(avgPerForMeasures != null && avgPerForMeasures.containsKey(tmpKey)){
										sum_data=(String)avgPerForMeasures.get(tmpKey);
										break;
									}
									cntt++;
								}
							}
							if(sum_data!= null && sum_data.indexOf("#")>-1)
							{
								StringTokenizer st_sum = new StringTokenizer(sum_data,"#");
								while(st_sum.hasMoreTokens())
								{
									String str1 = (String)st_sum.nextToken();
									String str2= (String)st_sum.nextToken();
									sum_data=str1+"#"+units+"#"+str2+"#"+units;
								}
							}
							else
								sum_data=sum_data+"#"+units;
							String firstmes = "";
							String secondmes = "";
							StringTokenizer st_m = new StringTokenizer(sum_data,"#");
							while(st_m.hasMoreTokens())
							{
								firstmes = (String)st_m.nextToken();
								secondmes= (String)st_m.nextToken();
								StringTokenizer st_tok = new StringTokenizer(firstmes,"@");
								String displaymes = st_tok.nextToken();
								String dispName="";
								String val="";
								if (displaymes.indexOf("-")>-1){
									dispName=displaymes.substring(0,displaymes.indexOf("-"));
									val=displaymes.substring(displaymes.indexOf("-")+1);
								}
								String displayval = "";
								if(st_tok.hasMoreTokens())
									displayval = st_tok.nextToken();
								summarytableData.put(intlmp.getTextDescription("reporter.common."+dispName)+" ("+intlmp.getTextDescription("reporter.common."+secondmes)+") -"+val,displayval);
								lst_dat.add(intlmp.getTextDescription("reporter.common."+displaymes));
								lst_dat.add(displayval);
								v_summary.add(displaymes);
								v_summary.add(displayval);
							}
						}
					}

				}
				if(lst_dat!=null && !lst_dat.isEmpty())
				{
					sen.put(vec,lst_dat);
					ht=new Hashtable();
					ht.put(s_tit,sen);
					lst.add(ht);
					session.setAttribute("list",lst);
					sen = new Hashtable();
					ht = new Hashtable();
					vec = new Vector();
					lst_dat = new LinkedList();
					s_tit = "";
				}
				if(s_compType!=null && aListApplicationComponentType.contains(s_compType) && isAppsEnabled )
				{					
					JSONObject jObj = new JSONObject();
					jObj.put("dispVal","top.gif");
					jObj.put("hrefUrl",queryForTopApps);
					summarytableData.put(intlmp.getTextDescription("reporter.user.Applications Accessed"),jObj);
				}
				if(!isSummary)
					reportDataJson.put("summarytableData",summarytableData);
				if(showDuration || showAllUsers || likeAllUsers)
				{

				
					if(!showAllUsers && !likeAllUsers)
					{
						int temp_totalspan=totalspan;
						if(s_compType!=null && aListApplicationComponentType.contains(s_compType))
								temp_totalspan=temp_totalspan-1;
						session.setAttribute("headingspan",String.valueOf(temp_totalspan));
						
						if(isVm)//for vm adding extra column for show link to virtual machine details
						{
							totalspan=totalspan+1;
						}
					}
					else
					{
						session.setAttribute("headingspan",String.valueOf(totalspan+1));
						if(isVm)//for vm adding extra column for show link to virtual machine details
						{
							totalspan=totalspan+2;
						}
					}
					JSONObject gridObj=new JSONObject();
					JSONObject gridColumnsDetails=new JSONObject();
					JSONObject unitForMeasure=new JSONObject();
					JSONArray gridDataArray=new JSONArray();
					int totalColumnCount=0;
					int havingSingleColumn=0;
					
					if(!showAllUsers && !likeAllUsers)
					{

						sessionTitle = "SESSION DETAILS FOR - " + s_user;
						s_tit1 = intlmp.getTextDescription("reporter.common.Session details for User")+" - "+erUtils.specialCharDecode(s_user);
					}
					else
					{
						if(likeAllUsers)
						{

							String userForPdf = "";
							sessionTitle = "SESSION DETAILS FOR - " + s_user;
							s_tit1 = intlmp.getTextDescription("reporter.common.Session details for")+" - "+s_user+" "+intlmp.getTextDescription("reporter.common.Users");
						}
						else if(onlyThisUser)
						{
							sessionTitle = "SESSION DETAILS FOR - "  + s_user;
						}
						else
						{

							sessionTitle = "SESSION DETAILS FOR - ALL USERS";
							s_tit1 = intlmp.getTextDescription("reporter.common.Session details for  User")+" - "+intlmp.getTextDescription("reporter.common.All Users");
						}
					}
					gridObj.put("gridTitle",s_tit1);

					//StringBuffer sb_sessionField = new StringBuffer();
					StringBuffer sb_field=new StringBuffer();
					if(!isSummary)
					{
					gridColumnsDetails.put(new String(),new JSONArray());
					}
					ArrayList a_measunit = new ArrayList(); // get measures unit name and no of column separator
					
					
					if(showAllUsers || likeAllUsers)
					{
						gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.User"),new JSONArray());
						vec1.add(intlmp.getTextDescription("reporter.common.User"));
					}
					if(isSummary)
					{
						gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Total Number of Sessions"),new JSONArray());
						vec1.add(intlmp.getTextDescription("reporter.common.Total Number of Sessions"));
						if(client_Version!= null && !client_Version.equalsIgnoreCase("")){
							for(int m=0;m<aListClientDetails.size();m++)
							{
								gridColumnsDetails.put(intlmp.getTextDescription("reporter.common."+aListClientDetails.get(m)),new JSONArray());
								vec1.add(intlmp.getTextDescription("reporter.common."+aListClientDetails.get(m)));
							}
						}
					}
					String clientIp=request.getParameter("clientIp");
					if(clientIp!=null && clientIp.equals("Yes"))
					{
						if(Report_data!=null && (Report_data.containsKey("Client_IP_Address")|| Report_data.containsKey("Client_name")))
						{
							if(aListClientDetails !=null && aListClientDetails.size()>0 && !isSummary)
							{
								for(int m=0;m<aListClientDetails.size();m++)
								{
									gridColumnsDetails.put(intlmp.getTextDescription("reporter.common."+aListClientDetails.get(m)),new JSONArray());
									vec1.add(intlmp.getTextDescription("reporter.common."+aListClientDetails.get(m)));
								}
							}
						}
					}
					if(!isSummary)
					{
					gridColumnsDetails.put(intlmp.getTextDescription("reporter.common. Session Start Time"),new JSONArray());
					totalColumnCount++;
					havingSingleColumn++;
					gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Logout / Disconnect Time"),new JSONArray());
					totalColumnCount++;
					havingSingleColumn++;
					


					}
						//
					chkJsonArr.add("(mins)");
					gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Session Duration"),chkJsonArr);

							havingSingleColumn++;
							totalColumnCount++;
							gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Idle Time"),chkJsonArr);
							havingSingleColumn++;
							totalColumnCount++;
							gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Active Time"),chkJsonArr);
					

				if(!isSummary)
					{
					if(!hasVMs)
					{
					//gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Server"),new JSONArray());
					gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Component"),new JSONArray());//check
					totalColumnCount++;
					havingSingleColumn++;
					}
				}
					if(clientIp!=null && clientIp.equals("Yes")){
						if(geoColumnList != null && geoColumnList.size() >0 ){
							if(Report_data!=null && Report_data.containsKey("CITY")){
								for(int m=0;m<geoColumnList.size();m++){
									gridColumnsDetails.put(intlmp.getTextDescription("reporter.common."+(String)geoColumnList.get(m)),new JSONArray());
									//vec1.add(intlmp.getTextDescription("reporter.common."+(String)geoColumnList.get(m)));
								}
							}
						}
					}
					if(s_compType!=null && aListVmComponentType.contains(s_compType) && !isSummary)
					{
					//if(( er_showResourceUsage!=null && er_showResourceUsage.equalsIgnoreCase("Yes")))
					{
						if(hasVMs)
						{
							gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.VM Name"),new JSONArray());
						}
						else
						{
							gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Desktop Name"),new JSONArray());
						}
						totalColumnCount++;
						havingSingleColumn++;
						}
					}
					 JSONArray subArr=new JSONArray();
					 subArr.add("(Sec)");
					gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Session Start-up Duration"),subArr);

					totalColumnCount++;
					havingSingleColumn++;
					if(!isSummary)
					{
						vec1.add(intlmp.getTextDescription("reporter.common.Session Start Time(Local time on server)"));
						vec1.add(intlmp.getTextDescription("reporter.common.Logout/Disconnect Time(Time on Mgmt)"));
						
						
					}


			vec1.add(intlmp.getTextDescription("reporter.common.Session Duration")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
			vec1.add(intlmp.getTextDescription("reporter.common.Idle Time")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
			vec1.add(intlmp.getTextDescription("reporter.common.Active Time")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
					if(!isSummary && !hasVMs)
					{
					vec1.add(intlmp.getTextDescription("reporter.common.Server"));
					}
					if(clientIp!=null && clientIp.equals("Yes")){
						if(geoColumnList != null && geoColumnList.size() >0 ){
							if(Report_data!=null && Report_data.containsKey("CITY")){
								for(int m=0;m<geoColumnList.size();m++){
									vec1.add(intlmp.getTextDescription("reporter.common."+(String)geoColumnList.get(m)));
								}
							}
						}
					}
					if(s_compType!=null && aListVmComponentType.contains(s_compType))
					{
						//if(( er_showResourceUsage!=null && er_showResourceUsage.equalsIgnoreCase("Yes")))
						{
							if(!isSummary)							
							{
								if(hasVMs)
								{
									vec1.add(intlmp.getTextDescription("reporter.common.VM Name"));
								}
								else
								{
								vec1.add(intlmp.getTextDescription("reporter.common.Desktop Name"));
								}
							}
						}
					}
					
					vec1.add(intlmp.getTextDescription("reporter.common.Session Start-up Duration")+" ("+intlmp.getTextDescription("reporter.common.Sec")+")");

					if(perServerDispMaxAvgPer!=null && perServerDispMaxAvgPer.size() > 0)
					{
						if(s_compType!=null && aListApplicationComponentType.contains(s_compType))
						{
							if(!isSummary)
							{
								if(( er_showResourceUsage!=null && er_showResourceUsage.equalsIgnoreCase("Yes")))
								{
								gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Applications"),new JSONArray());
								totalColumnCount++;
								havingSingleColumn++;
								if(strShowAppNames!=null && (strShowAppNames.equalsIgnoreCase("Yes") || strShowAppNames.equalsIgnoreCase("True")))
									vec1.add(intlmp.getTextDescription("reporter.common.Applications"));

								}
							}
						}
						Hashtable pServerData = (Hashtable)perServerDispMaxAvgPer.get(0);
						if(pServerData!=null && pServerData.size() > 0)
						{
							Enumeration p_keys = pServerData.keys();
							while(p_keys.hasMoreElements())
							{
								String key = (String)p_keys.nextElement();
								Hashtable value = (Hashtable)pServerData.get(key);

								session.setAttribute("colspan",ht_colspan);
								subjects=(ArrayList)reportInfo.getVariables(INI_SUBJECT);

								for(int count_dis=0; count_dis<subjects.size(); count_dis++)
								{
									String var=(String)subjects.get(count_dis);
									if(var.indexOf(s_compType)<0)
									{
										if(var.indexOf("Total:")>-1)
										{
											StringTokenizer colon_st_temp=new StringTokenizer(var,":");
											colon_st_temp.nextToken();
											colon_st_temp.nextToken();
											String totalMeasure=colon_st_temp.nextToken();
											if(totalMeasure.indexOf("+")>-1)
												totalMeasure = totalMeasure.substring(0,totalMeasure.indexOf("+"));
											if(allMeasures!=null && !allMeasures.contains(totalMeasure))
												continue;
										}else
											continue;
									}

									StringTokenizer colon_st=new StringTokenizer(var,":");
									String type=colon_st.nextToken();
									String stest = "";
									String hashvar = "";
									if(colon_st.hasMoreTokens())
									{
										stest=colon_st.nextToken();
										hashvar=colon_st.nextToken();
									}

									StringTokenizer temp_st=new StringTokenizer(hashvar,"#");
									String temp_disp = "";
									String measure = "";
									if(temp_st.hasMoreTokens())
									{
										measure=temp_st.nextToken();
										temp_disp=temp_st.nextToken();
									}
									temp_disp = temp_disp.trim();
									if(var.indexOf("Total:")>-1)
									{
										if(measure!=null && measure.indexOf("+")>-1)
											measure = measure.substring(0,measure.indexOf("+"));
									}

									String unitmeasure=tablesInfo.getUnitForMeasure(stest,measure);
									if(unitmeasure==null || unitmeasure.equals(""))
									{
										String str_measureName = dbInfo.getMeasureForColumn(stest,measure);
										unitmeasure = tablesInfo.getUnitForMeasure(stest,str_measureName);
									}
									if(unitmeasure==null || unitmeasure.equals(""))
										unitmeasure = "-";
									String cspan=(String)ht_colspan.get(temp_disp);
									if(cspan == null || cspan.length()==0)
										cspan ="1";
									a_measunit.add(unitmeasure+"="+cspan);
									unitForMeasure.put(temp_disp,unitmeasure);
								}
								break;
							}
						}
						if(isVm)
						{
							totalColumnCount++;
							havingSingleColumn++;
						}
					}
					if(perServerDispMaxAvgPer!=null && perServerDispMaxAvgPer.size() > 0)
					{							
						Hashtable pServerData = (Hashtable)perServerDispMaxAvgPer.get(0);
						if(pServerData!=null && pServerData.size() > 0)
						{
							Enumeration p_keys = pServerData.keys();
							while(p_keys.hasMoreElements())
							{
								String key = (String)p_keys.nextElement();
								Hashtable value = (Hashtable)pServerData.get(key);
								if(value!=null && value.size() > 0)
								{
									subjects=(ArrayList)reportInfo.getVariables(INI_SUBJECT);
									int count = 0;
									for(int count_dis=0; count_dis<subjects.size(); count_dis++)
									{
										String var=(String)subjects.get(count_dis);
										if(var.indexOf(s_compType)<0)
										{
											if(var.indexOf("Total:")>-1)
											{
												StringTokenizer colon_st_temp=new StringTokenizer(var,":");
												colon_st_temp.nextToken();
												colon_st_temp.nextToken();
												String totalMeasure=colon_st_temp.nextToken();
												if(totalMeasure.indexOf("+")>-1)
													totalMeasure = totalMeasure.substring(0,totalMeasure.indexOf("+"));
												if(allMeasures!=null && !allMeasures.contains(totalMeasure))
													continue;
											}else
												continue;
										}
										StringTokenizer temp_st=new StringTokenizer(var,"#");
										temp_st.nextToken();
										String temp_disp = "";
										if(temp_st.hasMoreTokens())
											temp_disp=temp_st.nextToken();
										if(temp_disp != null && temp_disp.indexOf(":") > -1)
											temp_disp=temp_disp.substring(0,temp_disp.indexOf(":"));
										String tempJson="";
											
										Vector v_data = (Vector)value.get(temp_disp);
										
										if(v_data!=null && v_data.size() > 0)
										{
											if(v_data.size()==1)
												havingSingleColumn++;
											JSONArray subheaders =  new JSONArray();
											for(int vd=0; vd < v_data.size(); vd++)
											{
												String val = (String)v_data.get(vd);
												StringTokenizer st_v = new StringTokenizer(val,"$");
												while(st_v.hasMoreTokens())
												{													
													String measure = (String)st_v.nextToken();
													String computed = (String)st_v.nextToken();
													
													String computedVal = (String)st_v.nextToken();
														
													String measureUnit=(String)a_measunit.get(count);
													StringTokenizer unitValue=new StringTokenizer(measureUnit,"=");

													String measUnitDisp = unitValue.nextToken();
													vec1.add(intlmp.getTextDescription("reporter.thin."+temp_disp)+"("+measUnitDisp+")"+"-"+"("+computed+")");
													subheaders.add(intlmp.getTextDescription("reporter.common."+computed));
													totalColumnCount++;
													tempJson=intlmp.getTextDescription("reporter.thin."+temp_disp);
												}
											}
											gridColumnsDetails.put(tempJson,subheaders);
											count++;	
										}
									}
								}
								break;
							}
						}
					}
					String msmttime = "";
					
					int cnt=0;
					int totalColumn = -1;
					ArrayList aListDispValue = getReportDisplayValues(INI_SUBJECT,s_compType,allMeasures);
					ArrayList aListTestName = getReportTestNameList(INI_SUBJECT,s_compType,allMeasures);
					for(int j=0;j<Rep_data.size();j++)
					{
						JSONObject rowOfdata=new JSONObject();
						Object v1 = (Object)Rep_data.get(j);
						if(v1 instanceof Hashtable)
							continue;
						Report_data = (HashMap)Rep_data.get(j);
						if(showAllUsers || likeAllUsers)
						{
							user = (String)Report_data.get("user");
							v_session.add(user);
						}

						server = (String)Report_data.get("trgt_host");
						if(server==null)
							server="";
						LoginTime = (String)Report_data.get("login_time");
						s_duration = (String)Report_data.get("duration");
						msmttime = (String)Report_data.get("msmttime");
						idleTime = (String)Report_data.get("idleTime");
						activeTime = (String)Report_data.get("activeTime");
						if(idleTime==null)
							idleTime="-";
						if(activeTime==null)
							activeTime="-";
						dispLoginTime=LoginTime;
						//
						logon_duration = (String)Report_data.get("logon_duration");
						logon_duration_splitup = (String)Report_data.get("logon_duration_splitup");
						//
						if(LoginTime!=null)
						{
							try
							{
								dispLoginTime = DateUtil.changeDateFormat(LoginTime,"MM/dd/yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss");
								dispLoginTime = getUserTimeZone(dispLoginTime,thisuser);
							}
							catch(Exception e)
							{
								dispLoginTime = DateUtil.changeDateFormat(LoginTime,"MM/dd/yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss");
								dispLoginTime = getUserTimeZone(dispLoginTime,thisuser);

							}
						}
						if(msmttime!=null && !msmttime.equals(""))
						{
							if(msmttime.indexOf(":000")>0)
								msmttime=msmttime.substring(0,msmttime.indexOf(":000"));
						}
						msmttime = DateUtil.changeDateFormat(msmttime,"dd-MM-yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss");
						msmttime = getUserTimeZone(msmttime,thisuser);
						String SHr =  (String)Report_data.get("stHr");
						String SMin =  (String)Report_data.get("stMin");
						String SDat = (String)Report_data.get("startdate");
						String EHr =  (String)Report_data.get("endHr");
						String EMin =  (String)Report_data.get("endMin");
						String EDat = (String)Report_data.get("enddate");
						v_session.add(LoginTime);
						if(!isSummary)
						v_session.add(server);
						v_session.add(s_duration);

						String selServer = request.getParameter("select_server1");
						backQueryForServer = "../servlet/com.eg.ErCtxServerReportC?select_farm=" + EgURLEncoder.encode(s_farmserver,"UTF-8") + "&pdfTime="+pdfTime+"&isSubmit=true&showAll=" + showAllUsers + "&er_compType=" + s_compType + "&showSearch=" + sSearch + "&likeAllUsers=" + likeAllUsers + "&onlyThisUser=" + onlyThisUser + "&uid=" + com.eg.EgURLEncoder.encode(loginid,"UTF-8")+"&userID="+com.eg.EgURLEncoder.encode(urs,"UTF-8")+"&option=Citrix&er_RmDispName=Operation_Application&showFrom="+showFrom;
						String parameter = "&startdate="+URLEncoder.encode(request.getParameter("startdate"))+"&enddate="+URLEncoder.encode(request.getParameter("enddate"))+"&er_timeline="+URLEncoder.encode(er_timeline)+"&isSubmit=true&enableBack=true&backServletName=/servlet/com.eg.ErAlarmHistoryC?&inidate="+EgURLEncoder.encode(request.getParameter("inidate"),"UTF-8")+"&er_mode=3D&";
						queryForServer = "../reporter/ErReporterMenu.jsp?er_reportType=operation&call=json&isSubmit=true&er_rtype=Application&er_bgreportfrom=Operation_Application&trendenable=true&er_gtype=Measure&reporttype=operation&us_id="+com.eg.EgURLEncoder.encode(urs,"UTF-8")+"&er_comptype="+s_compType+"&"+getDateInfoString(request.getParameter("starthr"),request.getParameter("endhr"),request.getParameter("startmin"),request.getParameter("endmin"),null,null)+"&userID="+com.eg.EgURLEncoder.encode(urs,"UTF-8")+"&uid="+com.eg.EgURLEncoder.encode(urs,"UTF-8")+"&er_component="+EgURLEncoder.encode(server+":"+s_compType, "UTF-8")+"&fromFavSch=true&er_trenddata=No&er_option=Components&showFrom="+showFrom+parameter;

						if(selServer!=null && !selServer.equals(""))
							backQueryForServer+="&select_server1=" +EgURLEncoder.encode(selServer,"UTF-8");

						queryForGraph = "../servlet/com.eg.ErRepoLiteC?er_rtype=Micro&er_trgttype=CitrixUser&isSubmit=true&er_period=&er_site=&er_gtype=Measure&select_farm=" + s_farmserver +  "&er_tbound=" + tbound + "&startdate=" +request.getParameter("startdate") + "&enddate=" +request.getParameter("enddate") + "&starthr=" +request.getParameter("starthr")  + "&endhr=" + request.getParameter("endhr") + "&er_timeline=" + URLEncoder.encode(er_timeline)+ "&currTime=" + cTime + "&timeto=" + timeTo + "&timefrom=" + timeFrom + "&er_excwe=" + excludeweekend + "&showAll=" + showAllUsers + "&minfrom=" + minFrom + "&minto=" + minTo + "&er_compType=" + s_compType + "&showSearch=" + sSearch + "&likeAllUsers=" + likeAllUsers +"&onlyThisUser="+onlyThisUser + "&uid=" + com.eg.EgURLEncoder.encode(loginid,"UTF-8")+"&showFrom="+showFrom;

						String select_server = request.getParameter("select_server1");
						
						queryForMaxAvgPer = "../reporter/ErCtxUserGraph.jsp?er_rtype=Micro&er_trgttype=CitrixUser&er_period=&er_site=&er_gtype=Measure&select_farm=" +EgURLEncoder.encode(s_farmserver,"UTF-8") +  "&er_tbound=Any" + "&showAll=" + showAllUsers + "&er_compType=" + s_compType + "&showSearch=" + sSearch + "&likeAllUsers=" + likeAllUsers +"&onlyThisUser="+onlyThisUser + "&userTBound=" + tbound + "&userStartDate=" +EgURLEncoder.encode(request.getParameter("startdate"),"UTF-8")+ "&userEndDate=" + EgURLEncoder.encode(request.getParameter("enddate"),"UTF-8")+ "&userStHr=" + request.getParameter("starthr") + "&userEndHr=" + request.getParameter("endhr") + "&er_timeline=" +URLEncoder.encode("Any") + "&userCurrTime=" + cTime +"&timeto=" + timeTo + "&timefrom=" + timeFrom + "&er_excwe=" + excludeweekend + "&minfrom=" + minFrom + "&minto=" + minTo + "&thisIs=UserGraph&uid=" + com.eg.EgURLEncoder.encode(loginid,"UTF-8");
						queryForVirualMachineDetails="../servlet/com.eg.ErEsxVMServerReportC?er_usertimeline=-1&ervm_disp=No&trendenable=true&er_reportgenration=foreground&forwardto=ErEsxGuestReport&er_trgttype=Virtual_Machine_Details&er_check=Virtualization&vmStrData=&er_mode=3D&er_ViewName=ErEsxGuestReport.jsp&er_type=Yes&fromSchedule=null&schedule_id=null&isSubmit=true&er_bgreportfrom=Virtualization_VM_Virtual_Resource&savereport=save&er_trenddata=No&detailtime=-1&servletName=com.eg.ErEsxVMServerReportC&er_timeline=Any&er_measure=All&er_rtype=Virtualization&reqfrom=vmGuest&enableBack=true&backServletName=/servlet/com.eg.ErCtxServerReportC?&minto="+minTo+"&minfrom="+minFrom+"&timeto="+timeTo+"&timefrom="+timeFrom+"&userID="+com.eg.EgURLEncoder.encode(loginid,"UTF-8")+"&fromSessionReport=true"+getVmReportDetails(menuForVM, isUserVmReport, isVmReports,s_compType,excludeweekend)+"&fromSessionReport=true";
						if(select_server!=null && !select_server.equals(""))
							queryForMaxAvgPer+="&select_server1=" + EgURLEncoder.encode(select_server,"UTF-8");

						String encc_user=user;
						if(user==null || user.trim().equals(""))
							encc_user=s_user;
						if(encc_user!=null && encc_user.trim().length()>0)
							encc_user = com.egurkha.util.StringUtils.replace(encc_user,"\\", "\\\\");
						String toFormAsKey = "";
						String app_user="";
						if(showAllUsers)
						{
							queryForGraph+="&er_user=" + java.net.URLEncoder.encode(encc_user) + "&t_user=-- All --";
							backQueryForServer+="&er_user=-- All --";//"&er_user=" + user + "&t_user=-- All --";
							app_user=user;
							toFormAsKey = user + "$";
							queryForMaxAvgPer+="&er_user=" + EgURLEncoder.encode(encc_user,"UTF-8") + "&t_user="+EgURLEncoder.encode(com.egurkha.util.StringUtils.replace(user,"\\","\\\\"),"UTF-8");//-- All --";
						
						}
						else if(likeAllUsers)
						{
							queryForGraph+="&er_user=" + java.net.URLEncoder.encode(encc_user) + "&er_tuser=" + EgURLEncoder.encode(s_user,"UTF-8") ;
							backQueryForServer+="&er_user=" + java.net.URLEncoder.encode(encc_user) + "&er_tuser=" + EgURLEncoder.encode(s_user,"UTF-8") ;
							app_user=user;
							toFormAsKey = user + "$";
							queryForMaxAvgPer+="&er_user=" + java.net.URLEncoder.encode(encc_user) + "&er_tuser=" + EgURLEncoder.encode(s_user,"UTF-8") ;
						}
						else if(onlyThisUser)
						{
							queryForGraph+="&er_tuser=" + EgURLEncoder.encode(s_user,"UTF-8")  + "&er_user=" + java.net.URLEncoder.encode(s_user) ;
							backQueryForServer+="&er_tuser=" + EgURLEncoder.encode(s_user,"UTF-8")  + "&er_user=" + java.net.URLEncoder.encode(s_user) ;
							//user = java.net.URLEncoder.encode(s_user) ;
							user = s_user;
							app_user=user;
							queryForMaxAvgPer+="&er_user=" + EgURLEncoder.encode(encc_user,"UTF-8") + "&er_tuser=" + EgURLEncoder.encode(s_user,"UTF-8") ;
						}
						else
						{
							queryForGraph+="&er_user=" + java.net.URLEncoder.encode(s_user) ;
							backQueryForServer+="&er_user=" + java.net.URLEncoder.encode(s_user) ;
							user = s_user;
							queryForMaxAvgPer+="&er_user=" + java.net.URLEncoder.encode(encc_user) + "&er_tuser=" + 
							EgURLEncoder.encode(com.egurkha.util.StringUtils.replace(s_user,"\\","\\\\"),"UTF-8");
						}
						queryForGraph+="&er_component=" +EgURLEncoder.encode(server,"UTF-8");
						queryForMaxAvgPer+="&er_component=" +EgURLEncoder.encode(server,"UTF-8"); 
						queryForVirualMachineDetails+="&er_component=" +EgURLEncoder.encode(server,"UTF-8");

						String site="NULL";
						test = getTestNameForType(aListSupportComponentType,s_compType,INI_SUBJECT);						
						String comp = "";
						String port  ="";
						if(!isSummary)
						{
							comp = server.substring(0,server.indexOf(":"));
							port  =server.substring(server.indexOf(":")+1,server.length());
						}
						String encuser_dd=user;//com.egurkha.util.StringUtils.replace(user,"\\", "\\\\");
						 encuser_dd = "*"+encuser_dd;
						String user_dd = "*"+user;
						String dd_url =""; 
						session.setAttribute("backQueryForUser",backQueryForServer);
						session.removeAttribute("farmQs");
						double d_duration = Math.round(Double.parseDouble(s_duration));
						String st_duration = String.valueOf(d_duration);
						
						if(st_duration!=null & st_duration.indexOf(".") > -1)
						{
							st_duration  = st_duration.substring(0,st_duration.indexOf("."));
						}
						//if(!isSummary)						
							toFormAsKey = toFormAsKey + LoginTime + "$" + server + "$" + st_duration;
						//else
						//	toFormAsKey = toFormAsKey + LoginTime + "$" +  st_duration;
						if(!isSummary)
						{
							rowOfdata.put(rowOfdata.size(),"Details~"+dd_url+"&showFrom="+showFrom);
						}
						if(showAllUsers || likeAllUsers)
						{
							lst_dat1.add('"'+user+'"');
							rowOfdata.put(rowOfdata.size(),user);
						}
						if(isSummary)
						{
							String val="";
							if(summarySessionVc!=null)
							{
								val=(String)summarySessionVc.get(user);
							}
							else
							{
								val=sess+"";
							}
							lst_dat1.add('"'+val+'"');
							rowOfdata.put(rowOfdata.size(),val);							
							if(client_Version!= null && !client_Version.equalsIgnoreCase("")){
								for(int m=0;m<aListClientDetails.size();m++)
								{
									String strColName = (String)aListClientDetails.get(m);
									String strColVal = (String)Report_data.get(strColName);
									if((strColVal == null || strColVal.length()==0))
										strColVal = "-";
									if(strColVal!=null && (strColVal.equals("-5") || strColVal.equals("-1")))
										strColVal = "-";
									lst_dat1.add('"'+strColVal+'"');
									rowOfdata.put(rowOfdata.size(),strColVal);
								}
							}
						}
						if(server.endsWith(":NULL"))
						{
							server = server.substring(0,server.indexOf(":"));
						}
						String logintimedisp=LoginTime.substring(0,LoginTime.indexOf(" "));
						String deskNameData = getDesktopName("",Report_data);
						if(perServerDispMaxAvgPer!=null && perServerDispMaxAvgPer.size() > 0)
						{
							Hashtable pServerDataSample = (Hashtable)perServerDispMaxAvgPer.get(0);
							if(pServerDataSample!=null&&pServerDataSample.size() > 0)
							{
								Hashtable p_val = (Hashtable)pServerDataSample.get(toFormAsKey);
								if(p_val!=null)
								{
									String deskName = (String)p_val.get("DeskTopName");
									if(deskName == null || deskName.equals(""))
										deskName = "-";
									deskName = getDesktopName(deskName,Report_data);
									strUserWithDesktop = deskName;
									deskNameData = deskName;
									if(deskName.indexOf("_")>-1)
										deskNameData = deskName.substring(deskName.lastIndexOf("_")+1,deskName.length());
									//else
										//deskNameData="-";
								}
							}
						}
						if(clientIp!=null && clientIp.equals("Yes"))
						{
							if(Report_data!=null && (Report_data.containsKey("Client_IP_Address") || Report_data.containsKey("Client_name")))
							{
								if(aListClientDetails_ColName !=null && aListClientDetails_ColName.size()>0 && !isSummary)
								{
									for(int cc=0;cc<aListClientDetails_ColName.size();cc++)
									{
										String strColName = (String)aListClientDetails_ColName.get(cc);
										String strColVal = (String)Report_data.get(strColName);
										if((strColVal == null || strColVal.length()==0))
											strColVal = "-";
										if(strColVal!=null && (strColVal.equals("-5") || strColVal.equals("-1")))
											strColVal = "-";
										lst_dat1.add('"'+strColVal+'"');
										rowOfdata.put(rowOfdata.size(),strColVal);
									}
								}
							}
						}
						if(!isSummary)
						{
							lst_dat1.add('"'+dispLoginTime+'"');
							lst_dat1.add('"'+msmttime+'"');						
							
							rowOfdata.put(rowOfdata.size(),dispLoginTime);
							rowOfdata.put(rowOfdata.size(),msmttime);						
							
					
						}
						//
						lst_dat1.add(s_duration);
						lst_dat1.add(idleTime);
						lst_dat1.add(activeTime);
						rowOfdata.put(rowOfdata.size(),s_duration);
						rowOfdata.put(rowOfdata.size(),idleTime);
						rowOfdata.put(rowOfdata.size(),activeTime);
						if(!isSummary)
						{
							if(!hasVMs)
							{
							lst_dat1.add('"'+server+'"');
							rowOfdata.put(rowOfdata.size(),server+"~"+queryForServer);
							}
							if(clientIp!=null && clientIp.equals("Yes"))
							{
								if(geoColumnList != null && geoColumnList.size() >0 ){
									for(int m=0;m<geoColumnList.size();m++){
										String str1=(String)geoColumnList.get(m);
										String strColVal = (String)Report_data.get(str1);
										lst_dat1.add('"'+strColVal+'"');
										rowOfdata.put(rowOfdata.size(),strColVal);
									}
								}
							}
						}
						if(s_compType!=null && aListVmComponentType.contains(s_compType))
						{
							if(deskNameData==null || deskNameData.equals(""))
							{
								deskNameData = "-";
							}
								if(!isSummary)			
								{
									//if(( er_showResourceUsage!=null && er_showResourceUsage.equalsIgnoreCase("Yes")))
									{
									lst_dat1.add('"'+deskNameData+'"');										
									rowOfdata.put(rowOfdata.size(),deskNameData);
									}
								}
						}

							//
							rowOfdata.put(rowOfdata.size(),logon_duration);
							lst_dat1.add(logon_duration);
							//
						if(perServerDispMaxAvgPer!=null && perServerDispMaxAvgPer.size() > 0)
						{
							Hashtable pServerData = (Hashtable)perServerDispMaxAvgPer.get(0);
							Hashtable ser_dur = (Hashtable)perServerDispMaxAvgPer.get(1);
							if(pServerData!=null&&pServerData.size() > 0)
							{
								Hashtable p_valuedd = (Hashtable)pServerData.get(toFormAsKey);
								totalnoofcols=0;
								String sDatedd = "";
								String eDatedd = "";
								String sHrdd = "";
								String eHrdd = "";
								String sMindd = "";
								String eMindd = "";
								if(ser_dur!=null && ser_dur.size() > 0)
								{
									String valdd = (String)ser_dur.get(toFormAsKey);
									if(valdd!=null)
									{
										StringTokenizer st_dd = new StringTokenizer(valdd,"$");
										String sTimedd = "";
										String eTimedd = "";
										while(st_dd.hasMoreTokens())
										{
											sTimedd = (String)st_dd.nextToken();
											eTimedd = (String)st_dd.nextToken();
										}

										String strtDate[]=getDateFormat(sTimedd);
									
										sDatedd = strtDate[1] + "/"  + strtDate[0] + "/" + strtDate[2];
										sDatedd = 
											DateUtil.changeDateFormat(sDatedd,"MM/dd/yyyy",currentDateFormat);
										sHrdd = strtDate[3];
										if(sHrdd.startsWith("0"))
											sHrdd = sHrdd.substring(1);
										sMindd = strtDate[4];
										if(sMindd.startsWith("0"))
											sMindd = sMindd.substring(1);
										String stendDate[]=getDateFormat(eTimedd);

										eDatedd = stendDate[1] + "/" + stendDate[0] + "/" + stendDate[2];
										eDatedd = 
											DateUtil.changeDateFormat(eDatedd,"MM/dd/yyyy",currentDateFormat);
										eHrdd = stendDate[3];
										eMindd = stendDate[4];
										String ddMeasure="No_of_sessions";
										if(s_compType!=null && (s_compType.equalsIgnoreCase("Vmware_vdi_server") || s_compType.equals("VmVdi_i_server")))
											ddMeasure="Current_sessions";
										ddMeasure = reportInfo.getCtxUserDDMeasure(INI_SUBJECT,s_compType);
										String ddTest = reportInfo.getCtxUserDDTest(INI_SUBJECT,s_compType);
										String vmuser_dd="";
										String vmuser_report=strUserWithDesktop;
										if(isVm)
										{
											if(strUserWithDesktop!=null && !strUserWithDesktop.equals("-"))
											{
												//vmuser_report=com.egurkha.util.StringUtils.replace(vmuser_report,"\\", "\\\\");
												if(vec_infos!=null && vec_infos.size()>0)
												{
													for(int i=0;i<vec_infos.size();i++)
														{
															String strInfo = (String) vec_infos.get(i);
															if(!strInfo.endsWith(":Summary"))
																continue;
															if(strInfo!=null && strInfo.toLowerCase().startsWith(("+"+strUserWithDesktop.toLowerCase())) || strInfo.toLowerCase().startsWith(strUserWithDesktop.toLowerCase()))
															{
																strUserWithDesktop = strInfo;
																break;
															}
														}
													}
													
													if(strUserWithDesktop!=null && !strUserWithDesktop.equals("-"))
												user_dd ="*"+strUserWithDesktop.trim().substring(1);
												
												vmuser_dd=user_dd;//com.egurkha.util.StringUtils.replace(user_dd,"\\", "\\\\");
							
											}
											dd_url = "/final/monitor/componentMeasureTabSet.jsp?type="+EgURLEncoder.encode(s_compType,"UTF-8")+"&site="+site+"&host="+EgURLEncoder.encode(comp,"UTF-8")+"&port="+port+"&info="+EgURLEncoder.encode(vmuser_dd,"UTF-8")+"&info="+deskNameData+"&state=&messy="+ddMeasure+"&msmt_host=&starttime=" +sDatedd + "&endtime=" + eDatedd + "&"+ getDateInfoString(sHrdd,eHrdd,sMindd,eMindd,null,null)+"&userID="+EgURLEncoder.encode(urs,"UTF-8")+"&test="+ ddTest+"&comptype="+s_compType+"&measureDisp="+ddMeasure+"&from=measurespage&dd=yes&clicked=dd&newWindow=true&fromReporterHis=true&popup=true&fromPage=UserSessionDetails";
											queryForMaxAvgPer+=appendInfoAndDesktopName(vmuser_dd,deskNameData,showFrom);
										}
										else
										{
											dd_url = "/final/monitor/componentMeasureTabSet.jsp?type="+EgURLEncoder.encode(s_compType,"UTF-8")+"&site="+site+"&host="+EgURLEncoder.encode(comp,"UTF-8")+"&port="+port+"&info="+EgURLEncoder.encode(encuser_dd,"UTF-8")+"&info="+deskNameData+"&state=&messy="+ddMeasure+"&msmt_host=&starttime=" +sDatedd + "&endtime=" + eDatedd + "&"+ getDateInfoString(sHrdd,eHrdd,sMindd,eMindd,null,null)+"&userID="+EgURLEncoder.encode(urs,"UTF-8")+"&test="+ ddTest+"&comptype="+s_compType+"&measureDisp="+ddMeasure+"&from=measurespage&dd=yes&clicked=dd&newWindow=true&fromReporterHis=true&popup=true&fromPage=UserSessionDetails";
											queryForMaxAvgPer+=appendInfoAndDesktopName(encuser_dd,deskNameData,showFrom);
										}
										queryForVirualMachineDetails+="&select_vm="+EgURLEncoder.encode(vmuser_report,"UTF-8");
									}
								}
							}
							
							boolean showDDUrl = false;
							if(s_compType!=null && aListApplicationComponentType.contains(s_compType))
								showDDUrl = true;
							if(isVm && (deskNameData==null || deskNameData.equals("") ||  deskNameData.equals("-") ))
								showDDUrl = false;
							if(!isSummary)
							{
								if(showDDUrl)
								{
									if(strShowAppNames!=null && (strShowAppNames.equalsIgnoreCase("Yes") || strShowAppNames.equalsIgnoreCase("True")) && ( er_showResourceUsage!=null && er_showResourceUsage.equalsIgnoreCase("Yes")))
									{
										ArrayList aListData = (ArrayList)Report_data.get("AppsName");
										String strAppNames = "";
										if(aListData!=null && aListData.size()>0)
										{
											for (int i=0;i<aListData.size();i++)
											{
												strAppNames+=aListData.get(i)+",";
											}
											if(strAppNames!=null && strAppNames.endsWith(","))
												strAppNames = strAppNames.substring(0,strAppNames.length()-1);
											if(strAppNames == null || strAppNames.length()==0)
											{
												lst_dat1.add("-");
												rowOfdata.put(rowOfdata.size(),"-");
											}else
											{
												if(!isSummary)												
													rowOfdata.put(rowOfdata.size(),"DD~"+strAppNames);
												else
													rowOfdata.put(rowOfdata.size(),strAppNames);
												lst_dat1.add("\""+strAppNames+"\"");
											}
										}else
										{
											rowOfdata.put(rowOfdata.size(),"-");
											lst_dat1.add("-");
										}
									}else
									{
										if(!isSummary)	
											rowOfdata.put(rowOfdata.size(),"DD~"+dd_url);
										else
											rowOfdata.put(rowOfdata.size(),dd_url);
									}
								}else
								{
									if(s_compType!=null && aListApplicationComponentType.contains(s_compType))
									{
										rowOfdata.put(rowOfdata.size(),"-");
									}
								}
							}
							if(pServerData!=null && pServerData.size() > 0)
							{
								Hashtable p_value = (Hashtable)pServerData.get(toFormAsKey);
								String sDate = "";
								String eDate = "";

								String sHr = "";
								String eHr = "";
								String sMin = "";
								String eMin = "";
								if(ser_dur!=null && ser_dur.size() > 0)
								{
									String val = (String)ser_dur.get(toFormAsKey);
									if(val!=null)
									{
										StringTokenizer st_d = new StringTokenizer(val,"$");
										String sTime = "";
										String eTime = "";
										while(st_d.hasMoreTokens())
										{
											sTime = (String)st_d.nextToken();
											eTime = (String)st_d.nextToken();
										}
										String strStrtDate[]=getDateFormat(sTime);


										sDate = strStrtDate[1] + "/"  + strStrtDate[0] + "/" + strStrtDate[2];
										sDate = DateUtil.changeDateFormat(sDate,"MM/dd/yyyy",currentDateFormat);
										sHr = strStrtDate[3];
										if(sHr.startsWith("0"))
											sHr = sHr.substring(1);
										sMin = strStrtDate[4];
										if(sMin.startsWith("0"))
											sMin = sMin.substring(1);
										String strEndDate[]=getDateFormat(eTime);

										eDate = strEndDate[1] + "/" + strEndDate[0] + "/" + strEndDate[2];
										eDate = DateUtil.changeDateFormat(eDate,"MM/dd/yyyy",currentDateFormat);
										eHr = strEndDate[3];
										eMin = strEndDate[4];
										if(eHr.startsWith("0"))
											eHr = eHr.substring(1);
										if(eMin.startsWith("0"))
											eMin = eMin.substring(1);
										
										queryForMaxAvgPer += "&startdate=" + EgURLEncoder.encode(sDate,"UTF-8")+ "&enddate=" + EgURLEncoder.encode(eDate,"UTF-8")+ "&" + getDateInfoString(sHr,eHr,sMin,eMin,null,null)+"&er_secs="+strEndDate[5];
										queryForMaxAvgPer += appendString(EgURLEncoder.encode(sDate,"UTF-8"),EgURLEncoder.encode(eDate,"UTF-8"),sHr,eHr) + "&er_startmin="+ sMin + "&er_endmin=" + eMin+"&inidate="+EgURLEncoder.encode(request.getParameter("inidate"),"UTF-8");
										String tmp_eDate=eDate;
										String tmp_eHr=eHr;
										double dle_duration = Math.round(Double.parseDouble(s_duration));
										if(dle_duration<60)
										{
											if(!tmp_eHr.equals("") && tmp_eHr.equals("23"))
											{
												SimpleDateFormat sdf = new SimpleDateFormat(currentDateFormat);
												Calendar cal = Calendar.getInstance();
												cal.setTime(sdf.parse(tmp_eDate));
												cal.add(Calendar.DATE, 1);  // number of days to add
												tmp_eDate = sdf.format(cal.getTime());
												tmp_eHr="1";
											}
											else
											{
											int aInt = Integer.parseInt(tmp_eHr);
											aInt+=1;
											tmp_eHr=String.valueOf(aInt);
											}
										}
										//need to encode using URL encoder
										queryForVirualMachineDetails+=appendString(URLEncoder.encode(sDate),URLEncoder.encode( tmp_eDate),sHr,tmp_eHr);
										queryForVirualMachineDetails+="&startdate=" +URLEncoder.encode(sDate)+ "&enddate=" + URLEncoder.encode(tmp_eDate)+ "&" +getDateInfoString(sHr,tmp_eHr,sMin,eMin,null,null);
										queryForVirualMachineDetails+="&st_date="+URLEncoder.encode((String)DateUtil.changeDateFormat(sDate,currentDateFormat,"dd-MM-yyyy"))+"&en_date="+URLEncoder.encode((String)DateUtil.changeDateFormat(tmp_eDate,currentDateFormat,"dd-MM-yyyy"));
										}
								}
								if(p_value!=null && p_value.size() >0)
								{
									String addmap="";
									String tmp1=null;
									String tmp2=null;
									String tmpVal="";
									boolean connectionInde=false;
									for(int count_dis=0; count_dis<aListDispValue.size(); count_dis++)
									{
										connectionInde=false;
										String temp_disp=(String)aListDispValue.get(count_dis);
										String strTestname = (String)aListTestName.get(count_dis);
										if(strTestname!=null && strTestname.equalsIgnoreCase("CtxXcXAUserTest:Connection_strength"))
											connectionInde = true;
										if(strTestname!=null && strTestname.indexOf(":")>-1)
											strTestname = strTestname.substring(0,strTestname.indexOf(":"));
										String dbName = "";
										String dispName = "";
										Vector p_val = (Vector)p_value.get(temp_disp);

										if(p_val!=null && p_val.size() >0)
										{
											totalnoofcols+=p_val.size();
											for(int pv=0; pv < p_val.size(); pv++)
											{
												String value = (String)p_val.get(pv);
												StringTokenizer st_v = new StringTokenizer(value,"$");
												String computedVal = "-";
												int nooftokens=st_v.countTokens();
												String b=(String)subjects.get(pv);

												while(st_v.hasMoreTokens())
												{
													String measure = (String)st_v.nextToken();
													StringTokenizer st_m = new StringTokenizer(measure,"#");
													dispName = (String)st_m.nextToken();
													if(AddfieldDisplay.indexOf(dispName)==-1)
													{
														if (!AddfieldDisplay.equals(""))
															AddfieldDisplay+=","+dispName;
														else
															AddfieldDisplay=dispName;
													}
													dbName = (String)st_m.nextToken();
													String computed = (String)st_v.nextToken();
													String computed1=computed;
													String dname=dispName;
													
													if (computed.indexOf(" ")>-1)
														computed=computed.substring(computed.lastIndexOf(" ")+1);
													if(Fields.indexOf(dbName + "_"+computed)==-1)
													{
														if (!Fields.equals(""))
														{
															Fields+=","+dbName+"_"+computed;
															fieldDisplay+=","+computed1;
														}
														else
														{
															Fields=dbName+"_"+computed;
															fieldDisplay+=","+computed1;
														}
													}
													computedVal = (String)st_v.nextToken();
												}

												if (v_session!=null)
													v_session.add(computedVal);
												else
													v_session.add("-");

												if(computedVal!=null && computedVal.equals("-"))
												{
													lst_dat1.add(computedVal);
													rowOfdata.put(rowOfdata.size(),computedVal);
												}
												else
												{
													if(connectionInde)
													{
														try{
															double d = Double.parseDouble(computedVal);
															d = Math.floor(d);
															//computedVal = d+"";
															computedVal = getConnectionQulityString(d);
														}catch(Exception e){}
													}
													lst_dat1.add(computedVal);
													if(!isSummary)
													{
														if(tmpVal != null && tmpVal.length() > 0){
															StringTokenizer stTokn=new StringTokenizer(tmpVal,":");
															while(stTokn.hasMoreTokens()){
																tmp1=(String)stTokn.nextToken();
																tmp2=(String)stTokn.nextToken();
																if(tmp2 != null && tmp2.equalsIgnoreCase(dbName))
																	strTestname=tmp1;
															}
														}
														rowOfdata.put(rowOfdata.size(),computedVal+"~"+queryForMaxAvgPer + "&getMeasure=" + dbName+"&getTest="+strTestname);
													}
													else
														rowOfdata.put(rowOfdata.size(),computedVal);

												}
											}
										}
									}
								}
							}
						}
						if(isVm)
						{
							if(!isSummary)
								rowOfdata.put(rowOfdata.size(),"top.gif~"+queryForVirualMachineDetails);
						}
						rowOfdata.put("indx",cnt);
						cnt++;
						
						JSONObject processObj = null;
						if(totalColumn==-1)
						{
							totalColumn = lst_dat1.size();
						}
						processObj = processSplitUpDetails(logon_duration_splitup,intlmp,totalColumn,lst_dat1);
						if(processObj!=null)
						{
							rootJson.put("needLogonSplitUp",needLogonSplitUp);
							rowOfdata.put("splitUpDetails",processObj);
						}
						gridDataArray.add(rowOfdata);
					}
					if(isVm &&!isSummary)
					{
								if(( er_showResourceUsage!=null && er_showResourceUsage.equalsIgnoreCase("Yes")))
								{
								gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.More Details"),new JSONArray());
								}
					}
						gridObj.put("columns",gridColumnsDetails);
						gridObj.put("units",unitForMeasure);
						gridObj.put("dataArray",gridDataArray);
						gridObj.put("TOTAL_COLUMN_COUNT",String.valueOf(totalColumnCount));
						gridObj.put("SINGLE_SUBCOLUMN_COUNT",										String.valueOf(havingSingleColumn));
						reportDataJson.put("measureGrid",gridObj);
					
					
					if(disconuser!=null && disconuser.size()> 0)
					{
						JSONObject tableObj=new JSONObject();
						JSONArray ColumnsDetails=new JSONArray();
						JSONArray tableData=new JSONArray();

						String t_users=request.getParameter("er_user");
						ArrayList a_colum=new ArrayList();
						boolean userselect=false;
						//check the give user are there.
							t_users=s_user;
						for(int n1=0; n1<disconuser.size();n1=n1+2)
						{
							ArrayList a_measure = (ArrayList)disconuser.get(n1+1);
							if(a_measure!=null && a_measure.size()>0)
							{
								for(int k1=0; k1<a_measure.size();k1++)
								{
									String col_val=(String)a_measure.get(k1);
									if(col_val.indexOf(colSeparator)> -1)
										a_colum= tokInfo.egTokenizer(col_val, colSeparator);
									if(a_colum.contains(t_users))
										userselect=true;
								}
							}
						}
											
						//
						boolean txtBoxAllusrFound=false;
						if(t_users!=null && t_users.equalsIgnoreCase("*"))
						{
								t_users="-- All --";
								txtBoxAllusrFound=true;
						}
						else if(t_users!=null && t_users.indexOf("*")>-1)
							userselect=true;
						//
						/* selected users are single users or all user*/

						ArrayList rowList=new ArrayList();
					if(t_users!=null && ( userselect || t_users.equals("-- All --")))
						{
							String getdescname=discontest.substring(discontest.lastIndexOf(":")+1);
							if(txtBoxAllusrFound)
							{

								s_tit = intlmp.getTextDescription("reporter.thin."+getdescname+" for User ")+" - "+t_users;
							}
							else if(t_users!=null && !t_users.equals("-- All --"))
							{
								s_tit = intlmp.getTextDescription("reporter.thin."+getdescname+" for User ")+" - "+t_users;
							}
							else
							{
								s_tit = getdescname+" for All Users";
							}
							tableObj.put("title",s_tit);
							String col_filed="";
							int col_length=0;
							ArrayList columname=new ArrayList();
							String getcolumname=discontest.substring(discontest.indexOf(":")+1,discontest.lastIndexOf(","));
							
							StringTokenizer getrowmeas=new StringTokenizer(getcolumname," ");
							while(getrowmeas.hasMoreTokens() )
							{
								columname.add(getrowmeas.nextToken());
							}
							columname.add(0,"Measure Time");
							col_length= columname.size();

							/* users measure column*/
							for(int s=0;s< columname.size();s++)
							{
								String s_colname=(String)columname.get(s);
								vec.add(intlmp.getTextDescription("reporter.thin."+s_colname));
								ColumnsDetails.add(intlmp.getTextDescription("reporter.thin."+s_colname));
							}
							ArrayList al_cols = new ArrayList();
							for(int n=0; n<disconuser.size(); n=n+2)
							{
								JSONArray rowOftable=null;
								
								String msmt_time=(String)disconuser.get(n); //get time
								int m=n;
								String s_starttime=msmt_time.substring(0,10);
								String sthrmin=msmt_time.substring(10,19);
								String logtime=DateUtil.changeDateFormat(s_starttime,"MM/dd/yyyy",currentDateFormat)+" "+sthrmin;
								ArrayList getmeasure = (ArrayList)disconuser.get(n+1); //get deal_measure(1 or more column)
								boolean morecol=false;
								if(getmeasure!=null && getmeasure.size()>0)
								{
									for(int k=0; k< getmeasure.size();k++)
									{
										rowOftable =  new JSONArray();
										if(logtime == null || logtime.equals("")){
											
											lst_dat.add(" ");
										}
										String col_value=(String)getmeasure.get(k);
										if(col_value.indexOf(colSeparator) > -1)
											al_cols= tokInfo.egTokenizer(col_value, colSeparator);
										String user1=(String)al_cols.get(0);

										if(t_users!=null && !t_users.equals("-- All --"))
										{
											// for text box user find..
											if(t_users.indexOf("*")>-1)
											{
												if(t_users.startsWith("*")&&t_users.endsWith("*"))
												{
												String tStr=t_users.substring(1,t_users.length()-1);
													if(user1!=null && user1.indexOf(tStr)==-1)
													{
													continue;
													}
												}
												else if(t_users.startsWith("*"))
												{
													
													int idx=t_users.indexOf("*");
													String tStr=t_users.substring(idx+1);
													if(user1!=null && !user1.endsWith(tStr))
													{
													continue;
													}
												}
												else if(t_users.endsWith("*"))
												{
																								//
													int idx=t_users.indexOf("*");
													String tStr=t_users.substring(0,idx);
													if(user1!=null && !user1.startsWith(tStr))
													{
													continue;
													}
												}
											}
											else if(!t_users.equals(user1))
												continue;
											lst_dat.add('"'+logtime+'"');
											rowOftable.add(logtime);
										}
										else if(n==m)
										{
											lst_dat.add('"'+logtime+'"');
											rowOftable.add(logtime);

											if(getmeasure.size()>1)
											{
												if(morecol)
												{
													for(int s=1;s< columname.size();s++)
													{
														lst_dat.add(" ");
														rowOftable.add(" ");

													}
												}
											}
										}
										if(t_users!=null && t_users.equals("-- All --"))
										{
											if(getmeasure.size()>1)
											{
												if(morecol)
												{
													rowOftable.add(logtime);
													lst_dat.add('"'+logtime+'"');
												}
											}
										}
								//		//System.out.println("al_cols:size:>>>>>"+al_cols.size());
										//for(int y=0;y<al_cols.size();y++)			//For BugId 15474
										for(int y=0;y<columname.size()-1;y++)
										{

											String trvalue=(String)al_cols.get(y);
									//			//System.out.println("trvalue:>>>>>"+trvalue);
											lst_dat.add(trvalue);
											rowOftable.add(trvalue);
										}
										m=m+1;
										morecol=true;
										tableData.add(rowOftable);
										////System.out.println("rowOftable::>>>>>"+rowOftable);
									}
								}
								rowList.add(rowOftable.size());
							//tableData.add(rowOftable);
							}
						}
						if(rowList!=null && rowList.size()>0)
						{
							rwSize=((Integer)Collections.max(rowList)).intValue();
						}

						if(rwSize>0)
						{
						tableObj.put("columnDetails",ColumnsDetails);
						tableObj.put("tableData",tableData);
						reportDataJson.put("disconnectUserTable",tableObj);
						}
						
					}
					HashMap param =new HashMap();
					HashMap m=ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap()));
					try{
						m.put("er_timeline",URLEncoder.encode((String)m.get("er_timeline")));
					}catch(Exception e){}
					param.put("REPORT_PARAM",m);
					param.put("REPORT_DATA",userPdfData);
					session.setAttribute("parameters", param);
						
					//-------------------						
				}
				Vector forPrint = new Vector();
				forPrint.add(new Boolean(showAllUsers));
				forPrint.add(new Boolean(showDuration));
				forPrint.add(new Boolean(showMeasure));
				
				forPrint.add(new Integer(tempsess));
				forPrint.add(new Boolean(onlyThisUser));
				forPrint.add(new Boolean(likeAllUsers));
				if(showDuration)
				{
					forPrint.add(avg);
					forPrint.add(maximum);
				}
				session.setAttribute("userReSummary", forPrint);
				reportDataJson.put("isVmComponent",reportInfo.isVmComponent(s_compType));
				String includeDetails=reportInfo.getValue("CITRIX_USER_REPORT","IncludeDetailsforComponents");
				if(includeDetails != null && includeDetails.indexOf(s_compType) > -1 )
					reportDataJson.put("includeDetails",new Boolean(true));
				else
					reportDataJson.put("includeDetails",new Boolean(false));
				rootJson.put("reportData",reportDataJson);
				
			}
		}else
		{
			
			if(ht_Rep_data!=null)
			{
				if(ht_Rep_data.size()>0)
				{
					JSONObject reportDataJson = new JSONObject();
					JSONObject gridObj=new JSONObject();
					JSONObject gridColumnsDetails=new JSONObject();
					JSONObject unitForMeasure=new JSONObject();
					JSONArray gridDataArray=new JSONArray();

					JSONArray gridDataRowArray=new JSONArray();
					JSONArray gridColumns=new JSONArray();
					JSONArray gridDisplayColumns=new JSONArray(); 

					int totalColumnCount=0;
					int havingSingleColumn=0;

					TreeMap Map_param = new TreeMap(ht_Rep_data);
					Iterator itr = Map_param.keySet().iterator();

						if(!showAllUsers && !likeAllUsers)
						{
							int temp_totalspan=totalspan;
							if(s_compType!=null && aListApplicationComponentType.contains(s_compType))
									temp_totalspan=temp_totalspan-1;
							session.setAttribute("headingspan",String.valueOf(temp_totalspan));
							
							if(isVm)//for vm adding extra column for show link to virtual machine details
							{
								totalspan=totalspan+1;
							}
						}
						else
						{
							session.setAttribute("headingspan",String.valueOf(totalspan+1));
							if(isVm)//for vm adding extra column for show link to virtual machine details
							{
								totalspan=totalspan+2;
							}
						}
						if(!showAllUsers && !likeAllUsers)
						{
							sessionTitle = "SESSION DETAILS FOR - " + s_user;
							s_tit1 = intlmp.getTextDescription("reporter.common.Session details for User")+" - "+s_user;
						}
						else
						{
							if(likeAllUsers)
							{
								String userForPdf = "";
								sessionTitle = "SESSION DETAILS FOR - " + s_user;
								s_tit1 = intlmp.getTextDescription("reporter.common.Session details for")+" - "+s_user+" "+intlmp.getTextDescription("reporter.common.Users");
							}
							else if(onlyThisUser)
							{
								sessionTitle = "SESSION DETAILS FOR - "  + s_user;
							}
							else
							{
								sessionTitle = "SESSION DETAILS FOR - ALL USERS";
								s_tit1 = intlmp.getTextDescription("reporter.common.Session details for  User")+" - "+intlmp.getTextDescription("reporter.common.All Users");
							}
						}
						gridObj.put("gridTitle",s_tit1);
						gridObj.put("gridTitleNew","Session Details");
								//
						if(adGroupFns!=null && (adGroupFns.equalsIgnoreCase("Details")||adGroupFns.equalsIgnoreCase("Summary")))
							s_tit1="Session Details";
								//
						//StringBuffer sb_sessionField = new StringBuffer();
						StringBuffer sb_field=new StringBuffer();
						ArrayList a_measunit = new ArrayList(); // get measures unit name and no of column separator
						if(showAllUsers || likeAllUsers)
						{
							if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details"))
								vec1.add(intlmp.getTextDescription("reporter.common.AD Group"));

							gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.User"),new JSONArray());
							gridColumns.add(intlmp.getTextDescription("reporter.common.User"));
							gridDisplayColumns.add(intlmp.getTextDescription("reporter.common.User"));
							
							vec1.add(intlmp.getTextDescription("reporter.common.User"));
						}
						String clientIp=request.getParameter("clientIp");
						if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details")){
							if(clientIp!=null && clientIp.equals("Yes")){
								if(aListClientDetails !=null && aListClientDetails.size()>0 ){
									for(int m=0;m<aListClientDetails.size();m++)
									{
										gridColumnsDetails.put(intlmp.getTextDescription("reporter.common."+(String)aListClientDetails.get(m)),new JSONArray());
										gridColumns.add(intlmp.getTextDescription("reporter.common."+(String)aListClientDetails.get(m)));
										gridDisplayColumns.add(intlmp.getTextDescription("reporter.common."+(String)aListClientDetails.get(m)));
										vec1.add(intlmp.getTextDescription("reporter.common."+(String)aListClientDetails.get(m)));
									}
								}
							}
						}
						gridColumnsDetails.put(intlmp.getTextDescription("reporter.common. Session Start Time"),new JSONArray());
						gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Logout / Disconnect Time"),new JSONArray());
						gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Server"),new JSONArray());
						
						gridColumns.add(intlmp.getTextDescription("reporter.common. Session Start Time"));
						gridColumns.add(intlmp.getTextDescription("reporter.common.Logout / Disconnect Time"));
						gridColumns.add(intlmp.getTextDescription("reporter.common.Server"));
						
						gridDisplayColumns.add(intlmp.getTextDescription("reporter.common. Session Start Time"));
						gridDisplayColumns.add(intlmp.getTextDescription("reporter.common.Logout / Disconnect Time"));
						gridDisplayColumns.add(intlmp.getTextDescription("reporter.common.Server"));
						if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details")){
							if(clientIp!=null && clientIp.equals("Yes")){
								if(geoColumnList != null && geoColumnList.size() >0 ){
									for(int m=0;m<geoColumnList.size();m++){
										gridColumnsDetails.put(intlmp.getTextDescription("reporter.common."+(String)geoColumnList.get(m)),new JSONArray());
										gridColumns.add(intlmp.getTextDescription("reporter.common."+(String)geoColumnList.get(m)));
										gridDisplayColumns.add(intlmp.getTextDescription("reporter.common."+(String)geoColumnList.get(m)));
									//	vec1.add(intlmp.getTextDescription("reporter.common."+(String)geoColumnList.get(m)));
									}
								}

							}
						}
					if(s_compType!=null && aListVmComponentType.contains(s_compType) && !isSummary)
					{
						String columnName = "Desktop Name";
						if(hasVMs)
							columnName = "VM Name";
						columnName = intlmp.getTextDescription("reporter.common. "+columnName);
						gridColumnsDetails.put(columnName,new JSONArray());
						gridColumns.add(columnName);
						gridDisplayColumns.add(columnName);
					}
					//
						gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Logon Duration"),new JSONArray());

				   //
						gridColumnsDetails.put(intlmp.getTextDescription("reporter.common. Total Connected Time"),new JSONArray());
						gridColumnsDetails.put(intlmp.getTextDescription("reporter.common. Total Elapsed Time"),new JSONArray());
						gridColumnsDetails.put(intlmp.getTextDescription("reporter.common. Total Idle Time"),new JSONArray());
						gridColumnsDetails.put(intlmp.getTextDescription("reporter.common. Total Active Time"),new JSONArray());
						gridColumnsDetails.put(intlmp.getTextDescription("reporter.common. Connected Time"),new JSONArray());
					//
						gridColumns.add(intlmp.getTextDescription("reporter.common.Logon Duration"));
					//					
						if(adGroupFns==null || adGroupFns.equalsIgnoreCase("Summary"))
						{
						gridColumns.add(intlmp.getTextDescription("reporter.common. Total Connected Time"));
						gridColumns.add(intlmp.getTextDescription("reporter.common. Total Elapsed Time"));
						//gridColumns.add(intlmp.getTextDescription("reporter.common. Total Idle Time"));
						//gridColumns.add(intlmp.getTextDescription("reporter.common. Total Active Time"));
						gridColumns.add(intlmp.getTextDescription("reporter.common. % Connected Time"));
					}
					else
					{
						gridColumns.add(intlmp.getTextDescription("reporter.common.Duration of Access"));
						gridColumns.add(intlmp.getTextDescription("reporter.common.Idle Time"));
						gridColumns.add(intlmp.getTextDescription("reporter.common.Active Time"));
					}
					gridDisplayColumns.add(intlmp.getTextDescription("reporter.common.Logon Duration"));
					if(adGroupFns==null || adGroupFns.equalsIgnoreCase("Summary"))
					{
						gridDisplayColumns.add(intlmp.getTextDescription("reporter.common. Total Connected Time"));
						gridDisplayColumns.add(intlmp.getTextDescription("reporter.common. Total Elapsed Time"));
						//gridDisplayColumns.add(intlmp.getTextDescription("reporter.common. Total Idle Time"));
						//gridDisplayColumns.add(intlmp.getTextDescription("reporter.common. Total Active Time"));
						gridDisplayColumns.add(intlmp.getTextDescription("reporter.common. % Connected Time"));
					}
					else
					{
						gridDisplayColumns.add(intlmp.getTextDescription("reporter.common.Duration of Access"));
						gridDisplayColumns.add(intlmp.getTextDescription("reporter.common.Idle Time"));
						gridDisplayColumns.add(intlmp.getTextDescription("reporter.common.Active Time"));
					}

					unitForMeasure.put(intlmp.getTextDescription("reporter.common.Logon Duration"),"Sec");

					if(adGroupFns==null || adGroupFns.equalsIgnoreCase("Summary"))
					{
						unitForMeasure.put(intlmp.getTextDescription("reporter.common. Total Connected Time"),"mins");
						unitForMeasure.put(intlmp.getTextDescription("reporter.common. Total Elapsed Time"),"mins");
						//unitForMeasure.put(intlmp.getTextDescription("reporter.common. Total Idle Time"),"mins");
						//unitForMeasure.put(intlmp.getTextDescription("reporter.common. Total Active Time"),"mins");
						unitForMeasure.put(intlmp.getTextDescription("reporter.common. % Connected Time"),"%");
					}
					else
					{
						unitForMeasure.put(intlmp.getTextDescription("reporter.common.Duration of Access"),"mins");
						unitForMeasure.put(intlmp.getTextDescription("reporter.common.Idle Time"),"mins");
						unitForMeasure.put(intlmp.getTextDescription("reporter.common.Active Time"),"mins");
					}

					vec1.add(intlmp.getTextDescription("reporter.common.Session Start Time(Local time on server)"));
					vec1.add(intlmp.getTextDescription("reporter.common.Logout/Disconnect Time(Time on Mgmt)"));
					vec1.add(intlmp.getTextDescription("reporter.common.Server"));
						if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details")){
							if(clientIp!=null && clientIp.equals("Yes")){
								if(geoColumnList != null && geoColumnList.size() >0 ){
									for(int m=0;m<geoColumnList.size();m++){
										vec1.add(intlmp.getTextDescription("reporter.common."+(String)geoColumnList.get(m)));
									}
								}
							}
						}
						if(s_compType!=null && aListVmComponentType.contains(s_compType))
						{
							if(!isSummary)							
							{
								if(hasVMs)
								{
									vec1.add(intlmp.getTextDescription("reporter.common.VM Name"));
								}
								else
								{
									vec1.add(intlmp.getTextDescription("reporter.common.Desktop Name"));
								}
							}
						}
						vec1.add(intlmp.getTextDescription("reporter.common.Logon Duration(Sec)"));


						if(adGroupFns==null || adGroupFns.equalsIgnoreCase("Summary"))
						{
						vec1.add(intlmp.getTextDescription("reporter.common.Total Connected Time")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
						vec1.add(intlmp.getTextDescription("reporter.common.Total Elapsed Time")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
						//vec1.add(intlmp.getTextDescription("reporter.common.Total Idle Time")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
						//vec1.add(intlmp.getTextDescription("reporter.common.Total Active Time")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
						vec1.add(intlmp.getTextDescription("reporter.common.% Connected Time"));
						}
						else
						{
						vec1.add(intlmp.getTextDescription("reporter.common.Duration of Access")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
						vec1.add(intlmp.getTextDescription("reporter.common.Idle Time")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
						vec1.add(intlmp.getTextDescription("reporter.common.Active Time")+" ("+intlmp.getTextDescription("reporter.common.Mins")+")");
						}
						if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details"))
							totalspan=totalspan-2;

						if(!isSummary)
						{
						
								gridColumns.add(intlmp.getTextDescription("reporter.common.Applications"));
								if(( er_showResourceUsage!=null && er_showResourceUsage.equalsIgnoreCase("Yes")))
								{
								gridDisplayColumns.add(intlmp.getTextDescription("reporter.common.Applications"));
								}
								
						}
						if(perServerDispMaxAvgPer!=null && perServerDispMaxAvgPer.size() > 0)
						{
							if(s_compType!=null && aListApplicationComponentType.contains(s_compType)&&!isSummary)
							{
								if(( er_showResourceUsage!=null && er_showResourceUsage.equalsIgnoreCase("Yes")))
								{
								gridColumnsDetails.put(intlmp.getTextDescription("reporter.common.Applications"),new JSONArray());
								}
								
							}
							Hashtable pServerData = (Hashtable)perServerDispMaxAvgPer.get(0);
							if(pServerData!=null && pServerData.size() > 0)
							{
								Enumeration p_keys = pServerData.keys();
								while(p_keys.hasMoreElements())
								{
									String key = (String)p_keys.nextElement();
									Hashtable value = (Hashtable)pServerData.get(key);

									session.setAttribute("colspan",ht_colspan);
									subjects=(ArrayList)reportInfo.getVariables(INI_SUBJECT);
									//if(strGroup==null || strGroup.equalsIgnoreCase("User"))
//										subjects.add(s_compType+":-:Total IO#IO Total");
									for(int count_dis=0; count_dis<subjects.size(); count_dis++)
									{
										String var=(String)subjects.get(count_dis);
										if(var.indexOf(s_compType)<0)
										{
											if(var.indexOf("Total:")>-1)
											{
												StringTokenizer colon_st_temp=new StringTokenizer(var,":");
												colon_st_temp.nextToken();
												colon_st_temp.nextToken();
												String totalMeasure=colon_st_temp.nextToken();
												if(totalMeasure.indexOf("+")>-1)
													totalMeasure = totalMeasure.substring(0,totalMeasure.indexOf("+"));
												if(allMeasures!=null && !allMeasures.contains(totalMeasure))
													continue;
											}else
												continue;
										}

										StringTokenizer colon_st=new StringTokenizer(var,":");
										String type=colon_st.nextToken();
										String stest=colon_st.nextToken();
										String hashvar=colon_st.nextToken();

										StringTokenizer temp_st=new StringTokenizer(hashvar,"#");
										String measure=temp_st.nextToken();
										String temp_disp=temp_st.nextToken();
										temp_disp = temp_disp.trim();
										if(var.indexOf("Total:")>-1)
										{
											if(measure!=null && measure.indexOf("+")>-1)
												measure = measure.substring(0,measure.indexOf("+"));
										}

										String unitmeasure=tablesInfo.getUnitForMeasure(stest,measure);
										if(unitmeasure==null || unitmeasure.equals(""))
										{
											String str_measureName = dbInfo.getMeasureForColumn(stest,measure);
											unitmeasure = tablesInfo.getUnitForMeasure(stest,str_measureName);
										}
										if(unitmeasure==null || unitmeasure.equals(""))
											unitmeasure = "-";
										String cspan=(String)ht_colspan.get(temp_disp);
										if(cspan == null || cspan.length()==0)
											cspan ="1";
										a_measunit.add(unitmeasure+"="+cspan);
										unitForMeasure.put(temp_disp,unitmeasure);
									}
									break;
								}
							}
						}
	
	if(( er_showResourceUsage!=null && er_showResourceUsage.equalsIgnoreCase("No")))
		a_measunit.add("=no");

						for(int u=0; u < a_measunit.size(); u++)
						{
							String measureUnit=(String)a_measunit.get(u);
							StringTokenizer unitValue=new StringTokenizer(measureUnit,"=");
							int tokensCount=unitValue.countTokens();
							String countDisp = unitValue.nextToken();
						}
						if(perServerDispMaxAvgPer!=null && perServerDispMaxAvgPer.size() > 0)
						{
							
							Hashtable pServerData = (Hashtable)perServerDispMaxAvgPer.get(0);
							if(pServerData!=null && pServerData.size() > 0)
							{
								Enumeration p_keys = pServerData.keys();
								while(p_keys.hasMoreElements())
								{
									String key = (String)p_keys.nextElement();
									Hashtable value = (Hashtable)pServerData.get(key);
									if(value!=null && value.size() > 0)
									{
										subjects=(ArrayList)reportInfo.getVariables(INI_SUBJECT);
										//if(strGroup==null || strGroup.equalsIgnoreCase("User"))
//											subjects.add(s_compType+":-:Total IO#IO Total");
										int count = 0;
										for(int count_dis=0; count_dis<subjects.size(); count_dis++)
										{
											String var=(String)subjects.get(count_dis);
											if(var.indexOf(s_compType)<0)
											{
												if(var.indexOf("Total:")>-1)
												{
													StringTokenizer colon_st_temp=new StringTokenizer(var,":");
													colon_st_temp.nextToken();
													colon_st_temp.nextToken();
													String totalMeasure=colon_st_temp.nextToken();
													if(totalMeasure.indexOf("+")>-1)
														totalMeasure = totalMeasure.substring(0,totalMeasure.indexOf("+"));
													if(allMeasures!=null && !allMeasures.contains(totalMeasure))
														continue;
												}else
													continue;
											}
											StringTokenizer temp_st=new StringTokenizer(var,"#");
											temp_st.nextToken();
											
											String temp_disp=temp_st.nextToken();
											
											Vector v_data = (Vector)value.get(temp_disp);
											
											if(v_data!=null && v_data.size() > 0)
											{
													
												for(int vd=0; vd < v_data.size(); vd++)
												{
													
													String val = (String)v_data.get(vd);
 													StringTokenizer st_v = new StringTokenizer(val,"$");
													JSONArray subheaders =  new JSONArray();
													JSONObject subCol =  new JSONObject();
													String computed =null;
													while(st_v.hasMoreTokens())
													{
														String measure = (String)st_v.nextToken();
														computed = (String)st_v.nextToken();
														
														String computedVal = (String)st_v.nextToken();
														
														 String measureUnit=(String)a_measunit.get(count);
														StringTokenizer unitValue=new StringTokenizer(measureUnit,"=");

														String measUnitDisp = unitValue.nextToken();
														vec1.add(intlmp.getTextDescription("reporter.thin."+temp_disp)+"("+measUnitDisp+")"+"-"+"("+computed+")");
														subheaders.add(intlmp.getTextDescription("reporter.common."+computed));

														}
 														String skipVal=temp_disp+"_"+intlmp.getTextDescription("reporter.common."+computed);
														//if(!skipVal.equalsIgnoreCase("Memory Usage_Avg"))
														gridColumns.add(temp_disp+"_"+intlmp.getTextDescription("reporter.common."+computed));
 														subCol.put(temp_disp,subheaders);
 														gridDisplayColumns.add(subCol);
		
 														gridColumnsDetails.put(temp_disp,subheaders);
 														
												}
												

											count++;	
											}

											
										}
										
									}
									break;
								}
							}

							if(isVm)
							{
								gridColumns.add(intlmp.getTextDescription("reporter.common.VM Details"));
								gridDisplayColumns.add(intlmp.getTextDescription("reporter.common.VM Details"));

							}
						}
						gridColumns.add(intlmp.getTextDescription("reporter.common.UserGroup"));


					//logon duration span for csv
					totalspan+=1;
					if(isVm)
					{
					if(vec1!=null && vec1.size()>0)
						{
						int tmpCnt=totalspan-vec1.size();
						if(tmpCnt==1)
							totalspan=totalspan+1;
						}
					}
					//

 					int summarCount = 0;
					ArrayList aListTotalIO = new ArrayList();
					while(itr.hasNext())
					{
						String strAdgroup = (String)itr.next();
						aListTotalIO = new ArrayList();
						Rep_data = new ArrayList();
					Rep_data = (ArrayList) ht_Rep_data.get(strAdgroup);

				if (Rep_data!=null && Rep_data.size()>0)
				{
					sess = Rep_data.size();
					int  tempsess=sess;
					Object check= (Object)Rep_data.get(sess-1);
					if(check instanceof Hashtable)
					{
						sess=sess-1;
					}

					try
					{
						ArrayList data = new ArrayList();
						for(int j=0; j < tempsess; j++)
						{
							try
							{
								Object v = (Object)Rep_data.get(j);
								if(v instanceof Hashtable)
								{
									avgPerForMeasures = (Hashtable)Rep_data.get(j);
									showMeasure = true;
									continue;
								}
								else if(v instanceof HashMap)
								{
									Report_data = (HashMap)Rep_data.get(j);
									if(likeAllUsers)
									user = (String)Report_data.get("user");
									if(likeAllUsers)
									{
										if(!v_users.contains(user))
										v_users.add(user);
									}
									sessionExists = true;
									if(!showAllUsers)
									{
										data.add((String)Report_data.get("duration"));
										if(onlyThisUser)
										{
											showDuration = true;
										}
										if(v_users!=null && v_users.isEmpty())
										{
											showDuration = true;
										}
									}
								}
							}
							catch(Exception e)
							{
								e.printStackTrace();
							}
						}
						if(!showAllUsers && v_users!=null && v_users.size() == 1 && likeAllUsers)
						{
							showDuration = true;
							onlyThisUser = true; 
						}
						if(showDuration || showMeasure)
						{
							summaryExists = true;
						}
						if(data!=null && data.size() > 0)
						{
							maximum = erUtils.getMaximum(data);
							maximum = (maximum == null || maximum.equals("-"))? "-" : erUtils.round(Float.parseFloat(maximum),2);
						
							avg = erUtils.calculateAvg(data);
							avg = (avg == null || avg.equals("-"))? "-" : erUtils.round(Float.parseFloat(avg),2);
						}
					}
					catch(Exception userReport)
					{
						System.out.println(userReport.toString());
					}
					//
				String tmpStr=new String(strAdgroup);
				if(strAdgroup!=null && strAdgroup.equalsIgnoreCase("AD_NULL"))
					{
					tmpStr="Default";
					}
					else
					tmpStr=strAdgroup;
					int groupRowCnt=0;
					if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details"))
					{	
						if(Rep_data!=null)
							groupRowCnt=Rep_data.size();
					}
					else if(s_user!=null && ((s_user=="-- All --")||( s_user=="*")))
					{	if(Rep_data!=null && Rep_data.size()>1)
							groupRowCnt=Rep_data.size()-1;
					}
					else
						groupRowCnt=Rep_data.size();

					//
					
					if(adGroupFns==null || adGroupFns.equalsIgnoreCase("Summary"))
					{
						if(tmpStr!=null && !tmpStr.equalsIgnoreCase("AD_NULL"))
						  {
								for(int dd=0;dd<(totalspan-1);dd++)
									{
										int mod = (totalspan)/2;
										if(isVm)
										{
											if(dd>=(totalspan-2))
												break;
											mod = (totalspan-2)/2;
										}
										if( mod ==dd)
											lst_dat1.add('"'+tmpStr+" ("+groupRowCnt+")"+'"');
										else
										lst_dat1.add(" ");
									}
							}
					}
						String msmttime = "";
 						JSONArray rowOfDataArr = new JSONArray();
						int totalColumn = -1;
						for(int j=0;j<Rep_data.size();j++)
						{
							int count=0;
							JSONObject rowOfdata = new JSONObject();
							JSONObject rowOfData = new JSONObject();
							Object v1 = (Object)Rep_data.get(j);
							if(v1 instanceof Hashtable)
								continue;
							Report_data = (HashMap)Rep_data.get(j);
 							if(showAllUsers || likeAllUsers)
							{
								user = (String)Report_data.get("user");
								v_session.add(user);
							}

							String stOrg_server = (String)Report_data.get("trgt_host");
							if(stOrg_server!=null && stOrg_server.indexOf(",")>-1)
								server = stOrg_server.substring(0,stOrg_server.indexOf(","));
							else
								server = stOrg_server;
							LoginTime = (String)Report_data.get("login_time");
							s_duration = (String)Report_data.get("duration");
							idleTime = (String)Report_data.get("idleTime");
							activeTime = (String)Report_data.get("activeTime");
							msmttime = (String)Report_data.get("msmttime");
							
							if(idleTime==null)
								idleTime="-";
							if(activeTime==null)
								activeTime="-";
							//
							logon_duration = (String)Report_data.get("logon_duration");
							logon_duration_splitup = (String)Report_data.get("logon_duration_splitup");
							//
							s_totalConnectiontime = (String)Report_data.get("connectionTime");
							s_pctConnectiontime = (String)Report_data.get("perConectionTime");
							dispLoginTime=LoginTime;
							if(LoginTime!=null)
							{
								try
								{
									dispLoginTime = DateUtil.changeDateFormat(LoginTime,"MM/dd/yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss");
									dispLoginTime = getUserTimeZone(dispLoginTime,thisuser);
								}
								catch(Exception e)
								{
								}
							}
							if(msmttime!=null && !msmttime.equals(""))
							{
								if(msmttime.indexOf(":000")>0)
									msmttime=msmttime.substring(0,msmttime.indexOf(":000"));
							}

							msmttime = DateUtil.changeDateFormat(msmttime,"dd-MM-yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss");
							msmttime = getUserTimeZone(msmttime,thisuser);

							String SHr =  (String)Report_data.get("stHr");
							String SMin =  (String)Report_data.get("stMin");
							String SDat = (String)Report_data.get("startdate");
							String EHr =  (String)Report_data.get("endHr");
							String EMin =  (String)Report_data.get("endMin");
							String EDat = (String)Report_data.get("enddate");

							v_session.add(LoginTime);
							v_session.add(stOrg_server);
							v_session.add(dbInfo.formatValue(s_totalConnectiontime));
							v_session.add(dbInfo.formatValue(s_duration));
							v_session.add(dbInfo.formatValue(s_pctConnectiontime));

							String selServer = request.getParameter("select_server1");
							//queryForServer="../servlet/com.eg.ErRepoLiteC?er_reportType=operation&er_rtype=Application&er_bgreportfrom=Operation_Application&trendenable=true&er_gtype=Measure&reporttype=operation&er_trenddata=No&er_option=Components&er_mode=3D&option=Citrix&timeto=" + timeTo + "&timefrom=" + timeFrom + "&minfrom=" + minFrom + "&minto=" + minTo + "&userID="+com.eg.EgURLEncoder.encode(loginid,"UTF-8")+"&us_id="+com.eg.EgURLEncoder.encode(loginid,"UTF-8")+"&startdate=" +URLEncoder.encode(request.getParameter("startdate"))+ "&enddate=" +URLEncoder.encode(request.getParameter("enddate")) + "&starthr=" + request.getParameter("starthr") + "&endhr=" + request.getParameter("endhr") +	"&startmin="+request.getParameter("startmin")+ "&endmin="+request.getParameter("endmin")+"&er_timeline=" + URLEncoder.encode(er_timeline)+"&er_compType=" + s_compType+"&fromFavSch=true&enableBack=true&backServletName=/servlet/com.eg.ErCtxServerReportC?"+"&showFrom="+showFrom;
							String parameter = "&startdate="+URLEncoder.encode(request.getParameter("startdate"))+"&enddate="+URLEncoder.encode(request.getParameter("enddate"))+"&er_timeline="+URLEncoder.encode(er_timeline)+"&isSubmit=true&enableBack=true&backServletName=/servlet/com.eg.ErAlarmHistoryC?&inidate="+EgURLEncoder.encode(request.getParameter("inidate"),"UTF-8")+"&er_mode=2D&";
							queryForServer = "../reporter/ErReporterMenu.jsp?er_reportType=operation&call=json&isSubmit=true&er_rtype=Application&er_bgreportfrom=Operation_Application&trendenable=true&er_gtype=Measure&reporttype=operation&us_id="+com.eg.EgURLEncoder.encode(urs,"UTF-8")+"&er_comptype="+s_compType+"&"+getDateInfoString(request.getParameter("starthr"),request.getParameter("endhr"),request.getParameter("startmin"),request.getParameter("endmin"),null,null)+"&userID="+com.eg.EgURLEncoder.encode(urs,"UTF-8")+"&uid="+com.eg.EgURLEncoder.encode(urs,"UTF-8")+"&er_component="+EgURLEncoder.encode(server+":"+s_compType, "UTF-8")+"&fromFavSch=true&er_trenddata=No&er_option=Components&showFrom="+showFrom+parameter;

							backQueryForServer = "../servlet/com.eg.ErCtxServerReportC?select_farm=" + EgURLEncoder.encode(s_farmserver,"UTF-8") + "&pdfTime="+pdfTime+"&isSubmit=true&showAll=" + showAllUsers + "&er_compType=" + s_compType + "&showSearch=" + sSearch + "&likeAllUsers=" + likeAllUsers + "&onlyThisUser=" + onlyThisUser + "&uid=" + com.eg.EgURLEncoder.encode(loginid,"UTF-8")+"&showFrom="+showFrom+"&userID="+com.eg.EgURLEncoder.encode(urs,"UTF-8")+"&option=Citrix&er_RmDispName=Operation_Application&enableBack=true&backServletName=/final/servlet/com.eg.ErCtxUserSummaryReportC?";
							if(stOrg_server!=null)
							{
								StringTokenizer stCompToken = new StringTokenizer(stOrg_server,",");
								while(stCompToken.hasMoreTokens()){
								queryForServer+="&er_component=" +EgURLEncoder.encode(stCompToken.nextToken()+":"+s_compType,"UTF-8");
								}
							}

							String encc_user=user;
							if(encc_user!=null && encc_user.trim().length()>0)
								encc_user = com.egurkha.util.StringUtils.replace(user,"\\", "\\\\");
							queryForUserReport="../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=" + timeFrom + "&timeto=" + timeTo + "&minfrom=" + minFrom + "&minto=" + minTo + "&startdate=" +URLEncoder.encode(request.getParameter("startdate")) + "&enddate=" +URLEncoder.encode(request.getParameter("enddate"))+ "&"+getDateInfoString(URLEncoder.encode(request.getParameter("starthr")),request.getParameter("endhr"),strmin,enmin,minFrom,minTo)+ "&pdfTime="+URLEncoder.encode(pdfTime)+ "&currTime=" + cTime + "&er_tbound="+tbound+"&select_farm=" + s_farmserver + "&er_excwe=" + excludeweekend + "&showAll=false &er_compType="+s_compType+"&showSearch=false&likeAllUsers=false&onlyThisUser=false&&er_user=" + EgURLEncoder.encode(encc_user,"UTF-8")+"&uid="+com.eg.EgURLEncoder.encode(loginid,"UTF-8")+"&inidate="+URLEncoder.encode(currentDateFormat)+"&enableBack=true&backServletName=/final/servlet/com.eg.ErCtxUserSummaryReportC?&showFrom="+showFrom;

							if(selServer!=null && !selServer.equals(""))
								backQueryForServer+="&select_server1=" +EgURLEncoder.encode(selServer,"UTF-8");

							queryForGraph = "../servlet/com.eg.ErRepoLiteC?er_rtype=Micro&er_trgttype=CitrixUser&isSubmit=true&er_period=&er_site=&er_gtype=Measure&select_farm=" + s_farmserver +  "&er_tbound=" + tbound + "&startdate=" +request.getParameter("startdate") + "&enddate=" +request.getParameter("enddate") + "&starthr=" +request.getParameter("starthr")  + "&endhr=" + request.getParameter("endhr") + "&er_timeline=" + URLEncoder.encode(er_timeline)+ "&currTime=" + cTime + "&timeto=" + timeTo + "&timefrom=" + timeFrom + "&er_excwe=" + excludeweekend + "&showAll=" + showAllUsers + "&minfrom=" + minFrom + "&minto=" + minTo + "&er_compType=" + s_compType + "&showSearch=" + sSearch + "&likeAllUsers=" + likeAllUsers +"&onlyThisUser="+onlyThisUser + "&uid=" + com.eg.EgURLEncoder.encode(loginid,"UTF-8")+"&showFrom="+showFrom;

							String select_server = request.getParameter("select_server1");
							//If the user wants to have a 4 measure graph, comment thisIs param in queryForMaxAvgPer and remove getMeasure from queryForMaxAvgPer.
							//queryForMaxAvgPer = "../servlet/com.eg.ErRepoLiteC?er_rtype=Micro&er_trgttype=CitrixUser&er_period=&er_site=&er_gtype=Measure&select_farm=" + s_farmserver +  "&er_tbound=Any" + "&showAll=" + showAllUsers + "&er_compType=" + s_compType + "&showSearch=" + sSearch + "&likeAllUsers=" + likeAllUsers +"&onlyThisUser="+onlyThisUser + "&userTBound=" + tbound + "&startdate=" +request.getParameter("startdate")+ "&enddate=" + request.getParameter("enddate")+ "&starthr=" + request.getParameter("starthr") + "&endhr=" + request.getParameter("endhr") + "&er_timeline=" +URLEncoder.encode(er_timeline) + "&userCurrTime=" + cTime +"&timeto=" + timeTo + "&timefrom=" + timeFrom + "&er_excwe=" + excludeweekend + "&minfrom=" + minFrom + "&minto=" + minTo + "&thisIs=UserGraph&uid=" + loginid;
							
							queryForMaxAvgPer = "../reporter/ErCtxUserGraph.jsp?er_rtype=Micro&er_trgttype=CitrixUser&er_period=&er_site=&er_gtype=Measure&select_farm=" +EgURLEncoder.encode(s_farmserver,"UTF-8") +  "&er_tbound=Any" + "&showAll=" + showAllUsers + "&er_compType=" + s_compType + "&showSearch=" + sSearch + "&likeAllUsers=" + likeAllUsers +"&onlyThisUser="+onlyThisUser + "&userTBound=" + tbound + "&userStartDate=" +EgURLEncoder.encode(request.getParameter("startdate"),"UTF-8")+ "&userEndDate=" + EgURLEncoder.encode(request.getParameter("enddate"),"UTF-8")+ "&userStHr=" + request.getParameter("starthr") + "&userEndHr=" + request.getParameter("endhr") + "&er_timeline=" +URLEncoder.encode(er_timeline) + "&userCurrTime=" + cTime +"&timeto=" + timeTo + "&timefrom=" + timeFrom + "&er_excwe=" + excludeweekend + "&minfrom=" + minFrom + "&minto=" + minTo + "&thisIs=UserGraph&uid=" + com.eg.EgURLEncoder.encode(loginid,"UTF-8");
							queryForVirualMachineDetails="../servlet/com.eg.ErEsxVMServerReportC?er_usertimeline=-1&ervm_disp=No&trendenable=true&er_reportgenration=foreground&forwardto=ErEsxGuestReport&er_trgttype=Virtual_Machine_Details&er_check=Virtualization&vmStrData=&er_mode=3D&er_ViewName=ErEsxGuestReport.jsp&er_type=Yes&fromSchedule=null&schedule_id=null&isSubmit=true&er_bgreportfrom=Virtualization_VM_Virtual_Resource&savereport=save&er_trenddata=No&detailtime=-1&servletName=com.eg.ErEsxVMServerReportC&er_timeline=Any&er_measure=All&er_rtype=Virtualization&reqfrom=vmGuest&enableBack=true&backServletName=/servlet/com.eg.ErCtxServerReportC?&minto="+minTo+"&minfrom="+minFrom+"&timeto="+timeTo+"&timefrom="+timeFrom+"&userID="+com.eg.EgURLEncoder.encode(loginid,"UTF-8") +"&fromSessionReport=true"+getVmReportDetails(menuForVM, isUserVmReport, isVmReports,s_compType,excludeweekend);
							if(select_server!=null && !select_server.equals(""))
								queryForMaxAvgPer+="&select_server1=" + EgURLEncoder.encode(select_server,"UTF-8");
							String toFormAsKey = "";
							String app_user="";
							if(showAllUsers)
							{
								queryForGraph+="&er_user=" + java.net.URLEncoder.encode(encc_user) + "&t_user=-- All --";
								backQueryForServer+="&er_user=-- All --";//"&er_user=" + user + "&t_user=-- All --";
								app_user=user;
								toFormAsKey = user + "$";
								queryForMaxAvgPer+="&er_user=" + EgURLEncoder.encode(encc_user,"UTF-8") + "&t_user="+EgURLEncoder.encode(com.egurkha.util.StringUtils.replace(user,"\\","\\\\"),"UTF-8");//-- All --";
							}
							else if(likeAllUsers)
							{
								queryForGraph+="&er_user=" + java.net.URLEncoder.encode(encc_user) + "&er_tuser=" + java.net.URLEncoder.encode(s_user) ;
								backQueryForServer+="&er_user=" + java.net.URLEncoder.encode(encc_user) + "&er_tuser=" + java.net.URLEncoder.encode(s_user) ;
								app_user=user;
								toFormAsKey = user + "$";
								queryForMaxAvgPer+="&er_user=" + java.net.URLEncoder.encode(encc_user) + "&er_tuser=" + java.net.URLEncoder.encode(s_user) ;
							}
							else if(onlyThisUser)
							{
								queryForGraph+="&er_tuser=" + java.net.URLEncoder.encode(s_user)  + "&er_user=" + java.net.URLEncoder.encode(s_user) ;
								backQueryForServer+="&er_tuser=" + java.net.URLEncoder.encode(s_user)  + "&er_user=" + java.net.URLEncoder.encode(s_user) ;
								user = java.net.URLEncoder.encode(s_user) ;
								app_user=user;
								queryForMaxAvgPer+="&er_user=" + EgURLEncoder.encode(encc_user,"UTF-8") + "&er_tuser=" + java.net.URLEncoder.encode(s_user) ;
							}
							else
							{
								queryForGraph+="&er_user=" + java.net.URLEncoder.encode(s_user) ;
								backQueryForServer+="&er_user=" + java.net.URLEncoder.encode(s_user) ;
								user = s_user;
								queryForMaxAvgPer+="&er_user=" + java.net.URLEncoder.encode(encc_user) + "&er_tuser=" + java.net.URLEncoder.encode(s_user) ;
							}
							queryForGraph+="&er_component=" +EgURLEncoder.encode(server,"UTF-8");
							queryForMaxAvgPer+="&er_component=" +EgURLEncoder.encode(stOrg_server,"UTF-8"); 
							queryForVirualMachineDetails+="&er_component=" +EgURLEncoder.encode(server,"UTF-8");

							String site="NULL";
							test = getTestNameForType(aListSupportComponentType,s_compType,INI_SUBJECT);
							String comp = server.substring(0,server.indexOf(":"));
							String port  =server.substring(server.indexOf(":")+1,server.length());
							String encuser_dd=user;//com.egurkha.util.StringUtils.replace(user,"\\", "\\\\");
							 encuser_dd = "*"+encuser_dd;
							String user_dd = "*"+user;
							String dd_url =""; 
							session.setAttribute("backQueryForUser",backQueryForServer);
							session.removeAttribute("farmQs");
							double d_duration = Math.round(Double.parseDouble(s_duration));
							String st_duration = String.valueOf(d_duration);
							if(s_totalConnectiontime!=null && !s_totalConnectiontime.startsWith("-"))
							{
								double d_totalConnectiontime = Math.round(Double.parseDouble(s_totalConnectiontime));
								s_totalConnectiontime = String.valueOf(d_totalConnectiontime);
							}
							if(s_pctConnectiontime!=null && !s_pctConnectiontime.startsWith("-"))
							{
								double d_pctConnectiontime = Math.round(Double.parseDouble(s_pctConnectiontime));
								s_pctConnectiontime = String.valueOf(d_pctConnectiontime);
							}
							if(st_duration!=null & st_duration.indexOf(".") > -1)
							{
								st_duration  = st_duration.substring(0,st_duration.indexOf("."));
							}
							//if(!isSummary)						
							toFormAsKey = toFormAsKey + LoginTime + "$" + stOrg_server + "$" + st_duration;
						//else
						//	toFormAsKey = toFormAsKey + LoginTime + "$" +  st_duration;
						
							if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details"))
								lst_dat1.add('"'+tmpStr+'"');


							if(showAllUsers || likeAllUsers)
							{
								lst_dat1.add('"'+user+'"');
								rowOfdata.put(rowOfdata.size(),user);
								rowOfData.put(gridColumns.get(count++),user);
							}
							if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details")){
								if(clientIp!=null && clientIp.equals("Yes")){
									if(aListClientDetails !=null && aListClientDetails.size()>0 ){
										for(int k=0;k<aListClientDetails.size();k++){
											String clientStr=(String)aListClientDetails.get(k);
											String clientVal = (String)Report_data.get(clientStr);
											lst_dat1.add('"'+clientVal+'"');
											rowOfdata.put(rowOfdata.size(),clientVal);
											rowOfData.put(gridColumns.get(count++),clientVal);
										}
									}
								}
							}
							stOrg_server = getComponentNameWithOutNullPort(stOrg_server);
							String logintimedisp=LoginTime.substring(0,LoginTime.indexOf(" "));
							String deskNameData = getDesktopName("",Report_data);
							if(perServerDispMaxAvgPer!=null && perServerDispMaxAvgPer.size() > 0)
							{
								Hashtable pServerDataSample = (Hashtable)perServerDispMaxAvgPer.get(0);
								if(pServerDataSample!=null&&pServerDataSample.size() > 0)
								{
									Hashtable p_val = (Hashtable)pServerDataSample.get(toFormAsKey);
									String deskName = (String)p_val.get("DeskTopName");
									if(deskName == null || deskName.equals(""))
										deskName = "-";
									deskName = getDesktopName(deskName,Report_data);
									strUserWithDesktop = deskName;
									deskNameData = deskName;
									if(deskName.indexOf("_")>-1)
										deskNameData = deskName.substring(deskName.lastIndexOf("_")+1,deskName.length());
									//else
										//deskNameData="";

								}
							}
						lst_dat1.add('"'+dispLoginTime+'"');
						lst_dat1.add('"'+msmttime+'"');
						lst_dat1.add('"'+stOrg_server+'"');
						rowOfdata.put(rowOfdata.size(),dispLoginTime);
						rowOfData.put(gridColumns.get(count++),dispLoginTime);
						rowOfdata.put(rowOfdata.size(),msmttime);
						rowOfData.put(gridColumns.get(count++),msmttime);
						rowOfdata.put(rowOfdata.size(),stOrg_server+"~"+queryForServer);
						rowOfData.put(gridColumns.get(count++),stOrg_server+"~"+queryForServer);
						if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details")){
							if(clientIp!=null && clientIp.equals("Yes")){
								if(geoColumnList != null && geoColumnList.size() >0 ){
									for(int k=0;k<geoColumnList.size();k++){
										String clientStr=(String)geoColumnList.get(k);
										String clientVal = (String)Report_data.get(clientStr);
										lst_dat1.add('"'+clientVal+'"');
										rowOfdata.put(rowOfdata.size(),clientVal);
										rowOfData.put(gridColumns.get(count++),clientVal);
									}

								}
							}
						}
						if(s_compType!=null && aListVmComponentType.contains(s_compType))
						{
							if(deskNameData == null || deskNameData.equals(""))
							{
								deskNameData = "-";
							}
							if(!isSummary)
							{
								lst_dat1.add('"'+deskNameData+'"');
								rowOfdata.put(rowOfdata.size(),deskNameData);
								rowOfData.put(gridColumns.get(count++),deskNameData);
							}
						}
						rowOfdata.put(rowOfdata.size(),logon_duration);
						rowOfData.put(gridColumns.get(count++),logon_duration);
						lst_dat1.add('"'+logon_duration+'"');

							lst_dat1.add(dbInfo.formatValue(s_duration));
							if(adGroupFns==null || adGroupFns.equalsIgnoreCase("Summary"))
							{
							lst_dat1.add(dbInfo.formatValue(s_totalConnectiontime));
							lst_dat1.add(dbInfo.formatValue(s_pctConnectiontime));
							//lst_dat1.add(dbInfo.formatValue(idleTime));
							//lst_dat1.add(dbInfo.formatValue(activeTime));
							}
							rowOfdata.put(rowOfdata.size(),dbInfo.formatValue(s_duration));
							rowOfData.put(gridColumns.get(count++),dbInfo.formatValue(s_duration));

							if(adGroupFns==null || adGroupFns.equalsIgnoreCase("Summary"))
							{
								rowOfdata.put(rowOfdata.size(),dbInfo.formatValue(s_totalConnectiontime));
								rowOfData.put(gridColumns.get(count++),dbInfo.formatValue(s_totalConnectiontime));

								rowOfdata.put(rowOfdata.size(),dbInfo.formatValue(s_pctConnectiontime));
								rowOfData.put(gridColumns.get(count++),dbInfo.formatValue(s_pctConnectiontime));
							}
							else
							{
								rowOfdata.put(rowOfdata.size(),idleTime);
								rowOfData.put(gridColumns.get(count++),idleTime);
								rowOfdata.put(rowOfdata.size(),activeTime);
								rowOfData.put(gridColumns.get(count++),activeTime);
								lst_dat1.add(idleTime);
								lst_dat1.add(activeTime);
							}

							if(perServerDispMaxAvgPer!=null && perServerDispMaxAvgPer.size() > 0)
							{
								Hashtable pServerData = (Hashtable)perServerDispMaxAvgPer.get(0);
								Hashtable ser_dur = (Hashtable)perServerDispMaxAvgPer.get(1);
								if(pServerData!=null&&pServerData.size() > 0)
								{
									Hashtable p_valuedd = (Hashtable)pServerData.get(toFormAsKey);
									totalnoofcols=0;
									String sDatedd = "";
									String eDatedd = "";
									String sHrdd = "";
									String eHrdd = "";
									String sMindd = "";
									String eMindd = "";
									if(ser_dur!=null && ser_dur.size() > 0)
									{
										String valdd = (String)ser_dur.get(toFormAsKey);
										StringTokenizer st_dd = new StringTokenizer(valdd,"$");
										String sTimedd = "";
										String eTimedd = "";
										while(st_dd.hasMoreTokens())
										{
											sTimedd = (String)st_dd.nextToken();
											eTimedd = (String)st_dd.nextToken();
										}
										String strDateArr[] = getDateFormat(sTimedd);
										sDatedd = getChangeFormat(strDateArr[1], strDateArr[0], strDateArr[2], "MM/dd/yyyy", currentDateFormat);
										sHrdd = strDateArr[3];

										if(sHrdd.startsWith("0"))
											sHrdd = sHrdd.substring(1);
										sMindd = strDateArr[4];
										if(sMindd.startsWith("0"))
											sMindd = sMindd.substring(1);
										//
										String strendDateArr[] = getDateFormat(eTimedd);
										eDatedd = getChangeFormat(strendDateArr[1], strendDateArr[0], strendDateArr[2],"MM/dd/yyyy",currentDateFormat);

										eHrdd = strendDateArr[3];
										eMindd = strendDateArr[4];

										String ddMeasure="No_of_sessions";
										if(s_compType!=null && (s_compType.equalsIgnoreCase("Vmware_vdi_server") || s_compType.equals("VmVdi_i_server")))
											ddMeasure="Current_sessions";
										ddMeasure = reportInfo.getCtxUserDDMeasure(INI_SUBJECT,s_compType);
										String ddTest = reportInfo.getCtxUserDDTest(INI_SUBJECT,s_compType);
										String vmuser_dd="";
										String vmuser_report_temp=strUserWithDesktop;
										if(isVm)
										{
										if(strUserWithDesktop!=null && !strUserWithDesktop.equals("-"))
										{
											if(vec_infos!=null && vec_infos.size()>0)
											{
												for(int i=0;i<vec_infos.size();i++)
													{
														String strInfo = (String) vec_infos.get(i);
														if(!strInfo.endsWith(":Summary"))
															continue;
														if(strInfo!=null && strInfo.toLowerCase().startsWith(("+"+strUserWithDesktop.toLowerCase())) || strInfo.toLowerCase().startsWith(strUserWithDesktop.toLowerCase()))
														{
															strUserWithDesktop = strInfo;
															break;
														}
													}
											}
											if(strUserWithDesktop!=null && !strUserWithDesktop.equals("-"))
												user_dd ="*"+strUserWithDesktop.trim().substring(1);
											vmuser_dd=user_dd;//com.egurkha.util.StringUtils.replace(user_dd,"\\", "\\\\");
											vmuser_report_temp=com.egurkha.util.StringUtils.replace(vmuser_report_temp,"\\", "\\\\");
										}
										dd_url = "/final/monitor/componentMeasureTabSet.jsp?type="+EgURLEncoder.encode(s_compType,"UTF-8")+"&site="+site+"&host="+EgURLEncoder.encode(comp,"UTF-8")+"&port="+port+"&info="+EgURLEncoder.encode(vmuser_dd,"UTF-8")+"&state=&messy="+ddMeasure+"&msmt_host=&starttime=" +sDatedd + "&endtime=" + eDatedd + "&"+ getDateInfoString(sHrdd,eHrdd,sMindd,eMindd,null,null) +"&userID="+EgURLEncoder.encode(urs,"UTF-8")+"&test="+ ddTest+"&comptype="+s_compType+"&measureDisp="+ddMeasure+"&from=measurespage&dd=yes&clicked=dd&newWindow=true&fromReporterHis=true&popup=true&fromPage=UserSessionDetails";
										queryForMaxAvgPer+=appendInfoAndDesktopName(vmuser_dd,deskNameData,showFrom);
									}
									else
									{
										dd_url = "/final/monitor/componentMeasureTabSet.jsp?type="+EgURLEncoder.encode(s_compType,"UTF-8")+"&site="+site+"&host="+EgURLEncoder.encode(comp,"UTF-8")+"&port="+port+"&info="+EgURLEncoder.encode(encuser_dd,"UTF-8")+"&info="+deskNameData+"&state=&messy="+ddMeasure+"&msmt_host=&starttime=" +sDatedd + "&endtime=" + eDatedd + "&"+ getDateInfoString(sHrdd,eHrdd,sMindd,eMindd,null,null)+"&userID="+EgURLEncoder.encode(urs,"UTF-8")+"&test="+ ddTest+"&comptype="+s_compType+"&measureDisp="+ddMeasure+"&from=measurespage&dd=yes&clicked=dd&newWindow=true&fromReporterHis=true&popup=true&fromPage=UserSessionDetails";
										queryForMaxAvgPer+=appendInfoAndDesktopName(encuser_dd,deskNameData,showFrom);
									}

										queryForVirualMachineDetails+="&select_vm="+EgURLEncoder.encode(vmuser_report_temp,"UTF-8");
									}
								}
								boolean showDDUrl = false;
								if(s_compType!=null && aListApplicationComponentType.contains(s_compType))
									showDDUrl = true;
								if(isVm && (deskNameData==null || deskNameData.equals("") ||  deskNameData.equals("-") ))
									showDDUrl = false;
								if(showDDUrl)
								{
 									rowOfdata.put(rowOfdata.size(),"DD"+"~"+dd_url);
 									rowOfData.put(gridColumns.get(count++),"DD"+"~"+dd_url);
								}
								else
								{
 									rowOfdata.put(rowOfdata.size(),"-");
 									rowOfData.put(gridColumns.get(count++),"-");
								}
								if(pServerData!=null && pServerData.size() > 0)
								{
									Hashtable p_value = (Hashtable)pServerData.get(toFormAsKey);
									String sDate = "";
									String eDate = "";

									String sHr = "";
									String eHr = "";
									String sMin = "";
									String eMin = "";
									if(ser_dur!=null && ser_dur.size() > 0)
									{
										String val = (String)ser_dur.get(toFormAsKey);
										StringTokenizer st_d = new StringTokenizer(val,"$");
										String sTime = "";
										String eTime = "";
										while(st_d.hasMoreTokens())
										{
											sTime = (String)st_d.nextToken();
											eTime = (String)st_d.nextToken();
										}
										String strStartDate[] = getDateFormat(sTime);
										sDate = getChangeFormat(strStartDate[1], strStartDate[0], strStartDate[2],"MM/dd/yyyy",currentDateFormat);
										sHr = strStartDate[3];
										if(sHr.startsWith("0"))
											sHr = sHr.substring(1);
										sMin = strStartDate[4];
										if(sMin.startsWith("0"))
											sMin = sMin.substring(1);

										String strendDate[] = getDateFormat(eTime);
										eDate = getChangeFormat(strendDate[1], strendDate[0], strendDate[2], "MM/dd/yyyy",currentDateFormat);
										eHr = strendDate[3];
										eMin = strendDate[4];
										if(eHr.startsWith("0"))
											eHr = eHr.substring(1);
										if(eMin.startsWith("0"))
											eMin = eMin.substring(1);
										queryForMaxAvgPer += "&startdate=" + EgURLEncoder.encode(sDate,"UTF-8")+ "&enddate=" + EgURLEncoder.encode(eDate,"UTF-8")+ "&" + getDateInfoString(sHr,eHr,sMin,eMin,null,null)+"&er_secs="+strendDate[5];
										queryForMaxAvgPer += appendString(sDate,eDate,sHr,eHr)+ "&er_startmin="+ sMin + "&er_endmin=" + eMin+"&inidate="+EgURLEncoder.encode(request.getParameter("inidate"),"UTF-8");
										String tmp_eDate=eDate;
										String tmp_eHr=eHr;
										double dle_duration = Math.round(Double.parseDouble(s_duration));
										if(dle_duration<60)
										{
											if(!tmp_eHr.equals("") && tmp_eHr.equals("23"))
											{
												SimpleDateFormat sdf = new SimpleDateFormat(currentDateFormat);
												Calendar cal = Calendar.getInstance();
												cal.setTime(sdf.parse(tmp_eDate));
												cal.add(Calendar.DATE, 1);  // number of days to add
												tmp_eDate = sdf.format(cal.getTime());
												tmp_eHr="1";
											}
											else
											{
											int aInt = Integer.parseInt(tmp_eHr);
											aInt+=1;
											tmp_eHr=String.valueOf(aInt);
											}
										}
										//need to encode using URL encoder
										queryForVirualMachineDetails+=appendString(URLEncoder.encode(sDate),URLEncoder.encode( tmp_eDate),sHr,tmp_eHr)+ "&"+getDateInfoString(sHr,tmp_eHr,sMin,eMin,null,null);
										queryForVirualMachineDetails+="&startdate=" +URLEncoder.encode(sDate)+ "&enddate=" + URLEncoder.encode(tmp_eDate);
										queryForVirualMachineDetails+="&st_date="+URLEncoder.encode((String)DateUtil.changeDateFormat(sDate,currentDateFormat,"dd-MM-yyyy"))+"&en_date="+URLEncoder.encode((String)DateUtil.changeDateFormat(tmp_eDate,currentDateFormat,"dd-MM-yyyy"));									}
									if(p_value!=null && p_value.size() >0)
									{
										String addmap="";
										subjects=(ArrayList)reportInfo.getVariables(INI_SUBJECT);

										for(int count_dis=0; count_dis<subjects.size(); count_dis++)
										{
											String var=(String)subjects.get(count_dis);
											if(var.indexOf(s_compType)<0)
											{
												if(var.indexOf("Total:")>-1)
												{
													StringTokenizer colon_st_temp=new StringTokenizer(var,":");
													colon_st_temp.nextToken();
													colon_st_temp.nextToken();
													String totalMeasure=colon_st_temp.nextToken();
													if(totalMeasure.indexOf("+")>-1)
														totalMeasure = totalMeasure.substring(0,totalMeasure.indexOf("+"));
													if(allMeasures!=null && !allMeasures.contains(totalMeasure))
														continue;
												}else
													continue;
											}
											StringTokenizer temp_st=new StringTokenizer(var,"#");
											String strtemp_ = temp_st.nextToken();
											String strTestname = "";
											if(strtemp_!=null && strtemp_.indexOf(":")>-1)
												strTestname = strtemp_.substring(strtemp_.indexOf(":")+1,strtemp_.lastIndexOf(":"));
											String temp_disp=temp_st.nextToken();
											String dbName = "";
											String dispName = "";
											Vector p_val = (Vector)p_value.get(temp_disp);
											if(p_val!=null && p_val.size() >0)
											{
 												totalnoofcols+=p_val.size();
												for(int pv=0; pv < p_val.size(); pv++)
												{
													String value = (String)p_val.get(pv);
													StringTokenizer st_v = new StringTokenizer(value,"$");
													String computedVal = "-";
													int nooftokens=st_v.countTokens();
													String b=(String)subjects.get(pv);

													while(st_v.hasMoreTokens())
													{
														String measure = (String)st_v.nextToken();
														StringTokenizer st_m = new StringTokenizer(measure,"#");
														dispName = (String)st_m.nextToken();
														if(AddfieldDisplay.indexOf(dispName)==-1)
														{
															if (!AddfieldDisplay.equals(""))
																AddfieldDisplay+=","+dispName;
															else
																AddfieldDisplay=dispName;
														}
														dbName = (String)st_m.nextToken();
														String computed = (String)st_v.nextToken();
														String computed1=computed;
														String dname=dispName;
														
														if (computed.indexOf(" ")>-1)
															computed=computed.substring(computed.lastIndexOf(" ")+1);
														if(Fields.indexOf(dbName + "_"+computed)==-1)
														{
															if (!Fields.equals(""))
															{
																Fields+=","+dbName+"_"+computed;
																fieldDisplay+=","+computed1;
															}
															else
															{
																Fields=dbName+"_"+computed;
																fieldDisplay+=","+computed1;
															}
														}
														computedVal = (String)st_v.nextToken();
													}

													if (v_session!=null)
														v_session.add(computedVal);
													else
														v_session.add("-");

													if(computedVal!=null && computedVal.equals("-"))
													{
	
						lst_dat1.add(computedVal);
						rowOfdata.put(rowOfdata.size(),computedVal);
						rowOfData.put(gridColumns.get(count++),computedVal);
													}
													else
													{

					
						String cval=computedVal+"~"+queryForMaxAvgPer + "&getMeasure=" + dbName+"&getTest="+strTestname;
						lst_dat1.add(computedVal);
						rowOfdata.put(rowOfdata.size(),computedVal+"~"+queryForMaxAvgPer + "&getMeasure=" + dbName+"&getTest="+strTestname);
						rowOfData.put(gridColumns.get(count++),cval);							
													}
												}
											}
										}
									}
								}
							}

						if(isVm)
						{
							if(!isSummary)
							{
							rowOfdata.put(rowOfdata.size(),"top.gif~"+queryForVirualMachineDetails);
							rowOfData.put(gridColumns.get(count++),"top.gif~"+queryForVirualMachineDetails);
							}

						}

						if(strAdgroup!=null && !strAdgroup.equalsIgnoreCase("AD_NULL"))
							rowOfData.put("UserGroup",strAdgroup);
						else
							rowOfData.put("UserGroup","Default");
						
						JSONObject processObj = null;
						if(totalColumn==-1)
						{
							totalColumn = lst_dat1.size();
						}
						processObj = processSplitUpDetails(logon_duration_splitup,intlmp,totalColumn,lst_dat1);
						if(processObj!=null)
						{
							rootJson.put("needLogonSplitUp",needLogonSplitUp);
							rowOfdata.put("splitUpDetails",processObj);
						}

						gridDataArray.add(rowOfdata);
						gridDataRowArray.add(rowOfData);
					}

			//if(adGroupFns==null || adGroupFns.equalsIgnoreCase("Summary"))
			//{
				if(aList_Rep_data!=null && aList_Rep_data.size()>0);
				{
					JSONArray rowOfdatas = new JSONArray();
					JSONObject sumRowOfData = new JSONObject();
 					ArrayList aList_temp = (ArrayList)aList_Rep_data.get(strAdgroup);
					if(aList_temp!=null)
					{
						int sum_count=0;
						if(strAdgroup!=null && strAdgroup.equalsIgnoreCase("AD_NULL"))
						{
								strAdgroup = "Default";
						}
						if(adGroupFns!=null && adGroupFns.equalsIgnoreCase("Details"))
						{
							lst_dat1.add(strAdgroup);
						}
						for (int i=0;i<aList_temp.size();i++)
						{
							String strAvg = (String)aList_temp.get(i);
							try
							{
								if(strAvg!=null && !(strAvg.equals("-") || strAvg.equalsIgnoreCase("Summary")))
								{
									try 
									{
									if(i>6)
									{
										strAvg= erUtils.round(Float.parseFloat(strAvg),2);
									}
										else
										{
									double d_data = Math.round(Double.parseDouble(strAvg));
									strAvg = String.valueOf(d_data);
										}
									}
									catch (Exception e)
									{}
								}
								rowOfdatas.add(strAvg);
								sumRowOfData.put(gridColumns.get(sum_count++),strAvg);
								if(adGroupFns==null || adGroupFns.equalsIgnoreCase("Summary"))
								{
								if(isVm)
								{
									if(i!=8 )
										lst_dat1.add(dbInfo.formatValue(strAvg));
								}
								else if(i!=7 )
									lst_dat1.add(dbInfo.formatValue(strAvg));
								}
								else
								{
									if(isVm)
									{
										if(i!=9 )
											lst_dat1.add(dbInfo.formatValue(strAvg));
									}
									else if(i!=8 )
										lst_dat1.add(dbInfo.formatValue(strAvg));
								}


							}catch(Exception e)
							{e.printStackTrace();}
		
						}
						if(!sumRowOfData.isEmpty())
						{
							//sumRowOfData.put(gridColumns.get(sum_count++),"-");
							//sumRowOfData.put(gridColumns.get(sum_count++),"-");
								sumRowOfData.put("UserGroup",strAdgroup);
							gridDataRowArray.add(sumRowOfData);
						}					
						gridDataArray.add(rowOfdatas);
					}
 						
				}
			//}
					//gridObj.put("columns",gridColumnsDetails);
					gridObj.put("fieldStore",gridColumns);
					gridObj.put("gridDisplayColumns",gridDisplayColumns);
					gridObj.put("units",unitForMeasure);
					//gridObj.put("dataArray",gridDataArray);
					gridObj.put("dataRowArray",gridDataRowArray);
					gridObj.put("groupField","UserGroup");
					//gridObj.put("TOTAL_COLUMN_COUNT",										totalColumnCount);
					//gridObj.put("SINGLE_SUBCOLUMN_COUNT",										havingSingleColumn);
					reportDataJson.put("measureGrid",gridObj);
					rootJson.put("reportData",reportDataJson);


					HashMap param =new HashMap();
					HashMap m=ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap()));
					m.put("er_timeline",URLEncoder.encode((String)m.get("er_timeline")));
					param.put("REPORT_PARAM",m);
					param.put("REPORT_DATA",userPdfData);
					session.setAttribute("parameters", param);
					Vector forPrint = new Vector();
					forPrint.add(new Boolean(showAllUsers));
					forPrint.add(new Boolean(showDuration));
					forPrint.add(new Boolean(showMeasure));
					
					forPrint.add(new Integer(tempsess));
					forPrint.add(new Boolean(onlyThisUser));
					forPrint.add(new Boolean(likeAllUsers));
					if(showDuration)
					{
						forPrint.add(avg);
						forPrint.add(maximum);
					}
					session.setAttribute("userReSummary", forPrint);
				}
					}
					// jj}
				}
			}
		}//rr
	}
	else
	{
		Hashtable pdfData = new Hashtable();
				JSONObject DrillDownreportData = new JSONObject();
				JSONArray tableArray  = new JSONArray();
		String strOption="";
		if(er_option!=null && er_option.length()>0)
		{
			strOption = er_option.toLowerCase();
			if(er_option.equals("-1"))
				strOption = "component";
		}
		if(topAppsDataForFarm!=null && topAppsDataForFarm.size() > 0)
		{
				JSONObject tableObj =  new JSONObject();
			Vector myVector = new Vector();
%>

<%
			
						s_tit = intlmp.getTextDescription("reporter.common.Summary of")+" "+intlmp.getTextDescription("reporter.common.Top Applications")+" "+intlmp.getTextDescription("reporter.common.in")+" "+s_farmserver+" "+intlmp.getTextDescription("reporter.common."+strOption+" for")+" "+s_user+" user"; 
						if(strOption!=null && strOption.equalsIgnoreCase("component"))
							s_tit = intlmp.getTextDescription("reporter.common.Summary of Top Applications")+" "+intlmp.getTextDescription("reporter.common.for Component ")+s_user+" user"; 

						tableObj.put("tableTitle",s_tit);
			JSONArray columns  = new JSONArray();
			vec.add(intlmp.getTextDescription("reporter.common.Application"));
			vec.add(intlmp.getTextDescription("reporter.common.% of Time"));
			columns.add(intlmp.getTextDescription("reporter.common.Application"));
			columns.add(intlmp.getTextDescription("reporter.common.% of Time"));

			int numTop = topAppsDataForFarm.size();
			JSONArray dataArray =  new JSONArray();

			for(int n=0; n < numTop; n++)
			{
				JSONArray tabledata =  new JSONArray();
				HashMap data = (HashMap)topAppsDataForFarm.get(n);
				String appName = (String)data.get("appName");
				String appPer = (String)data.get("appPer");
				myVector.add(appName);
				myVector.add(appPer);
				tabledata.add(appName);
				tabledata.add(appPer);
				dataArray.add(tabledata);
				lst_dat.add(appName);
				lst_dat.add(appPer);
			}
				summaryTitle = "Summay of Top Application in "+s_farmserver+" for "+ s_user;//"Top Applications in "+s_farmserver+"(SUMMARY)";
				pdfData.put("Summay of Top Application in "+s_farmserver+" for "+ s_user, myVector);
			tableObj.put("columns",columns);
			tableObj.put("data",dataArray);
			tableArray.add(tableObj);
}
		if(topAppsDataForServer!=null && topAppsDataForServer.size() > 0 && !topAppsDataForServer.isEmpty())
		{
			Vector myVector = new Vector();
			JSONObject tableObj =  new JSONObject();
			s_tit1 = intlmp.getTextDescription("reporter.common.Top")+" "+intlmp.getTextDescription("reporter.common.Applications used by")+" "+s_user+" user "+intlmp.getTextDescription("reporter.common.for each server in")+" "+s_farmserver+" "+intlmp.getTextDescription("reporter.common."+strOption); 
			if(strOption!=null && strOption.equalsIgnoreCase("component"))
				s_tit1 = intlmp.getTextDescription("reporter.common.Top")+" "+intlmp.getTextDescription("reporter.common.Applications used by")+" "+s_user+" user "+intlmp.getTextDescription("reporter.common.for each server");
			tableObj.put("tableTitle",s_tit1);
				JSONArray dataArray =  new JSONArray();
				JSONArray columns  = new JSONArray();

				vec1.add(intlmp.getTextDescription("reporter.common.Server"));
				vec1.add(intlmp.getTextDescription("reporter.common.Application"));
				vec1.add(intlmp.getTextDescription("reporter.common.% of Time"));

				columns.add(intlmp.getTextDescription("reporter.common.Server"));
				columns.add(intlmp.getTextDescription("reporter.common.Application"));
				columns.add(intlmp.getTextDescription("reporter.common.% of Time"));

			int numTop = topAppsDataForServer.size();
			for(int n=0; n < numTop; n++)
			{
				HashMap data = (HashMap)topAppsDataForServer.get(n);
				server = (String)data.get("server");
				Vector v_data = (Vector)data.get("data");
				int appCountForServer = v_data.size();
				String rowSpan = String.valueOf(appCountForServer);
				String appName = "";
				String appPer = "";
				lst_dat1.add('"'+server+'"');
				for(int v=0; v < v_data.size(); v++)
				{
					JSONArray dataobj =  new JSONArray();

					String appPercent = (String)v_data.get(v);
					StringTokenizer st_a = new StringTokenizer(appPercent,"$");
					appName = (String)st_a.nextToken();
					appPer = (String)st_a.nextToken();
					myVector.add(server);
					myVector.add(appName);
					myVector.add(appPer);
					dataobj.add(server);
					dataobj.add(appName);
					dataobj.add(appPer);
					lst_dat1.add(appName);
					lst_dat1.add(appPer);
					if(v != v_data.size()-1)
					{
						lst_dat1.add(" ");
						
					}
					dataArray.add(dataobj);
				}
			}
			tableObj.put("columns",columns);
			tableObj.put("data",dataArray);
			tableArray.add(tableObj);
			//hiddenfieldsJson.put("showTopApps","true");

			sessionTitle = "Top Applications in "+s_farmserver+" (SERVER)";
			pdfData.put("Top Applications in "+s_farmserver+" (SERVER)", myVector);
		}

		rootJson.put("drillDownData",tableArray);
		HashMap param1 =new HashMap();

		HashMap m=ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap()));
		m.put("er_timeline",URLEncoder.encode((String)m.get("er_timeline")));
		if((String)m.get("er_user")!=null)
			m.put("er_user",URLEncoder.encode((String)m.get("er_user")));
		if((String)m.get("er_tuser")!=null)
			m.put("er_tuser",URLEncoder.encode((String)m.get("er_tuser")));

		param1.put("REPORT_PARAM",m);
		param1.put("REPORT_DATA",userPdfData);
		session.setAttribute("parameters", param1);
		if(topAppsDataForFarm!=null && topAppsDataForFarm.size() > 0 || (topAppsDataForServer!=null && topAppsDataForServer.size() > 0 && !topAppsDataForServer.isEmpty()))
		{
		
			
			sen.put(vec,lst_dat);
			ht=new Hashtable();
			ht.put(s_tit,sen);
			lst.add(ht);
			sen = new Hashtable();
			ht = new Hashtable();
			s_tit = "";
			vec = new Vector();
			lst_dat = new LinkedList();
		
			if(topAppsDataForServer!=null && topAppsDataForServer.size() > 0 && !topAppsDataForServer.isEmpty())
			{
				sen1.put(vec1,lst_dat1);
				ht1=new Hashtable();
				ht1.put(s_tit1,sen1);
				lst.add(ht1);
				sen1 = new Hashtable();
				ht1 = new Hashtable();
				s_tit1 = "";
				vec1 = new Vector();
				lst_dat1 = new LinkedList();
			}
			session.setAttribute("list",lst);
		}
	}
	setCsvDatas(getMoreUsers,showAllUsers,disconuser,rwSize,vec1,lst_dat1,vec,lst_dat,s_tit1,s_tit,lst);
	if(s_compType==null || !s_compType.equalsIgnoreCase("Horizon_Pod"))
	{
		session.setAttribute("list",lst);
	}
	String strEncodetType = tType;
	String strEncode_er_timeline = er_timeline;
	if(tType!=null )
		strEncodetType = com.eg.EgURLEncoder.encode(tType,"UTF-8");
	if(er_timeline!=null )
		strEncode_er_timeline = com.eg.EgURLEncoder.encode(strEncode_er_timeline,"UTF-8");
	String strEncodeinidate = request.getParameter("inidate");
	if(request.getParameter("inidate")!=null)
		strEncodeinidate = com.eg.EgURLEncoder.encode(request.getParameter("inidate"),"UTF-8");
	String strEncodes_user = s_user;
	if(s_user!=null )
		strEncodes_user = com.eg.EgURLEncoder.encode(s_user,"UTF-8");
	String strTime = request.getParameter("startdate");
	String enTime = request.getParameter("enddate");
	String strEncodestrTime = strTime;
	if(strTime != null)
		strEncodestrTime = EgURLEncoder.encode(strTime,"UTF-8");
	String strEncodeenTime = enTime;
	if(enTime != null)
		strEncodeenTime = EgURLEncoder.encode(enTime,"UTF-8");
	String strEncodes_farmserver = s_farmserver;
	if(s_farmserver != null)
		strEncodes_farmserver = EgURLEncoder.encode(s_farmserver,"UTF-8");


	String dataProcess = mngrIProc+"/final/servlet/com.eg.ErCtxServerReportC;jsessionid="+session.getId()+"?"+"select_farm=" + strEncodes_farmserver + "&er_rtype="+rType+"&er_gtype="+gType+"&er_trgttype="+strEncodetType+"&er_user="+strEncodes_user+"&er_timeline="+strEncode_er_timeline+"&startdate="+strEncodestrTime+"&enddate="+strEncodeenTime+"&timefrom="+timefrom2+"&timeto="+timeto2+"&likeAllUsers="+likeAllUsers+"&"+getDateInfoString(s_st_hr,s_en_hr,strmin,enmin,minfrom2,minto2)+"&er_excwe="+excludeweekend+"&er_compType="+s_compType+"&userID="+urs+"&uid="+urs+"&er_view=PRINT"+"&inidate="+strEncodeinidate+"&er_organize="+strGroup+"&pageWidthProces="+pageWidthProces+"&er_aggregateValue="+er_aggregateValue+"&clientIp="+request.getParameter("clientIp")+"&er_showResourceUsage="+er_showResourceUsage+"&adGroupFns="+adGroupFns+"&adGroupForPrint="+adGroupForPrint+"&showFrom="+showFrom;

	session.setAttribute("MAIL_URL",dataProcess);
	session.setAttribute("PDF_URL", mngrIProc+"/final/servlet/com.eg.ErCtxServerReportC");
	if(reqFromOverviewReport){
		session.setAttribute("DRILLDOWN_PDF_URL", mngrIProc+"/final/reporter/ErUsersessionReportPrint.jsp;jsessionid="+session.getId());
		session.setAttribute("DRILLDOWN_MAIL_URL", mngrIProc+"/final/reporter/ErUsersessionReportPrint.jsp;jsessionid="+session.getId()+"?index=0&pdf=yes&er_RmDispName=UserSessionDetails&er_Duration="+er_durationValue);
	}
	out.println(rootJson.toString());
	
%>
<%!

public String getComponentNameWithOutNullPort(String s)
{
	String s_delimit = ",";
		StringBuffer sb = new StringBuffer();
		if(s != null && s_delimit != null)
		{
			if(s.indexOf(s_delimit) > -1)
			{
				StringTokenizer st = new StringTokenizer(s,s_delimit);
				while(st.hasMoreTokens())
				{
					String strTemp = st.nextToken();
					if(strTemp.endsWith(":NULL"))
					{
						strTemp = strTemp.substring(0,strTemp.indexOf(":"));
					}
					sb.append(strTemp+",");
				}
			}
			else
			{
				if(s.endsWith(":NULL"))
				{
					s = s.substring(0,s.indexOf(":"));
				}
				sb.append(s);
			}
		}
		String strReturn = sb.toString();
		if(strReturn!=null && strReturn.length()>0)
		{
			if(strReturn.endsWith(","))
				strReturn = strReturn.substring(0,strReturn.length()-1);
		}else
			strReturn = s;
		return strReturn;
}
%>
<%!
	public String[] getDateFormat(String sTimedd)
	{
		StringTokenizer st_startdd = new StringTokenizer(sTimedd,"/ :");
		String strReturn[] = new String[6];
		while(st_startdd.hasMoreTokens())
		{
			strReturn[0] = (String)st_startdd.nextToken();
			strReturn[1] = (String)st_startdd.nextToken();
			strReturn[2] = (String)st_startdd.nextToken();
			strReturn[3] = (String)st_startdd.nextToken();
			strReturn[4] = (String)st_startdd.nextToken();
			strReturn[5] = (String)st_startdd.nextToken();
		}
		return strReturn;
	}
	public String getUserTimeZone(String dispLoginTime,User thisuser)
	{
		String StrTempdispLoginTime = dispLoginTime;
		try{
			EgTimeZoneConverter converterStart = new EgTimeZoneConverter(dispLoginTime,thisuser);
			StrTempdispLoginTime = converterStart.getDateTime();
		}catch(Exception e){}
		return StrTempdispLoginTime;
	}
	public String getTestNameForType(ArrayList aListSupportComponentType,String s_compType, String INI_SUBJECT)
	{
		EgReportInfo reportInfo = new EgReportInfo("manager");
		String test="";
		if(aListSupportComponentType.contains(s_compType))
			test = reportInfo.getTestName(INI_SUBJECT,s_compType,false);
		else
			test ="CtxXpUserTest";
		return test;
	}
	public String appendInfoAndDesktopName(String info, String desktopName, String showFrom)
	{
		String returnStr="";
		ErUtils erUtils = new ErUtils();
		try
		{
			returnStr = "&er_info="+EgURLEncoder.encode(com.egurkha.util.StringUtils.replace(info,"\\","\\\\"),"UTF-8")+"&deskNameData="+erUtils.specialCharEncode(desktopName)+"&showFrom="+showFrom;
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return returnStr;
	}
	public String getChangeFormat(String s1, String s2, String s3, String format,String currentDateFormat)
	{
		String returnStr = "";
		try
		{
			returnStr = s1 + "/"  + s2 + "/" + s3;
			returnStr  = DateUtil.changeDateFormat(returnStr,format,currentDateFormat);
		}catch(Exception e)
		{
			e.printStackTrace();
		}
		return returnStr;
	}
	public String getChangeFormat(String eDate,String format,String currentDateFormat)
	{
		String returnStr = "";
		try
		{
			//DateUtil.changeDateFormat(eDate,format,currentDateFormat);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return returnStr;
	}
	public String getDesktopName(String deskNameData,HashMap Report_data)
	{
		String strReturnvalue ="-";
		if(deskNameData==null || deskNameData.equals("")|| deskNameData.equals("-"))
		{
			strReturnvalue = (String)Report_data.get("guestname");
			if(strReturnvalue==null)
			{
				strReturnvalue = "-";
			}
		}else
			strReturnvalue = deskNameData;
		return strReturnvalue;
	}
	public String getColumnString(boolean hasVMs,EgMappingInfo intlmp)
	{
		String returnStr = intlmp.getTextDescription("reporter.common.Desktop Name");
		if(hasVMs)
		{
			returnStr = intlmp.getTextDescription("reporter.common.VM Name");
		}
		return returnStr;
	}

	public String getVmReportDetails(String menuForVM, String isUserVmReport, String isVmReports,String s_compType,String excludeweekend)
	{
		String retStr="&menuForVM="+menuForVM+"&isUserVmReport="+isUserVmReport+"&isVmReport="+isVmReports+"&er_comptype="+s_compType+"&er_excwe=" + excludeweekend+"&er_excweekend="+excludeweekend;
		return retStr;
	}
	public String getDateInfoString(String s_st_hr,String s_en_hr,String strmin,String enmin,String minfrom2,String minto2)
	{
		String retStr = "starthr="+s_st_hr+"&endhr="+s_en_hr+"&startmin="+strmin+"&endmin="+enmin;
		if(minfrom2!=null)
		{
			retStr+="&minfrom="+minfrom2;
		}
		if(minto2!=null)
		{
			retStr+="&minto="+minto2;
		}
		return retStr;
	}
	public String appendString(String er_stdate, String er_enddate,String er_sthr, String er_endhr)
	{
		String retStr = "&er_stdate=" + er_stdate + "&er_enddate=" + er_enddate + "&er_sthr=" + er_sthr + "&er_endhr=" + er_endhr;
		return retStr;
	}
	public void setCsvDatas(boolean getMoreUsers,boolean showAllUsers,ArrayList disconuser,int rwSize,Vector vec1, List lst_dat1,Vector vec, List lst_dat,String s_tit1,String s_tit,List lst)
	{
		Hashtable sen1=new Hashtable();
		Hashtable ht1=new Hashtable();
		Hashtable sen=new Hashtable();
		Hashtable ht=new Hashtable();
		if(!getMoreUsers)
		{
			if(!(showAllUsers))
			{
				sen1.put(vec1,lst_dat1);
				ht1=new Hashtable();
				ht1.put(s_tit1,sen1);
				lst.add(ht1);
				sen.put(vec,lst_dat);
				ht=new Hashtable();
				ht.put(s_tit,sen);
				lst.add(ht);
				s_tit = "";
			}
			else
			{
				if(disconuser!=null && disconuser.size()> 0 && rwSize>0)
				{
					sen1.put(vec1,lst_dat1);
					ht1=new Hashtable();
					ht1.put(s_tit1,sen1);
					lst.add(ht1);
					sen.put(vec,lst_dat);
					ht=new Hashtable();
					ht.put(s_tit,sen);
					lst.add(ht);
					s_tit = "";
				}
				else
				{
					sen1.put(vec1,lst_dat1);
					ht1=new Hashtable();
					ht1.put(s_tit1,sen1);
					lst.add(ht1);
				}
			}
		}
		else 
		{
			if(disconuser!=null && disconuser.size()> 0 && rwSize>0)
			{
				sen1.put(vec1,lst_dat1);
				ht1=new Hashtable();
				ht1.put(s_tit1,sen1);
				lst.add(ht1);
				sen.put(vec,lst_dat);
				ht=new Hashtable();
				ht.put(s_tit,sen);
				lst.add(ht);
				s_tit = "";
			}
			else
			{
				sen1.put(vec1,lst_dat1);
				ht1=new Hashtable();
				ht1.put(s_tit1,sen1);
				lst.add(ht1);
			}
		}
	}
	public JSONObject processSplitUpDetails(String logon_duration_splitup, EgMappingInfo intlmp, int totalColumn,List lst_dat1)
	{
		JSONObject returnObj = null;
		if(logon_duration_splitup==null)
		{
			return returnObj;
		}
		StringTokenizer strTkns = new StringTokenizer(logon_duration_splitup,"#");
		String testName = null;
		if(strTkns.hasMoreTokens())
		{
			testName = strTkns.nextToken();
		}
		if(testName!=null)
		{
			ErUtils erUtils = new ErUtils();
			returnObj = new JSONObject();
			lst_dat1.add("");
			lst_dat1.add("");
			int dummy = 2;
			while(strTkns.hasMoreTokens())
			{
				String splitUpStr = strTkns.nextToken();
				if(splitUpStr.indexOf("$")>-1)
				{
					String heading  = splitUpStr.substring(0,splitUpStr.indexOf("$"));
					lst_dat1.add(intlmp.getTextDescription("reporter.common."+heading)+" (secs)");
					lst_dat1.add("");
					lst_dat1.add("");
					dummy=dummy+3;
				}
			}
			while(dummy<totalColumn)
			{
				lst_dat1.add("");
				dummy++;
			}
			strTkns = new StringTokenizer(logon_duration_splitup,"#");
			ArrayList totalList = new ArrayList();
			int maxVal = 0;
			while(strTkns.hasMoreTokens())
			{
				String splitUpStr = strTkns.nextToken();
				if(splitUpStr.indexOf("$")>-1)
				{
					ArrayList splitUpList = new ArrayList();
					String heading  = splitUpStr.substring(0,splitUpStr.indexOf("$"));
					splitUpStr  = splitUpStr.substring(splitUpStr.indexOf("$")+1);
					StringTokenizer str_Tkns = new StringTokenizer(splitUpStr,",");
					JSONObject valObj = new JSONObject();
					while(str_Tkns.hasMoreTokens())
					{
						String column_val = str_Tkns.nextToken();
						String column = column_val.substring(0,column_val.indexOf("@"));
						String val = column_val.substring(column_val.indexOf("@")+1);
						try 
						{
							val = erUtils.round(Float.parseFloat(val),2);
						}
						catch(Exception e)
						{
							val = "-";
						}
						splitUpList.add(intlmp.getMeasureDescription(testName,column));
						splitUpList.add(val);
						valObj.put(intlmp.getMeasureDescription(testName,column),val);
					}
					totalList.add(splitUpList);
					returnObj.put(intlmp.getTextDescription("reporter.common."+heading)+" (secs)",valObj);
					if(splitUpList.size()>maxVal)
					{
						maxVal = splitUpList.size();
					}
				}
			}
			for(int i=0;i<maxVal;i+=2)
			{
				lst_dat1.add("");
				lst_dat1.add("");
				dummy = 2;
				for(int j=0;j<totalList.size();j++)
				{
					ArrayList splitUpList = (ArrayList)totalList.get(j);
					if(splitUpList.size()>i)
					{
						lst_dat1.add(splitUpList.get(i));
						lst_dat1.add(splitUpList.get(i+1));
					}
					else
					{
						lst_dat1.add("");
						lst_dat1.add("");
					}
					lst_dat1.add("");
					dummy = dummy+3;
				}
				while(dummy<totalColumn)
				{
					lst_dat1.add("");
					dummy++;
				}
			}
		}
		return returnObj;
	}
	public ArrayList getReportDisplayValues(String iniSubject,String s_compType,ArrayList allMeasures)
	{
		EgReportInfo reportInfo = new EgReportInfo("manager");
		ArrayList subjects=(ArrayList)reportInfo.getVariables(iniSubject);
		ArrayList aListDispValue = new ArrayList();
		String tmpVal="";
		for(int count_dis=0; count_dis<subjects.size(); count_dis++)
		{
			String var=(String)subjects.get(count_dis);
			if(var.indexOf(s_compType)<0)
			{
				if(var.indexOf("Total:")>-1)
				{
					StringTokenizer colon_st_temp=new StringTokenizer(var,":");
					colon_st_temp.nextToken();
					colon_st_temp.nextToken();
					String totalMeasure=colon_st_temp.nextToken();
					if(totalMeasure.indexOf("+")>-1)
						totalMeasure = totalMeasure.substring(0,totalMeasure.indexOf("+"));
					if(allMeasures!=null && !allMeasures.contains(totalMeasure))
						continue;
				}else
					continue;
			}
			StringTokenizer temp_st=new StringTokenizer(var,"#");
			String strtemp_ = temp_st.nextToken();
			String strTestname = "";
			if(strtemp_!=null && strtemp_.indexOf(":")>-1)
				strTestname = strtemp_.substring(strtemp_.indexOf(":")+1,strtemp_.lastIndexOf(":"));
			String temp_disp = "";
			if(temp_st.hasMoreTokens())
				temp_disp=temp_st.nextToken();
			if(temp_disp != null && temp_disp.indexOf(":") > -1){
				tmpVal=strtemp_;
				if(tmpVal != null && tmpVal.indexOf(":") > -1)
					tmpVal=tmpVal.substring(tmpVal.indexOf(":")+1);
				tmpVal+=":"+temp_disp.substring(temp_disp.indexOf(":")+1);
				temp_disp=temp_disp.substring(0,temp_disp.indexOf(":"));
			}
			aListDispValue.add(temp_disp);
		}
		return aListDispValue;
	}
	public ArrayList getReportTestNameList(String iniSubject,String s_compType,ArrayList allMeasures)
	{
		EgReportInfo reportInfo = new EgReportInfo("manager");
		ArrayList subjects=(ArrayList)reportInfo.getVariables(iniSubject);
		ArrayList aListDispValue = new ArrayList();
		String tmpVal = "";
		for(int count_dis=0; count_dis<subjects.size(); count_dis++)
		{
			String var=(String)subjects.get(count_dis);
			if(var.indexOf(s_compType)<0)
			{
				if(var.indexOf("Total:")>-1)
				{
					StringTokenizer colon_st_temp=new StringTokenizer(var,":");
					colon_st_temp.nextToken();
					colon_st_temp.nextToken();
					String totalMeasure=colon_st_temp.nextToken();
					if(totalMeasure.indexOf("+")>-1)
						totalMeasure = totalMeasure.substring(0,totalMeasure.indexOf("+"));
					if(allMeasures!=null && !allMeasures.contains(totalMeasure))
						continue;
				}else
					continue;
			}
			StringTokenizer temp_st=new StringTokenizer(var,"#");
			String strtemp_ = temp_st.nextToken();
			String strTestname = "";
			if(strtemp_!=null && strtemp_.indexOf(":")>-1)
				strTestname = strtemp_.substring(strtemp_.indexOf(":")+1);
			aListDispValue.add(strTestname);
		}
		return aListDispValue;
	}
	public String getConnectionQulityString(double dd)
	{
		String strReturn ="";
		if(dd>0 && dd==1.0)
			strReturn = "Poor connection";
		else if(dd>0 && dd==2.0)
			strReturn = "Weak connection";
		else if(dd>0 && dd==3.0)
			strReturn = "Strong connection";
		else
			strReturn = "None";
		return strReturn;

	}
%>