<%@ include file="ErTracker.jsp"%>
<%@ page import = "egurkha.reporter.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.text.SimpleDateFormat" %>
<%@ page import = "java.text.ParseException" %>
<%@ page import ="com.eg.ErDbServer"%>
<%@ page import = "egurkha.*" %>
<%@ page import = "com.eg.EgDbInfo" %>
<%@ page import ="com.eg.EgInstallInfo"%>
<%@ page import = "com.eg.EgDbaseInfo" %>
<%@ page import ="com.eg.IniFile"%>
<%@ page import="com.egurkha.ini.*" %>
<%@ page import="com.eg.EgDateInfo" %>
<%@ page import="com.eg.EgGroupInfo" %>
<%@ page import="com.eg.EgReportInfo" %>
<%@ page import = "com.egurkha.*" %>
<%@ page import = "java.net.*" %>
<%@ page import="com.eg.EgThresholdInfo" %>
<%@ page import="com.eg.EgTablesInfo" %>
<%@ page import="com.eg.EgMappingInfo" %>
<%@ page import = "java.net.URLEncoder" %>
<%@ page import = "java.net.URLDecoder" %>
<%@ page import = "com.eg.EgURLEncoder" %>
<%@ page import = "com.egurkha.util.DateTimeTokenizer" %>
<%@ page import = "com.egurkha.util.DateUtil" %>
<%@ page import = "com.egurkha.util.StringUtils" %>
<%@ page import = "java.text.*" %>
<%@ page import = "net.sf.json.*" %>
<%@ page import = "com.eg.EgConfigInfo"%>
<%@ page import = "com.eg.EgAgentInfo" %>
<%@ page import = "java.util.Date" %>
<%@ page import = "java.math.BigDecimal" %>

