<%
/*****************************************************************************
*	File name		: ErPrintCustomReportBuilder.jsp
*	Purpose			: This page Handles Report Builder Report
*	Created by		: Gowtham
*	Version			: Reporter 6.2
********************************************************************************/
%>
<%@ include file="ErTracker.jsp"%>
<%@ page import="egurkha.reporter.*"%>
<%@ page import="com.eg.EgDiscInfoHelper"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.util.*"%>
<%@ page import="java.util.regex.*"%>
<%@ page import="egurkha.TransactionBean"%>
<%@ page import="egurkha.EgDbAdapterUI"%>
<%@ page import="com.eg.EgDbAdapterTypeUI"%>
<%@ page import="com.eg.*"%>
<%@ page import="com.eg.EgDbInfo"%>
<%@ page import="com.eg.IniFile"%>
<%@ page import="com.eg.EgInstallInfo,com.eg.EgTopoInfo,com.eg.EgSpecsInfo"%>
<%@ page import="egurkha.EgCrawler"%>
<%@ page import="com.eg.EgTopoInfo"%>
<%@ page import="com.eg.EgDateInfo"%>
<%@ page import="java.text.Format.*"%>
<%@ page import="java.text.DateFormat.*"%>
<%@ page import="java.text.*"%>
<%@ page import="java.net.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="com.eg.EgReportInfo"%>
<%@ page import="com.eg.EgMappingInfo"%>
<%@ page import="com.eg.EgTablesInfo"%>
<%@ page import="com.egurkha.util.DateUtil"%>
<%@ page import="com.egurkha.util.*"%>
<%@ page import="com.egurkha.util.DateTimeTokenizer"%>
<%@ page import="com.eg.EgTesterInfo"%>
<%@ page import="com.eg.EgTestInfo"%>
<%@ page import="com.eg.EgURLDecoder"%>
<%@ page import="com.eg.EgConfigInfo"%>
<%@ page import="java.io.*"%>
<%@ page import="com.egurkha.util.StringUtils"%>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import = "com.egurkha.monitor.EgServiceMappingBean"%>
<%@ page import="com.egurkha.util.StringUtils"%>
<%@ page import = "net.sf.json.*" %>

