<!DOCTYPE html>

<%@ include file = "ErTracker.jsp" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.text.*" %>
<%@ page import = "com.egurkha.util.DateUtil"%>
<%@ page import = "com.eg.EgConfigInfo"%>
<%@ page import = "com.eg.EgReportInfo" %>
<%@ page import = "com.eg.EgMappingInfo" %>
<%@ page import = "egurkha.reporter.uptime.*"%>
<%@ page import = "egurkha.reporter.*"%>
<%@ page import ="com.eg.EgDbInfo" %>
<%@ 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" %>

 <%!
	public String getDisplayString(String input, String defaultString) {
	String displayString = "";
	if (input.equals("-")) {
		displayString = input;
	} else {
		StringTokenizer st = new StringTokenizer(input);
			while(st.hasMoreTokens()) {
			if(displayString.equals("")) {
				displayString = st.nextToken();
			} else {
				displayString += " " + st.nextToken();
			}
			displayString += st.nextToken();
		}

		if(displayString.equals("")) {
			displayString = defaultString;
		} else if(displayString.equals("0m")) {
			displayString = defaultString;
		}
	}
	return displayString;
} 
%>
<%
	String titleToDisplay=request.getParameter("er_RmDispName");

try{
	EgDateInfo egDt = new EgDateInfo();
	String queryString = ErUtils.prepareQueryString(request.getParameterMap());

	String fromSchedule = request.getParameter("throughSchedule");
	if(fromSchedule !=null && fromSchedule.equalsIgnoreCase("true"))
	{
		String strQueryString = (String)session.getAttribute("Report_Query_String");
		if(strQueryString!=null && strQueryString.length()>0)
		{
			String strComp = "";
			 StringTokenizer strtok = new StringTokenizer(strQueryString,"&");
			while(strtok.hasMoreTokens()) {
				String parameter = strtok.nextToken();
				if(parameter.startsWith("er_component"))
					strComp+=parameter+"&";
			}
			queryString+="&"+strComp;
		}
	}

	/* For Save CSV  Format */
	List list = new LinkedList();
	Vector v_date = new Vector();
	List list_data = new LinkedList();
	Vector v_measure = new Vector();
	Hashtable h_tabrc = new Hashtable();
	Hashtable h_tab = new Hashtable();
	String csv_wk="";
	String s_title="";
	String 	dispCsvStartDate="";
	String dispCsvEndDate="";
	String data_abbrevation="";
	ErUtils erUtils = new ErUtils();

	String mngrIP = new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
	String strManagerURL = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
	String qString="";
	if(queryString!=null) {
		StringTokenizer strtok = new StringTokenizer(queryString,"&");
		while(strtok.hasMoreTokens()) {
			String parameter = strtok.nextToken();
			int ind = parameter.indexOf("=");
			if (ind < 0)
				continue;
			String reqparam =parameter.substring(0,ind);
			String value = parameter.substring(ind+1);
			if(reqparam!=null&&reqparam.equals("er_timeline")) {
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			} else if(reqparam!=null&&reqparam.equals("er_trgttype")) {
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			}
			if(reqparam!=null&&reqparam.equals("er_time")) {
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			} else if(reqparam!=null&&reqparam.equals("pdfTime")) {
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			} else if(reqparam!=null&&reqparam.equals("er_priority")) {
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			} else if(reqparam!=null&&reqparam.equals("er_uptimetest")) {
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			} else if(reqparam!=null&&reqparam.equals("inidate")) {
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			} else if(reqparam!=null&&reqparam.equals("er_enddate")) {
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			} else if(reqparam!=null&&reqparam.equals("startdate")) {
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			} else if(reqparam!=null&&reqparam.equals("enddate")) {
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			} else if(reqparam!=null&&reqparam.equals("er_stdate")) {
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			} else if(reqparam!=null&&reqparam.equals("er_site"))	{
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			} else if(reqparam!=null&&(reqparam.equals("er_usertimeline"))){
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			}else if(reqparam!=null && reqparam.equals("er_RmDispName") && value.indexOf("%")==-1){
				value=com.eg.EgURLEncoder.encode(value, "UTF-8");
			}
	
            if(reqparam!=null&&(reqparam.equals("er_sthr") || reqparam.equals("chartformat") || reqparam.equals("st_date") || reqparam.equals("Minto") || reqparam.equals("stmin") || reqparam.equals("er_startmin") || reqparam.equals("scheduleType") || reqparam.equals("er_views") || reqparam.equals("endate") || reqparam.equals("enmin") || reqparam.equals("er_endhr")))//reqparam.equals("throughSchedule") ||
			{
                continue;
            }
            qString += reqparam+"="+value.trim()+"&";
        }
    }
    Map resultDataMap = (Map) session.getAttribute("UPTIME_RESULT");
    if(resultDataMap ==null){
		resultDataMap = (Map) request.getAttribute("UPTIME_RESULTDATA");
    }
    EgReportInfo reportInfo = new EgReportInfo("manager");
    String thisLanguage="";
    if (thisuser != null) {
        String userLang = thisuser.getLanguage();
        if (userLang != null && !userLang.equalsIgnoreCase("NULL")) {
            thisLanguage = userLang;
        }
    }
    EgMappingInfo intlmap = new EgMappingInfo(thisuser.getLanguage());
    
    String selectedCompType = request.getParameter("er_comptype");
    String showDetails = request.getParameter("er_show_details");
    String er_timeline = request.getParameter("er_timeline");
    String excludeweekend = request.getParameter("er_excwe");
    String s_st_time = request.getParameter("startdate");
    String s_en_time = request.getParameter("enddate");
    String s_st_hr   = request.getParameter("starthr");
    String s_en_hr   = request.getParameter("endhr");
    String strmin    = request.getParameter("startmin");
    String enmin     = request.getParameter("endmin");
    String er_time   =  request.getParameter("er_time");
    String hourFrom = request.getParameter("timefrom");
    String minFrom = request.getParameter("minfrom");
    String hourTo = request.getParameter("timeto");
    String minTo = request.getParameter("minto");
    String iniDate = request.getParameter("inidate");
	String er_uptimetest = request.getParameter("er_uptimetest");
    if(selectedCompType != null && selectedCompType.equals("-1")) {
        selectedCompType = "All";
    }
    
    String uiFile = "eg_ui.ini";
    String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
    IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
    String currentDateFormat = strUserDateFormat;
    
    String dispStartDate = DateUtil.changeDateFormat(s_st_time.trim(),iniDate,currentDateFormat);
    String dispEndDate = DateUtil.changeDateFormat(s_en_time.trim(),iniDate,currentDateFormat);
    String timefrom = hourFrom + ":" + minFrom;
    String timeTo = hourTo + ":" + minTo;
    String stTime = "";
    String enTime = "";
	String st_dateTime="";
	String en_dateTime="";
	EgTimeZoneConverter converterStart=null;
	EgTimeZoneConverter converterEnd=null;
	
        stTime = s_st_hr + " "+ " " + strmin;
        enTime = s_en_hr + " "+ " " + enmin;

		converterStart = new  EgTimeZoneConverter(dispStartDate+" "+s_st_hr+":"+strmin,thisuser);
		st_dateTime=(String)converterStart.getDate(false)+" "+converterStart.getHour()+ " " + intlmap.getTextDescription("reporter.common.hrs")
		+ " " + converterStart.getMinute() + " " + intlmap.getTextDescription("reporter.common.mins");
		
		converterEnd = new  EgTimeZoneConverter(dispEndDate+" "+s_en_hr+":"+enmin,thisuser);
		en_dateTime=(String)converterEnd.getDate(false)+" "+converterEnd.getHour()+ " " + intlmap.getTextDescription("reporter.common.hrs")
		+ " " + converterEnd.getMinute() + " " + intlmap.getTextDescription("reporter.common.mins");

    String pdfPrint = request.getParameter("pdfPrint");
    EgDbInfo dbInfo = new EgDbInfo("manager");
    String fontStyleDblSingl = "";
    if((dbInfo.doubleByteEnabled || !thisuser.getLanguage().equals("en_US")) && !(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes")))
	{
        fontStyleDblSingl = "multi_font";
    } else {
        fontStyleDblSingl = "";
    }

	String headerTittle = request.getParameter("pgTittle");
	String backGroundTitle=request.getParameter("ReportFrom");
	String backGroundTitle1=request.getParameter("er_bgreportfrom");
		String er_RmDispName =request.getParameter("er_RmDispName");

%>

<!Doctype html>
    <head>
	<%
		if(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes"))
		{
	%>
		<title><egui:intnl text="reporter.common.eG Reporter"/></title>
	<%
		}
		else
		{
	%>
		<title>eG Reporter</title>
	<%
		}
	%>

<meta name="Author" content="">
<meta charset="UTF-8">
<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" />


<style type="text/css" media="print">
	@media print {body {-webkit-print-color-adjust: exact;}}
	body{font-size:11px;line-height:1.5em;color:#2a292a;}

	#printbt, #csvbt{ display:none}
</style>

</head>
<body marginwidth="20" marginheight="20" bgcolor="#FFFFFF">

<%
				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(er_RmDispName)){
%>
						<div class="printHeaderBoxTitle"><%= er_RmDispName %></div>
<%
	} else {
					if((headerTittle !=null && headerTittle.equalsIgnoreCase("VIRTUALIZATION")) ||( backGroundTitle !=null && backGroundTitle.equalsIgnoreCase("Virtualization_Uptime")) || ( backGroundTitle1 !=null && backGroundTitle1.equalsIgnoreCase("Virtualization_Uptime")))
						{
%>
						<div class="printHeaderBoxTitle"><egui:intnl text="reporter.common.VIRTUALIZATION REPORTS"/> - <egui:intnl text="reporter.common.UPTIME"/></div>
<%
						}
						else
						{
%>
						<div class="printHeaderBoxTitle"><egui:intnl text="reporter.common.OPERATION REPORTS"/> - <egui:intnl text="reporter.common.UPTIME"/></div>
<%
						}
	}
					if(pdfPrint !=null && pdfPrint.equalsIgnoreCase("yes"))
						{
%>
						<div class="printHeaderBoxPrintIcon" style="float:left"><img class="iconPrinter mouse"  id="prin tbt" 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"> 
<div class="printSelectionFields"><egui:intnl text="reporter.common.Component Type"/> - <span class="bold fontStyleDblSingl"><egui:intnl type="<%=selectedCompType%>"/></span></div>
<div class="printSelectionFields">Timeline - <span class="bold"><%=st_dateTime%> to <%=en_dateTime%> </span></div>
<div class="printSelectionFields"><egui:intnl text="reporter.common.Time Period"/> -<span class="bold fontStyleDblSingl"> <%=timefrom%>&nbsp;<egui:intnl text="reporter.common.to"/>&nbsp;<%=timeTo%></span></div>
</div>
</div>
<div class="clearDiv">&nbsp;</div>
<%
				if (!StringUtils.isNull(titleToDisplay)){ 
					list.add(titleToDisplay);
				}
				else
				{
					list.add(intlmap.getTextDescription("reporter.common.OPERATION REPORT")+" - "+intlmap.getTextDescription("reporter.uptime.UPTIME REPORT"));
				}
			list.add(intlmap.getTextDescription("reporter.common.Component Type")+" - "+intlmap.getTextDescription("reporter.uptime"+selectedCompType));
			dispCsvStartDate=dispStartDate+" "+stTime;
			dispCsvEndDate= dispEndDate+" "+enTime;
			v_date.add("\""+intlmap.getTextDescription("reporter.common.Start Date")+" : "+DateUtil.changeDateFormat(dispCsvStartDate,"MM/dd/yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss")+"\"");
			v_date.add("\""+intlmap.getTextDescription("reporter.common.End Date")+" : "+DateUtil.changeDateFormat(dispCsvEndDate,"MM/dd/yyyy HH:mm:ss",currentDateFormat+" HH:mm:ss")+"\"");

			list.add(v_date);
			s_title = intlmap.getTextDescription("reporter.uptime.Uptime Report");
			v_measure.add(intlmap.getTextDescription("reporter.uptime.Component"));
			if(er_uptimetest!=null && er_uptimetest.equalsIgnoreCase("Systems"))
			{
				v_measure.add(intlmap.getTextDescription("reporter.uptime.Running Since"));
			}
			v_measure.add(intlmap.getTextDescription("reporter.uptime.Uptime (yMdhm)"));
			v_measure.add(intlmap.getTextDescription("reporter.uptime.% Uptime"));
			v_measure.add(intlmap.getTextDescription("reporter.uptime.Downtime (yMdhm)"));
			v_measure.add(intlmap.getTextDescription("reporter.uptime.% Downtime"));
			v_measure.add(intlmap.getTextDescription("reporter.uptime.Reboots"));
	
			/*List uptimeList1 = (List)resultDataMap.get("COMPONENT_LIST");
			for(int i=0; i<uptimeList1.size(); i++)
			if(uptimeList1 !=null)
			{

				ErUptimeDowntimeBean uptimeBean1 = (ErUptimeDowntimeBean) uptimeList1.get(i);
				String sUpTime = uptimeBean1.getUpTime();
				list_data.add(uptimeBean1.getComponent());
				if(er_uptimetest!=null && er_uptimetest.equalsIgnoreCase("Systems"))
				{
					list_data.add(uptimeBean1.getRunningSince());
				}
				list_data.add(getDisplayString(uptimeBean1.getUpTime(), "0"));
				list_data.add(uptimeBean1.getPerUpTime());
				list_data.add(getDisplayString(uptimeBean1.getDownTime(), "0"));
				list_data.add(uptimeBean1.getPerDownTime());
				String sNoOfReboots = "-";
				if (sUpTime.equals("-")) {
					list_data.add(sNoOfReboots);
				} else {
					list_data.add(uptimeBean1.getNoOfReboots()+"");
					sNoOfReboots = uptimeBean1.getNoOfReboots()+"";
				}

			 }*/
					data_abbrevation=intlmap.getTextDescription("reporter.uptime.y - year, M - month, d - day, h - hour, m - min");
					 StringTokenizer st = null;
					 String datafrom = request.getParameter("er_datafrom");
					 String er_type = request.getParameter("er_type");
					 String s_site = request.getParameter("er_site");
					 String s_comptype = request.getParameter("er_comptype");
					 String colspanVal = "6";
					 if(er_uptimetest!=null && er_uptimetest.equalsIgnoreCase("Systems"))
					 {
						colspanVal = "7";
					 }
					 String detailsTitle = "";
					 if(er_uptimetest != null && er_uptimetest.equalsIgnoreCase("Physical Servers"))
					 {
						detailsTitle = intlmap.getTextDescription("reporter.uptime.Hypervisors") + " "+intlmap.getTextDescription("reporter.uptime.Uptime Report");
					 }
					 else
					 {
						if(er_uptimetest != null && er_uptimetest.equals("Both"))
							detailsTitle = intlmap.getTextDescription("reporter.uptime.Uptime Report");
						else
							detailsTitle = er_uptimetest + " "+intlmap.getTextDescription("reporter.uptime.Uptime Report");
					 }
                            
                            if(!datafrom.equals("Component")) {
                                detailsTitle = datafrom;
                                if(er_type == null || er_type.equals("No")) {
                                    detailsTitle += " Report";
                                } else if(er_type != null && er_type.equals("Yes")) {
                                    detailsTitle += " Chart";
                                }
                            }
                            String detailsSubTitle = "";
                            String detailsSubTitle1 = "";
                            String detailsSubTitle2 = "";
                            String detailsSubTitle3 = "";
                            if(!datafrom.equals("Component")) {
                                detailsTitle += " for";
                                detailsSubTitle = s_site;
                                detailsSubTitle1 = datafrom;
                            }
                            if(s_comptype != null && !s_comptype.equals("-1") && !s_comptype.equals("NotApplicable")) {
                                detailsSubTitle2 = " - ";
                                detailsSubTitle3 = s_comptype;
                            }
                            
                            List uptimeList = (List)resultDataMap.get("COMPONENT_LIST");
                            String compText = "Components";
							if(er_uptimetest!=null && er_uptimetest.equalsIgnoreCase("Network Devices"))
							{
								compText="Devices";
							}
                            if(resultDataMap !=null && uptimeList != null && uptimeList.size() > 0) {
                                if(er_type !=null && er_type.equalsIgnoreCase("No")) {
                                    if(resultDataMap !=null) {
                            %>
                                    <!-- changed width from 97 to 100-->

<div class="printOuterBox">

		<div class="newTable">
		<div class="printOuterBoxHeader" >
			<egui:intnl text='<%= "reporter.uptime." + detailsTitle %>'/>
			<%= detailsSubTitle %>
			<egui:intnl text='<%= detailsSubTitle1 == "" ? "" : "reporter.uptime." + detailsSubTitle1 %>'/>
			<%= detailsSubTitle3 == "" ? "" : detailsSubTitle2 %>
			<%
			if(detailsSubTitle3 != "") {
			%>
			<egui:intnl type="<%=detailsSubTitle3%>"/>
			<%
			}
			%>
			</div>
	<table align="center" valign="middle" cellspacing="0" cellpadding="0"  width="100%">
	<thead>
	<tr>
		<th style="text-align:left"><egui:intnl text="reporter.uptime.Component"/></th>
<%
		if(er_uptimetest!=null && er_uptimetest.equalsIgnoreCase("Systems"))
		{
%>
		<th style="text-align:left"><egui:intnl text="reporter.uptime.Running Since"/></th>
<%
		}
%>
		<th style="text-align:left"><egui:intnl text="reporter.uptime.Uptime"/><br/>(<egui:intnl text="reporter.uptime.yMdhm"/>)*</th>
		<th ><egui:intnl text="reporter.uptime.% Uptime"/></th>
		<th style="text-align:left"><egui:intnl text="reporter.uptime.Downtime"/><br/>(<egui:intnl text="reporter.uptime.yMdhm"/>)*</th>
		<th ><egui:intnl text="reporter.uptime.% Downtime"/></th>
		<th ><egui:intnl text="reporter.uptime.Reboots"/></th>
	</tr>
	</thead>
	<tbody>
<%
				for(int i=0; i<uptimeList.size(); i++) {
						ErUptimeDowntimeBean uptimeBean = (ErUptimeDowntimeBean) uptimeList.get(i);
									String sUpTime = uptimeBean.getUpTime();
									list_data.add(uptimeBean.getComponent());
									if(er_uptimetest!=null && er_uptimetest.equalsIgnoreCase("Systems"))
									{
										list_data.add(getDisplayString(uptimeBean.getRunningSince(), "0"));
									}
									list_data.add(getDisplayString(uptimeBean.getUpTime(), "0"));
									list_data.add(uptimeBean.getPerUpTime());
									list_data.add(getDisplayString(uptimeBean.getDownTime(), "0"));
									list_data.add(uptimeBean.getPerDownTime());
									String sNoOfReboots = "-";
									if (sUpTime.equals("-")) {
										list_data.add(sNoOfReboots);
									} else {
										list_data.add(uptimeBean.getNoOfReboots()+"");
										sNoOfReboots = uptimeBean.getNoOfReboots()+"";
									}	
%>
	<tr>
		<td align="left" ><%= uptimeBean.getComponent()%></td>
<%
		if(er_uptimetest!=null && er_uptimetest.equalsIgnoreCase("Systems"))
		{
%>
		<td align="left" ><%= getDisplayString(uptimeBean.getRunningSince(), "0")%></td>
<%
		}
                                                        String displayString = "";
                                                        if(uptimeBean.getUpTime().equals("-")) {
                                                            displayString = uptimeBean.getUpTime();
                                                        } else {
                                                            st = new StringTokenizer(uptimeBean.getUpTime());
                                                            while(st.hasMoreTokens()) {
                                                                if(displayString.equals("")) {
                                                                    displayString = st.nextToken();
                                                                } else {
                                                                    displayString += "&nbsp;" + st.nextToken();
                                                                }
                                                                displayString += st.nextToken();
                                                            }
                                                            if(displayString.equals("")) {
                                                                displayString += "&nbsp;";
                                                            }
                                                        }
                                                        String sReboots = uptimeBean.getNoOfReboots()+"";
                                                        if (uptimeBean.getUpTime().equals("-")){
                                                            sReboots = "-";
                                                        }
%>
		<td align="left"><%= displayString %></td>
		<td align="center"><%= uptimeBean.getPerUpTime() %></td>
<%
                                                        displayString = "";
                                                        if(uptimeBean.getDownTime().equals("-")) {
                                                            displayString = uptimeBean.getDownTime();
                                                        } else {
                                                            st = new StringTokenizer(uptimeBean.getDownTime());
                                                            while(st.hasMoreTokens()) {
                                                                if(displayString.equals("")) {
                                                                    displayString = st.nextToken();
                                                                } else {
                                                                    displayString += "&nbsp;" + st.nextToken();
                                                                }
                                                                displayString += st.nextToken();
                                                            }
                                                            if(displayString.equals("") || displayString.equals("0m")) {
                                                                displayString = "0";
                                                            }
                                                        }
%>
		<td align="left"><%= displayString %></td>
		<td align="center"><%= uptimeBean.getPerDownTime() %></td>
		<td align="center"><%= sReboots %></td>
	</tr>
<%
                                                    }
%>
	
	<tr>
		<td colspan="<%=colspanVal%>">
			* <egui:intnl text="reporter.uptime.y - year, M - month, d - day, h - hour, m - min"/>
		</td>
	</tr>
</tbody>
</table>
</div>
</div>
                            
                            <%
                                    } else {
                            %>
<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0">
	<tr>
		<td align='center' valign='middle'><img src='../images/Light/nomeasures_custom.png' /></td>
	</tr>
</table><br/>
<%
                                    }
                                } else if(er_type !=null && er_type.equalsIgnoreCase("Yes")){

									String queryStr = (String)session.getAttribute("querygraph");
                                    String queryStrPie ="";
                                    String str = "";
                                    String str1 = "";
                                    if(queryStr ==null) {
										str = mngrIP+"/final/servlet/com.eg.ErUptimeServletC;jsessionid=" + session.getId() + "?";
                                        str1 = qString;
                                    } else {
                                        queryStrPie = queryStr.substring(0,queryStr.indexOf("&er_width"));
                                        
                                        int index = queryStrPie.indexOf("?");
                                        str = queryStrPie.substring(0,index) + ";jsessionid=" + session.getId() + "?";
                                        str1 = queryStrPie.substring(queryStrPie.indexOf("?")+1,queryStrPie.length());
                                    }
                                    String erbarheightstyle = "230";
                                    String erbarheight = String.valueOf(uptimeList.size() * 15 > 500 ?uptimeList.size() * 15 : 500);

                                                int index = queryStrPie.indexOf("?");
                                                String strQry = "";
                                                StringTokenizer strtok = new StringTokenizer(str1,"&");
                                                while(strtok.hasMoreTokens()) {
                                                    String parameter = strtok.nextToken();
                                                    int ind = parameter.indexOf("=");
                                                    if (ind < 0)
                                                        continue;
                                                    String reqparam =parameter.substring(0,ind);
                                                    String value = parameter.substring(ind+1);
													if(value.indexOf("(") > -1)
														value = StringUtils.replace(value,"(","%28");
													if(value.indexOf(")") > -1)
														value = StringUtils.replace(value,")","%29");

													if(reqparam!=null && reqparam.equals("er_show")){
														if(value!=null && value.indexOf("%")==-1)
														{
															value = com.eg.EgURLEncoder.encode(value, "UTF-8");
														}
                                                    }
                                                    if(reqparam!=null && reqparam.equals("limitforbg")){
                                                        value = com.eg.EgURLEncoder.encode(value, "UTF-8");
                                                    }
                                                    if(reqparam!=null && reqparam.equals("er_timeline")){
                                                        value = com.eg.EgURLEncoder.encode(value, "UTF-8");
                                                    }
                                                    if(reqparam!=null && reqparam.equals("er_combination")){
                                                        value = com.eg.EgURLEncoder.encode(value, "UTF-8");
                                                    }
													if(reqparam!=null && reqparam.equals("er_usertimeline")){
																				value = com.eg.EgURLEncoder.encode(value, "UTF-8");
													}
													if(reqparam!=null && reqparam.equals("userTimeline")){
																				value = com.eg.EgURLEncoder.encode(value, "UTF-8");
													}
													if(reqparam!=null && (reqparam.equals("eruserid")||reqparam.equals("userID") || reqparam.equals("uid")||reqparam.equals("er_userid")||reqparam.equals("er_RmDispName")))
													{
														if(value!=null && value.indexOf("%")==-1)
														{
															 value = com.eg.EgURLEncoder.encode(value, "UTF-8");
														}
													}

                                                    if(reqparam!=null && reqparam.equals("throughSchedule")) {
                                                        continue;
                                                    }
													if(reqparam!=null && reqparam.equals("strbg_id"))
													{
														value = com.eg.EgURLEncoder.encode(value, "UTF-8");
													}
                                                    strQry += reqparam+"="+value+"&";
                                                }


												Map mapReqParamsData = ErUtils.parseQueryString(strQry);
												String valueP = "";
												Object obj = mapReqParamsData.get("er_component");
												if(obj instanceof String[])
												{
													String[] comps = (String[]) obj;
													for (int j = 0;j < comps.length; j++)
													{
														if(comps[j] != null && !comps[j].equals(""))
														{
															try
															{
																mapReqParamsData.remove("er_component");
																//param.put("er_component",EgURLEncoder.encode(comps[j],"UTF-8"));
																valueP +="&er_component="+ com.eg.EgURLEncoder.encode(comps[j].toString(),"UTF-8")+ "&";
															}catch(Exception t1){}
														}
													}
												}
												else
												{
													try
													{
														mapReqParamsData.remove("er_component");
														valueP +="&er_component="+ com.eg.EgURLEncoder.encode(obj.toString(),"UTF-8")+ "&";
													}catch(Exception t1){}
												}
String qstringData =(String)ErUtils.prepareQueryString(mapReqParamsData);
String dataQry = qstringData+valueP;
if(dataQry !=null)
{
HashMap hmData1 = ErUtils.parseQueryString(dataQry);
Hashtable table = new Hashtable(hmData1);
//For print, htData is passed, not the request, so decode the er_show
String show = (String)request.getParameter("er_show");
//String show = (String)table.get("er_show");
if(show!=null && show.length()>0)
{
	show = erUtils.specialCharDecode(show);
	table.put("er_show",show);
}
else
{
	show = (String)table.get("er_show");
	show = erUtils.specialCharDecode(show);
	table.put("er_show",show);
}
session.setAttribute("htData",table);
Object tempComp = table.get("er_component");
if(tempComp != null) {
	String[] erComps = null;
	if(tempComp instanceof String) {
		erComps = new String[1];
		erComps[0] = com.eg.EgURLDecoder.decode(tempComp.toString(), "UTF-8");
	} else {
		String[] tempObj = (String[]) tempComp;
		erComps = new String[tempObj.length];
		for(int i=0; i<tempObj.length; i++) {
			erComps[i] = com.eg.EgURLDecoder.decode(tempObj[i], "UTF-8");
		}
	}
	if(erComps != null) {
		table.put("er_component", erComps);
	}
}
//dataQry=dataQry+"er_RmDispName=Uptime&";
dataQry=dataQry.replaceAll("&er_view=GRAPH","");
HashMap hmData = ErUtils.parseQueryString(dataQry);
Hashtable htData = new Hashtable(hmData);
htData.remove("er_component");
htData.remove("er_combination");

/*if(htData.get("startdate")!=null)
	htData.put("startdate",com.eg.EgURLEncoder.encode((String)htData.get("startdate"), "UTF-8"));
if(htData.get("inidate")!=null)
	htData.put("inidate",com.eg.EgURLEncoder.encode((String)htData.get("inidate"), "UTF-8"));
if(htData.get("enddate")!=null)
	htData.put("enddate",com.eg.EgURLEncoder.encode((String)htData.get("enddate"), "UTF-8"));*/
if(htData.get("er_uptimetest")!=null)
	htData.put("er_uptimetest",com.eg.EgURLEncoder.encode((String)htData.get("er_uptimetest"), "UTF-8"));
if(htData.get("er_priority")!=null)
	htData.put("er_priority",com.eg.EgURLEncoder.encode((String)htData.get("er_priority"), "UTF-8"));
/*if(htData.get("er_RmDispName")!=null)
	htData.put("er_RmDispName",com.eg.EgURLEncoder.encode((String)htData.get("er_RmDispName"), "UTF-8"));*/
if(htData.get("er_enddate")!=null &&  ((String)htData.get("er_enddate")).indexOf("%")==-1)
	htData.put("er_enddate",com.eg.EgURLEncoder.encode((String)htData.get("er_enddate"), "UTF-8"));
if(htData.get("er_stdate")!=null && ((String)htData.get("er_stdate")).indexOf("%")==-1)
	htData.put("er_stdate",com.eg.EgURLEncoder.encode((String)htData.get("er_stdate"), "UTF-8"));


	String qstringDataP =(String)ErUtils.prepareQueryString(htData);
	String reporttype = (String)htData.get("reporttype");
	int totalNoOfServers      = uptimeList.size();
	int fullUptimeServerCount = 0;
	int downtimeServerCount   = 0;
	long perServerDownTime    = 0;
	long totalDownTimeMin     = 0;
	long avgDownTimeMin       = 0;
	String serverUptime       = "0";
	String serverDowntime     = "0";
	String compontentName     = "";
	double totalDownPercentage=0;

	for(int cnt=0;cnt<totalNoOfServers;cnt++)	
	{
		ErUptimeDowntimeBean uptimeBean = (ErUptimeDowntimeBean) uptimeList.get(cnt);
		perServerDownTime = uptimeBean.getDownTimeMills();
		if(perServerDownTime==0)
		{
			fullUptimeServerCount++;
		}
		else
		{
			 totalDownTimeMin+=perServerDownTime/60000;
			 downtimeServerCount++;
			 //totalDownPercentage +=Double.valueOf(uptimeBean.getPerDownTime());
			 totalDownPercentage +=Double.valueOf(uptimeBean.getDownTimeMills()+"");
		 }
	}
	if(totalDownTimeMin!=0 && downtimeServerCount!=0)
	{
		avgDownTimeMin=totalDownTimeMin/downtimeServerCount;
	}
	if(reporttype !=null && reporttype.equalsIgnoreCase("uptime"))
	{
%>

	<div class="printOuterBox">
		<div class="printOuterBoxHeader" ><%=detailsTitle%> Summary</div>
		<table align="center" cellspacing="0" cellpadding="0" border="0" width='100%'>
			<tr>
				<td  align="center" valign="top" height="252">
				<div style="width:100%;overflow:auto;padding:0px">
			<img src="<%=str+qstringDataP+"&forpdf=yes"%>&er_width=900&er_height=400&chartformat=No" align="middle"></div></td>
			</tr>
		</table>
	</div>
<%
	}
	else
	{
		if(er_uptimetest.equalsIgnoreCase("Virtual Machines")) 
		{
			compText = "VMs";
		}
%>	
	<div class="printOuterBox">
		<div class="printOuterBoxHeader" >Overview</div>
		<table align="center" width="100%" cellspacing="0" cellpadding="0" style="border:0px solid #c3c3c3;padding:10px 10px 10px 10px"><col width="25%"><col width="25%"><col width="25%"><col width="25%">
			<tr>
				<td style="border-right:1px solid #dadada">
					<table align="center"  cellspacing="0" cellpadding="0" border="0" style="align:center;margin:auto auto;" >
						<tbody>
							<tr>
								<td style="text-align:center;">
									<div style="text-align:center; width: 100%; height: 37px;">
											<table align="center">
												<tbody>
													<tr>
														<td align="right" style="padding-right:5px">
															<div class="iconServerGray"></div>
														</td>
														<td style="text-align:left;padding-left:5px" class="newFont_bold28"><%=totalNoOfServers%></td>
													</tr>
												</tbody>
											</table>
									</div>
								</td>
							</tr>
							<tr>
								<td style="text-align:center;">
									<div style="height: 26px;">
											<span class="newFont_normal13">Total number of <%=compText%></span>
									</div>
								</td>
							</tr>
						</tbody>
					</table>
				</td>
				
				<td style="border-right:1px solid #dadada">

				  <table align="center"  cellspacing="0" cellpadding="0" border="0" style="align:center;margin:auto auto;" >
						<tbody>
							<tr>
								<td style="text-align:center;">
									<div style="text-align:center; width: 100%; height: 37px;">
											<table align="center">
												<tbody>
													<tr>
														<td align="right" style="padding-right:5px">
															<div class="iconUpGreen"></div>
														</td>
														<td style="text-align:left;padding-left:5px" class="newFont_bold28"><%=(fullUptimeServerCount==0)?"0":fullUptimeServerCount%></td>
													</tr>
												</tbody>
											</table>
									</div>
								</td>
							</tr>
							<tr>
								<td style="text-align:center;">
									<div style="height: 26px;">
											<span class="newFont_normal13"><%=compText%> with no downtime</span>
									</div>
								</td>
							</tr>
						</tbody>
					</table>
				   </td>
				
				<td style="border-right:1px solid #dadada">
				<table align="center"  cellspacing="0" cellpadding="0" border="0" style="align:center;margin:auto auto;" >
						<tbody>
							<tr>
								<td style="text-align:center;">
									<div style="text-align:center; width: 100%; height: 37px;">
											<table align="center">
												<tbody>
													<tr>
														<td align="right" style="padding-right:5px">
															<div class="iconDownRed"></div>
														</td>
														<td style="text-align:left;padding-left:5px" class="newFont_bold28"><%=(downtimeServerCount==0)?"0":downtimeServerCount%></td>
													</tr>
												</tbody>
											</table>
									</div>
								</td>
							</tr>
							<tr>
								<td style="text-align:center;">
									<div style="height: 26px;">
											<span class="newFont_normal13"><%=compText%> with downtime</span>
									</div>
								</td>
							</tr>
						</tbody>
					</table>
					
				</td>
				<td >
					<table align="center"  cellspacing="0" cellpadding="0" border="0" style="align:center;margin:auto auto;" >
						<tbody>
							<tr>
								<td style="text-align:center;">
									<div style="text-align:center; width: 100%; height: 37px;">
											<table align="center">
												<tbody>
													<tr>
														<td align="right" style="padding-right:5px">
															<div class="iconDownRed"></div>
														</td>
														<td style="text-align:left;padding-left:5px" class="newFont_bold28"><%=(avgDownTimeMin==0?"0":avgDownTimeMin+" <span class='newFont_normal13'>mins</span>")%></td>
													</tr>
												</tbody>
											</table>
									</div>
								</td>
							</tr>
							<tr>
								<td style="text-align:center;">
									<div style="height: 26px;">
											<span class="newFont_normal13">Average downtime</span>
									</div>
								</td>
							</tr>
						</tbody>
					</table>
				</td>
			</tr>
		</table>
	</div>
	<%
		System.out.println("str+qstringDataP+++++++++++ "+str+qstringDataP);
	%>
	<div class="clearDiv">&nbsp;</div>
		<table align="center" valign="top" cellspacing="0" cellpadding="0" width="100%" border="0">
			<tr>
				<td align="left" valign="top" width="49%" height="100%" nowrap style="padding:0px">
					<div class="printOuterBox" >
						<div class="printOuterBoxHeader"><%=detailsTitle%> Summary</div>
						<div style="width:100%;overflow:none;padding:0px">
							<img src="<%=str+qstringDataP+"&forpdf=yes"%>&er_width=450&er_height=370&chartformat=No&er_mode=2D"/>
						</div>
					</div>
				</td>
				<td width="20px">&nbsp;</td>
				<td align="left" valign="top"  width="49%" height="100%" nowrap style="padding:0px">
					<div class="printOuterBox" >
						<div class="printOuterBoxHeader">Overall Uptime/Downtime (%)</div>
						<div style="width:100%;overflow:none;padding:0px">
							<img src="<%=str+qstringDataP+"&forpdf=yes"%>&er_width=450&er_height=390&chartformat=No&chartType=pie"/>
						</div>
					</div>
				</td>
			</tr>
		</table>
	</div>
<%
	}
}
                                }else{



                  //-------------------------------------------------------------------------
				   int totalNoOfServers      = 0;
							int fullUptimeServerCount = 0;
							int downtimeServerCount   = 0;
							long perServerDownTime    = 0;
							long totalDownTimeMin     = 0;
							long avgDownTimeMin       = 0;
                            String serverUptime       = "0";
							int graphLimit            = 10;
							String compontentName     = "";
							double totalDownPercentage=0;
                            totalNoOfServers = uptimeList.size();
                            
							for(int cnt=0;cnt<totalNoOfServers;cnt++){
                               
							   ErUptimeDowntimeBean uptimeBean = (ErUptimeDowntimeBean) uptimeList.get(cnt);
							     
								 perServerDownTime = uptimeBean.getDownTimeMills();

								
                                 
								 if(perServerDownTime==0){
									 fullUptimeServerCount++;
								 }else{
                                    
									 totalDownTimeMin+=perServerDownTime/60000;
                                     downtimeServerCount++;

									 totalDownPercentage +=Double.valueOf(uptimeBean.getPerDownTime());
								 }

                                   
                             }
							 if(totalDownTimeMin!=0 && downtimeServerCount!=0)
                                avgDownTimeMin=totalDownTimeMin/downtimeServerCount;
                              
							%>
                            

<div class="printOuterBox">
	<div class="printOuterBoxHeader" >Overview</div>

<table align="center" width="100%" cellspacing="0" cellpadding="0" style="border:0px solid #c3c3c3;padding:10px 10px 10px 10px"><col width="25%"><col width="25%"><col width="25%"><col width="25%">
	<tr>
		<td style="border-right:1px solid #dadada">
			<table align="center"  cellspacing="0" cellpadding="0" border="0" style="align:center;margin:auto auto;" >
				<tbody>
					<tr>
						<td style="text-align:center;">
							<div style="text-align:center; width: 100%; height: 37px;">
									<table align="center">
										<tbody>
											<tr>
												<td align="right" style="padding-right:5px">
													<div class="iconServerGray"></div>
												</td>
												<td style="text-align:left;padding-left:5px" class="newFont_bold28"><%=totalNoOfServers%></td>
											</tr>
										</tbody>
									</table>
							</div>
						</td>
					</tr>
					<tr>
						<td style="text-align:center;">
							<div style="height: 26px;">
									<span class="newFont_normal13">Total number of <%=compText%></span>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</td>
		
		<td style="border-right:1px solid #dadada">

          <table align="center"  cellspacing="0" cellpadding="0" border="0" style="align:center;margin:auto auto;" >
				<tbody>
					<tr>
						<td style="text-align:center;">
							<div style="text-align:center; width: 100%; height: 37px;">
									<table align="center">
										<tbody>
											<tr>
												<td align="right" style="padding-right:5px">
													<div class="iconUpGreen"></div>
												</td>
												<td style="text-align:left;padding-left:5px" class="newFont_bold28"><%=(fullUptimeServerCount==0)?"0":fullUptimeServerCount%></td>
											</tr>
										</tbody>
									</table>
							</div>
						</td>
					</tr>
					<tr>
						<td style="text-align:center;">
							<div style="height: 26px;">
									<span class="newFont_normal13"><%=compText%> with no downtime</span>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
           </td>
		
		<td style="border-right:1px solid #dadada">
		<table align="center"  cellspacing="0" cellpadding="0" border="0" style="align:center;margin:auto auto;" >
				<tbody>
					<tr>
						<td style="text-align:center;">
							<div style="text-align:center; width: 100%; height: 37px;">
									<table align="center">
										<tbody>
											<tr>
												<td align="right" style="padding-right:5px">
													<div class="iconDownRed"></div>
												</td>
												<td style="text-align:left;padding-left:5px" class="newFont_bold28"><%=(downtimeServerCount==0)?"0":downtimeServerCount%></td>
											</tr>
										</tbody>
									</table>
							</div>
						</td>
					</tr>
					<tr>
						<td style="text-align:center;">
							<div style="height: 26px;">
									<span class="newFont_normal13"><%=compText%> with downtime</span>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
			
		</td>
		<td >
			<table align="center"  cellspacing="0" cellpadding="0" border="0" style="align:center;margin:auto auto;" >
				<tbody>
					<tr>
						<td style="text-align:center;">
							<div style="text-align:center; width: 100%; height: 37px;">
									<table align="center">
										<tbody>
											<tr>
												<td align="right" style="padding-right:5px">
													<div class="iconDownRed"></div>
												</td>
												<td style="text-align:left;padding-left:5px" class="newFont_bold28"><%=(avgDownTimeMin==0?"0":avgDownTimeMin+" <span class='newFont_normal13'>mins</span>")%></td>
											</tr>
										</tbody>
									</table>
							</div>
						</td>
					</tr>
					<tr>
						<td style="text-align:center;">
							<div style="height: 26px;">
									<span class="newFont_normal13">Average downtime</span>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</td>
	</tr>
</table>
</div>
<div class="clearDiv">&nbsp;</div>
							  
                            <%  
                  //-------------------------------------------------------------------------
                              
                               String queryStr = (String)session.getAttribute("querygraph");
                                    String queryStrPie ="";
                                    String str = "";
                                    String str1 = "";
                                    if(queryStr ==null) {
										str = "/final/servlet/com.eg.ErUptimeServletC;jsessionid=" + session.getId() + "?";
                                        str1 = qString;
                                    } else {
                                        queryStrPie = queryStr.substring(0,queryStr.indexOf("&er_width"));
                                        
                                        int index = queryStrPie.indexOf("?");
                                        str = queryStrPie.substring(0,index) + ";jsessionid=" + session.getId() + "?";
                                        str1 = queryStrPie.substring(queryStrPie.indexOf("?")+1,queryStrPie.length());
                                    }
                                    String erbarheightstyle = "230";
                                    String erbarheight = String.valueOf(uptimeList.size() * 15 > 500 ?uptimeList.size() * 15 : 500);
%>


<%
                                                int index = queryStrPie.indexOf("?");
                                                String strQry = "";
                                                StringTokenizer strtok = new StringTokenizer(str1,"&");
                                                while(strtok.hasMoreTokens()) {
                                                    String parameter = strtok.nextToken();
                                                    int ind = parameter.indexOf("=");
                                                    if (ind < 0)
                                                        continue;
                                                    String reqparam =parameter.substring(0,ind);
                                                    String value = parameter.substring(ind+1);
                                                    if(reqparam!=null && reqparam.equals("limitforbg")){
                                                        value = com.eg.EgURLEncoder.encode(value, "UTF-8");
                                                    }
                                                    if(reqparam!=null && reqparam.equals("er_timeline")){
                                                        value = com.eg.EgURLEncoder.encode(value, "UTF-8");
                                                    }
                                                    if(reqparam!=null && reqparam.equals("er_combination")){
                                                        value = com.eg.EgURLEncoder.encode(value, "UTF-8");
                                                    }
													if(reqparam!=null && reqparam.equals("er_usertimeline")){
																				value = com.eg.EgURLEncoder.encode(value, "UTF-8");
													}
													if(reqparam!=null && reqparam.equals("userTimeline")){
																				value = com.eg.EgURLEncoder.encode(value, "UTF-8");
													}
													if(reqparam!=null && (reqparam.equals("eruserid")||reqparam.equals("userID") || reqparam.equals("uid")||reqparam.equals("er_userid")||reqparam.equals("er_RmDispName")))
													{
														if(value!=null && value.indexOf("%")==-1)
														{
															value = com.eg.EgURLEncoder.encode(value, "UTF-8");
														}
													}

                                                    if(reqparam!=null && reqparam.equals("throughSchedule")) {
                                                        continue;
                                                    }
													//
													if(reqparam!=null && reqparam.equals("strbg_id")){
														value = com.eg.EgURLEncoder.encode(value, "UTF-8");
													}
													if(reqparam!=null && reqparam.equals("er_show"))
													{
														if(value!=null && value.indexOf("%")==-1)
														{
															value = com.eg.EgURLEncoder.encode(value, "UTF-8");
														}
													}
													//
                                                    strQry += reqparam+"="+value+"&";
                                                }


												Map mapReqParamsData = ErUtils.parseQueryString(strQry);
												String valueP = "";
												Object obj = mapReqParamsData.get("er_component");
												if(obj instanceof String[])
												{
													String[] comps = (String[]) obj;
													for (int j = 0;j < comps.length; j++)
													{
														if(comps[j] != null && !comps[j].equals(""))
														{
															try
															{
																mapReqParamsData.remove("er_component");
																//param.put("er_component",EgURLEncoder.encode(comps[j],"UTF-8"));
																valueP +="&er_component="+ com.eg.EgURLEncoder.encode(comps[j].toString(),"UTF-8")+ "&";
															}catch(Exception t1){}
														}
													}
												}
												else
												{
													try
													{
														mapReqParamsData.remove("er_component");
														valueP +="&er_component="+ com.eg.EgURLEncoder.encode(obj.toString(),"UTF-8")+ "&";
													}catch(Exception t1){}
												}
String qstringData =(String)ErUtils.prepareQueryString(mapReqParamsData);
String dataQry = qstringData+valueP;
if(dataQry !=null)
{
HashMap hmData1 = ErUtils.parseQueryString(dataQry);
Hashtable table = new Hashtable(hmData1);
//For print, htData is passed, not the request, so decode the er_show
String show = (String)request.getParameter("er_show");
//String show = (String)table.get("er_show");
if(show!=null && show.length()>0)
{
	//show = com.eg.EgURLDecoder.decode(show,"UTF-8");
	show = erUtils.specialCharDecode(show);
	table.put("er_show",show);
}
session.setAttribute("htData",table);
Object tempComp = table.get("er_component");
if(tempComp != null) {
	String[] erComps = null;
	if(tempComp instanceof String) {
		erComps = new String[1];
		erComps[0] = com.eg.EgURLDecoder.decode(tempComp.toString(), "UTF-8");
	} else {
		String[] tempObj = (String[]) tempComp;
		erComps = new String[tempObj.length];
		for(int i=0; i<tempObj.length; i++) {
			erComps[i] = com.eg.EgURLDecoder.decode(tempObj[i], "UTF-8");
		}
	}
	if(erComps != null) {
		table.put("er_component", erComps);
	}
}
//dataQry=dataQry+"er_RmDispName=Uptime&";
dataQry=dataQry.replaceAll("&er_view=GRAPH","");
HashMap hmData = ErUtils.parseQueryString(dataQry);
Hashtable htData = new Hashtable(hmData);
htData.remove("er_component");
htData.remove("er_combination");

/*if(htData.get("startdate")!=null)
	htData.put("startdate",com.eg.EgURLEncoder.encode((String)htData.get("startdate"), "UTF-8"));
if(htData.get("inidate")!=null)
	htData.put("inidate",com.eg.EgURLEncoder.encode((String)htData.get("inidate"), "UTF-8"));
if(htData.get("enddate")!=null)
	htData.put("enddate",com.eg.EgURLEncoder.encode((String)htData.get("enddate"), "UTF-8"));*/
if(htData.get("er_uptimetest")!=null)
	htData.put("er_uptimetest",com.eg.EgURLEncoder.encode((String)htData.get("er_uptimetest"), "UTF-8"));
if(htData.get("er_priority")!=null)
	htData.put("er_priority",com.eg.EgURLEncoder.encode((String)htData.get("er_priority"), "UTF-8"));
/**
 * This is line comment for Bug Id 17152 
 */
/*if(htData.get("er_RmDispName")!=null)
	htData.put("er_RmDispName",com.eg.EgURLEncoder.encode((String)htData.get("er_RmDispName"), "UTF-8"));*/
if(htData.get("er_enddate")!=null &&  ((String)htData.get("er_enddate")).indexOf("%")==-1)
	htData.put("er_enddate",com.eg.EgURLEncoder.encode((String)htData.get("er_enddate"), "UTF-8"));
if(htData.get("er_stdate")!=null && ((String)htData.get("er_stdate")).indexOf("%")==-1)
	htData.put("er_stdate",com.eg.EgURLEncoder.encode((String)htData.get("er_stdate"), "UTF-8"));



String qstringDataP =(String)ErUtils.prepareQueryString(htData);

System.out.println("qstringDataP "+(str+qstringDataP));
%>
    
  <table align="center" valign="top" cellspacing="0" cellpadding="0" width="100%" border="0">
	<tr>
		<td align="left" valign="top" width="49%" height="100%" nowrap style="padding:0px">
		<div class="printOuterBox" >
			<div class="printOuterBoxHeader">Top 10 <%=compText%> with High Down Time</div>
		<div style="width:100%;overflow:none;padding:0px"><img src="<%=str+qstringDataP+"&forpdf=yes"%>&er_width=450&er_height=370&chartformat=No&er_mode=2D"/></div>
		</div>
		</td>
		<td width="20px">&nbsp;</td>
		<td align="left" valign="top"  width="49%" height="100%" nowrap style="padding:0px">
		<div class="printOuterBox" >
			<div class="printOuterBoxHeader">Overall Uptime/Downtime (%)</div>
			<div style="width:100%;overflow:none;padding:0px">
					<img src="<%=str+qstringDataP+"&forpdf=yes"%>&er_width=450&er_height=390&chartformat=No&chartType=pie"/></div>
		</div>
		</td>
	</tr>
</table>












<%
}
                                }
                                boolean canShowDetails = false;
                                if((er_type == null || er_type.equals("No")) && showDetails != null && showDetails.equalsIgnoreCase("Yes")) {
                                    for(int i=0; i<uptimeList.size(); i++) {
                                        ErUptimeDowntimeBean uptimeBean = (ErUptimeDowntimeBean) uptimeList.get(i);
                                        if(uptimeBean.getNoOfReboots() > 0) {
                                            canShowDetails = true;
                                            break;
                                        }
                                    }
                                }
                                if(canShowDetails) {
                                    List uptimeData = (List)resultDataMap.get("UPTIME_DATA");
                                    SimpleDateFormat sdf = new SimpleDateFormat(currentDateFormat+" HH:mm:ss");
%>

<div class="clearDiv">&nbsp;</div>

<div class="printOuterBox">
	<div class="printOuterBoxHeader" ><egui:intnl text="reporter.common.Reboot Details for"/>&nbsp;<%=er_uptimetest%></div>
	<div class="newTable">
		<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0" class="printTable">
			<thead>
				<tr>
					<th style="text-align:left"><%=er_uptimetest%></th>
					<th ><egui:intnl text="reporter.uptime.Shutdown At"/></th>
					<th ><egui:intnl text="reporter.uptime.Rebooted At"/></th>
					<th ><egui:intnl text="reporter.uptime.Downtime"/>&nbsp;(<egui:intnl text="reporter.uptime.mins"/>)</th>
					<th ><egui:intnl text="reporter.uptime.Uptime Before Reboot"/>&nbsp;(<egui:intnl text="reporter.uptime.yMdhm"/>)</th>
				</tr>
			</thead>
			<tbody>
							<%
							for(int i=0; i<uptimeList.size(); i++) {
				ErUptimeDowntimeBean uptimeBean = (ErUptimeDowntimeBean) uptimeList.get(i);
				if(uptimeBean.getNoOfReboots() > 0) {
					boolean compFound = false;
					ErUptimeData data = null;
					for(int j=0; j<uptimeData.size(); j++) {
						data = (ErUptimeData)uptimeData.get(j);
						if(data.getTrgtHost().equals(uptimeBean.getComponent())) {
							compFound = true;
							break;
						}
					}
					
					List detailBeanList = new ArrayList();
					if(compFound) {
						List rebootList = data.getFilteredReboot();
						List shutdownList = data.getFilteredShutdown();
						List durationList = data.getFilteredDuration();
						List lastUpTimesList = data.getLastUpTimesList();
						
						for(int j=0; j<shutdownList.size(); j++) {
							ErRebootDetailBean detailBean = new ErRebootDetailBean();
							detailBean.setShutdown((Calendar)shutdownList.get(j));
							detailBean.setReboot((Calendar)rebootList.get(j));
							detailBean.setDuration((String)durationList.get(j));
							detailBean.setLastUpTime((String)lastUpTimesList.get(j));
							detailBeanList.add(detailBean);
						}
						Collections.sort(detailBeanList);
					}
					
					if(detailBeanList.size() > 0) {
							%>
				<tr>
					<td rowspan="<%=detailBeanList.size()%>" nowrap align ="left"><%=uptimeBean.getComponent()%></td>
<%
		if(er_uptimetest!=null && er_uptimetest.equalsIgnoreCase("Systems"))
		{
%>
		<td rowspan="<%=detailBeanList.size()%>" nowrap align ="left"><%=getDisplayString(uptimeBean.getRunningSince(), "0")%></td>
<%
		}
						for(int j=0; j<detailBeanList.size(); j++) {
							ErRebootDetailBean bean = (ErRebootDetailBean)detailBeanList.get(j);
							String shutTime = sdf.format(bean.getShutdown().getTime());
							String rebootTime = sdf.format(bean.getReboot().getTime());
							if(j>0)
							 {
%>
				<tr>
<%
							}
%>
					<td align="center"><%=shutTime%> </td>
					<td align="center"><%=rebootTime%> </td>
					<td align="center"><%=bean.getDuration()%></td>
<%
						st = new StringTokenizer(bean.getLastUpTime());
						String displayString = "";
						while(st.hasMoreTokens()) {
							if(displayString.equals("")) {
								displayString = st.nextToken();
							} else {
								displayString += "&nbsp;" + st.nextToken();
							}
							displayString += st.nextToken();
						}
						if(displayString.equals("")) {
							displayString += "&nbsp;";
						}
						%>
					<td align="center"><%=displayString%></td>
	</tr>
<%
							}
				}
			}
						}
%>
</tbody>
</table>
</div>
</div>
                                        
<%
                                        }
                                        } else {
%>
<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0">
	<tr>
		<td align='center' valign='middle'><img src='../images/Light/nomeasures_custom.png' /></td>
	</tr>
</table><br/>
                                        <%
                                        }
		h_tabrc.put(v_measure,list_data);
		h_tab.put(s_title,h_tabrc); 
		list.add(h_tab);
		list.add(data_abbrevation);
		session.setAttribute("ScheduleCSVData",list);
	
	if(pdfPrint != null && pdfPrint.equalsIgnoreCase("yes"))
	{%>
		<div class="printFooterText"><%=strPrintFooterText%></div>
	<%
	}
}
catch(Throwable t){
t.printStackTrace();
}
                                        %>
                                       
        </form>
        <script>
		//window.print();
        </script>
        
    </body>
</html>
<%@ include file = "ErRemoveUser.jsp"%>

<%
// karthikeyan 

	 if(titleToDisplay!=null && !titleToDisplay.isEmpty())
	{
	//For Setting the PDf File Name
	String reportFileName=customReplaceAll(titleToDisplay," ","_");
	HashMap paramVal =new HashMap();
	paramVal.put("fileName",reportFileName);
	session.setAttribute("parameters", paramVal);
	}

%>

<%!
	// karthikeyan 
    public  String customReplaceAll(String source,String toReplace,String replacement) {
        int idx = source.lastIndexOf(toReplace);
        if (idx != -1) {
            StringBuffer ret = new StringBuffer(source);
            ret.replace(idx, idx + toReplace.length(), replacement);
            while ((idx = source.lastIndexOf(toReplace, idx - 1)) != -1) {
                ret.replace(idx, idx + toReplace.length(), replacement);
            }
            source = ret.toString();
        }
        return source;
    }
    //

%>