<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<%
		String strUserNameValue = null;
		String currentDateFormat="MMM dd, yyyy";
		com.eg.IniFile egUI = new com.eg.IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_ui.ini");
		String dateFormat = egUI.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");
		if(dateFormat != null)
			currentDateFormat=dateFormat;
		if(thisuser!=null)
		{
			strUserNameValue = thisuser.getLoginID();
			currentDateFormat = thisuser.getUserDateFormat();
		}
		EgMappingInfo intlmap = null;
		if (thisuser != null) 
		{
			intlmap = new EgMappingInfo(thisuser.getLanguage());
		}
		com.eg.EgDbInfo dbInfo = new com.eg.EgDbInfo("manager");
		EgTimeZoneConverter time_converter = new EgTimeZoneConverter();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		ErUtils erUtils = new ErUtils();
		String rowIndex = request.getParameter("index");
		String frompdf = request.getParameter("pdf");
		String showFrom = request.getParameter("showFrom");
		EgReportInfo reportInfo = new EgReportInfo("manager");
		String isHighChartEnable=reportInfo.getValue("MISC","isHighChartExportEnable");
		HashMap Report_data = null;
		JSONArray memeoryRow=null;
		JSONArray cpuRow=null;
		JSONArray ioRow=null;
		JSONObject sessionSummary=new JSONObject();
		ArrayList summarytableData=new ArrayList();

		ArrayList timeLst=new ArrayList();
		ArrayList  Rep_data = (ArrayList)session.getAttribute("sessionUserView");
		String ChartColrsPie = reportInfo.getValue("CITIX_USER_SESSION_VIEW","PieChartColor");
		String ChartColrs = reportInfo.getChartColor("CITIX_USER_SESSION_VIEW");
		ArrayList colr=ErUtils.egTokenizer(ChartColrs, ",");
		ArrayList piecolr=ErUtils.egTokenizer(ChartColrsPie, ",");
		JSONArray logonArr=null;
		String chartType=reportInfo.getValue("CITIX_USER_SESSION_VIEW","ApplicationChartType");
		if(chartType == null || chartType.length()==0)
			chartType="line";
        String mngrIP = new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
		if(rowIndex != null)
		{
			int index  = Integer.parseInt(rowIndex);
			boolean isSessionDataFound=false;
			boolean ismemorydatafound=false;
			boolean isCpudatafound=false;
			boolean isIOdatafound=false;
			boolean hasMultipleLogins=false;
			JSONObject summaryObj=null;
			Report_data = (HashMap)Rep_data.get(index);
			String userName=(String)Report_data.get("user");
			ErSessionDetailView es=new ErSessionDetailView(Report_data,strUserNameValue);
			es.setShowFromComboValue(showFrom);
			ErSessionInfoBean sessionInfobean=es.getAppResourceInfo();
			JSONObject logonDetailInfo1=sessionInfobean.getLogonDataMapforPie();
			JSONObject startupDetails=sessionInfobean.getLogonDataMap();
			JSONArray logonGPDetailInfo=sessionInfobean.getGPLogonDetails();
			JSONArray GPObjctHeadr=null;
			if(logonGPDetailInfo != null && logonGPDetailInfo.size() > 0){
				GPObjctHeadr=new JSONArray();
				String strTestName=sessionInfobean.getTestName();
				if(strTestName != null && strTestName.length() > 0){
					if(strTestName != null){
						if(strTestName.indexOf("_DDD") == -1)
							strTestName=strTestName+"_DDD";
						String measrData=reportInfo.getValue("CITIX_USER_SESSION_VIEW",strTestName+"_GPDuration_Splitup");
						if(measrData != null && measrData.length() > 0){
							ArrayList colmnLst=ErUtils.egTokenizer(measrData, ",");
							for(int z=0;z<colmnLst.size();z++){
								String strTmp=(String)colmnLst.get(z);
								if(strTmp != null && strTmp.indexOf("#") > -1)
									strTmp=strTmp.substring(strTmp.indexOf("#")+1);
								GPObjctHeadr.add(strTmp);
							}
						}
					}
				}
			}
			Map resultMap = new HashMap();
			Map mappedGraph = new HashMap();
			if(logonDetailInfo1!=null && logonDetailInfo1.size()>0)
			{
				int colrcunt=0;
				logonArr=new JSONArray();
				String logonBrkdwnTabl=reportInfo.getValue("CITIX_USER_SESSION_VIEW","LogonDetailsBreakdown");
				String logonBrkdwnData=reportInfo.getValue("CITIX_USER_SESSION_VIEW","Details:"+logonBrkdwnTabl);
				String logonBrkdwnInnerData=reportInfo.getValue("CITIX_USER_SESSION_VIEW","Details:"+logonBrkdwnTabl+":innerMeasure");
				if(logonDetailInfo1 != null && logonDetailInfo1.size() > 0 && logonBrkdwnData != null && logonBrkdwnData.length() > 0)
				{
					ArrayList logonBrkdwnDataLst=ErUtils.egTokenizer(logonBrkdwnData, ",");
					JSONObject userLogonGraphObj=new JSONObject();
					JSONObject obj=null;

					HashMap legMap=new HashMap();
					ArrayList legTmpArray=null;
					ArrayList innerMeasrKeysList=null;
					if(logonBrkdwnInnerData != null && logonBrkdwnInnerData.length() > 0){
						StringTokenizer strtk=new StringTokenizer(logonBrkdwnInnerData,"$");
						innerMeasrKeysList=new ArrayList();
						while(strtk.hasMoreTokens()){
							String strTmp=(String)strtk.nextToken();
							String innrMeasr = "";
							if(strTmp != null && strTmp.indexOf("^eG^") > -1){
								innrMeasr=strTmp.substring(0,strTmp.indexOf("^eG^"));
								strTmp=strTmp.substring(strTmp.indexOf("^eG^")+4);
								legTmpArray=ErUtils.egTokenizer(strTmp, ",");
								if(legTmpArray != null && legTmpArray.size() > 0){
									innerMeasrKeysList.addAll(legTmpArray);
									legMap.put(innrMeasr,legTmpArray);
								}
							}
						}
					}
					boolean islegCheckneeded=false;
					if(legMap != null && legMap.size() > 0)
						islegCheckneeded=true;


					if(logonBrkdwnDataLst != null && logonBrkdwnDataLst.size() > 0){
						for(int k=0;k<logonBrkdwnDataLst.size();k++){
							if(colrcunt == piecolr.size()-1){
								colrcunt=0;
							}
							String tmpStr=(String)logonBrkdwnDataLst.get(k);
							if(innerMeasrKeysList != null && innerMeasrKeysList.contains(tmpStr)){
								continue;
							}
							boolean needtoAddInnerMeasure=false;
							ArrayList tmpList=null;
							if(islegCheckneeded && legMap.containsKey(tmpStr)){
								tmpList=(ArrayList)legMap.get(tmpStr);
								if(tmpList != null && tmpList.size() > 0)
									needtoAddInnerMeasure=true;
							}
							String strDisp=tmpStr;
							if(tmpStr != null && tmpStr.indexOf("#") > -1){
								strDisp=tmpStr.substring(tmpStr.indexOf("#")+1);
								tmpStr=tmpStr.substring(0,tmpStr.indexOf("#"));
							}else if(logonBrkdwnTabl != null && logonBrkdwnTabl.length() > 0){
								strDisp=intlmap.getMeasureDescription(logonBrkdwnTabl,tmpStr);
							}
							if(tmpStr!=null && (tmpStr.equalsIgnoreCase("Logon duration") || tmpStr.equalsIgnoreCase("Logon_duration")))
								continue;
							String value="0";
							if(logonDetailInfo1.containsKey(tmpStr))
								value=(String)logonDetailInfo1.get(tmpStr);
							obj=new JSONObject();
							obj.put("name",strDisp);
							obj.put("y",Double.parseDouble(value));
							obj.put("color",(String)piecolr.get(colrcunt));
							if(needtoAddInnerMeasure){
								JSONArray innerArray=new JSONArray();
								JSONObject innerObj=null;
								for(int l=0;l<tmpList.size();l++){
									tmpStr=(String)tmpList.get(l);
									strDisp=tmpStr;
									if(tmpStr != null && tmpStr.indexOf("#") > -1){
										strDisp=tmpStr.substring(tmpStr.indexOf("#")+1);
										tmpStr=tmpStr.substring(0,tmpStr.indexOf("#"));
									}else if(logonBrkdwnTabl != null && logonBrkdwnTabl.length() > 0){
										strDisp=intlmap.getMeasureDescription(logonBrkdwnTabl,tmpStr);
									}
									if(tmpStr!=null && (tmpStr.equalsIgnoreCase("Logon duration") || tmpStr.equalsIgnoreCase("Logon_duration")))
										continue;
									value="0";
									if(logonDetailInfo1.containsKey(tmpStr))
										value=(String)logonDetailInfo1.get(tmpStr);
									innerObj=new JSONObject();
									innerObj.put("name",strDisp);
									innerObj.put("y",Double.parseDouble(value));
									innerArray.add(innerObj);
								}
								if(innerArray != null && innerArray.size() > 0)
									obj.put("innerArray",innerArray);
							}
							logonArr.add(obj);
							colrcunt++;
						}
					}
					JSONObject obj1=new JSONObject();
					JSONArray piedata=new JSONArray();
					obj1.put("data",logonArr);
					piedata.add(obj1);
					userLogonGraphObj.put("DataSet",piedata);
					userLogonGraphObj.put("showLegends","false");
					userLogonGraphObj.put("chartType","donut");
					userLogonGraphObj.put("chartHeight","200");
					userLogonGraphObj.put("chartWidth","200");
					userLogonGraphObj.put("pieSize","120%");
					userLogonGraphObj.put("innerSize","55%");
					String donutTitle="<span align='center' style=\"font-size:23px;font-family:Roboto;font-weight:400;\">"+sessionInfobean.getLogonTime()+"</span>";
					String donutSubTitle="<span style=\"font-size:11px;font-family:Roboto;font-weight:400;\">secs</span>";

					userLogonGraphObj.put("title",donutTitle);
					userLogonGraphObj.put("subTitle",donutSubTitle);
					userLogonGraphObj.put("isDataLabelEnabled",false);
					userLogonGraphObj.put("isDoNutTitleNeeded","true");
					resultMap.put("UserLogonChart",userLogonGraphObj);
				}

			}
			String compType=sessionInfobean.getComponentType();
			boolean isVmComp=reportInfo.isVmComponent(compType);
			List appInfoListz=sessionInfobean.getAppInfoList();
			TreeMap tmpMap=null;
			if(appInfoListz!=null)
			{
				JSONObject memoryApplicationGraph=new JSONObject();
				JSONObject cpuApplicationGraph=new JSONObject();
				JSONObject ioApplicationGraph=new JSONObject();
				JSONArray appMemoryDataSet=new JSONArray();
				JSONArray appCPUDataSet=new JSONArray();
				JSONArray appIODataSet=new JSONArray();
				String val[]= new String[appInfoListz.size()];
				int colrcnt=0;
				for(int k=0;k<appInfoListz.size();k++)
				{
					if(colrcnt == colr.size()-1){
						colrcnt=0;
					}
					String samValues="";
					ErApplicationInfoBean appInfoBeanz=(ErApplicationInfoBean)appInfoListz.get(k);
					String appNme=appInfoBeanz.getAppName();
					val[k]=appNme;
					HashMap applicationResourceMap=appInfoBeanz.getResourceMapforGraph();
					if(applicationResourceMap != null && applicationResourceMap.size() > 0){
						JSONObject timeValueMap=(JSONObject)applicationResourceMap.get("MEMORY");
						tmpMap=new TreeMap(timeValueMap);
						Iterator itr = tmpMap.keySet().iterator();
						JSONArray seqRow=new JSONArray();
						memeoryRow=new JSONArray();
						cpuRow=new JSONArray();
						ioRow=new JSONArray();
						while(itr.hasNext())
						{
							JSONArray rowData=new JSONArray();
							String msmt_time = (String) itr.next();
							String value=(String)timeValueMap.get(msmt_time);
							if(value != null && value.indexOf("#") > -1){
								String sumVal=value.substring(0,value.indexOf("#"));
								String sumCnt=value.substring(value.indexOf("#")+1);
								double sumvalue=Double.parseDouble(sumVal);
								int sumcount=Integer.parseInt(sumCnt);
								if(sumcount > 0)
									sumvalue=sumvalue/sumcount;
								value=String.valueOf(sumvalue);
							}
							Date tempDate = sdf.parse(msmt_time);
							rowData.add(tempDate.getTime());
							rowData.add(Double.valueOf(value));
							seqRow.add(rowData);
							timeLst.add(tempDate.getTime());
						}

						JSONObject s1=new JSONObject();
						s1.put("name",appNme);
						s1.put("data",seqRow);
						s1.put("color",(String)colr.get(colrcnt));
						appMemoryDataSet.add(s1);
						memeoryRow=seqRow;
						JSONObject timeValueMapforcpu=(JSONObject)applicationResourceMap.get("CPU");
						tmpMap=new TreeMap(timeValueMapforcpu);
						Iterator cpuitr = tmpMap.keySet().iterator();
						seqRow=new JSONArray();
						while(cpuitr.hasNext())
						{
								JSONArray rowData=new JSONArray();
								String msmt_time = (String) cpuitr.next();
								String value=(String)timeValueMapforcpu.get(msmt_time);
								if(value != null && value.indexOf("#") > -1){
									String sumVal=value.substring(0,value.indexOf("#"));
									String sumCnt=value.substring(value.indexOf("#")+1);
									double sumvalue=Double.parseDouble(sumVal);
									int sumcount=Integer.parseInt(sumCnt);
									if(sumcount > 0)
										sumvalue=sumvalue/sumcount;
									value=String.valueOf(sumvalue);
								}
								Date tempDate = sdf.parse(msmt_time);
								rowData.add(tempDate.getTime());
								rowData.add(Double.valueOf(value));
								seqRow.add(rowData);
						}
						s1=new JSONObject();
						s1.put("name",appNme);
						s1.put("data",seqRow);
						s1.put("color",(String)colr.get(colrcnt));
						appCPUDataSet.add(s1);
						cpuRow=seqRow;
						JSONObject timeValueMapforio=(JSONObject)applicationResourceMap.get("IO");
						if(timeValueMapforio != null && timeValueMapforio.size() > 0)
						{
							Iterator ioitr = timeValueMapforio.keySet().iterator();
							seqRow=new JSONArray();
							while(ioitr.hasNext())
							{
									JSONArray rowData=new JSONArray();
									String msmt_time = (String) ioitr.next();
									String value=(String)timeValueMapforio.get(msmt_time);
									if(value != null && value.indexOf("#") > -1){
										String sumVal=value.substring(0,value.indexOf("#"));
										String sumCnt=value.substring(value.indexOf("#")+1);
										double sumvalue=Double.parseDouble(sumVal);
										int sumcount=Integer.parseInt(sumCnt);
										if(sumcount > 0)
											sumvalue=sumvalue/sumcount;
										value=String.valueOf(sumvalue);
									}
									Date tempDate = sdf.parse(msmt_time);
									rowData.add(tempDate.getTime());
									rowData.add(Double.valueOf(value));
									seqRow.add(rowData);
							}
							s1=new JSONObject();
							s1.put("name",appNme);
							s1.put("data",seqRow);
							s1.put("color",(String)colr.get(colrcnt));
							appIODataSet.add(s1);
							ioRow=seqRow;
						}
						colrcnt++;
					}
				}
				if(memeoryRow!=null && memeoryRow.size()>0)
				{
					ismemorydatafound =true;
				}
				if(cpuRow != null && cpuRow.size() >0 ){
					isCpudatafound =true;
				}
				if(ioRow != null && ioRow.size() >0 ){
					isIOdatafound =true;
				}
				String strtdate=sessionInfobean.getSessionStartTime();
				time_converter.convertProcess(strtdate,thisuser,false);
				strtdate = time_converter.getDateTime();
				String enddate=sessionInfobean.getSessionEndTime();
				ArrayList dte=new ArrayList();
				dte.add(strtdate);
				dte.add(enddate);
				if(ismemorydatafound){
					memoryApplicationGraph.put("DataSet",appMemoryDataSet);	
					memoryApplicationGraph.put("chartType",chartType);
					memoryApplicationGraph.put("LegendPosition","top");
					memoryApplicationGraph.put("LineWidth","2");
					memoryApplicationGraph.put("showLegends","false");
					memoryApplicationGraph.put("lowerLimit",Collections.min(timeLst));
					memoryApplicationGraph.put("higherLimit",Collections.max(timeLst));
					memoryApplicationGraph.put("TimeFormatOut","HH:mm");
					memoryApplicationGraph.put("timeScale","30");
					memoryApplicationGraph.put("yAxisLabelYval","21");
					memoryApplicationGraph.put("showdisconnectedline","Yes");
					memoryApplicationGraph.put("legend",true);
					memoryApplicationGraph.put("legend","true");
					memoryApplicationGraph.put("showLegend",true);
					memoryApplicationGraph.put("reflow",false);
					memoryApplicationGraph.put("showLegend","true");
					memoryApplicationGraph.put("showLegendsEnable",true);
					memoryApplicationGraph.put("legendFontSize","true");
					memoryApplicationGraph.put("ShowLegendWithMinMaxAvg","true");
					memoryApplicationGraph.put("showLegendsEnable","11");
					memoryApplicationGraph.put("timezoneOffsetValue",timezoneOffsetValue);
//					memoryApplicationGraph.put("xLabel","hours");
					memoryApplicationGraph.put("yLabel","%");
				}
				if(isCpudatafound){
					cpuApplicationGraph.put("DataSet",appCPUDataSet);
					cpuApplicationGraph.put("LegendPosition","top");
					cpuApplicationGraph.put("chartType",chartType);
					cpuApplicationGraph.put("showLegends","false");
					cpuApplicationGraph.put("ShowLegendWithMinMaxAvg","true");
					cpuApplicationGraph.put("LineWidth","2");
					cpuApplicationGraph.put("lowerLimit",Collections.min(timeLst));
					cpuApplicationGraph.put("higherLimit",Collections.max(timeLst));
					cpuApplicationGraph.put("TimeFormatOut","HH:mm");
//					cpuApplicationGraph.put("xLabel","hours");
					cpuApplicationGraph.put("timeScale","30");
					cpuApplicationGraph.put("reflow",false);
					cpuApplicationGraph.put("yAxisLabelYval","21");
					cpuApplicationGraph.put("showdisconnectedline","Yes");
					cpuApplicationGraph.put("yLabel","%");
					cpuApplicationGraph.put("timezoneOffsetValue",timezoneOffsetValue);
				}
				if(isIOdatafound){
					ioApplicationGraph.put("DataSet",appIODataSet);
					ioApplicationGraph.put("LegendPosition","top");
					ioApplicationGraph.put("chartType",chartType);
					ioApplicationGraph.put("showLegends","false");
					ioApplicationGraph.put("ShowLegendWithMinMaxAvg","true");
					ioApplicationGraph.put("LineWidth","2");
					ioApplicationGraph.put("lowerLimit",Collections.min(timeLst));
					ioApplicationGraph.put("higherLimit",Collections.max(timeLst));
					ioApplicationGraph.put("TimeFormatOut","HH:mm");
					ioApplicationGraph.put("timeScale","30");
					ioApplicationGraph.put("reflow",false);
					ioApplicationGraph.put("yAxisLabelYval","21");
					ioApplicationGraph.put("showdisconnectedline","Yes");
//					ioApplicationGraph.put("xLabel","hours");
					ioApplicationGraph.put("yLabel","KB/Sec");
					ioApplicationGraph.put("timezoneOffsetValue",timezoneOffsetValue);
				}
				resultMap.put("MemoryChart",memoryApplicationGraph);
				resultMap.put("CPUChart",cpuApplicationGraph);
				resultMap.put("IOChart",ioApplicationGraph);
			}

			JSONArray logonArray=new JSONArray();
			JSONObject objct=new JSONObject();
			int idleTime=Integer.parseInt((String)sessionInfobean.getIdleTime());
			objct.put("name","idleTime");
			objct.put("y",idleTime);
			objct.put("color","#f49242");
			logonArray.add(objct);
			objct=new JSONObject();
			int actveTime=Integer.parseInt((String)sessionInfobean.getActiveTime());
			objct.put("name","activeTime");
			objct.put("y",actveTime);
			objct.put("color","#69c7b3");
			logonArray.add(objct);
				
			JSONObject dataObject=new JSONObject();
			dataObject.put("data",logonArray);
			JSONArray dataSetArray=new JSONArray();
			dataSetArray.add(dataObject);
			JSONObject donut_chrt=new JSONObject();
			donut_chrt.put("DataSet",dataSetArray);
			donut_chrt.put("chartType","donut");

			donut_chrt.put("type","bar");
			String strTitle="<div class='donutChartTitleOuter'><div class='donutChartTitleMiddle'>"+sessionInfobean.getSessionDuration()+"</div><div class='newFont_normal13' style='margin-top:-2px'>Duration</div><div class='newFont_normal10'>(mins)</div></div>";
			donut_chrt.put("title",strTitle);
			donut_chrt.put("pieSize","120%");
			donut_chrt.put("innerSize","70%");
			donut_chrt.put("chartHeight", "160");
			donut_chrt.put("chartWidth", "200");
			resultMap.put("donut_chrt",donut_chrt);


			boolean showActiveIdleGraph=false;
			String enableActiveIdleGraph=reportInfo.getValue("CITIX_USER_SESSION_VIEW","enableActiveIdleGraph");
			if(enableActiveIdleGraph != null && enableActiveIdleGraph.equalsIgnoreCase("yes")){
				JSONObject sessionidleTime=sessionInfobean.getSessionTimeMap();
				if(sessionidleTime != null && sessionidleTime.size() > 0){
					Iterator resoucrItr = sessionidleTime.keySet().iterator();
					JSONArray datasetArr=new JSONArray();
					JSONArray tmpdatasetArr=new JSONArray();
					ArrayList Xlabl=new ArrayList();
					ArrayList timeLstChk=new ArrayList();
					JSONObject obj=new JSONObject();
					while(resoucrItr.hasNext())
					{
						String key = (String) resoucrItr.next();
						int yVal=0;
						if(key != null && key.equalsIgnoreCase("ActiveTime"))
							yVal=1;
						JSONArray rMap=(JSONArray)sessionidleTime.get(key);
						if(rMap != null && rMap.size() % 2 == 0){
							for(int l=0;l<rMap.size();l+=2){
								SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
								java.util.Date dt = formatter.parse((String)rMap.get(l));
								java.util.Date dt2 = formatter.parse((String)rMap.get(l+1));
								obj=new JSONObject();
								obj.put("x",(new Long(dt.getTime())));
								obj.put("x2",(new Long(dt2.getTime())));
								obj.put("y",yVal);

								if(!timeLstChk.contains(dt))
									timeLstChk.add(dt);
								if(!timeLstChk.contains(dt2))
									timeLstChk.add(dt2);
								
								if(yVal == 1)
									obj.put("color","#69c7b3");
								else
									obj.put("color","#f49242");

								obj.put("partialFill",new Integer(0));
								datasetArr.add(obj);
							}
						}
					}
					if(datasetArr != null && datasetArr.size() > 0){
						JSONObject activeIdleGraph=new JSONObject();

						if(timeLstChk != null && timeLstChk.size() > 0){
							Collections.sort(timeLstChk);
							long diffMinutes=0; 
							try{
								Date stDatee=(Date)timeLstChk.get(0);
								Date enDatee=(Date)timeLstChk.get(timeLstChk.size()-1);
								long diff = enDatee.getTime() - stDatee.getTime();
								diffMinutes = Math.abs(diff / (60 * 1000));
							}
							catch (Exception e) {
								e.printStackTrace();
							}
							if(diffMinutes > 0 && diffMinutes <= 180){
								long intrvlVal=(diffMinutes/10);
								int tickIntrval=(int)intrvlVal;
								if(intrvlVal >= 3&& intrvlVal <=5 )
									 tickIntrval=5;
								else if(intrvlVal > 5 && intrvlVal <=10 )
									tickIntrval=10;
								else  if(intrvlVal > 10&& intrvlVal <=15 )
									tickIntrval=15;
								else if(intrvlVal > 15)
									tickIntrval=20;
								activeIdleGraph.put("tickIntervalValue",(tickIntrval*60000));
							}
						}


						obj=new JSONObject();
						obj.put("data",datasetArr);
						obj.put("pointWidth",new Integer(20));
						tmpdatasetArr.add(obj);
						Xlabl.add("Idle");
						Xlabl.add("Active");
						activeIdleGraph.put("xRangeArry",Xlabl);
						activeIdleGraph.put("DataSet",tmpdatasetArr);
						activeIdleGraph.put("chartType","xrange");
						activeIdleGraph.put("timezoneOffsetValue",timezoneOffsetValue);
						resultMap.put("XRange_Graph",activeIdleGraph);
						showActiveIdleGraph=true;
					}
				}
			}
			if(Report_data.containsKey("multipleLogin")){
				ArrayList loginLst=(ArrayList)Report_data.get("multipleLogin");
				if(loginLst != null && loginLst.size() > 0){
					String columnsVal = reportInfo.getValue("CITIX_USER_SESSION_VIEW","multilpleLoginSummary");
					ArrayList measureLst=ErUtils.egTokenizer(columnsVal, ",");
					summaryObj=es.getLoginSummaryTable(loginLst,measureLst,currentDateFormat);
					hasMultipleLogins=true;
				}
			}
			HashMap resourceMapTmp=sessionInfobean.getSessionResourceMap();
			String fromPage="Print";
			JSONArray resourceGraphDatas=es.getResourceGraphData(resourceMapTmp,compType,reportInfo,fromPage,timezoneOffsetValue);
			if(resourceGraphDatas != null && resourceGraphDatas.size() > 0){
				for(int j=0;j<resourceGraphDatas.size();j++){
					JSONObject tmpObjj=(JSONObject)resourceGraphDatas.get(j);
					resultMap.put("resourceGraph_"+j,tmpObjj);
				}
			}

			if(resultMap!= null && resultMap.size() >0)
			{
				session.setAttribute("ChrtData",resultMap);
			}
			String pdfPrint = request.getParameter("pdfPrint");
%>
<!Doctype html>
	<head>
<%
	if(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes"))
	{
%>
		<title>&nbsp; <egui:intnl text="reporter.common.Reporter" />
		&nbsp; &nbsp; <egui:intnl text="reporter.common.Print" /> &nbsp;</title>
<%
	}
	else
	{
%>
		<title>&nbsp; <egui:intnl text="reporter.common.Reporter" />
		&nbsp; &nbsp;</title>
<%
	}
%>
		<link rel="stylesheet" type="text/css" href="../../final/styles/eGLightThemeIcons.css" />
		<link rel="stylesheet" type="text/css" href="../../final/reporter/styles/printpagestyle.css" />
		<style>
			.reporterLogonPanelBody tbody td {
				padding:5px 8px 3px 0px;
			}

			.reporterLoginPopupVal{
				padding:5px 8px 6px 0px;
			}
		</style>
		<style type="text/css" media="print">
			#printbt{ display:none}
		</style>
		<style>
			.widgetBorder{
				border: 0px solid #d1d1d1 !important;
				background: #ffffff !important;
				-webkit-box-shadow: 1px 1px 1px 0px rgba(0,0,0,0.3);
				-moz-box-shadow: 1px 1px 1px 0px rgba(0,0,0,0.3);
				box-shadow: 1px 1px 1px 0px rgba(0,0,0,0.3);
				margin-bottom: 15px;
				-moz-border-radius: 0px 0px 0px 0px;
				-webkit-border-radius: 0px 0px 0px 0px;
				border-radius: 0px 0px 0px 0px;
				-ms-border-radius: 0px 0px 0px 0px;
				-o-border-radius: 0px 0px 0px 0px;
			}
			.donutChartTitleMiddle{
				font-size:28px;
				color:#2a292a;
			}
			.arrow_box {	
				top:0px;
				left:90px;
				position: absolute;
				background: #ffffff;
				margin:0px auto;
				width:25px;
				height:11px;
				background : url('../images/reporterArrowApplicationsAccessed.png') no-repeat top left;
			}
			.arrow_box_div{
				width:180px;height:90px;overflow:auto;text-align:left;margin:0px 10px 10px 10px;
				border: 1px solid #d8d8d8;
			}
			.legendCircle{
				width:6px;
				height:6px;
				/*border-radius: 3px;
				-moz-border-radius: 3px;
				-khtml-border-radius:3px;
				-o-border-radius: 3px;
				-webkit-border-radius: 3px;*/
			}
			.newFont_normal11{
				font-size: 11px !important;
				font-weight:400 !important;
				color:#2a292a;
			}
			.font_normal11{
				font-size:11px;
				font-weight:normal;
			}
			.reporterLogonSessionStartupBox{
				border:1px solid #e3e3e3 !important;
				background:#f0f0f0 !important;
				-moz-border-radius: 2em;
				-webkit-border-radius: 2em;
				-khtml-border-radius: 2em;
				border-radius: 2em;
				width:35%;
				font-size:14px;
				color:#2a292a;
				padding:0px;
				text-align:center;
			}
			.reporterLogonSessionStartup{
				font-size:14px;
				color:#2a292a;
				text-align:right;
				padding:0px 8px 0px 0px;
			}
			.reporterLogonSessionStartupValue{
				font-size:14px;
				color:#2a292a;
				text-align:left;
				padding:0px 0px 0px 0px;
			}
			.reporterLogonPanelHead{
				font-weight:500;
				font-size:12px;
				padding:5px 8px 5px 0px;
				border-bottom:1px solid #e3e3e3
			}
			.reporterLoginSessionLabel{
				font-size:11px;
				color:#2a292a;
				letter-spacing:-0.007em;
				text-align:center;
				margin-top:4px !important;
				/*font-weight:700*/
			}
			.reporterLoginPopupVal{
				font-size:11px;
				color:#2a292a;
				letter-spacing:-0.1em;
				text-align:center;
				padding:0px 30px 7px 30px;
			}
			.reporterLogonPanelBody{
				font-size:11px;
				margin-top:5px
			}
			.reporterLogonPanelBody tbody td div.valueDiv{
				width:60px !important;
				text-align:left;
				float:right;
			}
			.reporterLogonDivider{
				border-right:1px solid #ededed;
				width:1px;
				height:170px;
			}
			.newFont_bold26{
				font-size: 26px !important;
				font-weight:500;
				color:#2a292a;
				font-weight:800;
			}
			.newFont_normal17{
				font-size: 17px !important;
				color:#2a292a;
				font-weight:400;
			}
			.plainTableReporter{border-color: #cdcdcd;border-width: 1px 1px 1px 1px;}
			.plainTableReporter table{border-collapse:collapse;border-color: #cdcdcd;border-width: 1px 1px 1px 1px;}
			.plainTableReporter table tbody tr:nth-child(even) {background-color:#ffffff}
			.plainTableReporter table tbody tr:nth-child(odd) {background-color:#f9f9f9}
			.plainTableReporter table thead tr th{background-color:#e6e6e6;text-transform:uppercase}
			.plainTableReporter table thead tr th {border:1px solid #cdcdcd;padding:3px 10px 3px 10px;font-size:11px; }
			.plainTableReporter table tbody tr td{
				border:1px solid #cdcdcd;
				padding:3px 10px 3px 10px;
				font-size:11px;
				}
			.newPlainTable{
				background-color:#ffffff;
				border:1px solid #cdcdcd;
			}
			.newPlainTable div:first-child{
				border-bottom:1px solid #c4c4c4;
				padding:0px 0px 5px 0px;
				margin:10px 10px 0px 10px;
			}
			.newPlainTable div:nth-child(2){
				display:block;
				margin:0px 0px 0px 10px;
				padding:5px 0px 5px 0px;
			}
			.newPlainTable div:nth-child(2) table{
				width:100%;
			}
			.newPlainTable div:nth-child(2) table tbody tr td:first-child{
				padding:5px 10px 5px 0px;
				width:80%;
				vertical-align:top;
			}
			.newPlainTable div:nth-child(2) table tr td:nth-child(2){
				padding:5px 10px 5px 0px;
				width:20%;
				vertical-align:top;
			}
			</style>
		</head>
		<body  style="padding:10px 10px 10px 10px;">
	<%
		String strLogCls = "printHeaderBoxLogo";
		if(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes"))
		{
			strLogCls = "printHeaderBoxLogo";
		}
		else
			strLogCls = "printPdfHeaderBoxLogo";
	%>
			<div style="padding-top:10px" class="<%=strLogCls%>"><img src="<%=imageName%>" border="0"></div>
			<div class="printHeaderBox" style="border-bottom:0px;">
				<div class="printHeaderBoxTitle">Summary of <%= userName %>'s Session</div>

<%
		if(pdfPrint != null && pdfPrint.equalsIgnoreCase("yes"))
		{
%>
				<div class="printHeaderBoxPrintIcon"><img class="iconPrinter mouse" id="pri ntbt" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" border="0" onclick="javascript:window.print()" alt="PRINT" title="PRINT"></div>
		
<%
		}
%>
			</div>
			<div class="printOuterBox" style="padding:0px 10px 0px 10px;">
				<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0" >
					<tr>
						<td align="center" width="100%" style="padding-right:2px">
							<p class="newFont_bold15" style="padding:10px 10px 10px 0px;text-align:left;margin:0px;"><egui:intnl text="reporter.common.Summary " /></p>
							<table width="100%" align="center" style="border:0px !important" border="0px">
								<tr>
			<%
						if(hasMultipleLogins){

			%>
									<td width="75%" align="center" valign="top">
										<table width="100%">
			<%
									if(summaryObj != null && summaryObj.size() > 0){
										JSONArray headrArr=(JSONArray)summaryObj.get("header");
										JSONArray dataArr=(JSONArray)summaryObj.get("dataArray");
										JSONObject strObj=null;
										if(headrArr != null && headrArr.size() > 0 && dataArr != null && dataArr.size() > 0)
			%>
											<tr>
												<td>
													<div class="newTable">
														<table width="100%">
															<thead>
																<tr>
			<%
										for(int z=0;z<headrArr.size();z++){
											String strTmp=(String)headrArr.get(z);
			%>
																	<th><%=strTmp%></th>
			<%
										}
			%>
																</tr>
															</thead>
															<tbody>
			<%
										for(int z=0;z<dataArr.size();z++){
											JSONObject strObjct=(JSONObject)dataArr.get(z);
			%>
																<tr>
			<%
											for(int x=0;x<headrArr.size();x++){
												String strTmp=(String)headrArr.get(x);
												String strTmpvl=(String)strObjct.get(strTmp);
												if(strTmp != null && strTmp.equalsIgnoreCase("server") && ( strTmpvl.endsWith(":NULL") || strTmpvl.endsWith(":null")) )
													strTmpvl=strTmpvl.substring(0,strTmpvl.lastIndexOf(":"));

			%>
																	<td><%=strTmpvl%></td>
			<%

											}
			%>

																</tr>
			<%
										}
			%>
															</tbody>
														</table>
													</div>
												</td>
											</tr>
			<%
									}
			%>
											<tr>
												<td width="100%" align="center">
													<table>


										<%
												if(isVmComp){
										%>
													<tr>
														<td align="center">
															<table>
																<tr>
																	<td align="center"><div class="iconClientName" ></div></td>
																	<td style="vertical-align:bottom;margin-right:10px;padding-left:5px;" class="newFont_bold16" align="center"><%=sessionInfobean.getDesktopName()%></td>
																</tr>
															</table>
														</td>
													</tr>
													<tr>
														<td style="padding:10px;" class="newFont_normal13" align="center">Desktop Name</td>
													</tr>
										<%
												}
												else{
													String applnCnt=sessionInfobean.getUniqueApplicationsCnt();
													boolean enableApplnCombo=false;
													String paddingval="30";
													if(applnCnt != null && applnCnt.length()>0){
														double dd=Double.parseDouble(applnCnt);
														if(dd > 0){
															enableApplnCombo=true;
															paddingval="5";
														}
													}
										%>
													<tr>
														<td align="center">
															<table>
																<tr>
																	<td  align="right" ><div class="iconUniqueApp" ></div></td>
																	<td style="vertical-align:bottom;padding-left:5px;" class="newFont_bold16"><%=sessionInfobean.getUniqueApplicationsCnt()%></td>
																</tr>
															</table>
														</td>
										<%
													if(enableApplnCombo){
										%>
													<td rowspan="2">
														<div style="display:inline-block;padding:10px 10px 0px 10px;position:relative"><div class="arrow_box" ></div><div class="arrow_box_div" style="padding:10px 0px 5px 10px; overflow-wrap: break-word;"><%=sessionInfobean.getUniqueApplications()%></div></div>
													</td>
										<%
													}
										%>
													</tr>
													<tr>
														<td style="padding:10px;white-space: nowrap;" align="center" class="newFont_normal13" >Applications Accessed</td>
													</tr>
										<%
												}
										%>


													</table>
												</td>
											</tr>
										</table>
									</td>
			<%
						}else{
							String start_date = (String)sessionInfobean.getSessionStartTime();
							time_converter.convertProcess(start_date,thisuser,false);
							start_date = time_converter.getDateTime();
			%>
									<td align="center" valign="top"  width="25%">
										<table width="100%">
											<tr>
												<td align="center">
													<table>
														<tr>
															<td align="center"><div class="iconWebLogIn" ></div></td>
															<td style="vertical-align:bottom;margin-right:0px;padding-left:5px;" class="newFont_bold16" align="center"><%=start_date%></td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td style="padding:10px;" align="center" class="newFont_normal13">Login Time</td>
											</tr>
											<tr>
												<td><div style="clear:both;padding:30px">&nbsp;</div></td>
											</tr>
											<tr>
												<td align="center">
													<table>
														<tr>
															<td align="center"><div class="iconClientIP" ></div></td>
															<td style="vertical-align:bottom;margin-right:0px;padding-left:5px;" class="newFont_bold16"><%=sessionInfobean.getClientIp()%></td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td style="padding:10px;" align="center" class="newFont_normal13">Client Ip</td>
											</tr>
										</table>
									</td>
									<td align="center" valign="top"  width="25%">
										<table width="100%" border ="0">
											<tr>
												<td align="center">
													<table>
														<tr>
															<td align="center"><div class="iconClientName" ></div></td> 
															<td style="vertical-align:bottom;margin-right:0px;padding-left:5px;" class="newFont_bold16" align="center"><%=sessionInfobean.getClientName()%></td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td style="padding:10px;height:35px" align="center" class="newFont_normal13">Client Name</td>
											</tr>
											<tr>
												<td><div style="clear:both;padding:30px">&nbsp;</div></td>
											</tr>
											<tr>
												<td align="center">
													<table>
														<tr>
															<td><div class="iconXenAppServer" ></div></td>
															<td style="vertical-align:bottom;margin-right:10px;padding-left:5px;" class="newFont_bold16" align="center"><%=sessionInfobean.getTrgtHost()%></td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td style="padding:10px;height:35px" align="center" class="newFont_normal13" >Server</td>
											</tr>
										</table>
									</td>
									<td align="center" valign="top"  width="30%">
										<table width="100%">
											<tr>
												<td align="center">
													<table>
														<tr>

										<%
											String logon=sessionInfobean.getLogonDuration();
											if(logon == null){
												logon=" - ";
										%>
															<td width="50%" align="right"><div class="iconTimeGray" ></div></td>
															<td width="50%" style="vertical-align:bottom;padding-left:10px;" class="newFont_bold16" ><%=logon%></td>
										<%
											}
											else{
												logon=logon+" <span class='newFont_normal11'>secs</span>";
										%>
															<td width="40%" align="right"><div class="iconTimeGray" ></div></td>
															<td width="60%" style="vertical-align:bottom;padding-left:5px;" class="newFont_bold16" ><%=logon%></td>
										<%
											}

										%>
														</tr>
													</table>
												</td>
											</tr>
										<%
												String strTestName=sessionInfobean.getTestName();
												ArrayList tableColumnsLst=new ArrayList(Arrays.asList(dbInfo.getMeasurementsForTest(strTestName)));
												String logTit="Session Start-up Duration";
												if(tableColumnsLst != null && tableColumnsLst.contains("Logon_duration")){
													logTit=intlmap.getMeasureDescription(strTestName,"Logon_duration");
												}
										%>
											<tr>
												<td style="padding:10px;" class="newFont_normal13" align="center"><%=logTit%></td>
											</tr>
								<%
										if(isVmComp){
								%>
											<tr>
												<td><div style="clear:both;padding:30px">&nbsp;</div></td>
											</tr>
											<tr>
												<td align="center">
													<table>
														<tr>
															<td align="center"><div class="iconClientName" ></div></td>
															<td style="vertical-align:bottom;margin-right:10px;padding-left:5px;" class="newFont_bold16" align="center"><%=sessionInfobean.getDesktopName()%></td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td style="padding:10px;" class="newFont_normal13" align="center">Desktop Name</td>
											</tr>
								<%
										}
										else{
											String applnCnt=sessionInfobean.getUniqueApplicationsCnt();
											boolean enableApplnCombo=false;
											String paddingval="30";
											if(applnCnt != null && applnCnt.length()>0){
												double dd=Double.parseDouble(applnCnt);
												if(dd > 0){
													enableApplnCombo=true;
													paddingval="5";
												}
											}
								%>
											<tr>
												<td><div style="clear:both;padding:<%=paddingval%>px">&nbsp;</div></td>
											</tr>
											<tr>
												<td align="center">
													<table>
														<tr>
															<td  align="right" ><div class="iconUniqueApp" ></div></td>
															<td style="vertical-align:bottom;padding-left:5px;" class="newFont_bold16"><%=sessionInfobean.getUniqueApplicationsCnt()%></td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td style="padding:10px;white-space: nowrap;" align="center" class="newFont_normal13" >Applications Accessed</td>
											</tr>
								<%
											if(enableApplnCombo){
								%>
											<tr>
											<td >
												<div style="display:inline-block;padding:10px 10px 0px 10px;position:relative"><div class="arrow_box" ></div><div class="arrow_box_div" style="padding:10px 0px 5px 10px;overflow-wrap: break-word;"><%=sessionInfobean.getUniqueApplications()%></div></div></td>
											</tr>
								<%
											}
										}
								%>
										</table>
									</td>
							<%
								}
							%>

									<td align="center" valign="top" width="25%">
							<%
									String urlTmpz1 = "../../final/servlet/com.eg.ErCtxUserSessionReportC;jsessionid=" + session.getId()+"?imagereq=yes&chartType=donut&chrtVal=donut_chrt&er_width=180&er_height=180";
									if(frompdf != null && frompdf.equalsIgnoreCase("yes")){
							%>
										<div align="center" style="display:inline-block;position:relative;width:200px;height:200px;">
											<div style="border:0px solid red;position:relative"><img  src="<%=urlTmpz1%>" /></div>
											<div style="position:absolute;width:90px;top:70px;left:55px;z-index:99;background-color:transparent;text-align:center">
													<div class='donutChartTitleMiddle' style="text-align:center"><%=sessionInfobean.getSessionDuration()%></div>
													<div class='newFont_normal13' style='margin-top:-5px'>Duration</div>
													<div style='margin-top:-2px;' class='newFont_normal10'>(mins)</div>
											</div>
										</div>
										<br/>
										<table align="center" cellpadding="0" cellspacing="0" border="0" style="margin-top: -120;">
											<tbody>
												<tr>
													<!-- <td><div style="background-color:#69c7b3;" class="legendCircle">&nbsp;</div></td> -->
													<td>
														<div style="float:left;">
															<svg height="12" width="12"><circle cx="4" cy="6" r="4" fill="#69c7b3" stoke-width="0" /></svg>
														</div>
													</td>
													<td style="padding:5px 20px 5px 5px;float:left" class="newFont_normal13">Active Time</td>
													<td class="newFont_bold16" align="left"><%=sessionInfobean.getActiveTimeinDayWise()%></td>
												</tr>
												<tr>
													<!-- <td><div style="background-color:#fdb042;" class="legendCircle">&nbsp;</div></td> -->
													<td><div style="float:left;"><svg height="12" width="12">
													<circle cx="4" cy="6" r="4" fill="#fdb042" stoke-width="0" /></svg></div></td>
													<td style="padding:5px 20px 5px 5px;float:left" class="newFont_normal13">Idle Time</td>
													<td class="newFont_bold16" align="left"><%=sessionInfobean.getIdleTimeinDayWise()%></td>
												</tr>
												<tr>
													<!-- <td><div style="background-color:#fdb042;" class="legendCircle">&nbsp;</div></td> -->
													<td><div style="float:left;"><svg height="12" width="12">
													<circle cx="4" cy="6" r="4" fill="#fff" stoke-width="0" /></svg></div></td>
													<td style="padding:5px 20px 5px 5px;float:left" class="newFont_normal13">Duration</td>
													<td class="newFont_bold16" align="left"><%=sessionInfobean.getSessionDurationinDaywise()%></td>
												</tr>
											</tbody>
										</table>
								<%
									}else{
								%>
										<div align="center" style="position:relative; width:180px; height:180px"><img width="100%" height="90%" src="<%=urlTmpz1%>" />
											<div style="position:absolute;border:0px solid green;width:60px;height:60px;top:50%;left:50%;margin-top:-30px;margin-left:-30px;border-radius:30px;background:#ffffff"><div><div class='donutChartTitleMiddle'><%=sessionInfobean.getSessionDuration()%></div><div class='newFont_normal13' style='margin-top:-2px'>Duration</div><div class='newFont_normal10'>(mins)</div></div></div> 
										</div>
										<br/>
										<table align="center" cellpadding="0" cellspacing="0" border="0">
											<tbody>
												<tr>
													<!-- <td><div style="background-color:#69c7b3;" class="legendCircle">&nbsp;</div></td> -->
													<td><div style="float:left;"><svg height="12" width="12">
													<circle cx="4" cy="6" r="3" fill="#69c7b3" stoke-width="0" /></svg></div></td>
													<td style="padding:5px 20px 5px 5px;float:left" class="newFont_normal13">Active Time</td>
													<td class="newFont_bold16" align="left"><%=sessionInfobean.getActiveTimeinDayWise()%></td>
												</tr>
												<tr>
													<!-- <td><div style="background-color:#fdb042;" class="legendCircle">&nbsp;</div></td> -->
													<td><div style="float:left;"><svg height="12" width="12">
													<circle cx="4" cy="6" r="3" fill="#fdb042" stoke-width="0" /></svg></div></td>
													<td style="padding:5px 20px 5px 5px;float:left" class="newFont_normal13">Idle Time</td>
													<td class="newFont_bold16" align="left"><%=sessionInfobean.getIdleTimeinDayWise()%></td>
												</tr>
												<tr>
													<!-- <td><div style="background-color:#fdb042;" class="legendCircle">&nbsp;</div></td> -->
													<td><div style="float:left;"><svg height="12" width="12">
													<circle cx="4" cy="6" r="3" fill="#fff" stoke-width="0" /></svg></div></td>
													<td style="padding:5px 20px 5px 5px;float:left" class="newFont_normal13">Duration</td>
													<td class="newFont_bold16" align="left"><%=sessionInfobean.getSessionDurationinDaywise()%></td>
												</tr>
											</tbody>
										</table>
									<%
										}	
									%>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</div>
			<!-- <div class="clearDiv" height="20px"></div> -->
	<%
			if( (logonDetailInfo1!=null && logonDetailInfo1.size() > 0) || (startupDetails != null && startupDetails.size() > 0) ){
	%>
			<div class="printOuterBox" style="margin-top: 10px;" style="page-break-inside: auto !important">
					<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0" style="page-break-inside: auto !important">
			<%
						if(logonDetailInfo1!=null && logonDetailInfo1.size()>0)
						{
							String urlTmp1 ="../../final/servlet/com.eg.ErCtxUserSessionReportC;jsessionid=" + session.getId()+"?imagereq=yes&chartType=pie&chrtVal=UserLogonChart&er_width=190&er_height=190";
								String divStyle="";
								if(frompdf != null && frompdf.equalsIgnoreCase("yes"))
									divStyle="height:300px";
			%>
								<tr>
									<td align="center" width="100%" valign="top">
										<p class="newFont_bold15" style="padding:0px 10px 0px 10px;text-align:left"><egui:intnl text="reporter.common.Logon Time Breakdown" /></p>
										<table cellspacing="0" cellpadding="0" border="0" align="center" width="70%"  style="border-collapse:collapse;">
											<tr >
												<td width="60%" valign="top"><img src="<%=urlTmp1%>" style="height:200px;width: 300px;" /></td> 
												<td width="40%" style="<%=divStyle%>">
													<table cellpadding="0" cellspacing="0" border="0" style="margin:10px;">
														<tbody>
												<%
														if(logonArr != null && logonArr.size() > 0){
															JSONObject tmpObj=null;
															for(int n=0;n<logonArr.size();n++){
												%>
															<tr>
												<%
																tmpObj=(JSONObject)logonArr.get(n);
																if(tmpObj != null && tmpObj.size() > 0){
												%>
																<td>
																	<div style="float:left;"><svg height="12" width="12">
																	<circle cx="4" cy="6" r="3" fill="<%=(String)tmpObj.get("color")%>" stoke-width="0" /></svg></div></td>
																<td style="padding:2px 10px;" class="font_normal11"><%=(String)tmpObj.get("name")%></td>
																<td class="font_normal11"><%=(Double)tmpObj.get("y")%></td>
												<%
																}
												%>
															</tr>
												<%//innerArray
																if(tmpObj != null && tmpObj.size() > 0 && tmpObj.containsKey("innerArray")){
																	JSONArray tmplegArray=(JSONArray)tmpObj.get("innerArray");
																	if(tmplegArray != null && tmplegArray.size() > 0){
																		JSONObject tmpobj2=null;
																		for(int m=0;m<tmplegArray.size();m++){
												%>
															<tr>
												<%
																			tmpobj2=(JSONObject)tmplegArray.get(m);
																			if(tmpobj2 != null && tmpobj2.size() > 0){
												%>
																<td>&nbsp;</td>
																<td style="padding:2px 10px;" class="font_normal11">&nbsp;&nbsp;<%=(String)tmpobj2.get("name")%></td>
																<td class="font_normal11"><%=(Double)tmpobj2.get("y")%></td>
												<%
																			}
												%>
															</tr>
												<%
																		}
																	}
																}
															}
														}
												%>
														</tbody>
													</table>
												</td>
											</tr>
										</table>
									</td>
								</tr>
			<%
						}
						if(startupDetails != null && startupDetails.size() > 0){
				%>
								<tr>
									<td align="center" width="100%" style="padding-right:2px">
										<div class="printOuterBoxHeader" style="text-align:  left;"><egui:intnl text="reporter.common.Session Start-up Details (Secs)" /></div>
				<%
								JSONArray tmpArr=null;
								JSONObject tmpObj=null;
								if(startupDetails.containsKey("Header"))
									tmpArr=(JSONArray)startupDetails.get("Header");
								if(tmpArr != null && tmpArr.size() > 0){
									tmpObj=(JSONObject)tmpArr.get(0);
					%>
									<div align="center"><div class="reporterLogonSessionStartupBox" style="height: 24px;"><table style="margin:4px 0px 0px 10px;"><tr><td><egui:intnl text="reporter.common.Session start-up duration(Secs)" /> :</td><td><%=(String)tmpObj.get("value")%></td></tr></table></div></div>
					<%
								}
					%>

										<div class="newTable">
											<table width="100%" style="border:0px">
												<tr style="background:none">
		<%
									tmpArr=null;
									String serverTitle="Server Start up (secs)";
									String leftHeaderVal="";
									if(startupDetails.containsKey("ServerHeader")){
										tmpArr=(JSONArray)startupDetails.get("ServerHeader");
									}else if(startupDetails.containsKey("GpHeader")){
										tmpArr=(JSONArray)startupDetails.get("GpHeader");
									}
									if(tmpArr != null && tmpArr.size() > 0)
										tmpObj=(JSONObject)tmpArr.get(0);
									if(tmpObj != null && tmpObj.containsKey("value"))
										leftHeaderVal=(String)tmpObj.get("value");

									if(startupDetails.containsKey("logonBreakup")){
										tmpArr=(JSONArray)startupDetails.get("logonBreakup");
										serverTitle="logon Time Break up (secs)";
									}
									else if(startupDetails.containsKey("Server"))
										tmpArr=(JSONArray)startupDetails.get("Server");
		%>
													<td width="50%" valign="top" style="border:0px;padding:0px">
														<div style="margin:10px 10px 10px 0px;" class="newPlainTable">
															<div class="font_bold12"><%=serverTitle%><span style="float:right;padding-right:15%;"><%=leftHeaderVal%></span></div>
															<div style="height:155px;overflow:auto;">
																<table style="border:0px">
		<%
									for(int z=0;z<tmpArr.size();z++){
										tmpObj=(JSONObject)tmpArr.get(z);
		%>
																	<tr style="background:none"><td style="border:0px"><%=(String)tmpObj.get("key")%></td><td style="border:0px"><%=(String)tmpObj.get("value")%></td></tr>
		<%
									}
		%>
																</table>
															</div>
														</div>
													</td>
		<%
									tmpArr=null;
									String rightHeaderVal="";
									if(startupDetails.containsKey("ClinetHeader")){
										tmpArr=(JSONArray)startupDetails.get("ClinetHeader");
									}else if(startupDetails.containsKey("logonHeader")){
										tmpArr=(JSONArray)startupDetails.get("logonHeader");
									}
									if(tmpArr != null && tmpArr.size() > 0)
										tmpObj=(JSONObject)tmpArr.get(0);
									if(tmpObj != null && tmpObj.containsKey("value"))
										rightHeaderVal=(String)tmpObj.get("value");

									serverTitle="Client Start up (secs)";
									if(startupDetails.containsKey("gpBreakup")){
										tmpArr=(JSONArray)startupDetails.get("gpBreakup");
										serverTitle="Group policy Time Break up (secs)";
									}
									else if(startupDetails.containsKey("Client"))
										tmpArr=(JSONArray)startupDetails.get("Client");

		%>
													<td width="50%" valign="top" style="border:0px;padding:0px">
														<div style="margin:10px 0px 10px 0px;" class="newPlainTable">
															<div class="font_bold12"><%=serverTitle%><span style="float:right;padding-right:15%;"><%=rightHeaderVal%></span></div>
															<div style="height:155px;overflow:auto;">
																<table style="border:0px">
		<%
									for(int z=0;z<tmpArr.size();z++){
										tmpObj=(JSONObject)tmpArr.get(z);
		%>
																	<tr style="background:none"><td style="border:0px"><%=(String)tmpObj.get("key")%></td><td style="border:0px"><%=(String)tmpObj.get("value")%></td></tr>
		<%
									}
		%>
																</table>
															</div>
														</div>
													</td>
												</tr>
											</table>
										</div>
									</td>
								</tr>
		<%
							}
							if(logonGPDetailInfo != null && logonGPDetailInfo.size() > 0 && GPObjctHeadr != null && GPObjctHeadr.size() > 0){
		%>
								<tr>
									<td>
										<div class="newTable" >
											<div class="font_bold12" style="padding:5px 0px 10px 0px;"><egui:intnl text="reporter.common.Details of client side extension" /></div>
											<table width="100%">
												<thead>
													<tr>
		<%
								for(int x=0;x<GPObjctHeadr.size();x++){
									String gpHdr=(String)GPObjctHeadr.get(x);
		%>
														<th align="left"><%=gpHdr%></th>
		<%
								}
		%>
													</tr>
												</thead>
												<tbody>
		<%
								for(int z=0;z<logonGPDetailInfo.size();z++){
									JSONObject gpObj=(JSONObject)logonGPDetailInfo.get(z);
		%>
													<tr>
		<%
									for(int x=0;x<GPObjctHeadr.size();x++){
										String gpHdr=(String)GPObjctHeadr.get(x);
										String strTmpVal="-";
										if(gpObj != null && gpObj.containsKey(gpHdr))
											strTmpVal=(String)gpObj.get(gpHdr);
		%>
													<td><%=strTmpVal%></td>
		<%

									}
		%>
													</tr>
		<%
								}
		%>

												</tbody>
											</table>
										</div>
									</td>
								</tr>
		<%
							}
		%>
							</table>
			</div>
		<%
			}
		%>
		<%
			if(showActiveIdleGraph){
				String urlTmp ="../../final/servlet/com.eg.ErCtxUserSessionReportC;jsessionid=" + session.getId()+"?imagereq=yes&chartType=CombinedLine&chrtVal=XRange_Graph&er_width=900&er_height=300";
		%>
				<div class="printOuterBox newimg" style="margin-top: 10px;">
					<div class="printOuterBoxHeader"><egui:intnl text="reporter.common.Session Activity" /></div>
					<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0" >
						<tr>
							<td align="center" width="100%">
								<!-- <p class="newFont_bold15" style="padding:0px 10px 10px 0px;text-align:left"><egui:intnl text="reporter.common.Session Stages" /></p> -->
								<img src="<%=urlTmp%>" />
							</td>
						</tr>
					</table>
				</div>
		<%
			}
		%>
			

		<%
			if(resourceGraphDatas != null && resourceGraphDatas.size() > 0){
		%>
				 <!-- <pd4ml:page.break>   -->
				<div class="printOuterBox" style="margin-top: 10px;">
					<table  align="center" width="100%" cellspacing="0" cellpadding="0" border="0" >
						<tr>
		<%
				String urlTmp = "";
				for(int l=0;l<resourceGraphDatas.size();l++){
					JSONObject tmpObjj=(JSONObject)resourceGraphDatas.get(l);
					String grphTitle="";
					if(tmpObjj != null && tmpObjj.containsKey("TemplateName"))
						grphTitle=(String)tmpObjj.get("TemplateName");
					String grphKey="resourceGraph_"+l;
					urlTmp ="../../final/servlet/com.eg.ErCtxUserSessionReportC;jsessionid=" + session.getId()+"?imagereq=yes&chartType=line&chrtVal="+grphKey+"&er_width=420&er_height=300";
					String tdStyle="padding:10px 10px 10px 0px;";
					if(l%2 == 0)
						tdStyle+="border-right:1px solid #dedede;";
					if(l != resourceGraphDatas.size()-1 && l != resourceGraphDatas.size()-2)
						tdStyle+="border-bottom:1px solid #dedede;";

					if( l > 0 && (l%2 == 0)){
		%>
						</tr>
						<tr>
		<%
					}
		%>
							<td width="50%" style="<%=tdStyle%>" valign="top">
								<div class="printOuterBoxHeader" style="padding-left:15px;"><%=grphTitle%></div>
								<div align="center"><img src="<%=urlTmp%>" /></div>
							</td>
		<%

				}
				if(resourceGraphDatas.size() > 0 && resourceGraphDatas.size() % 2 != 0){
		%>
						</tr>
		<%
				}
		%>
					</table>
				</div>
		<%
			}else{
		%>
				<div class="printOuterBox" style="margin-top: 10px;">
					<div class="printOuterBoxHeader"><egui:intnl text="reporter.common.Resource Utilization" /></div>
						<table  align="center" width="100%" cellspacing="0" cellpadding="0" border="0" >
							<tr>
								<td align="center">
									<img src='/final/images/Light/nomeasures_custom.png' />
								</td>
							</tr>
						</table>
					</div>
				</div>
		<% 
			}

		%>
			<div class="clearDiv"></div>
		<%
			boolean isAppIODetailsFound=sessionInfobean.getAppIOOperationState();
			List appInfoList=sessionInfobean.getAppInfoList();
			if(appInfoList !=null && appInfoList.size() > 0){
		%>
			<pd4ml:page.break>
		<%
			}
		%>
			<div class="printOuterBox" style="padding:10px;margin-top: 10px;">
			<div class="printOuterBoxHeader"><egui:intnl text="reporter.common.Applications Used" /></div>
		<%
					boolean showLaunchDuratnCol=sessionInfobean.getApplaunchColumnState();;
					boolean enableApplnDurationColumn=es.getApplicationDurationDetails(appInfoList,currentDateFormat);

					if(appInfoList !=null && appInfoList.size() > 0 )
					{
		%>
							<div class="plainTableReporter">
								<table class="newimg" align="center" width="100%" cellspacing="0" cellpadding="0" border="0" >
									<thead>
										<tr>
											<th style="padding:6px 10px 4px 10px">Name</th>
											<th style="padding:6px 10px 4px 10px">Start Time</th>
		<%
										if(enableApplnDurationColumn){
		%>
											<th style="padding:6px 10px 4px 10px">End Time</th>
											<th style="padding:6px 10px 4px 10px">Duration (Mins)</th>
		<%
										}
										if(showLaunchDuratnCol){
		%>
											<th style="padding:6px 10px 4px 10px">Launch Time (Secs)</th>
		<%
										}
		%>
											<th style="padding:6px 10px 4px 10px">Cpu Util (%)</th>
											<th style="padding:6px 10px 4px 10px">Memory Util (%)</th>
		<%
										if(isAppIODetailsFound)
										{
		%>
											<th style="padding:6px 10px 4px 10px">IO Operations (KB/Sec)</th>
		<%
										}
		%>
										</tr>
									</thead>
									<tbody>
		<%
							SimpleDateFormat frmt = new SimpleDateFormat(currentDateFormat+" HH:mm:ss");

							JSONObject browserActivtyObj=sessionInfobean.getBrowserDetailsObj();
							boolean checkBrowsrActivty=false;
							String needBrowserDetailsForVMComp=reportInfo.getValue("CITIX_USER_SESSION_VIEW","needBrowserDetailsForVMComp");
							String supportedBrowsers=reportInfo.getValue("CITIX_USER_SESSION_VIEW","SupportedBrowsers");
							if(needBrowserDetailsForVMComp != null && needBrowserDetailsForVMComp.equalsIgnoreCase("yes") &&isVmComp && browserActivtyObj != null && browserActivtyObj.size() > 0){
								checkBrowsrActivty=true;
							}
							String browserDetails = reportInfo.getValue("CITIX_USER_SESSION_VIEW","browserDetails");
							String measuresForGrid="WEBSITEURL,WEBSITETITLE";
							if(browserDetails != null && browserDetails.length() > 0){
								measuresForGrid=browserDetails;
							}
							ArrayList measrLst=erUtils.egTokenizer(measuresForGrid, ",");
							SimpleDateFormat browsrDteFrmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
							
							for(int k=0;k<appInfoList.size();k++)
							{
								ErApplicationInfoBean appInfoBean=(ErApplicationInfoBean)appInfoList.get(k);
								String appName=appInfoBean.getAppName();
								String appLaunchTime=appInfoBean.getAppLaunchTime();
								String appEndTtime=appInfoBean.getAppEndTime();
								double appCpuUtil=appInfoBean.getAppCpuUtil();
								double appMemoryUtil=appInfoBean.getAppMemoryUtil();
								String launchDuration=appInfoBean.getAppLaunchDuration();
								String memeory_util_temp = BigDecimal.valueOf(appMemoryUtil).toString();
								String cpu_util_temp = BigDecimal.valueOf(appCpuUtil).toString();
								
								if(launchDuration==null || launchDuration.equals("null"))
								{
									launchDuration = "-";	
								}
								double iooperations=appInfoBean.getIoOperations();
								Date d1=frmt.parse(appLaunchTime);
								Date d2=frmt.parse(appEndTtime);
								long diff = d2.getTime() - d1.getTime();
								long diffMinutes = Math.abs(diff / (60 * 1000));
								int colCntt=6;
		%>
										<tr>
											<td style="padding:6px 10px 4px 10px" align="center"><%=appName%></td>
											<td style="padding:6px 10px 4px 10px" align="center"><%=appLaunchTime%></td>
		<%
								String applnEndTime=appEndTtime;
								String applnDuratn=diffMinutes+"";
								if(diffMinutes <= 0){
									applnEndTime="-";
									applnDuratn="-";
								}
								if(enableApplnDurationColumn){
		%>

											<td style="padding:6px 10px 4px 10px" align="center"><%=applnEndTime%></td>
											<td style="padding:6px 10px 4px 10px" align="center"><%=applnDuratn%></td>
		<%
								}
								if(showLaunchDuratnCol){
									colCntt++;
		%>
											<td style="padding:6px 10px 4px 10px" align="center"><%=launchDuration%></td>
		<%
								}
		%>

											<td style="padding:6px 10px 4px 10px" align="center"><%=cpu_util_temp%></td>
											<td style="padding:6px 10px 4px 10px" align="center"><%=memeory_util_temp%></td>
		<%
								if(isAppIODetailsFound)
								{
									colCntt++;
		%>
											<td style="padding:6px 10px 4px 10px" align="center"><%=iooperations%></td>
		<%	
								}
								if(checkBrowsrActivty && ((supportedBrowsers.toLowerCase()).indexOf(appName.toLowerCase())) > -1){
//									String keyId=childId;
//									if(keyId != null && keyId.indexOf(".") > -1)
//										keyId=keyId.substring(0,keyId.indexOf("."));
									String tmpkey=appName;
		//							String tmpkey=appName+"#"+keyId;
									if(browserActivtyObj.containsKey(tmpkey)){
										JSONObject tmpObject=(JSONObject)browserActivtyObj.get(tmpkey);
										if(tmpObject != null && tmpObject.size() > 0){
											JSONObject addtnlDat=es.getApplicationDetails(tmpObject,appLaunchTime,appEndTtime,measrLst,frmt,browsrDteFrmt);
											if(addtnlDat != null && addtnlDat.size() > 0){
		%>
										</tr>
										<tr>
											<td colspan="<%=colCntt%>">
												<div class="newTable" style="margin: 5px 0px 5px 10px;">
													<table width="100%">
														<thead>
															<tr>
		<%
												JSONArray hdrArr=(JSONArray)addtnlDat.get("header");
												for(int x=0;x<hdrArr.size();x++){
													String hdrStr=(String)hdrArr.get(x);
		%>
																<th><%=hdrStr%></th>
		<%
												}
		%>
															</tr>
														</thead>
														<tbody>
		<%
												Iterator subColitr=addtnlDat.keySet().iterator();
												while(subColitr.hasNext()){
													String tmpStr=(String)subColitr.next();
													if(tmpStr != null && tmpStr.equalsIgnoreCase("header"))
														continue;
													JSONObject obj5=(JSONObject)addtnlDat.get(tmpStr);
													if(obj5 != null && obj5.size() > 0){
		%>
															<tr>
		<%
														for(int x=0;x<hdrArr.size();x++){
															String hdrStr=(String)hdrArr.get(x);
															String tmpStr2=(String)obj5.get(hdrStr);
															String tdstyle="";
															if(tmpStr2 != null && tmpStr2.length() >80){
																tdstyle="40%";
															}

		%>
															<td style="word-wrap: break-word;" width="<%=tdstyle%>"><%=tmpStr2%></td>
		<%

														}
		%>
															</tr>
		<%

													}
													
												}
		%>
														</tbody>
													</table>
												</div>
											</td>
		<%
											}
										}
									}
								}
		%>
										</tr>
		<%
							}
		%>
									</tbody>
								</table>
							</div>

							<div>
							<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0" style="padding-top:10px;page-break-inside: auto !important">
								<tr>
									<td width="50%" style="padding:10px 0px 10px 10px;border-right:1px solid #dedede;" valign="top">
										<div class="printOuterBoxHeader"><egui:intnl text="reporter.common.Cpu" /></div>
		<%
	
							boolean IOGraphFound=false;
							if(isAppIODetailsFound)
								IOGraphFound=true;
							if(isCpudatafound)
							{
								String urlTmp ="../../final/servlet/com.eg.ErCtxUserSessionReportC;jsessionid=" + session.getId()+"?imagereq=yes&&chartType=line&chrtVal=CPUChart&er_width=400&er_height=300";
		%>
										<div ><img src="<%=urlTmp%>" /></div>
									</td>
		<%
							}
							else{
		%>
										<img src='/final/images/Light/nomeasures_custom.png' />
									</td>
		<% 
							}
								String memStyle="";
								if(IOGraphFound)
									memStyle="border-bottom:1px solid #dedede;";

		%>
									<td width="50%" style="padding:10px 0px 10px 10px;<%=memStyle%>" valign="top">
										<div class="printOuterBoxHeader"><egui:intnl text="reporter.common.Memory" /></div>
		<%
							if(ismemorydatafound)
							{
								String urlTmp ="../../final/servlet/com.eg.ErCtxUserSessionReportC;jsessionid=" + session.getId()+"?imagereq=yes&chartType=line&chrtVal=MemoryChart&er_width=450&er_height=300";//er_width=400 changed to 450
		%>
										<div ><img src="<%=urlTmp%>" /></div>
									</td>
		<%
							}
							else{
		%>
										<img src='/final/images/Light/nomeasures_custom.png' />
									</td>
		<% 
							}
		%>

								</tr>
								<tr>
								
		<%
							if(IOGraphFound)
							{
		%>
									<td width="50%" style="padding:10px 0px 10px 10px;border-right:1px solid #dedede;border-top:1px solid #dedede;" valign="top">
										<div class="printOuterBoxHeader"><egui:intnl text="reporter.common.IO Operations" /></div>
		<%
								if(isIOdatafound)
								{
									String urlTmp ="../../final/servlet/com.eg.ErCtxUserSessionReportC;jsessionid=" + session.getId()+"?imagereq=yes&chartType=line&chrtVal=IOChart&er_width=400&er_height=300";
		%>
		
										<div><img src="<%=urlTmp%>" /></div>
									</td>
		<% 
								}
								else{
		%>
										<img src='/final/images/Light/nomeasures_custom.png' />
									</td>
		<% 
								}
							}
		%>
								</tr>
							</table>
							</div>
		<%
					}else{
			
		%>
					<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0" >
						<tr>
							<td align="center">
								<img src='/final/images/Light/nomeasures_custom.png' />
							</td>
						</tr>
					</table>
		<%
					}
		%>
			</div>
	<%
		if(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes"))
		{
	%>
			<br/>
			<div class="printFooterText"><%=strPrintFooterText%></div>
	<%
		}
	%>
	</body>
</html>
<%
	}
%>