<jsp:useBean id="esmb" scope="page" class="com.egurkha.monitor.EgServiceMappingBean" />
<%
	String qStrng =(String)ErUtils.prepareQueryString(request.getParameterMap());
	
	EgReportInfo reportInfo=new EgReportInfo("manager");
	ErUtils utils=new ErUtils();
	EgMappingInfo intlmap=new EgMappingInfo(thisuser.getLanguage());
	EgDbInfo dbInfo = new EgDbInfo("manager");
	ErReqData erd = new ErReqData(request);
	
	System.out.println("ErPrintCustomReportBuilder.jsp query string  "+request.getQueryString());

	JSONObject resultJson=null;
	if(request.getParameter("dataDrill") != null)
	{
		String dataDrill=(String)request.getParameter("dataDrill");
		if(dataDrill.equals("yes"))
			resultJson = (JSONObject) session.getAttribute("htdataDrillDown");
	}
	else
		resultJson = (JSONObject) session.getAttribute("htdata");
	System.out.println("ErPrintCustomReportBuilder ===resultJson=.>>>>>>>>"+resultJson);

	String widgetIdInfo = (String)request.getParameter("widgetIdInfo");
	String printBy = (String)request.getParameter("printBy");
	//System.out.println("=====pritnBy=======>>>jsp>>"+printBy);
	//System.out.println("===widgetIdInfo======>>>..>>>>>>>>"+widgetIdInfo);
	//System.out.println("=========pdfby=====jsp==>>>>>"+request.getParameter("pdfBy"));
	String managerUrl="../..";
	if(reportInfo.getValue("MISC","CustomPDFurl") != null)
	{
		managerUrl=reportInfo.getValue("MISC","CustomPDFurl");
	}
	
	String fontStyleDbl = "";
	String fontStyleDblSingl = "";
	String pdfPrint = request.getParameter("pdfPrint");
	//String titleToDisplay=request.getParameter("er_RmDispName");
	String dataPageNo=request.getParameter("dataPageNo");
	String titleToDisplay=request.getParameter("titleDisp");
	JSONObject selDetails=null;
	String needNoMeasure=(String)resultJson.get("needNoMeasure");
	String firstColWordBreakPrint=(String)resultJson.get("firstColWordBreakPrint");
	String er_sortingColumn=(String)resultJson.get("er_sortingColumn");
	if(er_sortingColumn != null && er_sortingColumn.indexOf("$") != -1)
		er_sortingColumn=er_sortingColumn.substring(0,er_sortingColumn.indexOf("$"));
	String er_secondaryColSort=(String)resultJson.get("er_secondaryColSort");
	if(er_secondaryColSort != null && er_secondaryColSort.indexOf("$") != -1)
		er_secondaryColSort=er_secondaryColSort.substring(0,er_secondaryColSort.indexOf("$"));

	if(titleToDisplay != null && titleToDisplay.indexOf("jsessionid") > -1)
		titleToDisplay=titleToDisplay.substring(0,titleToDisplay.indexOf(";"));
	if(resultJson.get("templateTitle") != null)
	{
		titleToDisplay=(String)resultJson.get("templateTitle");
		
	}
	if(resultJson.get("selectionDetails") != null)
	{
		selDetails=new JSONObject();
		selDetails=(JSONObject)resultJson.get("selectionDetails");
	}
	String tempDesc=(String)request.getParameter("tempDesc");
	if(tempDesc==null)
	{
		tempDesc="";
	}
	String timefrom = request.getParameter("timefrom");
	String timeto = request.getParameter("timeto");
	String minfrom = request.getParameter("minfrom");
	String minto = request.getParameter("minto");
	String Strexcwe = request.getParameter("er_excwe");
	String fromdistributedPie=request.getParameter("fromdistributedPie");
	String dispStartDate = null;
	String dispEndDate = null;
	String start_date=erd.s_stdate;
	String end_date=erd.s_enddate;
	String graphIndex="";
	//System.out.println("titleToDisplaytitleToDisplay  = "+titleToDisplay);
	if(start_date==null)
	{
		
		start_date=(String)request.getParameter("er_stdate");
	}
	if(end_date==null)
	{
		end_date=(String)request.getParameter("er_enddate");
	}
	String opt = request.getParameter("opt");
	String Days = reportInfo.getExcludeWeekend("RUM_REPOTRS");
	
	EgDateInfo egDate = new EgDateInfo();
	Calendar cal = Calendar.getInstance();
	Date local_date = new Date(egDate.egetUTCDate());	  
	cal.setTime(local_date);
	cal.setTimeZone(egDate.getRealTimeZone());
	String temp1 = (cal.get(cal.MONTH)+1) + "/" + cal.get(cal.DAY_OF_MONTH) + "/" +cal.get(cal.YEAR);
	String mgr_time = cal.get(cal.HOUR_OF_DAY)+":"+cal.get(cal.MINUTE)+":"+cal.get(cal.SECOND);
	String dispDate = DateUtil.changeDateFormat(temp1,"MM/dd/yyyy",strUserDateFormat);
	TimeZone tzne = egDate.getRealTimeZone();
	String tzName = tzne.getDisplayName(tzne.inDaylightTime(local_date), TimeZone.SHORT);
	EgTimeZoneConverter timeZoneConverter = new EgTimeZoneConverter(dispDate+" "+mgr_time,thisuser);
	String loginUserDateTime = (String)timeZoneConverter.getDate(false);
	Date loginUserDate = (Date)timeZoneConverter.getDate(true);
	TimeZone user_tz = (TimeZone)timeZoneConverter.getTimeZone();
	String st_hr=erd.s_sthr,end_hr=erd.s_endhr;
	String st_min=erd.s_startmin,end_min=erd.s_endmin;	
	if( loginUserDateTime != null && !loginUserDateTime.trim().equals(""))
	{
		dispDate = loginUserDateTime;
		tzName = user_tz.getDisplayName(user_tz.inDaylightTime(loginUserDate), TimeZone.SHORT);
	}
	if(st_hr==null||st_hr.trim().length()==0)
	{
	st_hr="00";
	}
	if(st_min==null||st_min.trim().length()==0)
	{
	st_min="00";
	}
	if(end_hr==null||end_hr.trim().length()==0)
	{
	end_hr="00";
	}
	if(end_min==null||end_min.trim().length()==0)
	{
	end_min="00";
	}
	if(start_date!=null && end_date!=null)
	{
		dispStartDate=start_date.trim()+" "+st_hr+":"+st_min;	
		dispEndDate=end_date.trim()+" "+end_hr+":"+end_min;	
	}
	String st_dateTime ="";
	String en_dateTime="";

	EgTimeZoneConverter converterStart = new EgTimeZoneConverter(dispStartDate,thisuser);
	EgTimeZoneConverter converterEnd = new EgTimeZoneConverter(dispEndDate,thisuser);
	st_dateTime = converterStart.getDateTime();
	en_dateTime = converterEnd.getDateTime();


	String chartInfoString=request.getParameter("chartInfo");
	String chart_type=null;
	/*if(chartInfoString==null)
		chart_type="timeline";
	else*/
	if(chartInfoString!=null)
	{
		JSONObject chartInfoObj = (JSONObject) JSONSerializer.toJSON(chartInfoString);				
		chart_type=(String)chartInfoObj.get("chartType");
	}

	//..
	if(resultJson == null)
	{
		if(request.getParameter("dataDrill") != null)
		{
			String dataDrill=(String)request.getParameter("dataDrill");
			if(dataDrill.equals("yes"))
				resultJson = (JSONObject) session.getAttribute("htdataDrillDown");
		}
		else
			resultJson = (JSONObject) session.getAttribute("htdata");
	}
	//..
	
	if((dbInfo.doubleByteEnabled || !thisuser.getLanguage().equals("en_US")) && !(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes")))
	{
		fontStyleDbl = " multi_font";
		fontStyleDblSingl = "multi_font";
	}
	else
	{
		fontStyleDbl = "";
		fontStyleDblSingl = "";
	}
	if(titleToDisplay==null || titleToDisplay.equalsIgnoreCase("undefined"))
		titleToDisplay="Report Builder";
	if(titleToDisplay.indexOf(".")>-1)
	{
		titleToDisplay = titleToDisplay.substring(titleToDisplay.lastIndexOf(".")+1);
	}
	titleToDisplay = utils.specialCharDecode(titleToDisplay);
%>
<!Doctype html>
<head>
	<style>
		#only-table span.decimal-align{float: left; text-align: right; width:50%}
		#only-table span.decimal-align2{float: right; text-align: left; width:50%}
		

		.iconServerGray, .iconServerGreen, .iconServerRed,.iconUserHighIdleTime16{
			background : url('../images/Light/newReporterIcons.png') no-repeat top left;
		}
		.iconServerGray{
		background-position:0px 0px !important; width:24px; height:24px;
		}
		.iconServerGreen{
		background-position:-24px 0px !important; width:24px; height:24px;
		}
		.iconServerRed{
		background-position:-48px 0px !important; width:24px; height:24px;
		}
		.iconUserHighIdleTime16{
		background-position:0px -180px !important; width:16px; height:16px;
		}

		.heatmap_holder6{
			width:120px;
			height:100px;
			display:inline-block;
			border:0px solid red;
			font-size:1px;
			line-height:3px;
		}
		.heatmap_box_6 {
			width: 8px;
			height: 8px;
			font-size: 1px;
			margin: 0px 3px 1px 0px;
			display: inline-block;
			border-radius: 5px;
			line-height:2px;
		}
		.heatmap_box_6.healthyDiv {
			background: #69c7b3;
		}
		.heatmap_box_6.slowDiv {
			background: #f49242;
		}
		.heatmap_box_6.stalledDiv {
			background: #8399b0;
		}
		.heatmap_box_6.errorDiv {
			background: #ff0059;
		}
	</style>
	<%
	if(dataPageNo == null || (dataPageNo != null && Integer.parseInt(dataPageNo) == 1))
	{
		if(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes"))
		{
	%>
			<title>&nbsp; <egui:intnl text="reporter.common.Reporter" />&nbsp; &nbsp;-PDR- &nbsp;</title>
	<%
		}
		else
		{
	%>
			<title><%=titleToDisplay%></title>
	<%
		}
	}
	%>
	<meta http-equiv="refresh">
	<link rel="stylesheet" type="text/css" href="../../final/styles/eGLightThemeIcons.css" />
	<link rel="stylesheet" type="text/css" href="../../final/reporter/styles/printpagestyle.css" />
	<link rel="stylesheet" href="/final/reporter/styles/btmConsolidatedReport_light.css"/>
	<link rel="stylesheet" href="/final/styles/iconLibrary.css" media="all" />
</head>

<body marginwidth="20" marginheight="20" bgcolor="#FFFFFF">
	<%
	if(dataPageNo == null || (dataPageNo != null && Integer.parseInt(dataPageNo) == 1))
	{
	
		String strLogCls = "printHeaderBoxLogo";
		if(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes"))
		{
			strLogCls = "printHeaderBoxLogo";
		}
		else
			strLogCls = "printPdfHeaderBoxLogo";

		if(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes"))
		{
	%>
			<div class="<%=strLogCls%>" style="padding:10px"><img src="<%=imageName%>" border="0" /></div>
	<%
		}
		else
		{
	%>
			<div class="<%=strLogCls%>"><img src="<%=imageName%>" border="0" /></div>
	<%
		}
	%>
	
	<div class="printHeaderBox">
	<% 
	if (!StringUtils.isNull(titleToDisplay))
	{ 
		%>
		<div class="printHeaderBoxTitle"><%=titleToDisplay%></div>
		<%
	}
	else
	{ 
		%>
		<div class="printHeaderBoxTitle"><egui:intnl text="reporter.common.Report Builder" /></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='<egui:intnl text="reporter.common.PRINT"/>' title='<egui:intnl text="reporter.common.PRINT"/>'/></div>
<%
	}
%>
	</div>
	<div class="printOuterBoxNoBorder"> 
		<%
		String analysisBy=intlmap.getTextDescription("reporter.common.Analysis By");
		if(analysisBy != null && selDetails.get(analysisBy) != null)
		{
			%>
			<div class="printSelectionFields"><%=analysisBy%>: <span class="bold"><%=selDetails.get(analysisBy)%></span></div>
			<%
		}
		String componentType=intlmap.getTextDescription("reporter.common.Component Type");
		if(componentType != null && selDetails.get(componentType) != null)
		{
			%>
			<div class="printSelectionFields"><%=componentType%>: <span class="bold"><%=selDetails.get(componentType)%></span></div>
			<%
		}	
		String component=intlmap.getTextDescription("reporter.common.Component");
		if(component != null && selDetails.get(component) != null)
		{
			%>
			<div class="printSelectionFields"><%=component%>: <span class="bold"><%=selDetails.get(component)%></span></div>
			<%
		}
		String timePeriod=intlmap.getTextDescription("reporter.common.Time Period");
		if(timePeriod!= null && selDetails.get(timePeriod) != null)
		{
			%>
			<div class="printSelectionFields"><%=timePeriod%>: <span class="bold"><%=selDetails.get(timePeriod)%></span></div>
			<%
		}		
		if(er_sortingColumn != null)
		{
			String sortBy=intlmap.getTextDescription("reporter.common.Sort By");
			String secondSortCol=intlmap.getTextDescription("reporter.common.Second Sorted Column");
			%>
			<div class="printSelectionFields"><%=sortBy%>: <span class="bold"><%=er_sortingColumn%></span></div>
			<%
			if(er_secondaryColSort != null)
			{
				%>
					<div class="printSelectionFields"><%=secondSortCol%>: <span class="bold"><%=er_secondaryColSort%></span></div>
				<%
			}
		}
		String timeline=intlmap.getTextDescription("reporter.common.Timeline");
		String to=intlmap.getTextDescription("reporter.common.to");
		%>
		<div class="printSelectionFields"><%=timeline%> - <span class="bold"><%=st_dateTime%>&nbsp; <%=to%>&nbsp; <%=en_dateTime%> (<%=tzName%>)</span></div>
		<%
		if(tempDesc.length()>0)
		{
			%>
				<div class="printSelectionFields"><%=tempDesc%></div>
			<%
		}
		%>
	</div>
	
<%
}
	int cnt=0;
	JSONObject sessionChartCollecton=new JSONObject();
	boolean dataAvailable=false;
	// order the widget for pre loading 
	// start here
	JSONObject resultJson_sort = new JSONObject();
	List widgetOrderLst = new ArrayList();
	List widget_Order = new ArrayList();
	if(resultJson!=null && resultJson.size()>0)
	{
		Iterator itr1 = resultJson.entrySet().iterator();
		JSONArray widgetWiseAry = new JSONArray();
		while(itr1.hasNext())
		{
			Map.Entry entry1 = (Map.Entry)itr1.next();	
			String widget=(String)entry1.getKey();
			if(widget.equals("templateTitle") || widget.equals("selectionDetails") || widget.equals("needNoMeasure") || widget.equals("firstColWordBreakPrint") || widget.equals("er_sortingColumn"))
			{
				resultJson_sort.put(widget,entry1.getValue());
				continue;
			}
			else if(widget.startsWith("widgetInfo"))
			{
				widgetOrderLst.add(widget);
			}
		}
		for(int v=0;v<=widgetOrderLst.size();v++)
		{
			widget_Order.add("widgetInfo"+v+"_detail");
		}
	}
	for(int i = 0; i<widget_Order.size();i++)
	{
		String keey = (String)widget_Order.get(i);
		resultJson_sort.put(keey,resultJson.get(keey));
	}
	resultJson = resultJson_sort;
	// order the widget for pre loading 
	// end here
	if(resultJson!=null && resultJson.size()>0)
	{
		Iterator itr1 = resultJson.entrySet().iterator();
		JSONArray widgetWiseAry = new JSONArray();
		while(itr1.hasNext())
		{
			Map.Entry entry1 = (Map.Entry)itr1.next();	
			String widget=(String)entry1.getKey();
			if(widget.equals("templateTitle") || widget.equals("selectionDetails") || widget.equals("needNoMeasure") || widget.equals("firstColWordBreakPrint") || widget.equals("er_sortingColumn"))
			{
				continue;
			}
			if(printBy!=null && printBy.length()>0 && !widget.equalsIgnoreCase(widgetIdInfo))
			{
				//System.out.println("===widget====11==?>>>>>"+widget+"==widgetIdInfo=11=====?hhhh/==>>>"+widgetIdInfo);
				continue;
			}
		
			JSONObject widgetCollection=(JSONObject) resultJson.get(widget);
			Iterator itr2 = widgetCollection.entrySet().iterator();
			JSONObject widgetWiseObj = new JSONObject();
			JSONObject chartCollecton=new JSONObject();
			String widgetHeader="";
			String widgetFooter="";
			String headerDescription="";
			String widgetPosition="";
			String widgetSize="";
			int widgetHeight=0;
			int widgetWidth=0;
			while(itr2.hasNext())
			{
				Map.Entry entry2= (Map.Entry)itr2.next();	
				String chartType=(String)entry2.getKey();
			
				if(chartType.equalsIgnoreCase("widgetHeader"))
				{
					widgetHeader=(String)widgetCollection.get(chartType);
					widgetWiseObj.put("widgetHeader",widgetHeader);
					continue;
				}
				if(chartType.equalsIgnoreCase("widgetFooter"))
				{
					widgetFooter=(String)widgetCollection.get(chartType);
					widgetWiseObj.put("widgetFooter",widgetFooter);
					continue;
				}
				if(chartType.equalsIgnoreCase("headerDescription"))
				{
					headerDescription=(String)widgetCollection.get(chartType);
					widgetWiseObj.put("headerDescription",headerDescription);
					continue;
				}
				if(chartType.equalsIgnoreCase("widgetPosition"))
				{
					widgetPosition=(String)widgetCollection.get(chartType);
					widgetWiseObj.put("widgetPosition",widgetPosition);
					continue;
				}
				if(chartType.equalsIgnoreCase("widgetSize"))
				{
					widgetSize=(String)widgetCollection.get(chartType);
					widgetWiseObj.put("widgetSize",widgetSize);
					continue;
				}
				if(chartType.equalsIgnoreCase("widgetWidth"))
				{
					widgetWidth=(Integer)widgetCollection.get(chartType);
					widgetWiseObj.put("widgetWidth",widgetWidth);
					continue;
				}
				if(chartType.equalsIgnoreCase("widgetHeight"))
				{
					widgetHeight=(Integer)widgetCollection.get(chartType);
					widgetWiseObj.put("widgetHeight",widgetHeight);
					continue;
				}
				if(chartType.equalsIgnoreCase("adjustWidgetHeight"))
				{
					System.out.println("==chartheightius=>>>>>>>>"+widgetCollection.get(chartType));
					if(widgetCollection.get(chartType) != null)
						widgetWiseObj.put("adjustWidgetHeight",widgetCollection.get(chartType));
					continue;
				}
				if(chartType.equalsIgnoreCase("DigitalChartCount"))
				{
					if(widgetCollection.get(chartType) != null)
						widgetWiseObj.put("DigitalChartCount",widgetCollection.get(chartType));
					continue;
				}
				if(chartType.equalsIgnoreCase("lineCls"))
				{
					if(widgetCollection.get(chartType) != null)
						widgetWiseObj.put("lineCls",widgetCollection.get(chartType));
					continue;
				}
				if(widgetHeader!=null && widgetHeader.length()==0)
					widgetHeader=(String)widgetCollection.get("widgetHeader");
				
				if(widgetFooter!=null&& widgetFooter.length()==0)
					widgetFooter=(String)widgetCollection.get("widgetFooter");

				if(headerDescription!=null&& headerDescription.length()==0)
					headerDescription=(String)widgetCollection.get("headerDescription");

				JSONArray dataArray=(JSONArray) widgetCollection.get(chartType);
	
				if(dataArray!=null && dataArray.size()>0 && chartType!=null )
				{
					boolean noMeasure=false;
					String colKey="barChartCollection";
					if(chartType.equalsIgnoreCase("stackedbar"))
					{
						colKey="stackedBarChartCollection";
					}
					if(chartType.equalsIgnoreCase("verticalstackedbar")  || chartType.equalsIgnoreCase("combinedChart"))
					{
						colKey="stackedBarChartCollection";
						chartType="verticalstackedbar";
					}
					if(chartType.equalsIgnoreCase("distribution"))
					{
						colKey="distributionChartCollection";
					}
					if(chartType.equalsIgnoreCase("timeline"))
					{
						colKey="timelineChartCollection";
					}
					if(chartType.equalsIgnoreCase("area"))
					{
						colKey="timelineChartCollection";
					}
					if(chartType.equalsIgnoreCase("barHistogram"))
					{
						colKey="barHistogramChartCollection";
					}
					if(chartType.equalsIgnoreCase("distributedPie"))
					{
						colKey="distributedPieChartCollection";
					}
					if(chartType.equalsIgnoreCase("table"))
					{
						colKey="gridCollection";
					}
					if(chartType.equalsIgnoreCase("topn"))
					{
						colKey="topnCollection";
					}
					if(chartType.equalsIgnoreCase("digital")||chartType.equalsIgnoreCase("multiDigi"))
					{
						colKey="digitalCollection";
					}
					if(chartType.equalsIgnoreCase("heatMap"))
					{
						colKey="heatMapChartCollection";
					}
					if(chartType.equalsIgnoreCase("tableWithMergingColumns"))
					{
						colKey="gridCollectionSPO";
					}
					if(printBy!=null && printBy.length()>0 )
					{
						for(int i=0;i<dataArray.size();i++)
						{
							JSONObject dataObj=(JSONObject) dataArray.get(i);
							JSONArray gridCollection=(JSONArray)dataObj.get(colKey);
							//for(int j=0;j<gridCollection.size();j++)
							//{
							
								if(gridCollection.size() > 0)
								{
									JSONObject gridObj=(JSONObject) gridCollection.get(Integer.parseInt(graphIndex));
									sessionChartCollecton.put(chartType+"_0",gridObj);
									chartCollecton.put(chartType+"_0",gridObj);
								}
								else
								{
									if(needNoMeasure.equals("no"))
										continue;
									//System.out.println("==gridCollection===>>"+gridCollection);
									noMeasure=true;
									String nMeas=" No Measure...... ";
									chartCollecton.put(chartType+"_0",nMeas);
								}
								//chartCollecton.put(chartType+"_"+cnt,gridObj);
								//cnt++;
							//}
						}
					}
					else
					{
						
						for(int i=0;i<dataArray.size();i++)
						{
							JSONObject dataObj=(JSONObject) dataArray.get(i);
							if(!dataObj.containsKey(colKey) && chartType.equalsIgnoreCase("verticalstackedbar"))
							{
								colKey="combinedChartCollection";
								chartType="combinedChart";
							}
							JSONArray gridCollection=(JSONArray)dataObj.get(colKey);
							if(gridCollection != null)
							{
								for(int j=0;j<gridCollection.size();j++)
								{
									JSONObject gridObj=(JSONObject) gridCollection.get(j);
									sessionChartCollecton.put(chartType+"_"+cnt,gridObj);
									chartCollecton.put(chartType+"_"+cnt,gridObj);
									cnt++;
								}
							}
						}
					}
					widgetWiseObj.put("chartCollecton",chartCollecton);
					//if(!noMeasure)
						dataAvailable=true;
				}
				else
				{//...added for no measure widget
					if(needNoMeasure.equals("no"))
						continue;
					String nMeas=" No Measure...... ";
					chartCollecton.put(chartType+"_0",nMeas);
					widgetWiseObj.put("chartCollecton",chartCollecton);
				//..
				}
			}
			widgetWiseAry.add(widgetWiseObj);
		}
		//System.out.println("widgetWiseAry==== "+widgetWiseAry);
		session.setAttribute("chartCollecton",sessionChartCollecton);
		%>

	<div class="clearDiv"></div>
		<table width="100%" style="page-break-inside: auto !important">
		
	<%// starting graph table tag
	double widgetWidthPer=0;
	double width=0;
	int maxCol=1;
	int row=0;
	String strPreRow = "1";
	int colcount = 1;
	int colSpan1 = 12;
	int resetColspan=12;
	String strrowfirst="1";
	HashMap hcolspanMap = new HashMap();
	HashMap hrowspanMap = new HashMap();
	HashMap hfristspanMap = new HashMap();
	LinkedHashMap rowGroup = new LinkedHashMap();
	LinkedHashMap rowCountGroup = new LinkedHashMap();
	System.out.println("widgetWiseAry _____________ "+widgetWiseAry);
	int rowOrder = 1;
	int rowCount = 0;
	int totalRowCount = 0;
	ArrayList aListWidget = new ArrayList();
	HashSet<Integer> widegetHiegt = new HashSet<Integer>();
	Integer maxVal = null;

	for(int k=0;k<widgetWiseAry.size();k++)
	{
		JSONObject widgetWiseObj=(JSONObject)widgetWiseAry.get(k);
		JSONObject chartCollecton =(JSONObject) widgetWiseObj.get("chartCollecton");
		if(chartCollecton==null)
			continue;
		String widgetSize=(String)widgetWiseObj.get("widgetSize");
		String widgetPosition=(String)widgetWiseObj.get("widgetPosition");
		ArrayList stToken=ErUtils.egTokenizer(widgetSize,",");
		ArrayList posToken=ErUtils.egTokenizer(widgetPosition,",");
		String strDataRow = (String) stToken.get(0); // X axis (Width)
		String strCol = (String) stToken.get(1); // Y Axis (Height)
		String rowPos = (String) posToken.get(0); // X axis (Width)
		String colPos = (String) posToken.get(1); // Y Axis (Height)
		int rowPosInt = Integer.parseInt(rowPos);
		int colPsInt = Integer.parseInt(colPos);
		int rowTempReorder = 0;
		int columnTempReorder = 0;
		try {
			rowTempReorder = Integer.parseInt(strDataRow);
		} catch (Exception e) {
		}
		try {
			columnTempReorder = Integer.parseInt(strCol);
		} catch (Exception e) {
		}
		totalRowCount = totalRowCount + rowTempReorder;
		int endPos = rowPosInt + columnTempReorder;
		if (totalRowCount > 12 && widegetHiegt.size() == 1) 
		{
			rowGroup.put(rowOrder, aListWidget);
			if(rowCount==0)
			{
				rowCount = 1;
			}
			rowCountGroup.put(rowOrder, rowCount);
			aListWidget = new ArrayList();
			widegetHiegt = new HashSet();
			totalRowCount = rowTempReorder;
			rowCount = 0;
			rowOrder++;
		} 
		else if (totalRowCount > 12 && widegetHiegt.size() > 1) 
		{
			maxVal = Collections.max(widegetHiegt);
			widegetHiegt = new HashSet();
			totalRowCount = rowTempReorder;
			widegetHiegt.add(maxVal);
			if (k + 1 < widgetWiseAry.size()) 
			{
				JSONObject nextWidgetWiseObj=(JSONObject)widgetWiseAry.get(k+1);
				String nextWidgetPosition = (String) nextWidgetWiseObj.get("widgetPosition");
				if (nextWidgetPosition != null && nextWidgetPosition.indexOf(",01") > -1) 
				{
					totalRowCount = 12;
				}
			} else {
				// this is last widget of template
			}
		} 
		if (totalRowCount < 12) 
		{
			if (k + 1 < widgetWiseAry.size())
			{
				JSONObject nextWidgetWiseObj=(JSONObject)widgetWiseAry.get(k+1);
				String nextWidgetPosition = (String) nextWidgetWiseObj.get("widgetPosition");
				if (nextWidgetPosition != null && nextWidgetPosition.indexOf(",01") > -1) 
				{
					totalRowCount = 12;
				}
			} else {
				// this is last widget of template
			}
		}
		//System.out.println("colPsInt+rowTempReorder  "+(colPsInt+rowTempReorder));
		if(colPsInt+rowTempReorder>12)
		{
			rowCount++;
		}
		//aListWidget.add(new JSONObject());
		aListWidget.add(widgetWiseObj);
		widegetHiegt.add(new Integer(endPos));
	}
	if(aListWidget!=null && aListWidget.size()>0)
	{
		rowGroup.put(rowOrder, aListWidget);
		if(rowCount==0)
		{
			rowCount = 1;
		}
		rowCountGroup.put(rowOrder, rowCount);
	}
	Iterator grpItr = rowGroup.keySet().iterator();
	HashMap tempRowMap = new HashMap();
	while(grpItr.hasNext())
	{
		Integer strRowNumber = (Integer)grpItr.next();
		aListWidget = (ArrayList)rowGroup.get(strRowNumber);
		int rowspan=1;
		int colspan=1;
		if(aListWidget!=null && aListWidget.size()>0)
		{
			int widgetCount=aListWidget.size();
			int rowcount=0;
			int colCount=0;
			int totalCol=0;
			int maxRowHeight=0;
			int maxColumnHeight=0;
			List<Integer> aListDataForColumn = new LinkedList<Integer>();
			for(int kk=0;kk<widgetCount;kk++)
			{
				JSONObject widgetWiseObj=(JSONObject)aListWidget.get(kk);
				String widgetSize=(String)widgetWiseObj.get("widgetSize");
				ArrayList stToken=ErUtils.egTokenizer(widgetSize,",");
				String strDataRow = (String) stToken.get(0); // X axis (Width)
				String strCol = (String) stToken.get(1); // Y Axis (Height)
				int rowTempReorder = 0;
				int columnTempReorder = 0;
				try {
					rowTempReorder = Integer.parseInt(strDataRow);
				} catch (Exception e) {
				}
				try {
					columnTempReorder = Integer.parseInt(strCol);
				} catch (Exception e) {
				}
				if(maxRowHeight<columnTempReorder)
					maxRowHeight = columnTempReorder;
				if(maxColumnHeight<rowTempReorder)
					maxColumnHeight = rowTempReorder;
				colCount++;
				totalCol = totalCol+rowTempReorder;
				if(totalCol==12)
				{
					totalCol=maxColumnHeight;
					aListDataForColumn.add(new Integer(colCount));
					colCount=0;
					rowcount++;
				}
			}
			Integer maxVal_temp = new Integer(1);
			if(aListDataForColumn!=null && aListDataForColumn.size()>0)
				maxVal_temp = Collections.max(aListDataForColumn);
			tempRowMap.put(strRowNumber,maxVal_temp.intValue()+"#"+maxRowHeight+"#"+rowcount);
		}
	}

	Iterator grpItr2 = rowGroup.keySet().iterator();
	while(grpItr2.hasNext())
	{
		Integer strRowNumber = (Integer)grpItr2.next();
		aListWidget = (ArrayList)rowGroup.get(strRowNumber);
		String strTempRowCol = (String)tempRowMap.get(strRowNumber);
		int colcountT=1;
		int rowcountT=1;
		int rowSpancountT=1;
		StringTokenizer stTokenTemp1 = new StringTokenizer(strTempRowCol,"#");
		try {
			colcountT = Integer.parseInt(stTokenTemp1.nextToken());
			rowcountT = Integer.parseInt(stTokenTemp1.nextToken());
			rowSpancountT = Integer.parseInt(stTokenTemp1.nextToken());
		}catch(Exception e){}

%>
		<div style="width:1000px">
		<table align="center" style="vertical-align:top;table-layout: fixed" width="100%" cellspacing="10" cellpadding="0" border="0">
<%
		int maxHeightVal = 0;
		boolean closeRow = false;
		int totalWidgentCount = aListWidget.size();
		boolean rowspanRequired = false;
		if(rowSpancountT>0 &&(totalWidgentCount%rowSpancountT)>0)
			rowspanRequired = true;
		for(int u=0;u<totalWidgentCount;u++)
		{
			JSONObject widgetWiseObj=(JSONObject)aListWidget.get(u);
			JSONObject chartCollecton =(JSONObject) widgetWiseObj.get("chartCollecton");
			if(chartCollecton==null)
				continue;
			String widgetSize=(String)widgetWiseObj.get("widgetSize");
			//String widgetPosition=(String)widgetWiseObj.get("widgetPosition");
			ArrayList stToken=ErUtils.egTokenizer(widgetSize,",");
			//ArrayList posToken=ErUtils.egTokenizer(widgetPosition,",");
			String strDataRow = (String) stToken.get(0); // X axis (Width)
			String strCol = (String) stToken.get(1); // Y Axis (Height)

			int rowTempReorder = 0;
			int columnTempReorder = 0;
			try {
				rowTempReorder = Integer.parseInt(strDataRow);
			} catch (Exception e) {
			}
			try {
				columnTempReorder = Integer.parseInt(strCol);
			} catch (Exception e) {
			}
			if(maxHeightVal < columnTempReorder)
			{
				maxHeightVal = columnTempReorder;
			}
			int intColWidth = (rowTempReorder*100)/12;
			//System.out.println("colPsInt+rowTempReorder  "+(colPsInt+rowTempReorder));
			if(u==0 || ((u)%colcountT)==0)
			{
				if(u>0){
%>
					</tr>
<%
				}
%>
				<tr>
<%
			}
			String strRowSpan1_t="1";
			if((columnTempReorder ==rowcountT )&& rowspanRequired){
				strRowSpan1_t=rowSpancountT+"";
			}
%>
				<td  style="width:<%=intColWidth%>%;vertical-align:top;border:1px solid #F3F3F3;" colspan="<%=strDataRow%>" rowspan="<%=strRowSpan1_t%>">

<%
	//}

	
	int strfirstcol=1;
	//for(int k=0;k<widgetWiseAry.size();k++)
	//{
		
		//JSONObject widgetWiseObj=(JSONObject)widgetWiseAry.get(k);
		//JSONObject chartCollecton =(JSONObject) widgetWiseObj.get("chartCollecton");
		//if(chartCollecton==null)
		//		continue;
		String widgetFooter=(String)widgetWiseObj.get("widgetFooter"); 
		String widgetHeader=(String)widgetWiseObj.get("widgetHeader"); 
		String headerDescription=(String)widgetWiseObj.get("headerDescription");
		String widgetPosition=(String)widgetWiseObj.get("widgetPosition");
		String adjustWidgetHeight=(String)widgetWiseObj.get("adjustWidgetHeight");
		int widgetWidth=(Integer)widgetWiseObj.get("widgetWidth");
		int widgetHeight=(Integer)widgetWiseObj.get("widgetHeight");
		String lineCls=null;
		if(widgetWiseObj.get("lineCls") != null)
			lineCls=(String)widgetWiseObj.get("lineCls");		
		int digiChartCount=5;
		if(widgetWiseObj.containsKey("DigitalChartCount"))
			digiChartCount=(Integer)widgetWiseObj.get("DigitalChartCount");
		//StringTokenizer stToken = new StringTokenizer(widgetPosition,",");
		//ArrayList stToken=ErUtils.egTokenizer(widgetPosition,",");
		//String strDataRow =(String)stToken.nextToken();
		//String strDataRow =(String)stToken.get(0);
		//int dataRow = Integer.parseInt(strDataRow);
		width = (widgetWidth/1000.0)*100;
		int imgwidgetWidth = widgetWidth-50;
		String rowspan = "1";

		//String strColspan = (String)hcolspanMap.get(k+"");
		
		String queryString="";
		queryString="/final/servlet/com.eg.ErReportBuilderController;jsessionid="+session.getId()+"?forChartImage=yes&showLegendsEnable="+request.getParameter("showLegendsEnable");
		Iterator itr2 = chartCollecton.entrySet().iterator();
		Iterator itrTemp = chartCollecton.entrySet().iterator();
		int noOfCharts=chartCollecton.size();		
		//System.out.println("===noOfCharts====>>>>..>>>"+noOfCharts);
		int num=0;

		String alignStyle="";		
		String customBorder="border-bottom:1px solid #dedede;";		
		if(lineCls != null)
		{
//			if(k%2==0)
//			{
//				alignStyle="padding:10px 10px 10px 0px;";
//			}
//			else
			{
				alignStyle="padding:10px 10px 10px 10px;";
			}
			if(lineCls.equalsIgnoreCase("graphSeperatorLineRight"))
			{
				alignStyle+="border-right:1px solid #dedede;";
			}
			else if(lineCls.equalsIgnoreCase("graphSeperatorLineBottom"))
			{
				alignStyle+="border-bottom:1px solid #dedede;";
			}
			else if(lineCls.equalsIgnoreCase("graphSeperatorLineBottomRight"))
			{
				alignStyle+="border-right:1px solid #dedede;border-bottom:1px solid #dedede;";
			}												
		}
			String borderInfo = "";
			if(widgetHeader!=null && widgetHeader.equalsIgnoreCase("Widget Header"))
			{
				//borderInfo = "border:0px !important";
			}
			if(lineCls==null)				
				%><div class="print OuterBox"><%
			else
				%><div class=""><%
					String headerStyle="";
					boolean digitalAlignChange=false;
					while(itrTemp.hasNext())
					{
						Map.Entry entry2= (Map.Entry)itrTemp.next();	
						String chartKey=(String)entry2.getKey();
						if(chartKey.contains("digital")||chartKey.contains("multiDigi"))
						{
							if(chartCollecton.get(chartKey) != null && chartCollecton.get(chartKey) instanceof JSONObject)
							{
								JSONObject digitalObj=(JSONObject) chartCollecton.get(chartKey);
								if(digitalObj.get("needHeatMap") != null)
									digitalAlignChange=true;
							}
						}
						if(chartKey.contains("digital"))
						{
							headerStyle = "display:none";
						}
					}
			if(dataPageNo == null || (dataPageNo != null && Integer.parseInt(dataPageNo) == 1))
			{
				if(widgetHeader!=null &&  !widgetHeader.equalsIgnoreCase("Widget Header") && widgetHeader.length()>0 && !widgetHeader.equalsIgnoreCase("-1") && !widgetHeader.equalsIgnoreCase(""))
				{
					if(selDetails.get("er_headerCombo") != null)
					{
						widgetHeader+=" "+(String)selDetails.get("er_headerCombo");
					}
					if(selDetails.get("er_searchGroupBy") != null)
					{
						String er_searchGroupBy=(String)selDetails.get("er_searchGroupBy");
						if(er_searchGroupBy != null && !er_searchGroupBy.equalsIgnoreCase("none"))
						{
							String clientVersionn=(String)selDetails.get("clientVersionn"); //..common for all searching value.
							widgetHeader+=" that "+er_searchGroupBy+" \""+clientVersionn+"\"";
						}
					}
					if(selDetails.get("er_searchGroupBy2") != null)
					{
						String er_searchGroupBy2=(String)selDetails.get("er_searchGroupBy2");
						if(er_searchGroupBy2 != null && !er_searchGroupBy2.equalsIgnoreCase("none"))
						{
							String wildcardSearch2=(String)selDetails.get("wildcardSearch2"); //..common for all searching value.
							widgetHeader+=" and Username that "+er_searchGroupBy2+" \""+wildcardSearch2+"\"";
						}
					}
%>
						<div style="padding:10px 0px 10px 10px" class="printOuterBoxHeader"><%=widgetHeader%></div>

<%				
				}
			}
				String strImgWidth="400";
				String strGraphHeight=(widgetHeight-((widgetHeight*50)/100))+"";
				boolean isDigitalChart = false;
				if(noOfCharts==1)
					strImgWidth=widgetWidth+"";

				// vengat
				//strImgWidth=width+"";
		
				if(noOfCharts!=0)
				{
					int chartIndex=0;
					if(digitalAlignChange)
					{
						JSONObject digitalObj=(JSONObject)chartCollecton.get("multiDigi_0");
						String value = (String)digitalObj.get("value");
						String DisplayName =(String)digitalObj.get("DisplayName");
						String unit = (String)digitalObj.get("unit");
						unit=unit==null?"":unit;
						String imageCls = (String)digitalObj.get("imageCls");
						String eachTdTilte=null;
						if(digitalObj.get("title") != null)
							eachTdTilte = (String)digitalObj.get("title");
						if(noOfCharts>1)
						{
							widgetHeight=90;
						}						
						widgetHeight=widgetHeight-40;		
						String alignStyle1="border-right:1px solid #dedede;";
						%>
						<div style="width:100%;overflow:auto;padding:10px"><table align="center" width="100%" height="<%=widgetHeight%>px" cellspacing="0" cellpadding="0" style="border:0px solid #c3c3c3;padding:0px">
						<tr>
						<td width="20%" style="vertical-align:top;<%=alignStyle1%>">
							<table align="center" width="100%" height="<%=widgetHeight%>px" cellspacing="0" cellpadding="0" style="border:0px solid #c3c3c3;padding:0px">
							<tr><td style="text-decoration: underline;font-size:14px;font-weight:500;padding-bottom:10px"><%=eachTdTilte%></td></tr>
							<tr>
								<%=getDigitalData(imageCls,value,DisplayName,unit,0)%>
							</tr>
							<%
							digitalObj=(JSONObject)chartCollecton.get("multiDigi_4");
							value = (String)digitalObj.get("value");
							DisplayName =(String)digitalObj.get("DisplayName");
							unit = (String)digitalObj.get("unit");
							unit=unit==null?"":unit;
							imageCls = (String)digitalObj.get("imageCls");
							%>
							<tr>
								<%=getDigitalData(imageCls,value,DisplayName,unit,1)%>
							</tr>
							</table>
						</td>
						<td width="30%" style="vertical-align:middle;<%=alignStyle1%>">
						<%
						digitalObj=(JSONObject)chartCollecton.get("multiDigi_1");
						String healthyCount=(String)digitalObj.get("healthyCount");
						String slowCount=(String)digitalObj.get("slowCount");
						String errorCount=(String)digitalObj.get("errorCount");
						String stalledCount=(String)digitalObj.get("stalledCount");
						double healthyPer=Double.parseDouble(digitalObj.get("healthyPer").toString());
						double slowPer=Double.parseDouble(digitalObj.get("slowCountPer").toString());
						double errorPer=Double.parseDouble(digitalObj.get("errorCountPer").toString());
						double stalledPer=Double.parseDouble(digitalObj.get("stalledPer").toString());	
						healthyPer = Math.round(healthyPer);
						slowPer = Math.round(slowPer);
						errorPer = Math.round(errorPer);
						stalledPer = Math.round(stalledPer);								
						double total = healthyPer+stalledPer+slowPer+errorPer;								
						double maxaVal = Math.max(healthyPer,Math.max(stalledPer,Math.max(slowPer,errorPer)));
						double tolerance = 0;
						if(total!=100)
						{
							tolerance = 100-total;
						}
						if(healthyPer==maxaVal)
						{
							healthyPer=healthyPer+tolerance;
						}
						else if(stalledPer==maxaVal)
						{
							stalledPer=stalledPer+tolerance;
						}
						else if(slowPer==maxaVal)
						{
							slowPer=slowPer+tolerance;
						}
						else if (errorPer==maxaVal)
						{
							errorPer=errorPer+tolerance;
						}								
						%>
						<table align="center"  cellspacing="0" cellpadding="0" border="0" style="align:center;margin:auto auto;" >
						<tbody>
						<tr>
						<td>
						<%
						if (pdfPrint != null && pdfPrint.equalsIgnoreCase("yes")) 
						{
	%>
							<div class="heatmap_holder6">
	<%
							for(int i=0; i<healthyPer; i++)
							{
	%>
							<div class="heatmap_box_6 healthyDiv"></div>
	<%
							}
							for(int i=0; i<slowPer; i++)
							{
	%>
							<div class="heatmap_box_6 slowDiv"></div>
	<%
							}
							for(int i=0; i<stalledPer; i++)
							{
	%>
							<div class="heatmap_box_6 stalledDiv"></div>
	<%
							}
							for(int i=0; i<errorPer; i++)
							{
	%>
							<div class="heatmap_box_6 errorDiv"></div>
	<%
							}
	%>
						</div>
	<%
						}
						else
						{
						%>
						<div class="heatmap_holder6" valign="middle" style="border:0px solid blue;padding-left:10px" >
							<svg xmlns="http://www.w3.org/2000/svg" width="100" height="110"><g>
						<%
							int x=0;
							int y=13;
							int incx=0;
							int incy=0;
							for(int i=0; i<100; i++)
							{
								String strColor = "";
								if(i<healthyPer)
								{
									strColor="#69c7b3";
								}
								else if(i<slowPer+healthyPer)
								{
									strColor="#f49242";
								}
								else if(i<stalledPer+healthyPer+slowPer)
								{
									strColor="#8399b0";
								}
								else
								{
									strColor="#ff0059";//..error
								}
								if(i==0)
								{
									x=0;
									y=13;
									incx=0;
									incy=0;
								}
								else if(i%10 ==0)
								{
									incx=0;
									incy=0;
									y+=10;
									x=0;
								}
								else
								{											
									incx+=10;
									incy=0;
								}
						%>
						<circle cx="<%=x+incx+5%>" cy="<%=y+incy%>" r="4.1" fill="<%=strColor%>" stoke-width="0" ></circle>
						<%
							}%>
							</g>
							</svg>
						</div>
						<%
					}
						String tableMargin="margin:0px 10px 10px 10px;";
						String cellSpacing="10";
						if (pdfPrint != null && pdfPrint.equalsIgnoreCase("yes"))
							cellSpacing="0";
						%>
						</td>
						<td>					
							<table cellpadding="0" cellspacing="<%=cellSpacing%>" border="0" style="<%=tableMargin%>" >
								<tbody>
								<tr>	
									<td style="padding-left:3px"><svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><g>
										<circle cx="5" cy="5" r="4" fill="#69c7b3" stoke-width="0" ></circle>
										</g></svg>
									</td>
									<td style="padding-left:3px;font-size:13px;">
										Healthy
									</td>
									<td style="padding-left:3px;font-size:13px;" class="font_normal13">
										<%=digitalObj.get("healthyPer")%>%
									</td>
								</tr>
								<tr>
									<td style="padding-left:3px"><svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><g>
										<circle cx="5" cy="5" r="4" fill="#f49242" stoke-width="0" ></circle>
										</g></svg>
									</td>
									<td style="padding-left:3px;font-size:13px;">
										Slow
									</td>
									<td style="padding-left:3px;font-size:13px;" class="font_normal13">
										<%=digitalObj.get("slowCountPer")%>%
									</td>
								</tr>									
								<tr>
									<td style="padding-left:3px"><svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><g>
										<circle cx="5" cy="5" r="4" fill="#8399b0" stoke-width="0" ></circle>
										</g></svg>
									</td>
									<td style="padding-left:3px;font-size:13px;">
										Stalled
									</td>
									<td style="padding-left:3px;font-size:13px;" class="font_normal13">
										<%=digitalObj.get("stalledPer")%>%
									</td>
								</tr>
								<tr>
									<td style="padding-left:3px"><svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><g>
										<circle cx="5" cy="5" r="4" fill="#ff0059" stoke-width="0" ></circle>
										</g></svg>
									</td>
									<td style="padding-left:3px;font-size:13px;">
										Error
									</td>
									<td style="padding-left:3px;font-size:13px;" class="font_normal13">
										<%=digitalObj.get("errorCountPer")%>%
									</td>
								</tr>
								</tbody>
							</table>							
						</td>
						</tr>
						</tbody>
						</table>					
						</td>
						<td width="25%" style="vertical-align:top;<%=alignStyle1%>">
							<table align="center" width="100%" height="<%=widgetHeight%>px" cellspacing="0" cellpadding="0" style="border:0px solid #c3c3c3;padding:0px">
							<%
								digitalObj=(JSONObject)chartCollecton.get("multiDigi_3");
								value = (String)digitalObj.get("value");
								DisplayName =(String)digitalObj.get("DisplayName");
								unit = (String)digitalObj.get("unit");
								unit=unit==null?"":unit;
								imageCls = (String)digitalObj.get("imageCls");
								if(digitalObj.get("title") != null)
									eachTdTilte = (String)digitalObj.get("title");

							%>
							<tr><td style="text-decoration: underline;font-size:14px;font-weight:500;padding-left:5px;padding-bottom:10px"><%=eachTdTilte%></td></tr>
							<tr>								
								<%=getDigitalData(imageCls,value,DisplayName,unit,2)%>
							</tr>
							<%
							digitalObj=(JSONObject)chartCollecton.get("multiDigi_6");
							value = (String)digitalObj.get("value");
							DisplayName =(String)digitalObj.get("DisplayName");
							unit = (String)digitalObj.get("unit");
							unit=unit==null?"":unit;
							imageCls = (String)digitalObj.get("imageCls");
							%>
							<tr>
								<%=getDigitalData(imageCls,value,DisplayName,unit,3)%>
							</tr>
							</table>
						</td>
						<td width="25%">
							<table align="center" width="100%" height="<%=widgetHeight%>px" cellspacing="0" cellpadding="0" style="border:0px solid #c3c3c3;padding:0px">
							<%
								digitalObj=(JSONObject)chartCollecton.get("multiDigi_2");
								value = (String)digitalObj.get("value");
								DisplayName =(String)digitalObj.get("DisplayName");
								unit = (String)digitalObj.get("unit");
								unit=unit==null?"":unit;
								imageCls = (String)digitalObj.get("imageCls");
								if(digitalObj.get("title") != null)
									eachTdTilte = (String)digitalObj.get("title");

							%>
							<tr><td style="text-decoration: underline;font-size:14px;font-weight:500;padding-left:5px;padding-bottom:10px"><%=eachTdTilte%></td></tr>
							<tr>								
								<%=getDigitalData(imageCls,value,DisplayName,unit,4)%>
							</tr>
							<%
							digitalObj=(JSONObject)chartCollecton.get("multiDigi_5");
							value = (String)digitalObj.get("value");
							DisplayName =(String)digitalObj.get("DisplayName");
							unit = (String)digitalObj.get("unit");
							unit=unit==null?"":unit;
							imageCls = (String)digitalObj.get("imageCls");
							%>
							<tr>
								<%=getDigitalData(imageCls,value,DisplayName,unit,5)%>
							</tr>
							</table>
						</td>
						</tr>
						</table>
						</div>
						
						<%												
						
						
					}
					while(itr2.hasNext())
					{
						String sentQuery="";
						Map.Entry entry2= (Map.Entry)itr2.next();	
						String chartKey=(String)entry2.getKey();
						String 	digitStyle="border-right:1px solid #d9d9d9";
						if(!itr2.hasNext())
							digitStyle="";
						//System.out.println("chartKey::::::::::::::::::   "+chartKey);
						if(chartKey.contains("digital")||chartKey.contains("multiDigi"))
						{
							isDigitalChart=true;
							JSONObject digitalObj=(JSONObject) chartCollecton.get(chartKey);
							String value = (String)digitalObj.get("value");
							String DisplayName =(String)digitalObj.get("DisplayName");
							String unit = (String)digitalObj.get("unit");
							unit=unit==null?"":unit;
							String imageCls = (String)digitalObj.get("imageCls");
							
							if(digitalAlignChange)
							{
								
							}
							else if(chartCollecton.get(chartKey) != null && chartCollecton.get(chartKey) instanceof JSONObject)
							{	
							//digital chart changed design
							if(chartIndex==0)
							{
								if(noOfCharts>1)
								{
									widgetHeight=90;
								}
								if(chartKey.contains("digital"))
								{
									widgetHeight=widgetHeight-40;
								}
%>
								<div style="width:100%;overflow:auto;padding:10px"><table align="center" width="100%" height="auto" cellspacing="0" cellpadding="0" style="border:0px solid #c3c3c3;padding:0px">
<%
							}
							if(chartIndex==0||chartIndex%digiChartCount==0)
							{
%>
								<tr>
<%
							}
							%>
								<td style="<%=digitStyle%>">
									<table align="center"  cellspacing="0" cellpadding="0" border="0" style="align:center;margin:auto auto;" >
										<tbody>
											<tr>
												<td style="text-align:center;" colspan="1" rowspan="1">
													<table align="center" style="padding:5px 5px 8px 5px">
														<tbody>
															<tr>
																<%
																if(imageCls!=null)
																{
																%>
																<td align="right" style="padding-right:5px"><div class="<%=imageCls%>"></div></td>
																<%
																}
																%>
																<td style="text-align:left;padding-left:5px;" class="newFont_bold33"><%=value%><span class="newFont_normal13"> <%=unit%></span></td>
															</tr>
														</tbody>
													</table>
												</td>
											</tr>
											<%
											if(digitalObj.get("sparkline") != null && digitalObj.get("sparkline").toString().equalsIgnoreCase("yes"))
											{
											%>
												<tr><td style="text-align:center;" colspan="1" rowspan="1">
													<div style="width:100%;overflow:auto;padding:10px">
													<%
													String sparklineQuery=	queryString+"&chartKey="+chartKey+"&adjustWidgetHeight="+adjustWidgetHeight;
													%>
													<img src="<%=sparklineQuery%>&optt=graph&er_width=<%=imgwidgetWidth%>&er_height=<%=strGraphHeight%>&er_view=IMAGE" border="0" hspace="0"  vspace="0" ></img>
													</div></td>
												</tr>
											<%
											}
											%>
											<tr>
												<td style="text-align:center;" colspan="1" rowspan="1" >
													<span class="font_normal13" style="font-size:13px"><%=DisplayName%><br></span>
												</td>
											</tr>
										</tbody>
									</table>
								</td>							
	<%
								if(chartIndex+1%digiChartCount==0 || noOfCharts-1==chartIndex)
								{
	%>
									</tr>
	<%
								}
								if(!itr2.hasNext())
								{
	%>
									</table></div>
	<%
								}
							chartIndex=chartIndex+1;
							}
							else
							{
									//.. for {"digit_0":" No Measure...... "}
									%>
											<div class="errorMsgBox" align="center">
												<img src="../images/Light/nomeasures_custom.png"></img>
											</div>
									<%
							}
						}
						else if(chartKey.contains("heatMap"))
						{
							JSONObject chartObject=(JSONObject) chartCollecton.get(chartKey);
							if(chartObject.get("xAxisLabel") != null && chartObject.get("DataSet") != null)
							{
								JSONArray xAxisLabel=(JSONArray)chartObject.get("xAxisLabel");
								int tempTextWidth=(900/xAxisLabel.size()+1);
								tempTextWidth = tempTextWidth-80;

							%>
							<div class="newTable" style="padding:10px">
							<table border="0" align="center" width="100%" height="100%" style="table-layout:fixed">
								<thead>
									<tr>
										<th width="<%=tempTextWidth+80%>px" align="center" style="padding-left: 10px;"></th>
<%
											for(int i=0;i<xAxisLabel.size();i++)
											{
												String xAxisdate=(String)xAxisLabel.get(i);
												%>
												<th width="<%=tempTextWidth%>px" align="center" class="theadBo rderHtml" style="padding-left: 10px;"><%=xAxisdate%></th>
												<%
											}
		%>
									</tr>
									</thead>
									<tbody>
		<%
										JSONArray dataSetArry=(JSONArray)chartObject.get("DataSet");
										for(int j=0;j<dataSetArry.size();j++)
										{
											JSONObject eachObj=(JSONObject)dataSetArry.get(j);
											String objName=(String)eachObj.get("name");
											JSONArray dataArry=(JSONArray)eachObj.get("data");
												%>
												<tr style="padding-left: 10px;">
												<%
												String ddd="<td style='background-color:#ffffff;'>"+objName+"</td>";
												for(int k1=0;k1<dataArry.size();k1++)
												{
													String data=(String)dataArry.get(k1);
													String colorr="";//..default color green is ren=moved
													if(data != null && data.indexOf("$$") != -1)
													{
														colorr=data.substring(data.indexOf("$$")+2);
														data=data.substring(0,data.indexOf("$$"));
													}
													ddd+="<td align='center' style='background-color:"+colorr+"'>";
													ddd+="<span class='font_bold11'><div style=\"width:"+tempTextWidth+"px;word-wrap:break-word;overflow-x:auto;\">"+data+"</span></td>";
												}
												%>
												<%=ddd%>
												</tr>
										<%
										}
									%>
								</tbody>
							</table>
							</div>
		<%
								
								if(widgetFooter!=null && !widgetFooter.equalsIgnoreCase("Notes") && widgetHeader.trim().length()>0)
								{
		%>
									<div style="margin:0px 0px 10px 20px;font-size:13px"><span class="bold" style="font-weight:500">Notes:&nbsp;</span><span><%=widgetFooter%></span></div>
		<%				
								}
							}
							else
							{
								%>
										<div class="errorMsgBox" align="center">
												<img src="../images/Light/nomeasures_custom.png"></img>
										</div>
								<%
							}
						}
						else if(chartKey.contains("tableWithMergingColumns"))
						{
							JSONObject gridObj=(JSONObject) chartCollecton.get(chartKey);
							boolean isDataSetAvailable=false;
							if(gridObj!=null && gridObj.size()>0)
							{
								JSONArray gridData=(JSONArray) gridObj.get("gridData");
								if(gridData != null && gridData.size() > 0)
									isDataSetAvailable=true;
							}
							if(isDataSetAvailable)
							{
								String title=(String) gridObj.get("title");
								if(title==null)
									title="";
								JSONArray gridData=(JSONArray) gridObj.get("gridData");
								JSONArray gridColums=(JSONArray) gridObj.get("gridColums");
								JSONObject rowSpanCountObj=(JSONObject) gridObj.get("rowSpanCountObj");
%>
								<div class="newTable" style="padding:10px;page-break-inside: auto !important">
									<table id="only-table" align="center" cellspacing="0" cellpadding="0" width="100%" style="page-break-inside: auto !important">
										<thead>
											<tr>
												<%
												for(int tk=0;tk<gridColums.size();tk++)
												{
													String str=(String) gridColums.get(tk);
													%>
													<th align="center" ><%=str%></th>
												<%}
												%>
											</tr>
										</thead>
										<tbody>
											<%
											ArrayList tempList = new ArrayList();
											for(int tk=0;tk<gridData.size();tk++)
											{
												JSONArray strArr=(JSONArray) gridData.get(tk);
												Object objT = rowSpanCountObj.get((String)strArr.get(0));
												int rowSpanCount =0;
												if(objT!=null)
												 rowSpanCount = ((Integer)objT).intValue();
												%>
												<tr>
													<%for(int k=0;k<strArr.size();k++)
													{
														String val = (String)strArr.get(k);
														if(val != null && val.indexOf("eGTilteG")>-1)
														{
															val = val.replace("eGTilteG","~");
														}
														if(k==0 && tempList.indexOf(val) < 0)
														{
															tempList.add(val);
													%>
															<td style="text-align:center" rowspan=<%=rowSpanCount%>><%=val%></td>
													<%
														}
														else
														{
															if(k>0)
															{
													%>
																<td style="text-align:center"><%=val%></td>
													<%
															}
														}
													%>
													<%
													}
													%>
												</tr>
											<%}%>
										</tbody>
									</table>
								</div>
							<%}
						}
						else if(chartKey.contains("table")||chartKey.contains("topn"))
						{
							String paddingInfo = "padding:10px 10px 10px 10px;";
							if(widgetHeader!=null && widgetHeader.equalsIgnoreCase("Widget Header"))
							{
								paddingInfo = "";
							}
							if(chartCollecton.get(chartKey) != null && chartCollecton.get(chartKey) instanceof JSONObject)
						{
							JSONObject gridObj=(JSONObject) chartCollecton.get(chartKey);
							boolean isDataSetAvailable=false;
							if(gridObj!=null && gridObj.size()>0)
							{
								JSONArray gridData=(JSONArray) gridObj.get("gridData");
								if(gridData != null && gridData.size() > 0)
									isDataSetAvailable=true;
							}
							if(isDataSetAvailable)
							{
								String title=(String) gridObj.get("title");
								if(title==null)
									title="";
								JSONArray gridData=(JSONArray) gridObj.get("gridData");
								Object gridColums_temp= gridObj.get("gridColums");
									boolean enableSymbolImageTd=false;
									if(gridObj.get("enableSymbolImageTd") != null)
										enableSymbolImageTd= (Boolean)gridObj.get("enableSymbolImageTd");
									JSONObject gridColLanguageObj=null;
									if(gridObj.get("gridColLanguageObj") != null)
										gridColLanguageObj=(JSONObject) gridObj.get("gridColLanguageObj");
									if(gridObj.get("rowExpander") != null && gridObj.get("rowExpander").toString().equalsIgnoreCase("yes"))
									{
										%>
										<div class="newTable" style="padding:10px;page-break-inside: auto !important">
											<table id="only-table" align="center" cellspacing="0" cellpadding="0" width="100%" style="page-break-inside: auto !important">
											<thead>
											<tr>
										<%
										JSONObject gridColums=(JSONObject) gridObj.get("gridColums");
										Iterator exItr=gridColums.entrySet().iterator();
										JSONArray gridColArry=new JSONArray();
										while(exItr.hasNext())
										{
											Map.Entry eachKeyVal=(Map.Entry)exItr.next();
											String headerVal=(String)eachKeyVal.getValue();
											String headerKey=(String)eachKeyVal.getKey();
											if(gridColLanguageObj != null && gridColLanguageObj.get(headerKey) != null)
											{
												headerVal=(String)gridColLanguageObj.get(headerKey);
											}
											gridColArry.add(eachKeyVal.getKey());
											if(headerVal != null && headerVal.indexOf("~") != -1)
												headerVal=headerVal.substring(0,headerVal.indexOf("~"));
											%>
											<th align="left" ><%=headerVal %></th>
											<%
										}
											%>
											</tr>
											</thead>
											<tbody>
										<%
										for(int d=0;d<gridData.size();d++)
										{
											%>
											<tr>
											<%
											Map eachObj=(Map)gridData.get(d);
											String ddUrlStr;
											for(int g=0;g<gridColArry.size();g++)
											{
												String eachColKey=(String)gridColArry.get(g);
												String eachColVal=(String)eachObj.get(eachColKey);
												if(eachColVal != null && eachColVal.indexOf("eGTilteG")>-1)
												{
													eachColVal = eachColVal.replace("eGTilteG","~");
												}
												ddUrlStr=null;
												if(eachColVal != null && eachColVal.indexOf("~DDLink") != -1)
												{
													eachColVal=eachColVal.substring(0,eachColVal.indexOf("~DDLink"));
												}
												if(eachColVal != null && eachColVal.indexOf("~DD") != -1)
												{
													ddUrlStr=eachColVal.substring(eachColVal.indexOf("~DD")+3);
													eachColVal=eachColVal.substring(0,eachColVal.indexOf("~DD"));												
												}
												
												if(ddUrlStr != null)
												{
													%>
													<td width="17%" style="word-break:break-all; word-wrap:break-word;"><a href="<%=managerUrl+ddUrlStr%>" class="cellbgdark" target="_blank"><%=eachColVal%></a></td>
													<%
												}
												else
												{
													%>
													<td width="17%" style="word-break:break-all; word-wrap:break-word;"><div style="overflow-x:auto;"><%=eachColVal%></div></td>
													<%
												}												
											}
											%>
											</tr>
											<%
											if(eachObj != null && eachObj.containsKey("subColumnDatas") && eachObj.containsKey("subColumnHeader")){
												JSONArray headrArr=(JSONArray)eachObj.get("subColumnHeader");
												JSONArray dataArr=(JSONArray)eachObj.get("subColumnDatas");
												if(headrArr != null && headrArr.size() > 0 && dataArr != null && dataArr.size() > 0){
											%>
												<tr>
													<td style="padding:10px" width="100%" colspan="<%=gridColArry.size()%>">
														<div class="newTable" style="page-break-inside: auto !important">
															<table width="100%">
																<thead>
																	<tr>
											<%
													for(int z=0;z<headrArr.size();z++){
												String eachHeader=(String)headrArr.get(z);
												if(eachHeader != null && eachHeader.indexOf("~") != -1)
													eachHeader=eachHeader.substring(0,eachHeader.indexOf("~"));
											%>
																		<th align="left"><%=eachHeader%></th>
											<%
													}
											%>
																	</tr>
																</thead>
																<tbody>
											<%
													for(int x=0;x<dataArr.size();x++){
														JSONObject tmpObj=(JSONObject)dataArr.get(x);
											%>
																	<tr>
											<%
														if(tmpObj != null && tmpObj.size()> 0){
															for(int z=0;z<headrArr.size();z++){
																String strTmp=(String)headrArr.get(z);
																if(strTmp != null && strTmp.indexOf("~") != -1)
																	strTmp=strTmp.substring(0,strTmp.indexOf("~"));
																String tdColStyl="";
																if(strTmp != null && strTmp.equalsIgnoreCase("Dump message"))
																	tdColStyl="width:450px;word-break: break-all;";
																String tempSubData=(String)tmpObj.get(strTmp);
																ddUrlStr=null;
																if(tempSubData != null && tempSubData.indexOf("~DDLink") != -1)
																	tempSubData=tempSubData.substring(0,tempSubData.indexOf("~DDLink"));
																if(tempSubData != null && tempSubData.indexOf("~DD") != -1)
																{
																	ddUrlStr=tempSubData.substring(tempSubData.indexOf("~DD")+3);
																	tempSubData=tempSubData.substring(0,tempSubData.indexOf("~DD"));
																}
																if(ddUrlStr != null)
																{
																	%>
																		<td style="<%=tdColStyl%>"><a class="cellbgdark" target="_blank" href="<%=managerUrl+ddUrlStr%>" ><%=tempSubData%></a></td>
																	<%
																}
																else
																{
																	%>
																		<td style="<%=tdColStyl%>"><%=tempSubData%></td>
																	<%
																}
															}
														}
											%>
																	</tr>
											<%
													}
											%>
																</tbody>
															</table>
														</div>
													</td>
												</tr>
											<%
												}
											}											
											if(eachObj.get("userDetailList") != null)
											{
											%>
												<tr>
												<td style="padding:10px" width="100%" colspan="5"><%=eachObj.get("userDetailList").toString()%></td>
												</tr>
											<%
											}
										}
										%>
											</tbody>
											</table>
										</div>
											<%
									}
									else if(gridColums_temp instanceof JSONArray)
									{
										JSONArray gridColums=(JSONArray) gridObj.get("gridColums");										
										System.out.println("instance of array");
			%>
										<div class="newTable" style="padding:10px;page-break-inside: auto !important">
											<table id="only-table" align="center" cellspacing="0" cellpadding="0" width="100%" style="page-break-inside: auto !important">
											<thead>
											<tr>
			<%
												for(int tk=0;tk<gridColums.size();tk++)
												{
													String str=(String) gridColums.get(tk);
													if(gridColLanguageObj != null && gridColLanguageObj.get(str) != null)
													{
														str=(String)gridColLanguageObj.get(str);
													}
													if(str != null && str.indexOf("$") > -1)
														str=str.substring(0,str.indexOf("$"));//.for table header alignmet(left or center)
													if(str != null && str.indexOf("~") != -1)
														str=str.substring(0,str.indexOf("~"));
													if(tk==0)
													{
														if(str != null && (str.endsWith("Time") || str.endsWith("Date")))
														{
															%>
															<th nowrap width=100 align="left" ><%=str%></th>
															<%	
														}
														else
														{
															%>
															<th align="left" ><%=str%></th>
															<%	
														}
													}
													else
													{
														%>
														<th align="center" ><%=str%></th>
														<%	
													}

												}
			%>
										</tr>		
										</thead>
										<tbody>
			<%						
									String ddUrlStr;
									for(int tk=0;tk<gridData.size();tk++)
									{
										JSONArray strArr=(JSONArray) gridData.get(tk);
										if(strArr!=null &&strArr.size()>0)
										{
			%>
											<tr>			
			<%	
											for(int jk=0;jk<strArr.size();jk++)
											{
												ddUrlStr=null;
												String str=strArr.get(jk)+"";
												if(str != null && str.indexOf("$") != -1)
													str=str.substring(0,str.indexOf("$"));
												if(str != null && str.indexOf("~DD") != -1)
												{
													ddUrlStr=str.substring(str.indexOf("~DD")+3);
													str=str.substring(0,str.indexOf("~DD"));													
												}
												//..for applying color and symbol in td
												String symbolClass="";//..default symbol also removed
												String enableSymbol="no";
												String colourr="";
												if(enableSymbolImageTd)
												{
													if(str.indexOf("@@") != -1)
													{
														symbolClass=str.substring(str.indexOf("@@")+2);
														str=str.substring(0,str.indexOf("@@"));
														enableSymbol="yes";
													}
													if(str.indexOf("$$")!=-1)
													{
														colourr=str.substring(str.indexOf("$$")+2);
														str=str.substring(0,str.indexOf("$$"));
													}
												}
												if(str.indexOf(" week")>-1)
												{
													str=getDataForWeekGroup(str);
												}
											if(str!=null && (str.equals("iconUserHighIdleTime16") || str.equals("noSymbol")))
											{
												if(str.equals("iconUserHighIdleTime16"))
												{
												%>
													<td style="padding:3px 10px 2px 10px;"><div class="iconUserHighIdleTime16" style="width:16px;height:16px;border:1px solid #FFFFFF">&nbsp;</div></td>
												<%
												}
												else
												{
												%>
													<td><div class="">&nbsp;</div></td>
												<%
												}
											}
											else if(str.indexOf("~")>-1 && str.indexOf("~#~")==-1)
											{
												String valueAry[]=str.split("~");
												String valueStr = valueAry[0];

												if(valueStr != null && valueStr.indexOf("eGTilteG")>-1)
												{
													valueStr = valueStr.replace("eGTilteG","~");
												}
												String barStr = "<table width='" + valueAry[2] + "' cellpadding='0' cellspacing='0' height='8' class='prog_border' style='border:0px !important'>";
												barStr += "<tr>";
												barStr += "<td class='reporterProgressBar' width='" + valueAry[2] + "'  style='background:"+valueAry[1]+";border-radius:16px;padding:0px;height:8px'> </td>";
												barStr += "</tr>";
												barStr += "</table>";
												str = "<table width='100%' cellpadding='0' cellspacing='0' style='border:0px !important'><tr style='background:transparent;'><td style='padding:0px 20px 0px 0px;width:50%;border:0px' class='font_normal11'>" + valueStr + "</td><td style='padding:0px;height:10px;border:0px'>" + barStr + "</td></tr></table>";
												if(ddUrlStr !=null)
												{
													%>
														<td><a href="<%=managerUrl+ddUrlStr%>" class="cellbgdark" target="_blank"><%=str %></a></td>
													<%
												}
												else
												{
													%>
														<td><%=str %></td>
													<%
												}
				
											}
											else
											{
												if(str != null && str.indexOf("eGTilteG")>-1)
												{
													str = str.replace("eGTilteG","~");
												}
												if(isNumeric(str) && enableSymbolImageTd)
												{
													if(enableSymbol.equals("yes"))
													{
			%>
														<td><table><tr><td class="<%=symbolClass%>">&nbsp;&nbsp;&nbsp;</td><td><%=str %></td></tr></table></td>
			<%
													}
													else 
													{
			%>
														<td style="background:<%=colourr%>"><%=str %></td>
			<%
													}
												}
												else
												{
													String groupedUrlWidthBtm="";
													if(firstColWordBreakPrint != null && firstColWordBreakPrint.indexOf("yes") > -1 && jk==0)
													{
														groupedUrlWidthBtm=firstColWordBreakPrint.substring(firstColWordBreakPrint.indexOf("yes")+3)+"%";
														if(ddUrlStr != null)
														{
															%>
															<td width="<%=groupedUrlWidthBtm%>" style="word-break:break-all; word-wrap:break-word;"><a href="<%=managerUrl+ddUrlStr%>" class="cellbgdark" target="_blank"><%=str %></a></td>
															<%
														}
														else
														{
															%>
															<td width="<%=groupedUrlWidthBtm%>" style="word-break:break-all; word-wrap:break-word;"><%=str %></td>
															<%
														}												
													}
													else
													{
														
														if(jk==0)
														{
															if(ddUrlStr != null)
															{
																%><td align="left"><a href="<%=managerUrl+ddUrlStr%>" class="cellbgdark" target="_blank"><%=str%></a></td><%
															}
															else
															{
																%><td align="left"><%=str %></td><%
															}															
														}
														else
														{
															if(ddUrlStr != null)
															{
																%><td align="center"><a href="<%=managerUrl+ddUrlStr%>" class="cellbgdark" target="_blank"><%=str %></a></td><%
															}
															else
															{
																String strCellAlign = "center";
																try{
																	Double.parseDouble(str);
																}catch(Exception e){
																	strCellAlign = "left";
																}
																if(str!=null && str.equalsIgnoreCase("-"))
																	strCellAlign = "center";
																%><td align="<%=strCellAlign%>"><%=str %></td><%
															}
														}
													}
												}
											}
										}									
			%>
								</tr>									
			<%	
								}
							}
			%>
							</tbody>
							</table>
						</div>			
			<%

					}
					else
					{
							//System.out.println("instance of object");
						JSONObject gridColumsObj=(JSONObject) gridObj.get("gridColums");
						JSONArray dataAry=(JSONArray) gridData.get(0);
						ArrayList subColList = new ArrayList();
						Iterator iter = gridColumsObj.entrySet().iterator();
			%> 		
						<div class="newTable" style="padding:10px;page-break-inside: auto !important">
							<table id="only-table" align="center" cellspacing="0" cellpadding="0" width="100%" style="page-break-inside: auto !important">
							<thead>
							<tr>
			<%
						int mainColCount=0;
						int decimalAlignBaneColNo=0;
						while(iter.hasNext())
						{
							Map.Entry entryItr= (Map.Entry)iter.next();	
							String mainCol=(String)entryItr.getKey();
							JSONArray mainColAry = (JSONArray) gridColumsObj.get(mainCol);
								String settingInfo=" rowspan=\"2\" ";
							if(mainColAry.size()>0)
							{
								settingInfo= " colspan=\""+mainColAry.size()+"\" ";
								for(int rv = 0;rv<mainColAry.size();rv++)
								{
									subColList.add(mainColAry.get(rv));
								}
							}
							if(mainCol != null && mainCol.equalsIgnoreCase("Response Time (Msecs)"))
							{
								decimalAlignBaneColNo=mainColCount;
							}
							if(gridColLanguageObj != null && gridColLanguageObj.get(mainCol) != null)
							{
								mainCol=(String)gridColLanguageObj.get(mainCol);
							}
							if(mainCol != null && mainCol.indexOf("~") != -1)
							{
								mainCol=mainCol.substring(0,mainCol.indexOf("~"));
							}
							if(mainColCount==0)
							{
							%>
								<th align="left"  <%=settingInfo%> ><%=mainCol %></th>
							<%
							}
							else
							{
							%>
								<th align="center"  <%=settingInfo%> ><%=mainCol %></th>
							<%
							}
							mainColCount++;
						}
			%>
						</tr>
			<%
					if(subColList.size()>0)
					{
			%>
						<tr>
			<%
					for(int tk=0;tk<subColList.size();tk++)
					{
						String str=(String) subColList.get(tk);	
						if(gridColLanguageObj != null && gridColLanguageObj.get(str) != null)
						{
							str=(String)gridColLanguageObj.get(str);
						}
			%>
							<th align="center" class="subHeader"><%=str %></th>
			<%
					}
			%>
						</tr>
						</thead>
			<%
					}									
					for(int tk=0;tk<gridData.size();tk++)
					{
						JSONArray strArr=(JSONArray) gridData.get(tk);
						if(strArr!=null &&strArr.size()>0)
						{
			%>
						<tbody>
						<tr>			
			<%	
						String ddUrlStr;
						for(int jk=0;jk<strArr.size();jk++)
						{
							//String str=(String) strArr.get(jk);	
							String str=strArr.get(jk)+"";		
							ddUrlStr=null;
							if(str != null && str.indexOf("~DD") != -1)
							{
								ddUrlStr=str.substring(str.indexOf("~DD")+3);
								str=str.substring(0,str.indexOf("~DD"));								
							}
							//class="state_transition_GOOD"
							//..for applying color and symbol in td
							String symbolClass="";
							String enableSymbol="no";
							String colourr="";
							if(enableSymbolImageTd)
							{
								if(str.indexOf("@@") != -1)
								{
									symbolClass=str.substring(str.indexOf("@@")+2);
									//alert("==symbolClass=>>>"+symbolClass+"<<<<<");
									str=str.substring(0,str.indexOf("@@"));
									enableSymbol="yes";
								}
								if(str.indexOf("$$")!=-1)
								{
									colourr=str.substring(str.indexOf("$$")+2);	
									str=str.substring(0,str.indexOf("$$"));										
								}
							}
							//..
							if(str.indexOf(" week")>-1)
							{
								str=getDataForWeekGroup(str);
							}
							if(str != null && str.indexOf("eGTilteG")>-1)
							{
								str = str.replace("eGTilteG","~");
							}
				
							if(jk==0)
							{
								String groupedUrlWidthBtm="";
								if(firstColWordBreakPrint != null && firstColWordBreakPrint.indexOf("yes") > -1)
								{
									groupedUrlWidthBtm=firstColWordBreakPrint.substring(firstColWordBreakPrint.indexOf("yes")+3)+"%";
									if(ddUrlStr != null)
									{
										%>
											<td align="left" width="<%=groupedUrlWidthBtm%>" style="word-break:break-all; word-wrap:break-word;"><a href="<%=managerUrl+ddUrlStr%>" class="cellbgdark" target="_blank"><%=str %></a></td>
										<%
									}
									else
									{
										%>
											<td align="left" width="<%=groupedUrlWidthBtm%>" style="word-break:break-all; word-wrap:break-word;"><%=str %></td>
										<%
									}
										
								}
								else
								{
									if(ddUrlStr != null)
									{
										%>
											<td align="left" width="130"><a href="<%=managerUrl+ddUrlStr%>" class="cellbgdark" target="_blank"><%=str%></a></td>
										<%
									}
									else
									{
										%>
											<td align="left" width="130"><%=str %></td>
										<%
									}
								}
							}
							else
							{
								String strDecimal="";
								// pattern is used to find the string is float or not
								String pattern = "(^[\"]?\\d+[\"]?$)|(^[\"]?\\d+(\\.\\d*)[\"]?$)"; 
								Pattern r = Pattern.compile(pattern);
								Matcher m = r.matcher(str);
								if(str!=null && str.indexOf(".")>-1 && m.find() && decimalAlignBaneColNo==0)
								{
									strDecimal = str.substring(str.indexOf("."));
									str = str.substring(0,str.indexOf("."));

									if(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes"))
									{
										if(enableSymbol.equals("yes") && enableSymbolImageTd)
										{
	%>
											<td><table><tr><td class="<%=symbolClass%>">&nbsp;&nbsp;&nbsp;</td><td><span class="decimal-align"><%=str %></span><span class="decimal-align2"><%=strDecimal%></span></td></tr></table></td>
	<%
										}
										else if(enableSymbolImageTd)
										{
	%>
											<td style="background:<%=colourr%>;"><span class="decimal-align" style="background:<%=colourr%>"><%=str %></span><span class="decimal-align2" style="background:<%=colourr%>"><%=strDecimal %></span></td>
	<%
										}
										else
										{
	%>
											<td><span class="decimal-align"><%=str%></span><span class="decimal-align2"> <%=strDecimal%></span></td>
	<%
										}
									}
									else
									{
										if(enableSymbol.equals("yes") && enableSymbolImageTd)
										{
	%>
											<td><table><tr><td class="<%=symbolClass%>" style="text-align:center">&nbsp;&nbsp;&nbsp;</td><td><span><%=str%></span><span><%=strDecimal%></span></td></tr></table></td>
	<%
										}
										else if(enableSymbolImageTd)
										{
	%>
											<td style="background:<%=colourr%>;text-align:center"><span style="background:<%=colourr%>"><%=str%></span><span style="background:<%=colourr%>"><%=strDecimal%></span></td>
	<%
										}
										else
										{
	%>
											<td style="text-align:center"><span><%=str%></span><span> <%=strDecimal %></span></td>
	<%
										}
									}
									
								}
								else if(m.find() && decimalAlignBaneColNo==0)
								{
									if(enableSymbol.equals("yes") && enableSymbolImageTd)
									{
%>
										<td><table><tr><td class="<%=symbolClass%>">&nbsp;&nbsp;&nbsp;</td><td><span class="decimal-align"><%=str %></td></tr></table></td>
<%		
									}
									else if(enableSymbolImageTd)
									{
%>
										<td style="background:<%=colourr%>"><span class="decimal-align" style="background:<%=colourr%>"><%=str %></td>
<%
									}
									else
									{
										if(ddUrlStr != null)
										{
											%>
												<td><span class="decimal-align"><a href="<%=managerUrl+ddUrlStr%>" class="cellbgdark" target="_blank"><%=str %></a></td>
											<%
										}
										else
										{
											%>
												<td><span class="decimal-align"><%=str %></td>
											<%
										}

									}
								}
								else
								{
									if(ddUrlStr != null){
										%>
											<td><a href="<%=managerUrl+ddUrlStr%>" class="cellbgdark" target="_blank"><%=str %></a></td>
										<%
									}
									else
									{
										%>
											<td><%=str %></td>
										<%
									}
								}
							}
						}									
			%>
						</tr>	
						</tbody>
			<%	
						}
					}
			%>
						</table>
					</div>
			<%
									if(widgetFooter!=null && !widgetFooter.equalsIgnoreCase("Notes") && widgetHeader.trim().length()>0)
									{
			%>
										<div style="margin:0px 0px 10px 20px;font-size:13px"><span class="bold" style="font-weight:500">Notes:&nbsp;</span><span><%=widgetFooter%></span></div>
			<%				
									}

								}
							}
							else
							{
								%>
										<div class="errorMsgBox" align="center">
												<img src="../images/Light/nomeasures_custom.png"></img>
										</div>
								<%
							}
						}
						else
						{
								%>
										<div class="errorMsgBox" align="center">
												<img src="../images/Light/nomeasures_custom.png"></img>
										</div>
								<%
							}
						}
						else
						{

							sentQuery=	queryString+"&chartKey="+chartKey+"&adjustWidgetHeight="+adjustWidgetHeight;					
							if(num==0)			
							{				
				%>
								<div style="width:100%;padding:10px">
				<%				
							}
							String genHTML=null;
							System.out.println("==chartKey==sdfd>>>>>"+chartKey);
							if(chartKey.contains("distribution") || chartKey.contains("distributedPie"))
							{
								if(chartCollecton.get(chartKey) != null && chartCollecton.get(chartKey) instanceof JSONObject)
								{
								JSONObject chartObj=(JSONObject)entry2.getValue();							
								System.out.println("chartObj::::::::::::::::::   "+chartObj);
								imgwidgetWidth = imgwidgetWidth-150;
								genHTML = "<table cellpadding='0' cellspacing='0' border='0' style='margin:10px;'>";
								genHTML += "<tr>";
								JSONArray dataSet=(JSONArray)chartObj.get("DataSet");
								if(dataSet != null && dataSet.size()>0)
								{
								JSONObject dataObj=(JSONObject)dataSet.get(0);
								JSONArray data=(JSONArray)dataObj.get("data");
								JSONArray pieLabels = (JSONArray)chartObj.get("pieLabels");
								JSONArray pieColors = (JSONArray)chartObj.get("pieColors");
								strGraphHeight = strGraphHeight=(widgetHeight-((widgetHeight*60)/100) +150)+"";

				%>		
								<table width="100%" height="100%">
									<tr>
										<td width="70%">
											<img width="100%" height="100%" src="<%=sentQuery%>&optt=graph&er_width=<%=imgwidgetWidth%>&er_height=<%=strGraphHeight%>&er_view=IMAGE" border="0" hspace="0"  vspace="0" ></img>
										</td>
									
										<td width="30%">
										<div class="egFlexParentDiv column spaceAround">
											<div>
											<%											
											for (int l=0;l<pieLabels.size();l++)
											{
												String legendLabel = (String)pieLabels.get(l);
												String legendColors = (String)pieColors.get(l);
												JSONObject eachData=(JSONObject)data.get(l);
												if (l>0 && ((l+1)%1)==0)
												{
													%>
													</div><div>
													<%
												}
											%>
											<table width="100%"><tr>
												<td>
													<svg xmlns="http://www.w3.org/2000/svg" height="10" width="10">
													  <circle cx="5" cy="5" r="4" fill="<%="#"+legendColors%>" />
													</svg>
												</td>
												<td style='padding:0px 10px 0px 5px;' class='newFont_bold15'>
											<%
												String val=null;
												double dblVal=0;
												if(eachData != null && eachData.get("percentVal") != null)
												{
													val=(String)eachData.get("percentVal");	val = dbInfo.formatValue(val);										
													%>
														<%=val%></td>
													<%
												}
												else
												{
													dblVal=(Double)eachData.get("y");
													String strtempRoundVal = dbInfo.formatValue(dblVal+"");
													%>
														<%=strtempRoundVal%></td>
													<%
												}
												%>
												</tr>
												<tr>
													<td></td><td style='padding:0px 5px;' class='newFont_normal11'><%=legendLabel%></td>
												</tr></table>
												<%
											}	
											
											%>
											</div>
											</div>
										</td>
									</tr>
								</table>
								<%
									}
									else
									{
										%>
											<div class="errorMsgBox" align="center">
												<img src="../images/Light/nomeasures_custom.png"></img>
											</div>
										<%
									}
								}
								else
								{
									%>
										<div class="errorMsgBox" align="center">
												<img src="../images/Light/nomeasures_custom.png"></img>
										</div>
									<%
								}
							}
							else
							{
				%>				
									<img src="<%=sentQuery%>&optt=graph&er_width=<%=imgwidgetWidth%>&er_height=<%=strGraphHeight%>&er_view=IMAGE" border="0" hspace="0"  vspace="0" ></img>
									
				<%			
							}
				%>
								</div>
				<%
							if(widgetFooter!=null && !widgetFooter.equalsIgnoreCase("Notes") && widgetHeader.trim().length()>0)
							{
				%>
								<div style="margin:0px 0px 10px 20px;font-size:13px"><span class="bold" style="font-weight:500">Notes:&nbsp;</span><span><%=widgetFooter%></span></div>
				<%				
							}					
					
						}
				}
			}
			else
			{
				//System.out.println("===nomeasure==>>>");
				%>
						<div class="errorMsgBox" align="center">
							<img src="../images/Light/nomeasures_custom.png"></img>
						</div>
				<%

			}
		
%>


			</td>
				
<%
		strfirstcol = strfirstcol+1;
	}
%>
		</table>
		</div>
		<div style="width:1000px;height:26px">&nbsp;</div>
<%

		}
	}

try{
	String currentTime_1 = egDate.egetDate();
	currentTime_1 = DateUtil.changeDateFormat(currentTime_1,"dd/MM/yyyy HH:mm:ss",strUserDateFormat+" HH:mm:ss");
	EgTimeZoneConverter timeZoneConverter_temp = new EgTimeZoneConverter(currentTime_1,thisuser);
	currentTime_1 = timeZoneConverter_temp.getDateTime();
%>			
			</tr>
		</table>
		<%
		if(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes"))
		{
			%>
			<div class="printFooterText"><%=strPrintFooterText%></div>
			<%
		}
		%>
		
</body>
</html>
<%}catch(Exception e) { e.printStackTrace();}%>
<%!
public String getDataForWeekGroup(String inVal)
{
	String value=inVal;
	inVal=inVal.substring(0,inVal.indexOf("."));
	int intInVal = Integer.parseInt(inVal);
	switch(intInVal)
	{
		case 1:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="Jan-"+value;
			break;
		case 2:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="Feb-"+value;
			break;
		case 3:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="Mar-"+value;
			break;
		case 4:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="Apr-"+value;
			break;
		case 5:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="May-"+value;
			break;
		case 6:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="Jun-"+value;
			break;
		case 7:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="Jul-"+value;
			break;
		case 8:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="Aug-"+value;
			break;
		case 9:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="Sep-"+value;
			break;
		case 10:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="Oct-"+value;
			break;
		case 11:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="Nov-"+value;
			break;
		case 12:
			value=value.substring(value.indexOf(".")+1,value.length());
			value="Dec-"+value;	
			break;			
	}
	return value;
}
public String getDigitalData(String imageCls,String value,String DisplayName,String unit,int chartIndex)
{
	StringBuffer sf=new StringBuffer();
	sf.append("<td>");
	sf.append("<table align=\"center\"  cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"align:center;margin:auto auto;\" >");
	sf.append("<tbody><tr>");
	sf.append("<td style=\"text-align:center;\" colspan=\"1\" rowspan=\"1\">");
	sf.append("<table align=\"center\" style=\"padding:5px 5px 8px 5px\"><tbody><tr>");
	if(imageCls!=null)
	{
		sf.append("<td align=\"right\" style=\"padding-right:5px\"><div class=\""+imageCls+"\"></div></td>");
	}
	sf.append("<td style=\"text-align:left;padding-left:5px;font-size:26px\" class=\"newFont_bold28\">"+value+"</td></tr></tbody>");
	sf.append("</table></td></tr>");
	sf.append("<tr><td style=\"text-align:center;\" colspan=\"1\" rowspan=\"1\" >");
	sf.append("<span class=\"font_normal13\" style=\"font-size:13px\">"+DisplayName+"<br>"+unit+"</span></td></tr>");
	if(chartIndex==0 || chartIndex==2 || chartIndex==4)
	sf.append("<tr><td><div style=\"text-align:center;border-bottom:1px solid #dedede;margin-top:15px;position:relative;width:170px\" colspan=\"1\" rowspan=\"1\"></div></td></tr>");
	sf.append("</tbody></table></td>");
	return sf.toString();
}
public static boolean isNumeric(String str)  
{  
  try  
  {  
    double d = Double.parseDouble(str);  
  }  
  catch(NumberFormatException nfe)  
  {  
    return false;  
  }  
  return true;  
}
%>
