<%
/*******************************************************************************
*	File name		:	ErMeasure.jsp
*	Purpose			:	This page Handles a single Line chart
*	Version			:	Reporter 1.0
*	Creation Date	:	29/01/2003 - (dd/mm/yyyy)
*	Author			:	Krishnakumar.C
*	Last Modified	:
							7/12/05 - Citrix Report Changes-09/08/2004  M.Saravanan
							bug fixed-02/08/2004  M.Saravanan
							Table border changed & Mail Feature added-30/07/2004  M.Saravanan
							Descriptor alignment changed---20/07/2004  M.Saravanan
							TimeLine Selection added,Icon Added
							22/05/2004 - solomon - enhanced to support filtering infos.
							7/1/2004	 - Solomon //javascript:saveMe() function is changed
*							22/10/2003  Karthick -Snap shot specific changes
*							21/02/2003	Arun	Add PDF-saving support
*							17/07/2003	Gopi/Karthick Comparison feature specific changes

*******************************************************************************/
%>

<%@ include file="ErReporterTracker.jsp" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.text.SimpleDateFormat" %>
<%@ page import = "egurkha.reporter.*" %>
<%@ page import = "com.eg.EgDateInfo"%>
<%@ page import = "com.eg.EgTablesInfo" %>
<%@ page import = "com.eg.IniFile" %>
<%@ page import = "com.eg.EgInstallInfo" %>
<%@ page import = "com.eg.EgURLEncoder" %>
<%@ page import = "com.eg.EgURLDecoder"%>
<%@ page import = "com.eg.EgExternalInfo" %>
<%@ page import = "com.eg.EgSpecsInfo" %>
<%@ page import = "com.eg.ErDbServer" %>
<%@ page import = "com.eg.EgMappingInfo" %>
<%@ page import = "egurkha.TestBean" %>
<%@ page import = "java.net.URLEncoder" %>
<%@ page import = "java.net.URLDecoder" %>
<%@ page import = "egurkha.reporter.ErReportHelper" %>
<%@ page import = "com.eg.EgThresholdInfo" %>
<%@ page import = "com.egurkha.util.StringUtils" %>
<%@ page import = "com.egurkha.util.DateTimeTokenizer" %>
<%@ page import = "com.eg.EgDbInfo" %>
<%@ page import = "com.egurkha.util.DateUtil" %>
<%@ page import = "com.eg.EgConfigInfo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page import="net.sf.json.*"%>
<jsp:useBean id="dd" scope="page" class="com.egurkha.monitor.EgDiagnosisBean" />
<%@ page import = "com.egurkha.ini.IniUI" %>
<%@ page import = "com.egurkha.ini.IniUI" %>
<%
try
{
	response.setHeader("Cache-Control","no-store");
	response.setHeader("Pragma","no-cache");
	response.setDateHeader("Expires", -1);

	String queryString = ErUtils.prepareQueryString(request.getParameterMap());
	String st_componentNew = request.getParameter("er_component");
	String reportFor = request.getParameter("reportFor");
	String er_RmDispName = request.getParameter("er_RmDispName");
	request.setCharacterEncoding("UTF-8");
	com.egurkha.ini.IniUI ui = (com.egurkha.ini.IniUI)com.egurkha.ini.IniUI.getInstance();
	UserRegistry mregistry = UserRegistry.getInstance();
	User muser = mregistry.getUser(session.getId());
	String thisLanguage = ui.getDefaultLanguage();
	EgDbInfo dbInfo=new EgDbInfo("manager");
	String pdfPrint = request.getParameter("pdfPrint");
	String drillDown = request.getParameter("drillDown");
	String drilldownenabled = request.getParameter("drilldownenabled");
	IniFile egFormat = new IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_format.ini");
	String mngrIProc = new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
	String fromPrintPage= request.getParameter("print");
	String er_rtype1 = request.getParameter("er_rtype");
	String er_nick = request.getParameter("er_nick");
	String er_graphtype = request.getParameter("er_graphtype");
	String select_farm = request.getParameter("select_farm");
	EgTimeZoneConverter realDateTime = new EgTimeZoneConverter();
	if (muser!=null)
	{
		String userLang = muser.getLanguage();
		if (userLang!=null && !userLang.equalsIgnoreCase("NULL"))
		{
			thisLanguage=userLang;
		}
	}
	String sample = request.getParameter("sample");
	if(sample == null)
	{
		sample = "no";
	}
	ArrayList singleColors = new ArrayList();
	ArrayList singleSelection = new ArrayList();
	Map reqMap = request.getParameterMap();
	Hashtable erComparisonMap = new Hashtable(reqMap);
	ErReqData erd = new ErReqData(request);

	String uiFile = "eg_ui.ini";
	String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
	IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
	String currentDateFormat = strUserDateFormat;
	EgDateInfo egDt = new EgDateInfo();

	String[] options = {"Any","10 mins","15 mins","30 mins","45 mins","1 hour", "2 hours", "3 hours", "6 hours", "12 hours", "18 hours", "1 day", "2 days", "3 days", "4 days", "5 days", "6 days"};

	String s_st_time = request.getParameter("startdate");
	// Convert dateFormat From userdateFormat to MM/dd/MM/yyyy Format
	s_st_time= DateUtil.changeDateFormat(s_st_time.trim(),currentDateFormat,"MM/dd/yyyy");
	String s_en_time = request.getParameter("enddate");	
	s_en_time= DateUtil.changeDateFormat(s_en_time.trim(),currentDateFormat,"MM/dd/yyyy");
	String s_st_hr = request.getParameter("starthr");
	String s_en_hr = request.getParameter("endhr");
	String startMins = request.getParameter("startmin");
	String endMins = request.getParameter("endmin");
	String er_timeline=request.getParameter("er_timeline");
	String trendenable=request.getParameter("er_trend");
	String s_trenddata=request.getParameter("er_trenddata");
	String strStartTime = DateUtil.changeDateFormat(s_st_time.trim(),"MM/dd/yyyy","dd/MM/yyyy")+" "+s_st_hr+":"+startMins+":00";
	String strEndTime = DateUtil.changeDateFormat(s_en_time.trim(),"MM/dd/yyyy","dd/MM/yyyy")+" "+s_en_hr+":"+endMins+":00";
	String action = request.getParameter("measurePopupAction");
	String isKpiHealthReport=request.getParameter("isKpiHealthReport");
	if(s_trenddata==null)
		s_trenddata="No";


	String disable="";
	String dispDate = null;
	String comFormat = null;
	String startDateTime="";
	String endDateTime="";
	String port ="";

	if(er_timeline!=null)
		er_timeline=URLDecoder.decode(er_timeline);
	if(er_timeline==null)
	{
		er_timeline="1 Day";
	}
	String[] opt=new String[21];
	String gtype=request.getParameter("er_gtype");
	String snaptim=request.getParameter("snaptime");
	String period=request.getParameter("er_period");
	String er_time=request.getParameter("er_time");
	String isOnlyVMAssigned=request.getParameter("isOnlyVMAssigned");
	String isFromAlarmHistory=request.getParameter("isFromAlarmHistory");
	String strScreenWidth = request.getParameter("screenWidth");
	EgMappingInfo mappingInfo=new EgMappingInfo(thisLanguage);
	String showLegend = request.getParameter("showLegend");
	String enableComponentCombo=request.getParameter("enableComponentCombo");
	boolean isComponentCombo=false;
	if(enableComponentCombo != null && enableComponentCombo.equalsIgnoreCase("yes") && gtype != null && gtype.equalsIgnoreCase("intrasnap") && er_rtype1 != null && er_rtype1.equalsIgnoreCase("Snapshot"))
	{
		isComponentCombo=true;
	}

	String chartType= null;
	int screenWidth = 990;
	try{
		screenWidth = Integer.parseInt(strScreenWidth);
	}
	catch(Exception e)
		{screenWidth = 990;}

	EgSpecsInfo eSpec = new EgSpecsInfo("manager");
	EgInstallInfo installInfo = new EgInstallInfo();
	EgTablesInfo tablesInfo = new EgTablesInfo("manager");
	ErUtils erUtils = new ErUtils(); 
	
	if(isOnlyVMAssigned==null || isOnlyVMAssigned.equals(""))
		isOnlyVMAssigned="false";
	if(isFromAlarmHistory==null || isFromAlarmHistory.equals(""))
		isFromAlarmHistory="false";
	if(period==null ||er_time==null)
	{
		period="";
		er_time="";
	}
	if("Summary".equalsIgnoreCase(gtype) || "Trend".equalsIgnoreCase(gtype))
	{
		if("M".equalsIgnoreCase(request.getParameter("er_period")))
		{
			opt=new String[]{"Any","3 months","6 months","9 months","12 months"};
		}
		else
		{
			opt=new String[]{"Any","1 day", "2 days", "3 days", "4 days", "5 days", "6 days","1 week","2 weeks","3 weeks","4 weeks","1 month"};
		}

	}
	else
	{
		if("intrasnap".equalsIgnoreCase(gtype)&& snaptim!=null && snaptim.equals("Yes"))
		{
			opt=new String[]{"Any","10 mins","15 mins","30 mins","45 mins","1 hour", "3 hours", "6 hours", "9 hours", "12 hours", "15 hours", "18 hours", "21 hours","1 day", "2 days", "3 days", "4 days", "5 days", "6 days","1 week","2 weeks","3 weeks","4 weeks","1 month"};
		}
		else
		{
			if(s_trenddata.equals("Yes"))
			{
				opt=new String[]{"Any","1 day", "2 days", "3 days", "4 days", "5 days", "6 days","1 week","2 weeks","3 weeks","4 weeks","1 month"};
			}
			else
			{
				opt=new String[]{"Any","1 hour", "3 hours", "6 hours", "9 hours", "12 hours", "15 hours", "18 hours", "21 hours","1 day", "2 days", "3 days", "4 days", "5 days", "6 days","1 week","2 weeks","3 weeks","4 weeks","1 month"};
			}
		}
	}  
	long msecsPerHour = (long) 1000 * 60 * 60;
	int blankSpaceIndex =0;
	long val=0;
	String unit="";
	if(er_timeline!=null&&!er_timeline.equals("Any"))
	{
		blankSpaceIndex = er_timeline.indexOf(DateTimeTokenizer.BLANK_SPACE);
		val= Integer.parseInt(er_timeline.substring(0, blankSpaceIndex));
		unit = er_timeline.substring(blankSpaceIndex+1).toLowerCase();
	}
	if(er_timeline!=null&&!er_timeline.equals("Any")&& gtype!=null && !gtype.equals("Summary"))
	{
		if(blankSpaceIndex > 0)
		{
			SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm");
			java.util.Date today = egDt.egetRealDate();
			endDateTime = sdf.format(today);

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

			

			//if(erd.s_gtype !=null && (erd.s_gtype.equalsIgnoreCase("interSnap")||erd.s_gtype.equalsIgnoreCase("intrasnap")))
			if(action!=null && action.equalsIgnoreCase("timelineChange"))
			{
				String sb_hr = startDateTime.substring(startDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE)+1,startDateTime.indexOf(":"));

				s_st_hr = String.valueOf(sb_hr);

				String sb_en_hr = endDateTime.substring(endDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE)+1,endDateTime.indexOf(":"));

				s_en_hr = String.valueOf(sb_en_hr);
			}
		}
		chartType=ErHighchartUtils.getChartType(startDateTime,endDateTime,"MM/dd/yyyy HH:mm");
	}
	else if(er_timeline!=null&&!er_timeline.equals("Any")&&gtype!=null &&gtype.equals("Summary"))
	{
		if (unit.startsWith("d"))
		{
			val= 24*val;
		}
		if (unit.startsWith("w"))
		{
			val=168*val;
		}
		if (unit.startsWith("mo"))
		{
			SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm");
			java.util.Date thisDay = egDt.egetRealDate();
			String endDatTime = sdf.format(thisDay);
			val = (ErUtils.getTotalDays(endDatTime,val))*24;
		}
		erd.s_end_time = egDt.egetDate(egDt.egetUTCDate());
		if(erd.s_period.equalsIgnoreCase("H"))
		{
			erd.s_start_time = egDt.egetDate(egDt.egetUTCDate() - ((long)((long)val * (long)msecsPerHour)));
			erd.s_start_time = (erd.s_start_time.substring(0, erd.s_start_time.indexOf(":"))) + ":00:00";
			erd.s_end_time = (erd.s_end_time.substring(0, erd.s_end_time.indexOf(":"))) + ":00:00";
			long i_timeline = 0;
			if(er_time !=null){
				i_timeline = val;
			}

			if((i_timeline < 24)){
				erd.s_sthr = erd.s_start_time.substring(erd.s_start_time.indexOf(" ")+1,erd.s_start_time.indexOf(":"));
				erd.s_endhr = erd.s_end_time.substring(erd.s_end_time.indexOf(" ")+1,erd.s_end_time.indexOf(":"));
			}else
			{
				long l_temp = (long)((long)egDt.egetUTCDate(erd.s_start_time)+(long)(24l * (long)msecsPerHour));
				erd.s_start_time = (erd.s_start_time.substring(0, erd.s_start_time.indexOf(" "))) + " 00:00:00";
				erd.s_end_time = (erd.s_end_time.substring(0, erd.s_end_time.indexOf(" "))) + " 00:00:00";
				
			}
		}
		else if(erd.s_period.equalsIgnoreCase("D"))
		{
			erd.s_start_time = egDt.egetDate(egDt.egetUTCDate() - ((long)((long)val * (long)msecsPerHour)));
			erd.s_end_time = egDt.egetDate(egDt.egetUTCDate());
			erd.s_start_time = (erd.s_start_time.substring(0,
			erd.s_start_time.indexOf(" "))) + " 00:00:00";
			erd.s_end_time = (erd.s_end_time.substring(0, erd.s_end_time.indexOf(" "))) + " 00:00:00";
			
		}
		else if(erd.s_period.equalsIgnoreCase("M"))
		{
			erd.s_start_time = egDt.egetDate(egDt.egetUTCDate() - ((long)((long)val * (long)msecsPerHour)));
			erd.s_start_time = (erd.s_start_time.substring(0, erd.s_start_time.indexOf(" "))) + " 00:00:00";
			long l_st = egDt.egetUTCDate(erd.s_start_time);
			long l_end = egDt.egetUTCDate(erd.s_end_time);
			erd.s_end_time = erd.s_end_time = egDt.egetDate(egDt.egetUTCDate());
			erd.s_end_time = (erd.s_end_time.substring(0, erd.s_end_time.indexOf(" "))) + " 00:00:00";
			
		}
		else{
			erd.s_end_time = egDt.egetDate(egDt.egetUTCDate());
				erd.s_start_time = egDt.egetDate(egDt.egetUTCDate() - ((long)((long)val * (long)msecsPerHour)));
			erd.s_start_time = (erd.s_start_time.substring(0, erd.s_start_time.indexOf(":"))) + ":00:00";
			erd.s_end_time = (erd.s_end_time.substring(0, erd.s_end_time.indexOf(":"))) + ":00:00";
	
		}
		s_st_time = erd.s_start_time.substring(0,erd.s_start_time.indexOf(" "));
		s_en_time = erd.s_end_time.substring(0,erd.s_end_time.indexOf(" "));
		s_st_time = DateUtil.changeDateFormat(s_st_time,"dd/MM/yyyy","MM/dd/yyyy");
		s_en_time = DateUtil.changeDateFormat(s_en_time,"dd/MM/yyyy","MM/dd/yyyy");
		
	}


	if(er_timeline!=null&&er_timeline.equals("Any"))
	{
		String StrDate="";
		try
		{
			java.text.SimpleDateFormat df=new java.text.SimpleDateFormat("MM/dd/yyyy k 'at' hh:mm");
			StrDate =df.format(new java.util.Date());
		}
		catch(Exception ee)
		{
			System.out.println("Exception is"+ee);
		}
		String SDate =StrDate.substring(0,StrDate.indexOf(" "));
		String shour =StrDate.substring(StrDate.indexOf(" "),StrDate.lastIndexOf(""));
		shour = shour.substring(0,3);
		if(s_st_time==null)
		{
			s_st_time=SDate;
		}
		if(s_en_time==null)
		{
			s_en_time=SDate;
		}
		if(s_st_hr==null)
		{
			shour =shour.trim();
			int starthr = Integer.parseInt(shour);
			starthr = starthr-1;
			s_st_hr=String.valueOf(starthr);
		}
		if(s_en_hr==null)
		{
			shour =shour.trim();
			s_en_hr =shour;
		}
		if(gtype.trim().equalsIgnoreCase("intrasnap"))
		{
			if(startMins==null)
				startMins = StrDate.substring(StrDate.indexOf(":")+1);
			if(endMins==null)
				endMins = StrDate.substring(StrDate.indexOf(":")+1);
		}
		
		String startDate_1 = DateUtil.changeDateFormat(s_st_time.trim(),currentDateFormat,"MM/dd/yyyy");
		String endDate_1 = DateUtil.changeDateFormat(s_en_time.trim(),currentDateFormat,"MM/dd/yyyy");
		String strStartTime_1 = startDate_1+" "+s_st_hr+":"+startMins+":00";
		String strEndTime_1 = endDate_1+" "+s_en_hr+":"+endMins+":00";
		chartType=ErHighchartUtils.getChartType(strStartTime_1,strEndTime_1,"MM/dd/yyyy HH:mm");
	}
	chartType="highchart";
	session.setAttribute("DRILLDOWN_PDF_URL", mngrIProc+"/final/reporter/ErMeasure.jsp");
	JSONObject json = new JSONObject();
	JSONObject pageParams = new JSONObject();
	JSONObject screenLabels = new JSONObject();
	JSONObject hiddenParams = new JSONObject();
	StringBuffer sbHiddenQStr = new StringBuffer();
	if(action!=null && action.equals("defaultLoad"))
	{
		json.put("chartType",chartType);
		if(erd.s_gtype !=null && erd.s_gtype.equalsIgnoreCase("Comparison") || (reportFor!=null && reportFor.equalsIgnoreCase("CompareGraph")))
		{
			ErComparisonBean erc = new ErComparisonBean();
			erc.initRequest(request);
			erc.processData();
			singleColors = erc.singleColors;
			singleSelection = erc.singleSelection;
		}
		else if(erd.s_gtype != null && erd.s_gtype.equalsIgnoreCase("Measure"))
		{
			ErMicroTime ermicro = new ErMicroTime();
			ermicro.initRequest(request);
			ermicro.initRequest(erComparisonMap);
			ermicro.processData();
			singleColors = ermicro.singleColors;
			singleSelection = ermicro.singleSelection;
		}
		else if(erd.s_gtype !=null && (erd.s_gtype.equalsIgnoreCase("interSnap")||erd.s_gtype.equalsIgnoreCase("intrasnap")||erd.s_gtype.equalsIgnoreCase("Citrix")))
		{
			//ErSnapshot ersnap = new ErSnapshot();
			//ersnap.initRequest(request);
			//ersnap.initRequest(erComparisonMap);
			//ersnap.processData("");
			//ersnap.snapShotProcessGraph();
			singleColors = null;//ersnap.singleColors;
			singleSelection = null;//ersnap.singleSelection;
			if(isComponentCombo)
			{
				JSONArray componentsArry=new JSONArray();
				JSONObject compBasedTestObj=(JSONObject)session.getAttribute("compBasedTestObj");
				String testStr=request.getParameter("er_test");
				testStr=mappingInfo.getTestDescription(testStr);
				if(compBasedTestObj != null && testStr != null && compBasedTestObj.get(testStr) != null)
				{	
					JSONArray compArry=(JSONArray)compBasedTestObj.get(testStr);
					//String[] compArry=request.getParameterValues("er_component");
					if(compArry != null)
					{
						JSONObject eachCompObj=null;
						for(int c=0;c<compArry.size();c++)
						{
							eachCompObj=new JSONObject();
							String eachComp=(String)compArry.get(c);
							String tempComp=eachComp;
							String cType=eachComp.substring(eachComp.lastIndexOf(":")+1);
							cType=mappingInfo.getComponentTypeDescription(cType);
							String portNo=eachComp.substring(eachComp.indexOf(":")+1,eachComp.lastIndexOf(":"));
							if(portNo.equalsIgnoreCase("null"))
							{
								eachComp=eachComp.substring(0,eachComp.indexOf(":"))+":"+cType;
							}
							else
								eachComp=eachComp.substring(0,eachComp.lastIndexOf(":")+1)+cType;
							eachCompObj.put("displayField",eachComp);
							eachCompObj.put("valueField",tempComp);
							componentsArry.add(eachCompObj);
						}
					}
				}
				json.put("ComponentsArry",componentsArry);
				json.put("enableComponentCombo","yes");
			}

		}
		
		TestBean testBean = new TestBean();
		EgExternalInfo extInfo=new EgExternalInfo("Manager");
		ErInfo erInfo=new ErInfo();
		int count = 0;
		double d_min = 0;
		double d_max = Double.MAX_VALUE;
		int maxInfo = (new ErReportHelper()).getMaxInfos("INFOS","MaxInfos");
		boolean showFilter = false;
		String strCommonMax = request.getParameter("er_commonMax");
		String strCommonMaxRangeValue = request.getParameter("er_commonMaxRange");
		String strAutoCommonMax = request.getParameter("er_AutoCommonMax");

		String s_filter = request.getParameter("er_filter");
		if(s_filter == null || s_filter.equals("")) s_filter = "INFO";

		String s_min ="";
		String s_max ="";

		if ("RANGE".equalsIgnoreCase(s_filter))
		{
			s_min = request.getParameter("er_range_min");
			s_max = request.getParameter("er_range_max");
		}

		String s_priority = request.getParameter("er_priority");
		String s_qry_string = request.getQueryString();
		String info=request.getParameter("er_info_list");
		int i_serv_port = request.getServerPort();
		String s_serv_name = installInfo.getUrlPrefix()+"//" +request.getServerName();
		String s_serv_pdf = installInfo.getUrlPrefix()+"//" +eSpec.getEGServer() + ":" + i_serv_port;

		String s_control_servlet = "/final/servlet/com.eg.";
		String compType = "";
		String er_info = "";
		Enumeration ew=request.getParameterNames();
		StringBuffer sb=new StringBuffer();
		String site=request.getParameter("er_site");
	/*	try
		{
			while(ew.hasMoreElements())
			{
				String name=ew.nextElement().toString();
				sb.append(name).append("=").append(request.getParameter(name)).append("&");
			}
		}catch(Exception e)
		{
			e.printStackTrace();
		}*/

	//	String qs=request.getQueryString();
		String qs=ErUtils.prepareQueryString(request.getParameterMap());
		StringTokenizer strtokk = new StringTokenizer(qs,"&");
		while(strtokk.hasMoreTokens())
		{
				String param = strtokk.nextToken();
				if(param.indexOf("=")>-1)
				{
					String reqparam =param.substring(0,param.indexOf("="));
					String value = param.substring(param.indexOf("=")+1,param.length());
					if(reqparam!=null && reqparam.equals("er_nick"))
						value=EgURLEncoder.encode(value,"UTF-8");
					sb.append(reqparam).append("=").append(value).append("&");
				}
		}
		String s_timeline=erd.s_timeline;
		int timeline=0;
		if((erd.s_gtype != null && erd.s_gtype.equalsIgnoreCase("Measure")|| erd.s_gtype.equalsIgnoreCase("Trend"))|| erd.s_gtype !=null && erd.s_gtype.equalsIgnoreCase("Comparison"))
		{
			if (reportFor!=null && reportFor.equalsIgnoreCase("CompareGraph"))
				s_qry_string = s_control_servlet + "ErCompareServersC?er_filter=" + s_filter+"&" + sb;

			else if (erd.s_gtype.equalsIgnoreCase("Measure"))
				s_qry_string = s_control_servlet +"ErMicroTimeC?er_filter=" + s_filter+"&"+sb;
			else if(erd.s_gtype.equalsIgnoreCase("Trend"))
				s_qry_string = s_control_servlet +"ErTrendC?er_filter=" + s_filter+"&"+sb;
			else if (erd.s_gtype.equalsIgnoreCase("Comparison"))
				s_qry_string = s_control_servlet + "ErCompareServersC?er_filter=" + s_filter+"&" + sb;

			if (erd.s_gtype.equalsIgnoreCase("Comparison"))
			{
				s_qry_string +="&er_commonMax="+strCommonMax+"&er_commonMaxRange="+strCommonMaxRangeValue+"&er_AutoCommonMax="+strAutoCommonMax; 
			}

			String trgttype = request.getParameter("er_trgttype");
			boolean showTop = true;
			String st_day="";
			String end_day="";
			if(trgttype!=null && trgttype.equals("CitrixUser"))
				showTop= false;
			if(showTop)
			{
				EgDbAdapterR egDb = ErDbServer.getObject();
				EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
				boolean portReleventForTest = specsInfo.isPortRelevantForTest(erd.s_test);
				boolean siteReleventForTest = specsInfo.isSiteRelevantForTest(erd.s_test);
				if(er_timeline!=null&&!er_timeline.equals("Any"))
				{
					st_day=DateUtil.changeDateFormat(s_st_time,"MM/dd/yyyy","dd/MM/yyyy");
					end_day=DateUtil.changeDateFormat(s_en_time,"MM/dd/yyyy","dd/MM/yyyy");
				}
				else
				{
					st_day=DateUtil.changeDateFormat(s_st_time,"MM/dd/yyyy","dd/MM/yyyy");
					end_day=DateUtil.changeDateFormat(s_en_time,"MM/dd/yyyy","dd/MM/yyyy");
				}
				erd.range_stdate=st_day+" "+s_st_hr+ ":"+startMins+":00";
				erd.range_enddate=end_day+" "+s_en_hr+ ":"+endMins+":00";
				strStartTime =st_day+" "+s_st_hr+ ":"+startMins+":00";
				strEndTime =end_day+" "+s_en_hr+ ":"+endMins+":00";
				try
				{
					egDb.set_Connection();
					if (erd.s_tbound.equalsIgnoreCase("Fixed") || erd.s_tbound.equalsIgnoreCase("Any") && erd.s_stdate!=null && erd.s_enddate!=null)
					{
						egDb.dbsel(egDb.buildInfoDetails(erd,portReleventForTest,siteReleventForTest));
						if(egDb.rs.next())
						{
							count = egDb.rs.getInt(1);
							d_min = egDb.rs.getDouble(2);
							d_max = egDb.rs.getDouble(3);
						}
					}
				}catch(Exception e){
					System.out.println("Info "+e);
				}
				egDb.release_Connection(false);
				ErDbServer.releaseObject(egDb);
				showFilter = Math.min(5,maxInfo)<count;
				if (s_priority == null || s_priority.equals(""))
				{
					if(maxInfo < count)
					{
						//s_priority="TOP-" + maxInfo;
						EgThresholdInfo threshInfo = new EgThresholdInfo("manager");
						port = portReleventForTest?erd.s_port:"NULL";
						if(erd.s_dataFrom!=null && erd.s_dataFrom.equalsIgnoreCase("Service"))
						{
							//EgDbInfo dbInfo=new EgDbInfo("manager");
							String temp_measure=dbInfo.getMeasureForColumn(erd.s_test,erd.s_disp_meas);
							if(temp_measure!=null && !temp_measure.equals(""))
								erd.s_disp_meas=temp_measure;
						}
						String s_thresh[]= threshInfo.getThresholdAttributes(erd.s_test,erd.s_disp_meas,erd.s_host,port + (erd.s_info!=null && !erd.s_info.equals("")?":" + erd.s_info:""));
						s_priority = "TOP-" + maxInfo;
						if(!s_thresh[1].equals("-1") && s_thresh[2].equals("-1"))
							s_priority = "LAST-" + maxInfo;
					}
					else
					{
						s_priority = "ALL";
					}
				}

				if("RANGE".equalsIgnoreCase(request.getParameter("er_filter")))
				{
					s_qry_string += "&er_range_min=" + s_min + "&er_range_max=" + s_max;
				}
				else
				{
					s_qry_string += "&er_priority=" + s_priority;
				}
			}
		}
		else if(erd.s_gtype != null && erd.s_gtype.equalsIgnoreCase("Summary"))
		{
			s_qry_string = s_control_servlet + "ErSummaryC?" + sb;


		}
		else if(erd.s_gtype != null && erd.s_gtype.equalsIgnoreCase("intrasnap"))
		{
			if (s_priority == null || s_priority.equals(""))
			{
				EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
				boolean portReleventForTest = specsInfo.isPortRelevantForTest(erd.s_test);
				if(maxInfo < count)
				{
					//s_priority="TOP-" + maxInfo;
					EgThresholdInfo threshInfo = new EgThresholdInfo("manager");
					port = portReleventForTest?erd.s_port:"NULL";
					if(erd.s_dataFrom!=null && erd.s_dataFrom.equalsIgnoreCase("Service"))
					{
						//EgDbInfo dbInfo=new EgDbInfo("manager");
						String temp_measure=dbInfo.getMeasureForColumn(erd.s_test,erd.s_disp_meas);
						if(temp_measure!=null && !temp_measure.equals(""))
							erd.s_disp_meas=temp_measure;
					}
					String s_thresh[]= threshInfo.getThresholdAttributes(erd.s_test,erd.s_disp_meas,erd.s_host,port + (erd.s_info!=null && !erd.s_info.equals("")?":" + erd.s_info:""));
					s_priority = "TOP-" + maxInfo;
					if(!s_thresh[1].equals("-1") && s_thresh[2].equals("-1"))
						s_priority = "LAST-" + maxInfo;
				}
				else
				{
					s_priority = "ALL";
				}
			}
		}

		/*	if(erd.s_gtype !=null && erd.s_gtype.equalsIgnoreCase("Comparison")){
			s_qry_string = s_control_servlet + "ErCompareServersC?" + sb;
		}*/

		if(erd.s_gtype !=null && (erd.s_gtype.equalsIgnoreCase("interSnap")||erd.s_gtype.equalsIgnoreCase("intrasnap")||erd.s_gtype.equalsIgnoreCase("Citrix")))
		{
			s_qry_string = s_control_servlet + "ErSnapshotC?" + sb;

		}
		Vector v_qry_string = new Vector();
		Vector v_pdf_qry = new Vector();

		String st_component = erd.s_component;
		String st_comp ="";
		String st_comptype ="";
		
		if(st_component == null)
		{
			st_component = request.getParameter("er_component");
		}
		if(st_component!=null && st_component.indexOf(":")>-1)
		{
			st_comp = st_component.substring(0,st_component.lastIndexOf(":"));
			if(st_comp.indexOf(":NULL") >-1) {
				st_comp = st_comp.substring(0,st_comp.indexOf(":"));
			}
			st_comptype = st_component.substring(st_component.lastIndexOf(":")+1);
			st_component = st_comp+":"+mappingInfo.getComponentTypeDescription(st_comptype);
		}
		String s_mes_unit = "";
		if(erd.s_test != null && erd.s_disp_meas != null)
		{
			if (erd.s_test.endsWith("_trend"))
			{
				erd.s_test=erd.s_test.substring(0,erd.s_test.lastIndexOf("_"));
				erd.s_measure=erd.s_measure.substring(0,erd.s_measure.lastIndexOf("_"));
			}
			s_mes_unit = tablesInfo.getUnitForMeasure(erd.s_test,erd.s_disp_meas);
		}
		if(erd.s_gtype!=null && erd.s_gtype.equalsIgnoreCase("Comparison"))
		{
			if(er_nick!= null && er_nick.length()>0 && !er_nick.equalsIgnoreCase("null"))
			{
				v_qry_string.add(er_nick);
				v_pdf_qry.add(er_nick);
			}
			else if(erd.s_component!=null)
			{
				v_qry_string.add(erd.s_component);
				v_pdf_qry.add(st_component);
			}
		}
		else
		{
			v_qry_string.add(erd.s_test + "/" + erd.s_disp_meas + " (" + s_mes_unit + ")");
			v_pdf_qry.add(mappingInfo.getTestDescription(erd.s_test) + "/" + mappingInfo.getMeasureDescription(erd.s_test,erd.s_disp_meas) + " (" + s_mes_unit + ")");
		}
		//s_qry_string += "&er_priority=" + s_priority;
		v_qry_string.add(s_qry_string);
		//v_pdf_qry.add(s_serv_pdf + s_qry_string+"&option=graph&er_legendPosition=right");
		String fontStyleDbl = "";
		String fontStyleDblSingl = "";
		if((dbInfo.doubleByteEnabled || !thisuser.getLanguage().equals("en_US")) && !(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes") || (sample != null && !sample.equalsIgnoreCase("yes") && drilldownenabled !=null && drilldownenabled.equalsIgnoreCase("yes"))))
		{
			fontStyleDbl = " multi_font";
			fontStyleDblSingl = "multi_font";
		}
		else
		{
			fontStyleDbl = "";
			fontStyleDblSingl = "";
		}

		pageParams.put("pdfPrint",pdfPrint);
		if(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes"))
		{
			pageParams.put("pageTitle",mappingInfo.getTextDescription("reporter.common.Reporter")+" - "+mappingInfo.getTextDescription("reporter.common.Measure"));
		}

		pageParams.put("fontStyle",fontStyleDblSingl);

		String option = request.getParameter("option");

		

		if(er_rtype1!=null && (er_rtype1.equals("SnapShot") ||  er_rtype1.equals("server")))
		{
			sbHiddenQStr.append("&er_gtype=intrasnap");	
		}
		else if(gtype!=null && !gtype.equals(""))
		{
			sbHiddenQStr.append("&er_gtype="+gtype);	
		}
		else
		{
			sbHiddenQStr.append("&er_gtype=");
		}

		if(er_rtype1!=null)
			sbHiddenQStr.append("&er_rtype="+er_rtype1);
		else
			sbHiddenQStr.append("&er_rtype=");

		sbHiddenQStr.append("&er_period="+request.getParameter("er_period"));
		sbHiddenQStr.append("&er_timeline_change=");
		sbHiddenQStr.append("&enlarged="+request.getParameter("enlarged"));
		if(request.getParameter("hasMultipleHosts") != null)
			sbHiddenQStr.append("&hasMultipleHosts="+request.getParameter("hasMultipleHosts"));
		if(request.getParameter("er_hostNames") != null)
			sbHiddenQStr.append("&er_hostNames="+request.getParameter("er_hostNames"));

		String er_chartcolor = request.getParameter("er_chartcolor");
		if(er_chartcolor!=null)
			sbHiddenQStr.append("&er_chartcolor="+er_chartcolor);
		else
			sbHiddenQStr.append("&er_chartcolor=");

		if(er_graphtype!=null)
			sbHiddenQStr.append("&er_graphtype="+er_graphtype);
		else
			sbHiddenQStr.append("&er_graphtype=");

		sbHiddenQStr.append("&er_test="+request.getParameter("er_test"));

		sbHiddenQStr.append("&er_disp_meas="+request.getParameter("er_disp_meas"));
		sbHiddenQStr.append("&er_measure="+request.getParameter("er_measure"));
		if(!isComponentCombo)
			sbHiddenQStr.append("&er_component="+request.getParameter("er_component"));
		if(isKpiHealthReport != null && !isKpiHealthReport.equalsIgnoreCase(""))
			sbHiddenQStr.append("&isKpiHealthReport="+isKpiHealthReport);
		//
		/*String [] er_seleArr=request.getParameterValues("er_selection");
		for(int i=0;i<er_seleArr.length;i++)
		{
		sbHiddenQStr.append("&er_selection="+er_seleArr[i]);
		}*/

		Map ParamMap = request.getParameterMap();
		if(ParamMap!=null && ParamMap.size()>0){
			Iterator itr = ParamMap.keySet().iterator();
			while(itr.hasNext()){
				String map_key = (String)itr.next();
				if(map_key.equalsIgnoreCase("er_selection")){
					Object obj_val = ParamMap.get(map_key);
						String map_value ="";
					if(obj_val instanceof String[]){
						String [] er_seleArr = (String[])ParamMap.get(map_key);
						for(int i=0;i<er_seleArr.length;i++)
							{
								sbHiddenQStr.append("&er_selection="+com.eg.EgURLEncoder.encode(er_seleArr[i],"UTF-8"));
							}
					}else
					{
						map_value = (String)ParamMap.get(map_key);
						sbHiddenQStr.append("&er_selection="+com.eg.EgURLEncoder.encode(map_value,"UTF-8"));
					}
					break;
				}
				
			}
		}
		//
		if(er_nick!=null)
			sbHiddenQStr.append("&er_nick="+er_nick);
		else
			sbHiddenQStr.append("&er_nick=");

		//if(option!=null)
			//sbHiddenQStr.append("&option="+option);
		//else
			//sbHiddenQStr.append("&option=");

		sbHiddenQStr.append("&er_site="+request.getParameter("er_site"));

		if(select_farm!=null)
			sbHiddenQStr.append("&select_farm="+select_farm);
		else
			sbHiddenQStr.append("&select_farm=");

	//	sbHiddenQStr.append("&snaptime="+request.getParameter("snaptime"));
		sbHiddenQStr.append("&er_graph="+request.getParameter("er_graph"));

		if(s_trenddata!=null)
			sbHiddenQStr.append("&er_trenddata="+s_trenddata);
		else
			sbHiddenQStr.append("&er_trenddata=");

		sbHiddenQStr.append("&er_dataFrom="+request.getParameter("er_dataFrom"));
		sbHiddenQStr.append("&er_service="+request.getParameter("er_service"));
		sbHiddenQStr.append("&drilldownenabled="+request.getParameter("drilldownenabled"));
		sbHiddenQStr.append("&er_user="+request.getParameter("er_user"));
		sbHiddenQStr.append("&er_excwe="+request.getParameter("er_excwe"));
		sbHiddenQStr.append("&timefrom="+request.getParameter("timefrom"));
		sbHiddenQStr.append("&timeto="+request.getParameter("timeto"));
		sbHiddenQStr.append("&minfrom="+request.getParameter("minfrom"));
		sbHiddenQStr.append("&minto="+request.getParameter("minto"));
		sbHiddenQStr.append("&er_trgttype="+request.getParameter("er_trgttype"));

		sbHiddenQStr.append("&er_comptype="+request.getParameter("er_comptype"));
		sbHiddenQStr.append("&currTime="+request.getParameter("currTime"));
		sbHiddenQStr.append("&er_muser="+request.getParameter("er_tuser"));
		sbHiddenQStr.append("&inidate="+currentDateFormat);
		sbHiddenQStr.append("&userID="+request.getParameter("userID"));
		sbHiddenQStr.append("&er_commonMax="+strCommonMax);
		sbHiddenQStr.append("&er_commonMaxRange="+strCommonMaxRangeValue);
		sbHiddenQStr.append("&er_AutoCommonMax="+strAutoCommonMax);
		
		sbHiddenQStr.append("&getMaxDaysInMonth="+ErUtils.getMaxDaysInMonth());
		sbHiddenQStr.append("&er_msmthost="+request.getParameter("er_msmthost"));
		sbHiddenQStr.append("&reportName=ErMeasure");
		sbHiddenQStr.append("&isOnlyVMAssigned="+isOnlyVMAssigned);
		sbHiddenQStr.append("&select_vm="+request.getParameter("select_vm"));
		sbHiddenQStr.append("&isFromAlarmHistory="+isFromAlarmHistory);
		if(s_trenddata != null && s_trenddata.equalsIgnoreCase("yes")){
			sbHiddenQStr.append("&er_duration="+request.getParameter("er_duration"));
			sbHiddenQStr.append("&er_trendGraphType="+request.getParameter("er_trendGraphType"));
		}

		hiddenParams.put("getMaxDaysInMonth",String.valueOf(ErUtils.getMaxDaysInMonth()));
		

		pageParams.put("d_min",String.valueOf(d_min));

		pageParams.put("d_max",String.valueOf(d_max));

		

		if(isFromAlarmHistory!=null && (isFromAlarmHistory.equalsIgnoreCase("true") || isFromAlarmHistory.equalsIgnoreCase("Yes"))&& request.getParameter("info_list")!=null)
		{
			info=request.getParameter("info_list");
		}
		if(info != null)
		{
	//		sbHiddenQStr.append("er_info_list",info);
			hiddenParams.put("er_info_list",info);
		}

		String strer_info= request.getParameter("er_infos");
		if(strer_info != null)
		{
			sbHiddenQStr.append("&er_infos="+strer_info);
		//	hiddenParams.put("er_infos",strer_info);
		}

		String s_qryString = "";
		String Qstring="";
	
		if(!v_qry_string.isEmpty())
		{
		for(int j=0;j < v_qry_string.size();j=j+2)
		{
			s_qryString = (String)v_qry_string.get(j+1);
			if(s_qryString!=null)
			{
				StringTokenizer strtok = new StringTokenizer(s_qryString,"&");
				while(strtok.hasMoreTokens())
				{
					String param = strtok.nextToken();
					//param=java.net.URLDecoder.decode(param);
					if(param.indexOf("=")>-1)
					{
						String reqparam =param.substring(0,param.indexOf("="));
						String value = param.substring(param.indexOf("=")+1,param.length());
						if(reqparam.equals("er_component"))
						{
							value=request.getParameter("er_component");
						}
						if(er_graphtype != null && er_graphtype.equalsIgnoreCase("single"))
						{
							if(reqparam!=null && reqparam.equalsIgnoreCase("er_width"))
								value="450";
							if(reqparam!=null && reqparam.equalsIgnoreCase("er_height"))
								value="200";
						}
						if(request.getParameter("er_gtype") != null && request.getParameter("er_gtype").equalsIgnoreCase("Summary"))
						{
							if(reqparam!=null && reqparam.equalsIgnoreCase("er_width"))
								value="350";
							if(reqparam!=null && reqparam.equalsIgnoreCase("er_height"))
								value="350";
						}
						if(reqparam.equals("info_list"))
							continue;

						if(reqparam.equals("er_info_list") || reqparam.equals("select_vm") )
						{
							value=request.getParameter(reqparam);
							if( value != null)
							{
								try {
									if(value.indexOf("+")>-1){
									value=StringUtils.replace(value,"+","|plus|");
								} if (value.indexOf("&")>-1){
									value=StringUtils.replace(value,"&","|amp|");
								} if (value.indexOf("%")>-1){
									value=StringUtils.replace(value,"%","|pct|");
								} if (value.indexOf("#")>-1){
									value=StringUtils.replace(value,"#","|hash|");
								}
									value = java.net.URLDecoder.decode(value);
								} catch (Exception e1) {e1.printStackTrace();}
							}
						}
						if(reqparam!=null && ( reqparam.equals("comptypes") || reqparam.equals("toScrpText") || reqparam.equals("measures") || reqparam.equals("er_selection") || reqparam.equals("er_combination") || reqparam.equals("hiddens") || reqparam.equals("infos") || reqparam.equals("tests") || reqparam.equals("servers")))
						{
							value=com.eg.EgURLEncoder.encode(value, "UTF-8");
						}
						if (reportFor!=null && reportFor.equalsIgnoreCase("CompareGraph"))
						{
							Qstring=Qstring+reqparam+"="+value+"&";
						}
						else
						{
							Qstring=Qstring+reqparam+"="+EgURLEncoder.encode(value,"UTF-8")+"&";
						}
					}else
						Qstring=Qstring+param+"&";
				}
			}
			v_pdf_qry.add(s_serv_pdf+Qstring+"&option=graph&er_legendPosition=right");

			if(!(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes") || (sample != null && !sample.equalsIgnoreCase("yes") && drilldownenabled !=null && drilldownenabled.equalsIgnoreCase("yes"))))
			{
				pageParams.put("downloadedLogo",imageName);
			}
			String mainPageTitle = "";
			if(erd.s_gtype != null && erd.s_gtype.equalsIgnoreCase("Comparison"))
			{
				mainPageTitle = erd.s_gtype+" "+mappingInfo.getTextDescription("reporter.common.report for")+" "+st_component;
			}
			else if(erd.s_gtype != null && (erd.s_gtype.equalsIgnoreCase("interSnap")||erd.s_gtype.equalsIgnoreCase("intrasnap")))
			{
				String hasMultipleHosts=request.getParameter("hasMultipleHosts");
				String er_hostNames=request.getParameter("er_hostNames");
				String trgttype=request.getParameter("er_trgttype");
				if(hasMultipleHosts != null && hasMultipleHosts.equalsIgnoreCase("true") && er_hostNames != null && !er_hostNames.equalsIgnoreCase(""))
					er_hostNames=StringUtils.replace(er_hostNames,"|",", ");
				else
					er_hostNames=st_component;

				if (trgttype==null)
				{
					if(!isComponentCombo)
						mainPageTitle = mappingInfo.getTextDescription("reporter.common."+er_RmDispName)+" - "+er_hostNames;
					else
						mainPageTitle = mappingInfo.getTextDescription("reporter.common."+er_RmDispName);
				}
				else
				{
					if(isOnlyVMAssigned!=null && isOnlyVMAssigned.equalsIgnoreCase("true"))
					{
						mainPageTitle = mappingInfo.getTextDescription("reporter.common. Report for VM:")+" "+info;
					}
					else
					{
						if(!isComponentCombo)
							mainPageTitle = mappingInfo.getTextDescription("reporter.common.Measurement Graph for")+" "+st_component;
						else
							mainPageTitle = mappingInfo.getTextDescription("reporter.common.Measurement Graph");
					}
				}
			}//new code for snapshot
			else if ("Micro".equalsIgnoreCase(er_rtype1) && "CitrixUser".equalsIgnoreCase(request.getParameter("er_trgttype")))
			{
				compType = request.getParameter("er_comptype");
				er_info = request.getParameter("er_user");
				if(er_info == null)
				{
					er_info = request.getParameter("er_tuser");
				}
				mainPageTitle = mappingInfo.getTextDescription("reporter.common."+er_RmDispName)+" - "+st_component;
			}
			else if("User Report".equalsIgnoreCase(request.getParameter("er_trgttype")))
			{
				mainPageTitle = mappingInfo.getTextDescription("reporter.common."+er_RmDispName)+" - "+request.getParameter("select_farm")+" "+mappingInfo.getTextDescription("reporter.measure.User")+" - "+request.getParameter("er_user");
			}
			else
			{
				if(erd.s_rtype!=null)
				{
				mainPageTitle = mappingInfo.getTextDescription("reporter.common."+er_RmDispName)+" - "+mappingInfo.getTextDescription("reporter.common."+erd.s_rtype)+" - "+st_component;
				}
				else
				{
					mainPageTitle = mappingInfo.getTextDescription("reporter.common."+er_RmDispName)+" - "+st_component;
				}
			}
			screenLabels.put("mainPageTitle",mainPageTitle);
			if(!"yes".equalsIgnoreCase(fromPrintPage))
			{
				if(!("yes".equalsIgnoreCase(request.getParameter("er_timeline_change"))))
				{
					pageParams.put("pdfUrl",Qstring+"&print=yes&is_pdf=yes");
				}
			}
			if(erd.s_gtype !=null)
			{
				//String pdfPrint = request.getParameter("pdfPrint");
				if(!("yes".equalsIgnoreCase(request.getParameter("er_timeline_change"))))
				{
					pageParams.put("printPageUrl",Qstring+"&print=yes");
					pageParams.put("dataPageUrl",Qstring+"&option=data");

					String s_test=erd.s_test;
					String s_measure =erd.s_disp_meas;
					if(erd.s_dataFrom!=null && erd.s_dataFrom.equalsIgnoreCase("Service"))
					{
						//EgDbInfo dbInfo=new EgDbInfo("manager");
						s_measure=dbInfo.getMeasureForColumn(s_test,s_measure);
					}
					if(testBean.isDdEnabled(s_test,s_measure))
					{
						String s_site = erd.s_site;
						if (s_site ==null || s_site.length()==0 || s_site.equals("null") || s_site.equals("NONE") )
							s_site ="NULL";
						String reporttype=request.getParameter("reporttype");
						if(reporttype!=null && reporttype.equals("operation"))
						{
							//String er_rtype=request.getParameter("er_rtype");
							if(er_rtype1!=null && (er_rtype1.equals("Application")||er_rtype1.equalsIgnoreCase("System")||er_rtype1.equalsIgnoreCase("Network")))
							{
								s_site ="NULL";
							}
						}
						
						String s_component = erd.s_component;
						String s_info =request.getParameter("er_info_list");
						if(s_info!=null && !s_info.equals(""))
							s_info=EgURLEncoder.encode(s_info,"UTF-8");
						if (s_info==null || s_info.equals("")|| s_info.equals("null"))
						{
							String strStartTimeTmp = strStartTime;//DateUtil.changeDateFormat(strStartTime,"MM/dd/yyyy","dd/MM/yyyy");
							String strEndTimeTemp = strEndTime;//DateUtil.changeDateFormat(strEndTime,"MM/dd/yyyy","dd/MM/yyyy");
							Vector v_infos=erInfo.getInfosForTest(s_site,s_test,s_component,strStartTimeTmp,strEndTimeTemp,s_measure,"",s_trenddata,s_priority,maxInfo);
							if (v_infos!=null && v_infos.size()>0)
							{
								for (int m=0;m<v_infos.size();m++)
								{
									String s1=(String)v_infos.get(m);
									if (m==0)
									{
										s_info=s1.substring(s1.indexOf("+"));
									}
									else
									{
										s_info+="|"+s1.substring(s1.indexOf("+"));
									}
								}
							}
						}

						boolean isSnapshot =(erd.s_gtype !=null && (erd.s_gtype.equalsIgnoreCase("interSnap")||erd.s_gtype.equalsIgnoreCase("intrasnap")));

						if(isSnapshot && (s_info==null || s_info.length()==0))
							s_info = "|";

						if(s_info!=null && s_info.length()>0 && !s_info.equals("null"))
						{
							if(s_info.indexOf("|")>-1)
							{
								s_info=s_info.substring(0,s_info.indexOf("|"));
							}
						if(s_info.length()>0 && s_info.charAt(0)=='+')
							if(s_info.length() > 1 )
							{
								s_info = s_info.substring(1);
							}
							else
							{
								s_info="";
							}
							s_info = (erd.s_info==null?"":erd.s_info) + "*" +s_info;
						}
						else
						{
							StringTokenizer st=new StringTokenizer(s_component,":");
							if (st.countTokens()>3)
							{
								st.nextToken();
								st.nextToken();
								s_info=st.nextToken()+"*";
							}
							else
							{
								s_info="*";
							}
						}

						String s_sdate=erd.s_stdate;
						String s_shr=erd.s_sthr;
						String s_edate=erd.s_enddate;
						String s_ehr=erd.s_endhr;
						String  tmpComp=s_component;
						String strTempCompType = "";
						if(erd.s_comp_type != null)
							strTempCompType=erd.s_comp_type;
						if (tmpComp!=null && tmpComp.indexOf(":")>-1)
							tmpComp = s_component.substring(0,s_component.indexOf(":"));
						//modified on 16/11/07 stalin to display DD page
//						if (s_component!=null && s_component.lastIndexOf(":")>-1)
//							strTempCompType = s_component.substring(s_component.lastIndexOf(":")+1);
						if(s_component.indexOf(":") > 0 && s_component.lastIndexOf(":") > 0)
						{
							int firstIndex = s_component.indexOf(":");
							if(s_component != null && s_component.indexOf(":",firstIndex+1) > -1){
								strTempCompType=s_component.substring(s_component.lastIndexOf(":")+1);
								port = s_component.substring(firstIndex+1, s_component.indexOf(":",firstIndex+1));
							}
							else
								port = s_component.substring(firstIndex+1);
						}
						if(s_component.indexOf(":") > 0)
						{
							s_component = s_component.substring(0,s_component.indexOf(":"));
						}
						if(port == null || port.equals(""))
						{
							port = "NULL";
						}
						if(s_info != null && !s_info.trim().startsWith("*"))
							s_info="*"+s_info;
						String s_infovalue="";
						String servertype=request.getParameter("er_trgttype");
						System.out.println("servertype    "+servertype);
						/*if(servertype!=null && servertype.trim().equalsIgnoreCase("Server Report"))
							s_infovalue=s_info;
						else*/
						s_infovalue=EgURLDecoder.decode(s_info,"UTF-8");
						String mhost="";
						if(eSpec.isExternalTest(s_test,strTempCompType))//to ensure whether mgmt_host coming with info or not
						{
							if (s_infovalue!=null && s_infovalue.lastIndexOf("(") >-1 && s_infovalue.lastIndexOf(")") >-1 )
							{
								mhost=s_infovalue.substring(s_infovalue.lastIndexOf("(")+1,s_infovalue.lastIndexOf(")"));
								s_infovalue=s_infovalue.substring(0,s_infovalue.lastIndexOf("("));
							} 
						}
						if(request.getParameter("er_option")!=null)
						{
							String er_opt=request.getParameter("er_option");
							if(er_opt.equalsIgnoreCase("Group") || er_opt.equalsIgnoreCase("Segment") || er_opt.equalsIgnoreCase("Zone") )
								s_site="";
						}
						if(s_test.equalsIgnoreCase("JvmThreadTest"))
						{
							String strComponent = erd.s_component;
							Vector v_infos = erInfo.getMsmtHostForGraph(s_site,s_test,strComponent);
							if(v_infos!=null && v_infos.size() >0 )
								mhost = (String)v_infos.get(0);
						}
						if(s_infovalue.indexOf("\\")>-1)
						{
							s_infovalue = StringUtils.replace(s_infovalue,"\\","\\\\");
						}	
						String tempTimeline = "Any";

						String infoValuesTmp=s_infovalue;
						if(infoValuesTmp != null && infoValuesTmp.indexOf("|") > -1){
							infoValuesTmp=infoValuesTmp.substring(infoValuesTmp.lastIndexOf("|")+1);							
						}
						if(infoValuesTmp != null)
							infoValuesTmp=com.egurkha.util.StringUtils.replace(infoValuesTmp,"\\\\","\\");
						if(infoValuesTmp!=null && infoValuesTmp.startsWith("*"))
						{
							infoValuesTmp = infoValuesTmp.substring(1);
						}
						String _infosVal = EgURLEncoder.encode(infoValuesTmp,"UTF-8");
						if(infoValuesTmp.indexOf("*")==-1)
						{
							if(strTempCompType!=null && strTempCompType.equalsIgnoreCase("Oracle_server"))
								_infosVal = EgURLEncoder.encode(infoValuesTmp,"UTF-8");
							else
								_infosVal = "*"+EgURLEncoder.encode(infoValuesTmp,"UTF-8");							
						}
						//for DD timeline issue - check
						String starttime_temp = request.getParameter("startdate");
						String enddate_temp = request.getParameter("enddate");
						String comFormat_temp ="";
						//for starttime
						if(DateUtil.isDate(starttime_temp,"MM/dd/yyyy"))
						{
							comFormat_temp = "MM/dd/yyyy";
						}
						else
						{
							comFormat_temp = currentDateFormat;
						}
						String disp_startDate_temp = 	DateUtil.changeDateFormat(starttime_temp,comFormat_temp,currentDateFormat);
						starttime_temp = disp_startDate_temp;
						
						//for endtime
						if(DateUtil.isDate(enddate_temp,"MM/dd/yyyy"))
						{
							comFormat_temp = "MM/dd/yyyy";
						}
						else
						{
							comFormat_temp = currentDateFormat;
						}
						String disp_endDate_temp = 	DateUtil.changeDateFormat(enddate_temp,comFormat_temp,currentDateFormat);
						enddate_temp = disp_endDate_temp;
						//
						String dd_url = "/final/monitor/componentMeasureTabSet.jsp?type="+EgURLEncoder.encode(strTempCompType,"UTF-8")+"&site="+site+"&host="+EgURLEncoder.encode(s_component,"UTF-8")+"&port="+port+"&info="+_infosVal+"&starttime="+starttime_temp+"&endtime="+enddate_temp+"&starthr="+s_shr+"&endhr="+ s_ehr+"&startmin="+request.getParameter("startmin")+"&endmin="+request.getParameter("endmin")+"&state=&messy="+s_measure+"&msmt_host="+EgURLEncoder.encode(mhost,"UTF-8")+"&userID="+EgURLEncoder.encode(urs,"UTF-8")+"&test="+ s_test+"&comptype="+strTempCompType+"&measureDisp="+s_measure+"&from=measurespage&dd=yes&clicked=dd&newWindow=true&fromReporterHis=true&popup=true&fromPage=eveHist&isVM="+isOnlyVMAssigned;

						StringBuffer key = new StringBuffer(32);
						key.append(s_test);
						key.append(":");
						key.append(s_measure);
						String tm = key.toString();
						String disInfo = egFormat.getValue("Tests_For_DDWithoutInfos",tm);
						if(disInfo!=null && disInfo.equalsIgnoreCase("Yes"))
						{
							s_infovalue = "+";
						}
						else
						{
							if(s_infovalue!=null)
							{
								if(s_infovalue.indexOf("+")>-1)
								{
									s_infovalue=com.egurkha.util.StringUtils.replace(s_infovalue,"+","|plus|");
								}
								if(s_infovalue.indexOf("&")>-1)
								{
									s_infovalue=com.egurkha.util.StringUtils.replace(s_infovalue,"&","|amp|");
								}
								if(s_infovalue.indexOf("%")>-1)
								{
									s_infovalue=com.egurkha.util.StringUtils.replace(s_infovalue,"%","|pct|");
								}
								if(s_infovalue.indexOf("#")>-1)
								{
									s_infovalue=com.egurkha.util.StringUtils.replace(s_infovalue,"#","|hash|");
								}
								if(s_infovalue.indexOf("*")>-1)
								{
									int numChar=s_infovalue.length();
									char[] charArray=new char[numChar];
									s_infovalue.getChars(0, numChar, charArray,0);
									for(int i=0;i<charArray.length;i++)
									{
										if(charArray[i]=='*')
										{
											charArray[i]='+';
											break;
										}
									}
									s_infovalue = new String(charArray);
								}
							}
						}					
						pageParams.put("ddPageUrl",dd_url);
						/*
						if(dd.ShowDDData(s_site,s_component,s_test,s_measure,s_infovalue,mhost))
						{
							pageParams.put("ddPageUrl",dd_url);
						}
						else
						{
							pageParams.put("ddPageUrl","-");
						}
						*/
					}
					else
					{
						pageParams.put("ddPageUrl","-");
					}
				}

				String tgttype=request.getParameter("er_trgttype");
				if(erd.s_rtype!=null && erd.s_rtype.equalsIgnoreCase("Micro") && tgttype!=null && tgttype.equalsIgnoreCase("CitrixUser"))
				{
					String temp_user = request.getParameter("er_user");
					if(temp_user == null)
					{
						temp_user = request.getParameter("er_tuser");
					}

					screenLabels.put("subTitle",mappingInfo.getTextDescription("reporter.common.Farm")+" - "+request.getParameter("select_farm")+" "+mappingInfo.getTextDescription("reporter.common.User")+" - "+temp_user);
				}
				else if(!(erd.s_gtype!=null && erd.s_gtype.equalsIgnoreCase("comparison")) )
				{
					String trgttyppe=request.getParameter("er_trgttype");
					if(trgttyppe==null || trgttyppe.equals(""))
					{
						if("yes".equalsIgnoreCase(fromPrintPage))
						{
							screenLabels.put("subTitle",mappingInfo.getTextDescription("reporter.common.Report Type")+" : "+mappingInfo.getTextDescription("reporter.common."+erd.s_gtype));
						}
					}
					else
					{
						if("yes".equalsIgnoreCase(fromPrintPage))
						{
							String reporttype="";
							String servertype=request.getParameter("er_trgttype");
							if(servertype!=null &&   servertype.trim().equalsIgnoreCase("Server Report"))
								reporttype="Consolidated";
							else if(gtype.equalsIgnoreCase("Measure")|| gtype.equalsIgnoreCase("Trend"))
								reporttype="Operation Measure";
							else if(gtype.equalsIgnoreCase("Summary"))
								reporttype="Operation Summary";
							else
							reporttype="Citrix";
							if(isOnlyVMAssigned==null || isOnlyVMAssigned.equalsIgnoreCase("false"))
							{
									screenLabels.put("subTitle",mappingInfo.getTextDescription("reporter.common.Report Type")+" : "+reporttype);

							}
						}
					}
				}

				if("yes".equalsIgnoreCase(fromPrintPage))
				{
					String d1="";
					String d2="";
					String startdate = request.getParameter("startdate");
					String enddate  = request.getParameter("enddate");
					String starthr  = request.getParameter("starthr");
					String endhr    = request.getParameter("endhr");
					String startmin = request.getParameter("startmin");
					String endmin   = request.getParameter("endmin");
					startdate = startdate==null ? "" : URLDecoder.decode(startdate);
					enddate = enddate==null ? " " : URLDecoder.decode(enddate);
					d1 = startdate + " " + starthr + ":" + startmin + " Hrs";
					d2 = enddate + " " + endhr + ":" + endmin + " Hrs";

					screenLabels.put("startDateEndDateTitle",mappingInfo.getTextDescription("reporter.common.Start Date")+" : "+d1+"    "+mappingInfo.getTextDescription("reporter.common.End Date")+" : "+d2);
				}
				String showFilterOption = "No";
				if( showFilter && !"yes".equalsIgnoreCase(fromPrintPage))
				{
					showFilterOption = "Yes";
					if(s_filter.equalsIgnoreCase("RANGE"))
					{
						pageParams.put("selectedFilterOption","Range");
					}
					else
					{
						pageParams.put("selectedFilterOption","DescriptorPriority");
					}
				//	screenLabels.put("reporter.common.Descriptor",mappingInfo.getTextDescription("reporter.common.Descriptor"));
					screenLabels.put("reporter.common.Range",mappingInfo.getTextDescription("reporter.common.Range"));
					screenLabels.put("reporter.common.To",mappingInfo.getTextDescription("reporter.common.To"));
					screenLabels.put("reporter.common.Detailed Diagnosis",mappingInfo.getTextDescription("reporter.common.Detailed Diagnosis"));

					pageParams.put("s_min",s_min);
					pageParams.put("s_max",s_max);

					JSONArray descriptorPriorityFilterOptions = new JSONArray();

					int k = 1;
					for(;k<=10; k++)
					{
						if(count-1<k)break;

						JSONObject jObj = new JSONObject();
						jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.TOP")+" - "+k);
						jObj.put("valueField","TOP-"+k);

						descriptorPriorityFilterOptions.add(jObj);
					}
					if(maxInfo >10 && maxInfo < count && s_priority.startsWith("TOP"))
					{
						JSONObject jObj = new JSONObject();
						jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.TOP")+" - "+maxInfo);
						jObj.put("valueField",s_priority);

						descriptorPriorityFilterOptions.add(jObj);
					}

					JSONObject jObj1 = new JSONObject();
					jObj1.put("displayField",mappingInfo.getTextDescription("reporter.common.ALL"));
					jObj1.put("valueField","ALL");

					descriptorPriorityFilterOptions.add(jObj1);

					if(maxInfo >10 && maxInfo < count && s_priority.startsWith("LAST"))
					{
						JSONObject jObj = new JSONObject();
						jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.LAST")+" - "+maxInfo);
						jObj.put("valueField",s_priority);
						descriptorPriorityFilterOptions.add(jObj);
					}
					for(k--;k>0; k--)
					{
						JSONObject jObj = new JSONObject();
						jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.LAST")+" - "+k);
						jObj.put("valueField","LAST-"+k);
						descriptorPriorityFilterOptions.add(jObj);
					}
					if(s_priority!=null)
						pageParams.put("selectedDescriptorPriorityOption",s_priority);
					else
						pageParams.put("selectedDescriptorPriorityOption","-");

					json.put("descriptorPriorityFilterOptions",descriptorPriorityFilterOptions);
				}
				pageParams.put("showFilter",showFilterOption);
				pageParams.put("showLegend",showLegend);
			
				String showDescriptorFilterList ="No";
				String showMinutes = "No";
				if(erd.s_gtype !=null && (erd.s_gtype.equalsIgnoreCase("interSnap")||erd.s_gtype.equalsIgnoreCase("intrasnap")||erd.s_gtype.equalsIgnoreCase("Citrix")))
				{
					showMinutes = "Yes";
					if (erd.s_startmin!=null && !erd.s_startmin.equals("") && Integer.parseInt(erd.s_startmin)<10 && erd.s_startmin.length()==2)
						erd.s_startmin=erd.s_startmin.substring(1);
					if (erd.s_endmin!=null && !erd.s_endmin.equals("") && Integer.parseInt(erd.s_endmin)<10 && erd.s_endmin.length()==2)
						erd.s_endmin=erd.s_endmin.substring(1);
					Vector vec_infos=erInfo.getInfosForTest(erd.s_site,erd.s_test,erd.s_component);

					JSONArray descriptorListFilter = new JSONArray();

					if(isFromAlarmHistory!=null && (isFromAlarmHistory.equalsIgnoreCase("true") || isFromAlarmHistory.equalsIgnoreCase("Yes")) && vec_infos!=null && vec_infos.size()>0)
					{
						showDescriptorFilterList = "Yes";
						pageParams.put("selectedDescriptor",info);
						for(int i=0;vec_infos.size()>i;i++)
						{	
							String str_selected="";
							String tmp_info=(String)vec_infos.get(i);
							if(tmp_info.indexOf("+")>-1 && tmp_info.indexOf("+")==0)
								tmp_info=tmp_info.substring(1);
							if(tmp_info.equals(info))
								str_selected="selected";
							JSONObject jObj = new JSONObject();
							jObj.put("displayField",tmp_info);
							jObj.put("valueField",tmp_info);
							descriptorListFilter.add(jObj);
						}
					}
					json.put("descriptorListFilter",descriptorListFilter);
				}
				
				pageParams.put("showDescriptorListFilter",showDescriptorFilterList);
				pageParams.put("showMinutes",showMinutes);
				

			}
			int gWidth = screenWidth-50;
			String strImgWidth=String.valueOf(gWidth);
			String strGraphWidth=String.valueOf(gWidth);
			String strImgHeight="400";
			String strGraphHeight="400";
/*			if(screenWidth>1200)
			{
				try{
					strImgWidth = (Integer.parseInt(strImgWidth)+300)+"";
					strImgHeight = (Integer.parseInt(strImgHeight)+100)+"";

				}catch(Exception e){}
				try{
					strGraphWidth = (Integer.parseInt(strGraphWidth)+300)+"";
					strGraphHeight = (Integer.parseInt(strGraphHeight)+100)+"";

				}catch(Exception e){}
			}	*/
			if(!("yes".equalsIgnoreCase(request.getParameter("er_timeline_change"))))
			{
				String strTodispLay ="";
				String stokstrok=(String)v_qry_string.get(j);
				if(stokstrok.indexOf("/")>-1)
				{
					String s_distest= stokstrok.substring(0,stokstrok.indexOf("/"));
					String s_dismeas=stokstrok.substring(stokstrok.indexOf("/")+1);
					String struni="";	if(s_dismeas.indexOf("(")>-1)
					{
						struni=s_dismeas.substring(s_dismeas.indexOf("("));	s_dismeas=s_dismeas.substring(0,s_dismeas.indexOf("("));
					}
					strTodispLay =mappingInfo.getTestDescription(s_distest) + "/" + mappingInfo.getMeasureDescription(s_distest,s_dismeas) +" " + struni ;
				}
				else if(stokstrok.indexOf(":")>-1)
				{
					if(stokstrok.indexOf("NULL:")>-1)
					{
					//	stokstrok.substring(0,stokstrok.lastIndexOf("NULL:"));
						strTodispLay =stokstrok.substring(0,stokstrok.lastIndexOf("NULL:"))+mappingInfo.getComponentTypeDescription(stokstrok.substring(stokstrok.lastIndexOf(":")+1));
					}
					else
					{
						strTodispLay =stokstrok.substring(0,stokstrok.lastIndexOf(":"))+mappingInfo.getComponentTypeDescription(stokstrok.substring(stokstrok.lastIndexOf(":")+1));
					}
				}
				else
				{
					strTodispLay =mappingInfo.getTextDescription("reporter.measure."+stokstrok);
				}
				pageParams.put("blockTitle",strTodispLay);
				String printOption = fromPrintPage;
				String graphDisplayType = "";
				if(!(gtype !=null && gtype.equalsIgnoreCase("Summary")) || (printOption != null && printOption.equalsIgnoreCase("yes")))
				{
					graphDisplayType="Summary";
					pageParams.put("imgUrl",Qstring+"&er_width="+strImgWidth+"&er_height="+strImgHeight+"&option=graph&er_legendPosition=right&drilldownenabled=yes");
					pageParams.put("imgWidth",strGraphWidth);
					pageParams.put("imgHeight",strGraphHeight);
					pageParams.put("imgToolTip",v_qry_string.get(j));
					pageParams.put("imgTitle",strTodispLay);
				}
				else
				{
					graphDisplayType="Others";
					Map requestMap = new HashMap(request.getParameterMap());
					if (requestMap.containsKey("drilldownenabled")) {
						requestMap.remove("drilldownenabled");
					}
					if (requestMap.containsKey("er_width")) {
						requestMap.remove("er_width");
					}
					if (requestMap.containsKey("er_height")) {
						requestMap.remove("er_height");
					}
					String qstring = ErUtils.prepareQueryString(requestMap);
					qstring = "/final/servlet/com.eg.ErSummaryC?"+qstring;

					pageParams.put("imgUrl",qstring+"&er_width="+strGraphWidth+"&er_height="+strImgHeight+"&er_align=center&option=graph&er_view=APPLET&drilldownenabled=yes");
					pageParams.put("imgHeight",strGraphHeight);

				}

				pageParams.put("graphDisplayType",graphDisplayType);

				com.eg.EgReportInfo reportinfo = new com.eg.EgReportInfo("manager");
				String strselectioncount = reportinfo.getValue("MISC","RightDisplaySelectioncount");
				int selectioncount=10;
				if(strselectioncount !=null && !strselectioncount.equals(""))
				{
					try
					{
						selectioncount = Integer.parseInt(strselectioncount);
					}
					catch (Exception e)
					{
						selectioncount = 10;
					}
				}
				String showLegendsAtBottom = "false";
				if (singleSelection != null && singleSelection.size() >selectioncount)
				{
					showLegendsAtBottom = "true";
					JSONArray tableMeasureData = new JSONArray();
					int count1=0;
					for (int k=0; k <singleSelection.size();k++)
					{
						String st_key = (String)singleColors.get(k);
						String value = (String)singleSelection.get(k);
						if(st_key != null && st_key.indexOf("#") > -1)
						{
							st_key = st_key.substring(1,st_key.length());
						}
						JSONObject jObj = new JSONObject();
						jObj.put("colorCode",st_key);
						jObj.put("legend",value);
						tableMeasureData.add(jObj);
					}
					json.put("tableMeasureData",tableMeasureData);
				}
				pageParams.put("showLegendsAtBottom",showLegendsAtBottom );
			}

	 
			HashMap param =new HashMap();
			param.put("REPORT_PARAM",ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap())));
			param.put("REPORT_DATA",v_pdf_qry);
			session.setAttribute("enlargedparameters", param);

			session.setAttribute("DrillDownPage","yes");
			String qryValue = Qstring.substring(Qstring.indexOf("?")+1,Qstring.length());
			String dataProcess =  mngrIProc+ "/final/reporter/ErMeasure.jsp"+";jsessionid="+ session.getId()+"?"+qryValue+"&print=yes&sample=yes&drillSes=yes&";
			session.setAttribute("DRILLDOWN_MAIL_URL",dataProcess);
		}
	}
	

		screenLabels.put("reporter.common.Descriptor",mappingInfo.getTextDescription("reporter.common.Descriptor"));

	//	screenLabels.put("reporter.common.Timeline",mappingInfo.getTextDescription("reporter.common.Timeline"));
	//	screenLabels.put("reporter.common.From",mappingInfo.getTextDescription("reporter.common.From"));
	//	screenLabels.put("reporter.common.Hr",mappingInfo.getTextDescription("reporter.common.Hr"));
	//	screenLabels.put("reporter.common.Graph",mappingInfo.getTextDescription("reporter.common.Graph"));
		screenLabels.put("admin.filter.Filter by",mappingInfo.getTextDescription("admin.filter.Filter by"));

		String mode = request.getParameter("er_mode");
		boolean use3DGraphs = ui.use3DGraphs(IniUI.REPORTER);

		JSONArray graphModeArr = new JSONArray();
		String selectedGraphMode=" ";
		if(mode!=null && !mode.equals(""))
		{
			if(mode.equals("2D"))
			{
				selectedGraphMode="2D";
			}
			else if(mode.equals("3D"))
			{
				selectedGraphMode="3D";
			}
			else
			{
				selectedGraphMode="3D";
			}
		}
		else
		{

			if(use3DGraphs)
				selectedGraphMode="3D";
			else
				selectedGraphMode="2D";
		}

		JSONObject graphDObj = new JSONObject();
		graphDObj.put("displayField",mappingInfo.getTextDescription("reporter.common.2D"));
		graphDObj.put("valueField","2D");
		graphModeArr.add(graphDObj);
		graphDObj = new JSONObject();
		graphDObj.put("displayField",mappingInfo.getTextDescription("reporter.common.3D"));
		graphDObj.put("valueField","3D");
		graphModeArr.add(graphDObj);

		json.put("graphModeOptions",graphModeArr);
		pageParams.put("selectedGraphMode",selectedGraphMode);

		JSONArray filterOptionsArr = new JSONArray();
		JSONObject filterOptionsObj = new JSONObject();
		filterOptionsObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Descriptor By Priority"));
		filterOptionsObj.put("valueField","DescriptorPriority");
		filterOptionsArr.add(filterOptionsObj);
		filterOptionsObj = new JSONObject();
		filterOptionsObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Range"));
		filterOptionsObj.put("valueField","Range");
		filterOptionsArr.add(filterOptionsObj);

		json.put("filterOptionsArr",filterOptionsArr);

		if(er_timeline!=null)
		pageParams.put("er_timeline",er_timeline);
 
		String hiddenQStr ="";

		if(sbHiddenQStr!=null)
		{
			hiddenQStr = sbHiddenQStr.toString();
		/*	if(hiddenQStr!=null && hiddenQStr.indexOf(",")==0)
			{
				hiddenQStr = hiddenQStr.substring(1,hiddenQStr.length());
			}*/
		}
		json.put("hiddenQStr",hiddenQStr);
	}
	JSONObject selectionDetails=new JSONObject();
	
 
// by karthikeyan
%>

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

<%
 
	/*String strStartTimee = s_st_time+" "+s_st_hr+":"+startMin+":00";
	String strEndTimee = s_en_time+" "+s_en_hr+":"+endMin+":00";
	ErUserData userData = new ErUserData(erd.userId,false);
	com.egurkha.User usr = userData.usr;
	String dateToConvertStart = DateUtil.changeDateFormat(strStartTimee,"MM/dd/yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss");
	EgTimeZoneConverter timeZoneConverterStart = new EgTimeZoneConverter(dateToConvertStart,usr);
	String startDateForDisplay = (String) timeZoneConverterStart.getDate(false);
	String startHourForDisplay = timeZoneConverterStart.getHour();
	String startMinForDisplay = timeZoneConverterStart.getMinute();
	String dateToConvertEnd = DateUtil.changeDateFormat(strEndTimee,"MM/dd/yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss");
	EgTimeZoneConverter timeZoneConverterEnd = new EgTimeZoneConverter(dateToConvertEnd,usr);
	String endDateForDisplay = (String) timeZoneConverterEnd.getDate(false);
	String endHourForDisplay = timeZoneConverterEnd.getHour();
	String endMinForDisplay = timeZoneConverterEnd.getMinute();*/
	
	alist = Arrays.asList(opt);
	if(strUsrTimeline != null && !strUsrTimeline.equals("") && !strUsrTimeline.equalsIgnoreCase("-1"))
	{
		len = alist.indexOf(strUsrTimeline)+1;
	}
	else
	{
		len = opt.length;
	}
	
	JSONArray timelineJSONArr =  new JSONArray();
	for(int e_ctr=0; e_ctr < len;e_ctr++)
	{
		JSONObject jObj = new JSONObject();
		jObj.put("displayField",mappingInfo.getTextDescription("reporter.measure."+opt[e_ctr]));
		jObj.put("valueField",String.valueOf(opt[e_ctr]));
		timelineJSONArr.add(jObj);
	}

	lastDataList = new ArrayList();
	lastDataJSON = null;
	if(isLastTimeLine){
		if(strUsrTimeline.equals("-1")){
			for(int i=0;i<lstWeeksArr.length;i++){
				lastDataList.add(lstWeeksArr[i]);
			}
			lastDataJSON = getLastCalenJson(lastDataList,mappingInfo);
			for(int i=0;i<lastDataJSON.size();i++){
				timelineJSONArr.add(lastDataJSON.get(i));
			}
		}else if(strUsrTimeline.equals("1 week")){
			lastWeekCount = 1;
			for(int i=0; i<lastWeekCount;i++){
				lastDataList.add(lstWeeksArr[i]);
			}			
			lastDataJSON = getLastCalenJson(lastDataList,mappingInfo);
			for(int i=0;i<lastDataJSON.size();i++){
				timelineJSONArr.add(lastDataJSON.get(i));
			}
		}else if(strUsrTimeline.equals("2 weeks")){
			lastWeekCount = 1;
			for(int i=0; i<lastWeekCount;i++){
				lastDataList.add(lstWeeksArr[i]);
			}			
			lastDataJSON = getLastCalenJson(lastDataList,mappingInfo);
			for(int i=0;i<lastDataJSON.size();i++){
				timelineJSONArr.add(lastDataJSON.get(i));
			}
		}else if(strUsrTimeline.equals("3 weeks")){
			lastWeekCount = 1;
			for(int i=0;i<lastWeekCount;i++){
				lastDataList.add(lstWeeksArr[i]);
			}
			lastDataJSON = getLastCalenJson(lastDataList,mappingInfo);
			for(int i=0;i<lastDataJSON.size();i++){
				timelineJSONArr.add(lastDataJSON.get(i));
			}
		}else if(strUsrTimeline.equals("4 weeks")){
			lastWeekCount = 1;
			for(int i=0;i<lastWeekCount;i++){
				lastDataList.add(lstWeeksArr[i]);
			}
			lastDataJSON = getLastCalenJson(lastDataList,mappingInfo);
			for(int i=0;i<lastDataJSON.size();i++){
				timelineJSONArr.add(lastDataJSON.get(i));
			}
		}else if(strUsrTimeline.equals("1 month")){
			lastWeekCount = 2;
			for(int i=0;i<lastWeekCount;i++){
				lastDataList.add(lstWeeksArr[i]);
			}
			lastDataJSON = getLastCalenJson(lastDataList,mappingInfo);
			for(int i=0;i<lastDataJSON.size();i++){
				timelineJSONArr.add(lastDataJSON.get(i));
			}		
		}	
	}
	json.put("timelineJSONArray",timelineJSONArr); 
	pageParams.put("startDateForDisplay",startDateForDisplay);
	pageParams.put("startHourForDisplay",startHourForDisplay);
	pageParams.put("startMinForDisplay",startMinForDisplay);
	pageParams.put("endDateForDisplay",endDateForDisplay);
	pageParams.put("endHourForDisplay",endHourForDisplay);
	pageParams.put("endMinForDisplay",endMinForDisplay); 
	hiddenParams.put("er_usertimeline",strUsrTimeline);
	sbHiddenQStr.append("&er_usertimeline="+strUsrTimeline);
 
	pageParams.put("selectedEndDate",endDateJSON);
	pageParams.put("selectedStDate",startDateJSON);
	pageParams.put("selectedStarthour",startHourJSON);
	pageParams.put("selectedStartMins",startMin);
	pageParams.put("selectedEndhour",endHourJSON);
  	pageParams.put("selectedEndMins",endMin);
  	pageParams.put("timeline_value",er_timeline);
   


	json.put("pageParams",pageParams);
	json.put("hiddenParams",hiddenParams);
	json.put("screenLabels",screenLabels);
	//
	String sDispStartDate = startDateForDisplay+" "+startHourForDisplay+":"+startMinForDisplay;
	String sDispEndDate = endDateForDisplay+" "+endHourForDisplay+":"+endMinForDisplay;
	selectionDetails.put("Timeline", "<span class='font_bold'></span> "+sDispStartDate+" hrs <span class='font_bold'>to</span> "+sDispEndDate+" hrs");
	json.put("selectionDetails", selectionDetails);
	//

	response.setContentType("application/json;charset=UTF-8");
	response.getWriter().write(json.toString());
}catch(Throwable e)
{
	e.printStackTrace();
}
%>
<%!
	public String getDisplayNameForComp(EgMappingInfo mappingInfo, String inputStr)
	{
		String returnStr="";
		if(inputStr!=null && inputStr.indexOf(":")>-1)
		{
			StringTokenizer str = new StringTokenizer(inputStr,":");
			String comp = "";
			String port = "";
			String compType = "";
			if(str.hasMoreTokens())
			{
				comp = str.nextToken();
			}
			if(str.hasMoreTokens())
			{
				port = str.nextToken();
				if(!port.equals("NULL"))
				{
					port = ":"+port;
				}
				else
				{
					port = "";
				}
			}
			if(str.hasMoreTokens())
			{
				compType = str.nextToken();
				compType = mappingInfo.getComponentTypeDescription(compType);
			}
			returnStr = comp+port+":"+compType;
			return returnStr;
		}
		return inputStr;
	}
%>