<%
/*******************************************************************************************************************
*	File name		:	ErSnapshot.jsp
*	Purpose			:	Caters the over all snap view of Component on diff tests and vice versa
*	Version			:	Reporter v4.0
*	Author			:	Karthick Krishnan
*	Creation Date	:	10/10/2003
*	Last Modified	:	02/09/2004 - Solomon - DD not shown for Agentless server except external tests.
*							02/08/2004  M.Saravanan - Table border changed & Mail Feature added
*							25/07/2004  M.Saravanan - Submit button disabled functionality added,alignment changed
*							25/07/2004  Vijaykumar - did add Tray Icons -(SAVE, ADD, FAVORITES, SCHEDULES,PRINT,DD)
*							28/04/2004 -M.Saravanan - SAVE,ADD TO FAVORITES,ADD TO SCHEDULES buttons are replaced by ICONS
*							20/11/2003 -Gopi changes done to incorporate 5 states than 3 states
*								04/11/2009 - sakthi - code change for loade data use separate table
							14jul/11- muralikanth-- implemented "Report for" filter 
*******************************************************************************/
%>

<%@ include file = "ErReporterTracker.jsp" %>
<%@ page import = "egurkha.reporter.*" %>
<%@ page import = "com.eg.EgDateInfo"%>
<%@ page import = "com.eg.EgInstallInfo" %>
<%@ page import = "com.eg.EgSpecsInfo" %>
<%@ page import = "com.eg.EgMemInfo" %>
<%@ page import = "com.eg.EgThresholdInfo" %>
<%@ page import = "com.eg.EgDiscInfo" %>
<%@ page import = "egurkha.EgCrawler" %>
<%@ page import = "com.eg.EgDbaseInfo" %>
<%@ page import = "com.eg.EgTablesInfo" %>
<%@ page import = "com.eg.EgGroupInfo" %>
<%@ page import = "com.eg.IniFile" %>
<%@ page import = "com.eg.EgTopoInfo" %>
<%@ page import = "com.eg.EgURLEncoder" %>
<%@ page import = "com.eg.EgURLDecoder" %>
<%@ page import = "com.eg.EgMappingInfo" %>
<%@ page import = "com.eg.EgReportInfo"%>
<%@ page import = "com.eg.MappingNameSorter"%>
<%@ page import = "com.eg.EgName"%>
<%@ page import = "com.eg.EgTestInfo"%>
<%@ page import = "com.egurkha.ini.*" %>
<%@ page import = "com.egurkha.ini.IniUI" %>
<%@ page import = "com.egurkha.util.DateTimeTokenizer" %>
<%@ page import = "com.egurkha.util.DateUtil" %>
<%@ page import = "com.egurkha.util.StringUtils"%>
<%@ page import = "java.text.*" %>
<%@ page import = "java.net.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "com.eg.EgConfigInfo"%>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import = "com.egurkha.admin.AuditLogHashtable"%>
<%@ page import="net.sf.json.*"%>
<%@ page import="com.egurkha.monitor.EgDiagnosisBean"%>
<%@ page import="com.egurkha.monitor.EgDashBoardModel"%>

<%
//Back Button - End
	response.setHeader("Cache-Control","no-store");
	response.setHeader("Pragma","no-cache");
	response.setDateHeader("Expires", -1);
	String titleToDisplay=request.getParameter("er_RmDispName");					
	String currentDateFormat=null;
	String dashboardConfig = "/manager/config/eg_dashboardConfig.ini";
	IniFile dashboardConfigIni = new IniFile(EgInstallInfo.getInstallDir() + dashboardConfig);
	EgDashBoardModel  egDashboard=new  EgDashBoardModel();
	try
	{
		JSONObject json = new JSONObject();
		JSONObject screenLabels = new JSONObject();
		JSONObject pageParams = new JSONObject();
		JSONObject hiddenParams = new JSONObject();
		JSONObject selectionDetails = new JSONObject();

		
		String action = request.getParameter("snapShotUIAction");
		String mngrIProc = new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");
		String type = request.getParameter("er_gtype");
		if(action!=null && action.equals("defaultLoad"))
		{
			HashMap backreqMap = (HashMap)session.getAttribute("backQuery");
			String backQnumber = request.getParameter("backQnumber");
			String servlet2 = request.getParameter("backServletName");

			ErHelperUtils erhelputils = null;

			if( servlet2!=null && !servlet2.equals(""))
				erhelputils = new ErHelperUtils(backreqMap,backQnumber,servlet2);
			else
				erhelputils = new ErHelperUtils(backreqMap,backQnumber);

			boolean enableBack=erhelputils.isBackButtonEnable();

			String backButtonEnable = request.getParameter("back");
			if(backButtonEnable != null && backButtonEnable.equalsIgnoreCase("True"))
			{
				request.setAttribute("snapData",null);
			}

			String skinColor="";
			String ctr = "0";
			skinColor = thisuser.getReporterSkin();

			ErReqData erd = new ErReqData(request);
			UBean = new ErUserData(urs,false);
			ErUtils erUtils = new ErUtils();
			EgDateInfo egDt = new EgDateInfo();
			ErReportHelper rHelper = new ErReportHelper();
			EgSpecsInfo egSpecsInfo = new EgSpecsInfo("manager");
			EgReportInfo rptInfo=new EgReportInfo("manager");
			EgTestInfo tokInfo = new EgTestInfo("manager");
			ErReportHelper er_rpthelper = new ErReportHelper();
			ErComponentsUtils compUtil = new ErComponentsUtils(thisuser.getLoginID());
			IniUI iniui = IniUI.getInstance();
			User usr = UserRegistry.getInstance().getUser(session.getId());
			String thisLanguage = iniui.getDefaultLanguage();
			if (usr!=null)
			{
				String userLang = usr.getLanguage();
				if (userLang!=null && !userLang.equalsIgnoreCase("NULL"))
				{
					thisLanguage = userLang;
				}
			}
			UBean = usr.getReporterData();
			Map User_tests = UBean.getTests();
			EgMappingInfo mappingInfo = new EgMappingInfo(thisLanguage);

			ArrayList serverList = new ArrayList();
			MappingNameSorter sorter = new MappingNameSorter(thisLanguage);
			IniFile egFormat = new IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_format.ini");
			String reqFromSchedule = request.getParameter("fromSchedule");
			String fromScheduleModify = request.getParameter("fromScheduleModify");
			String fromFavoriteModify = request.getParameter("fromFavoriteModify");
			String favorite_id = request.getParameter("id");
			String er_favorite = request.getParameter("er_favorite");

			String schedule_id = request.getParameter("schedule_id");
			String s_component = request.getParameter("er_component");
			String s_test = request.getParameter("er_test");
			String st_dataFrom=request.getParameter("er_dataFrom");
			String s_option=request.getParameter("er_option");
			String er_service = request.getParameter("er_service");
			if(s_option==null && er_service!=null)
			{
				s_option=er_service;
			}

			String isForceSubmit = request.getParameter("isForceSubmit");
			String treeParam = request.getParameter("treeParam");
			if(treeParam!=null && treeParam.length() > 0)
			{
				s_option = treeParam;
			}
			String s_treeParam = request.getParameter("treeCompType");
			String s_componentType=request.getParameter("er_componentType");
			String s_subZone=request.getParameter("er_dataZone");
			String _search=request.getParameter("er_search");
			String prior_type = request.getParameter("prior_type");
			String infosearch=request.getParameter("er_info_search");
			String divStatus = request.getParameter("divStatus");
			String srcForImg="";
			if(divStatus==null)
			{
			divStatus="none";
			}

			if(divStatus.equals("none"))
			{
				srcForImg="/final/images/moreoption.png";
			}
			else if(divStatus.equals("block"))
			{
				srcForImg="/final/images/lessoption.png";
			}

			if(infosearch==null)
			{
				infosearch="";
			}
			
			if(prior_type == null || prior_type.equals(""))
			{
				prior_type = "All";
			}

			if(s_componentType == null || s_componentType.equals(""))
			{
				s_componentType = "All";
			}
			
			if(request.getParameter("count")!=null)
				ctr = request.getParameter("count");
			Vector v_prior_type = new Vector();
			v_prior_type.add("All");
			v_prior_type.add("Critical & Major");
			v_prior_type.add("Critical & Major & Minor");
			v_prior_type.add("Critical");
			v_prior_type.add("Major");
			v_prior_type.add("Minor");
			v_prior_type.add("Abnormal");
			v_prior_type.add("Normal");
			v_prior_type.add("Unknown");

			Vector v_prior_type_value = new Vector();
			v_prior_type_value.add("All");
			v_prior_type_value.add("Critical and Major");
			v_prior_type_value.add("Critical and Major and Minor");
			v_prior_type_value.add("Critical");
			v_prior_type_value.add("Major");
			v_prior_type_value.add("Minor");
			v_prior_type_value.add("Abnormal");
			v_prior_type_value.add("Normal");
			v_prior_type_value.add("Unknown");

			Vector v_test_popup = new Vector();
			Vector v_test_popup_disp = new Vector();
			Vector v_comp_popup = new Vector();
			Vector v_comp_popup_disp = new Vector();
			Vector v_availTest = rHelper.getAllMetaTests();
			Vector v_test=new Vector();
			Vector v_availComps = compUtil.getAllUserComponents1();
			Vector v_singleSelectData = null;
			Vector v_componentType= null;
			Vector v_multiSelectData = null;
			Vector v_compareOptions = new Vector(Arrays.asList(compUtil.groupLists));
			Collections.sort(v_compareOptions, String.CASE_INSENSITIVE_ORDER);
			String arr_highlightData[] = null;
			Vector v_componetdisp=new Vector();
			String s_singleSelectLabel = null;
			String s_multiSelectLabel = null;
			String s_singleSelectValue = null;
			Vector filledup=new Vector();
			Vector v_componentTypeForZone=null;
			Vector v_comps=new Vector();
			Vector v_component=null;
			Vector v_testForComp=new Vector();//added by murali
			Vector v_compForTest=new Vector();//added by murali
			String default_select="";
			
			if(st_dataFrom==null || st_dataFrom.equals(""))		
			{
				st_dataFrom="Component" ;
			}
			
			if(st_dataFrom!=null && !st_dataFrom.equals("")&&st_dataFrom.equalsIgnoreCase("Component"))
			{
				if(type!=null&&type.equalsIgnoreCase("intersnap"))
				{
					for(int k=0;v_availTest.size()>k;k++)
					{
						String str_test=(String)v_availTest.get(k);
						if(!str_test.endsWith("_cf"))
						{
							if(!v_test.contains(str_test) && User_tests.containsKey(str_test) )
							v_test.add(str_test);
						}
					}
					v_componentType=new Vector();
					if(s_componentType!=null&&!s_componentType.equalsIgnoreCase("-1")&&!s_componentType.equalsIgnoreCase("Not Applicable"))
					{
						Vector 	v_componentTypes=compUtil.getComponentType(v_availComps);
						for(int j=0;v_componentTypes.size()>j;j++)
						{
							if(egSpecsInfo.isTestRelevantForServer((String)v_componentTypes.get(j),s_test))
							{		
								v_componentType.add(v_componentTypes.get(j));
							}
						}
						if(s_componentType.equalsIgnoreCase("All"))
						{
							for(int j=0;v_componentTypes.size()>j;j++)
							{
								String str_type=v_componentTypes.get(j).toString();
								if(egSpecsInfo.isTestRelevantForServer(str_type,s_test))
								{
									for(int k=0;v_availComps.size()>k;k++)
									{
										String s_com = v_availComps.get(k).toString();
										String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
										if(str_type.equalsIgnoreCase(strCompType))
												v_compForTest.add(v_availComps.get(k));
									}
								}
							}
						} else {
							for(int i=0;v_availComps.size()>i;i++)
							{
								String s_com = v_availComps.get(i).toString();
								String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
								if(s_componentType.equalsIgnoreCase(strCompType))
									v_compForTest.add(v_availComps.get(i));
							}
						}
					}
					if(s_component==null)
					{
						Vector 	v_componentTypes;
						if(v_test.size()>0)
						{
								v_componentTypes=compUtil.getComponentType(v_availComps);

								if(s_treeParam!=null && s_treeParam.length() > 0)
								{
									for(int vi=0; vi < v_componentTypes.size(); vi++)
									{
										String s_compType = (String)v_componentTypes.get(vi);
										if(s_compType.equals(s_treeParam))
										{
											for(int v=0; v< v_test.size();v++)
											{
												String test = (String)v_test.get(v);

												if(egSpecsInfo.isTestRelevantForServer(s_compType,test))
												{	
													s_test = test;
													
												}
											}
											v_componentType.add(s_compType);
										}
									}
									
								}
								else
								{
									s_test=(String)v_test.get(0);
									v_componentTypes=compUtil.getComponentType(v_availComps);
									for(int j=0;v_componentTypes.size()>j;j++)
									{
										if(egSpecsInfo.isTestRelevantForServer((String)v_componentTypes.get(j),s_test))
										{		
											v_componentType.add(v_componentTypes.get(j));
										}
									}
									if(v_componentType.size()==1)
									{
										s_componentType=(String)v_componentType.get(0);
									}
									for(int i=0;v_availComps.size()>i;i++)
									{
										String s_com = v_availComps.get(i).toString();
										String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
										if(v_componentType.contains(strCompType))
											v_compForTest.add(v_availComps.get(i));
									}
								}
						}
					}
				}
				else 	if(type!=null&&type.equalsIgnoreCase("intrasnap"))
				{
					 v_componentType=compUtil.getAllComponentType() ;
					 if(s_component!=null&&!s_component.equalsIgnoreCase("-1"))
					{
						if(s_componentType.equalsIgnoreCase("All"))
						{
							 v_component=new Vector();
							if(v_availComps!=null)
								 v_component.addAll(v_availComps);	 
						 }
						 else
						{
							 v_component=new Vector();
							for(int i=0;v_availComps.size()>i;i++)
							{
								String s_com = v_availComps.get(i).toString();
								String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
								if(s_componentType.equalsIgnoreCase(strCompType))
								{			
									v_component.add(v_availComps.get(i));
								}
							}
						}

						if(s_test!=null&&!s_test.equalsIgnoreCase("-1")&&!s_test.equalsIgnoreCase("Not Applicable"))
						{
							String  comType=s_component.substring(s_component.lastIndexOf(":")+1);
							String s_tests[] = egSpecsInfo.getTestsForServer(comType);
							if(s_treeParam!=null && s_treeParam.length() > 0)
							{
								
								s_tests = egSpecsInfo.getTestsForServer(s_componentType);
							}
							List list = new ArrayList();
							if(s_tests==null && s_component.equalsIgnoreCase("All"))
							{
								Map usrTest = usr.getTests();
								Set set1 = usrTest.entrySet();
								Iterator iterator1 = set1.iterator();
								while (iterator1.hasNext())
								{
									Map.Entry mentry1 = (Map.Entry) iterator1.next();
									String childKey1 = (String) mentry1.getKey();
									list.add(childKey1);
								}
							}
							else
							{
								list=Arrays.asList(s_tests);
							}
							for (int i=0;list.size()>i;i++ )
							{
								String str_test=(String)list.get(i);
								if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(i)))
								{
									v_testForComp.add(str_test);
								}
							}
						}
					}
					if(s_component==null) {
						v_component=new Vector();
						v_componentType=compUtil.getAllComponentType() ;
						v_component=v_availComps;
						default_select="selected";
						if(v_availComps.size()>0)
						{
							if(s_componentType==null || s_componentType.equalsIgnoreCase("All"))
							{
								if(v_componentType.size()==1)
								{
									s_componentType=(String)v_componentType.get(0);
								}
							} else {
								 v_component=new Vector();
								for(int i=0;v_availComps.size()>i;i++)
								{
									String s_com = v_availComps.get(i).toString();
									String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
									if(s_componentType.equalsIgnoreCase(strCompType))
									{
										v_component.add(v_availComps.get(i));
									}
								}
							}
							if(s_componentType != null && !s_componentType.trim().equals(""))
							{
								Collections.sort(v_component,String.CASE_INSENSITIVE_ORDER);
								s_component=(String)v_component.get(0);
								String  comType=s_component.substring(s_component.lastIndexOf(":")+1);
								String s_tests[] = egSpecsInfo.getTestsForServer(comType);
								if(s_tests != null)
								{
									List list=Arrays.asList(s_tests);
									for (int i=0;list.size()>i;i++ )
									{
										String str_test=(String)list.get(i);
										if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(i)))
										{
											v_testForComp.add(str_test);
										}
									}
									if(v_testForComp!=null && v_testForComp.size()>0)
									s_test=(String)v_testForComp.get(0);
								}
							}
						}
					}
				}
			}
			else if(st_dataFrom!=null && !st_dataFrom.equals("")&&st_dataFrom.equalsIgnoreCase("Zone"))
			{
				boolean isSubZone;
				if(compUtil.getUserZones()!=null)
				{
					filledup.addAll(compUtil.getUserZones());
					Collections.sort(filledup, String.CASE_INSENSITIVE_ORDER);
				}
				if(s_option!=null&&!s_option.equals("-1")&&!s_option.equalsIgnoreCase("Not Applicable"))
				{
					if(s_subZone!=null)
					{
						isSubZone=(s_subZone.equalsIgnoreCase("yes"))?true:false;
						ArrayList alList=compUtil.getZoneComponents(s_option,isSubZone);
						if(alList!=null)
							v_comps.addAll(alList);
					}
					else
					{
						isSubZone=true;
						ArrayList alList=compUtil.getZoneComponents(s_option,isSubZone);
						v_comps=new Vector();
						if(alList!=null)
							v_comps.addAll(alList);
					}
					v_componentType=new Vector();
					if(type!=null&&type.equalsIgnoreCase("intersnap"))
					{
						//------------
						if(isForceSubmit!=null && isForceSubmit.equals("true"))
						{
							if(s_component==null) {
									v_component=new Vector();
									v_componentType=compUtil.getAllComponentType() ;
									v_component=v_availComps;
									default_select="selected";
									if(v_availComps.size()>0)
									{
										if(s_componentType==null || s_componentType.equalsIgnoreCase("All"))
										{
											if(v_componentType.size()==1)
											{
												s_componentType=(String)v_componentType.get(0);
											}
										} else {
											 v_component=new Vector();
											for(int i=0;v_availComps.size()>i;i++)
											{
												String s_com = v_availComps.get(i).toString();
												String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
												if(s_componentType.equalsIgnoreCase(strCompType))
												{
													v_component.add(v_availComps.get(i));
												}
											}
										}
										if(s_componentType != null && !s_componentType.trim().equals(""))
										{
											Collections.sort(v_component,String.CASE_INSENSITIVE_ORDER);
											s_component=(String)v_component.get(0);
											String  comType=s_component.substring(s_component.lastIndexOf(":")+1);
											String s_tests[] = egSpecsInfo.getTestsForServer(comType);

											if(s_tests != null)
											{
												List list=Arrays.asList(s_tests);
												for (int i=0;list.size()>i;i++ )
												{
													String str_test=(String)list.get(i);
													if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(i)))
													{
														v_testForComp.add(str_test);
													}
												}

												if(v_testForComp!=null && v_testForComp.size()>0)
												s_test=(String)v_testForComp.get(0);
											}
										}
									}
								}
							
						}
						//---------------
						if((s_test!=null&&!s_test.equals("-1")&&!s_test.equalsIgnoreCase("Not Applicable"))	
							|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
						{
							v_test=new Vector();
							Vector v_componentTypes1=compUtil.getComponentType(v_comps);
							for(int i=0;v_componentTypes1.size()>i;i++)
							{
								String s_tests[] = egSpecsInfo.getTestsForServer((String)v_componentTypes1.get(i));
								List list=Arrays.asList(s_tests);
								for (int k=0;list.size()>k;k++ )
								{
									String str_test=(String)list.get(k);
									if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(k)))
									{
										if(!v_test.contains(str_test) && User_tests.containsKey(str_test) )
											v_test.add(str_test);
									}
								}
							}
							if(s_componentType!=null&&!s_componentType.equalsIgnoreCase("-1")&&!s_componentType.equalsIgnoreCase("Not Applicable"))
							{
								if(isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All"))
									s_test = (String) v_test.get(0);
								Vector 	v_componentTypes=compUtil.getComponentType(v_comps);
								for(int j=0;v_componentTypes.size()>j;j++)
								{
									if(egSpecsInfo.isTestRelevantForServer((String)v_componentTypes.get(j),s_test))
									{		
										v_componentType.add(v_componentTypes.get(j));
									}
								}
								if((s_component!=null&&!s_component.equalsIgnoreCase("-1")&&!s_component.equalsIgnoreCase("Not Applicable"))
									|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
								{
									if(s_componentType.equalsIgnoreCase("All"))
									{						
										for(int j=0;v_componentTypes.size()>j;j++)
										{
											String str_type=v_componentTypes.get(j).toString();
											if(egSpecsInfo.isTestRelevantForServer(str_type,s_test))
											{
												for(int k=0;v_comps.size()>k;k++)
												{
													String s_com = v_comps.get(k).toString();
													String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
													if(str_type.equalsIgnoreCase(strCompType))
														v_compForTest.add(v_comps.get(k));
												}
											}
										}
									}
									else
									{
										for(int i=0;v_comps.size()>i;i++)
										{
											String s_com = v_comps.get(i).toString();
											String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
											if(s_componentType.equalsIgnoreCase(strCompType))
												v_compForTest.add(v_comps.get(i));
										}
									}
								}
							}
						}
					}
					else if (type!=null&&type.equalsIgnoreCase("intrasnap"))
					{
					if(s_componentType!=null&&!s_componentType.equalsIgnoreCase("-1")&&!s_componentType.equalsIgnoreCase("Not Applicable"))
					{
						v_componentType=compUtil.getComponentType(v_comps);

//------------------
							if(s_component==null) {
									v_component=new Vector();
									v_componentType=compUtil.getAllComponentType() ;
									v_component=v_availComps;
									default_select="selected";
									if(v_availComps.size()>0)
									{
										if(s_componentType==null || s_componentType.equalsIgnoreCase("All"))
										{
											if(v_componentType.size()==1)
											{
												s_componentType=(String)v_componentType.get(0);
											}
										} else {
											 v_component=new Vector();
											for(int i=0;v_availComps.size()>i;i++)
											{
												String s_com = v_availComps.get(i).toString();
												String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
												if(s_componentType.equalsIgnoreCase(strCompType))
												{
													v_component.add(v_availComps.get(i));
												}
											}
										}
										if(s_componentType != null && !s_componentType.trim().equals(""))
										{
											Collections.sort(v_component,String.CASE_INSENSITIVE_ORDER);
											s_component=(String)v_component.get(0);
											String  comType=s_component.substring(s_component.lastIndexOf(":")+1);
											String s_tests[] = egSpecsInfo.getTestsForServer(comType);
											if(s_tests != null)
											{
												List list=Arrays.asList(s_tests);
												for (int i=0;list.size()>i;i++ )
												{
													String str_test=(String)list.get(i);
													if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(i)))
													{
														v_testForComp.add(str_test);
													}
												}
												if(v_testForComp!=null && v_testForComp.size()>0)
												s_test=(String)v_testForComp.get(0);
											}
										}
									}
								}
//----------
						if((s_component!=null&&!s_component.equalsIgnoreCase("-1")&&!s_component.equalsIgnoreCase("Not Applicable"))
							|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
							{
								if(s_componentType.equalsIgnoreCase("All"))
								{
									 v_component=new Vector();
									 v_component.addAll(v_comps);	 
								}
								else
								{
									 v_component=new Vector();
									for(int i=0;v_comps.size()>i;i++)
									{
										String s_com = v_comps.get(i).toString();
										String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
										if(s_componentType.equalsIgnoreCase(strCompType))
										{			
											v_component.add(v_comps.get(i));
										}
									}
								}
								if((s_test!=null&&!s_test.equalsIgnoreCase("-1")&&!s_test.equalsIgnoreCase("Not Applicable"))
									|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
								{
									if(isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All"))
										s_component = (String) v_component.get(0);
									String  comType=s_component.substring(s_component.lastIndexOf(":")+1);
									String s_tests[] = egSpecsInfo.getTestsForServer(comType);
									List list=Arrays.asList(s_tests);
									for (int i=0;list.size()>i;i++ )
									{
										String str_test=(String)list.get(i);
										if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(i)))
										{
											v_testForComp.add(str_test);
										}
									}
								}
							}
						}
					}
				}
			}
			
			else if(st_dataFrom!=null && !st_dataFrom.equals("")&&st_dataFrom.equalsIgnoreCase("segment"))
			{
				filledup=compUtil.getUserSegments();
				Collections.sort(filledup, String.CASE_INSENSITIVE_ORDER);
				if(s_option!=null&&!s_option.equals("-1")&&!s_option.equalsIgnoreCase("Not Applicable"))
				{
					v_comps=new Vector();
					v_comps=compUtil.getSegmentComponents(s_option);
					v_componentType=new Vector();
					if(type!=null&&type.equalsIgnoreCase("intersnap"))
					{
						//------------
						if(isForceSubmit!=null && isForceSubmit.equals("true"))
						{
							if(s_component==null) {
									v_component=new Vector();
									v_componentType=compUtil.getAllComponentType() ;
									v_component=v_availComps;
									default_select="selected";
									if(v_availComps.size()>0)
									{
										if(s_componentType==null || s_componentType.equalsIgnoreCase("All"))
										{
											if(v_componentType.size()==1)
											{
												s_componentType=(String)v_componentType.get(0);
											}
										} else {
											 v_component=new Vector();
											for(int i=0;v_availComps.size()>i;i++)
											{
												String s_com = v_availComps.get(i).toString();
												String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
												if(s_componentType.equalsIgnoreCase(strCompType))
												{
													v_component.add(v_availComps.get(i));
												}
											}
										}
								
										if(s_componentType != null && !s_componentType.trim().equals(""))
										{
											Collections.sort(v_component,String.CASE_INSENSITIVE_ORDER);
											s_component=(String)v_component.get(0);
											String  comType=s_component.substring(s_component.lastIndexOf(":")+1);
											String s_tests[] = egSpecsInfo.getTestsForServer(comType);

											if(s_tests != null)
											{
												List list=Arrays.asList(s_tests);
												for (int i=0;list.size()>i;i++ )
												{
													String str_test=(String)list.get(i);
													if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(i)))
													{
														v_testForComp.add(str_test);
													}
												}
									
												if(v_testForComp!=null && v_testForComp.size()>0)
												s_test=(String)v_testForComp.get(0);
											}
										}
									}
								}
							
						}
						//---------------
						if((s_test!=null&&!s_test.equals("-1")&&!s_test.equalsIgnoreCase("Not Applicable"))	
								|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
						{
							v_test=new Vector();
							Vector v_componentTypes1=compUtil.getComponentType(v_comps);
							for(int i=0;v_componentTypes1.size()>i;i++)
							{
								String s_tests[] = egSpecsInfo.getTestsForServer((String)v_componentTypes1.get(i));
								List list=Arrays.asList(s_tests);
								for (int k=0;list.size()>k;k++ )
								{
									String str_test=(String)list.get(k);
									if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(k)))
									{
										if(!v_test.contains(str_test) && User_tests.containsKey(str_test))
											v_test.add(str_test);
									}
								}
							}	
							if((s_componentType!=null&&!s_componentType.equalsIgnoreCase("-1")&&!s_componentType.equalsIgnoreCase("Not Applicable"))
								|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
							{
								if(isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All"))
									s_test = (String) v_test.get(0);
								Vector 	v_componentTypes=compUtil.getComponentType(v_comps);
								for(int j=0;v_componentTypes.size()>j;j++)
								{
									if(egSpecsInfo.isTestRelevantForServer((String)v_componentTypes.get(j),s_test))
									{		
										v_componentType.add(v_componentTypes.get(j));
									}
								}
								if((s_component!=null&&!s_component.equalsIgnoreCase("-1")&&!s_component.equalsIgnoreCase("Not Applicable"))
									|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
								{
									if(s_componentType.equalsIgnoreCase("All"))
									{
										for(int j=0;v_componentTypes.size()>j;j++)
										{
											String str_type=v_componentTypes.get(j).toString();
											if(egSpecsInfo.isTestRelevantForServer(str_type,s_test))
											{
												for(int k=0;v_comps.size()>k;k++)
												{
													String s_com = v_comps.get(k).toString();
													String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
													if(str_type.equalsIgnoreCase(strCompType))
															v_compForTest.add(v_comps.get(k));
												}
											}
										}
									}					
									else
									{
										for(int i=0;v_comps.size()>i;i++)
										{
												String s_com = v_comps.get(i).toString();
												String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
												if(s_componentType.equalsIgnoreCase(strCompType))
													v_compForTest.add(v_comps.get(i));
										}
									}
								}
							}
						}
					}
					else if (type!=null&&type.equalsIgnoreCase("intrasnap"))
					{
						//-------------
						if(s_component==null) {
								v_component=new Vector();
								v_componentType=compUtil.getAllComponentType() ;
								v_component=v_availComps;
						
								default_select="selected";
								if(v_availComps.size()>0)
								{
									if(s_componentType==null || s_componentType.equalsIgnoreCase("All"))
									{
										if(v_componentType.size()==1)
										{
											s_componentType=(String)v_componentType.get(0);
										}
									} else {
										 v_component=new Vector();
										for(int i=0;v_availComps.size()>i;i++)
										{
											String s_com = v_availComps.get(i).toString();
											String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
											if(s_componentType.equalsIgnoreCase(strCompType))
											{
												v_component.add(v_availComps.get(i));
											}
										}
									}
									if(s_componentType != null && !s_componentType.trim().equals(""))
									{
										Collections.sort(v_component,String.CASE_INSENSITIVE_ORDER);
										s_component=(String)v_component.get(0);
										String  comType=s_component.substring(s_component.lastIndexOf(":")+1);
										String s_tests[] = egSpecsInfo.getTestsForServer(comType);
										if(s_tests != null)
										{
											List list=Arrays.asList(s_tests);
											for (int i=0;list.size()>i;i++ )
											{
												String str_test=(String)list.get(i);
												if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(i)))
												{
													v_testForComp.add(str_test);
												}
											}
											if(v_testForComp!=null && v_testForComp.size()>0)
											s_test=(String)v_testForComp.get(0);
										}
									}
								}
							}
							//------------
						if(s_componentType!=null&&!s_componentType.equalsIgnoreCase("-1")&&!s_componentType.equalsIgnoreCase("Not Applicable"))
						{
							v_componentType=compUtil.getComponentType(v_comps);
							if((s_component!=null && !s_component.equalsIgnoreCase("-1") && !s_component.equalsIgnoreCase("Not Applicable"))
								 || (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
							{
								if(s_componentType.equalsIgnoreCase("All"))
								{
									v_component=compUtil.getSegmentComponents(s_option);
								}
								else
								{
									v_component=new Vector();
									for(int i=0;v_comps.size()>i;i++)
									{
										String s_com = v_comps.get(i).toString();
										String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
										if(s_componentType.equalsIgnoreCase(strCompType))
										{			
											v_component.add(v_comps.get(i));
										}
									}
								}
								if((s_test!=null&&!s_test.equalsIgnoreCase("-1")&&!s_test.equalsIgnoreCase("Not Applicable"))
									|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
								{
									if(isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All"))
										s_component = (String) v_component.get(0);
									String  comType=s_component.substring(s_component.lastIndexOf(":")+1);
									String s_tests[] = egSpecsInfo.getTestsForServer(comType);
									List list=Arrays.asList(s_tests);
									for (int i=0;list.size()>i;i++ )
									{
										String str_test=(String)list.get(i);
										if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(i)))
										{
											v_testForComp.add(str_test);
										}
									}
								}
							}
						}
					}
				}
			}

			else if(st_dataFrom!=null && !st_dataFrom.equals("")&&st_dataFrom.equalsIgnoreCase("service"))
			{
				filledup=compUtil.getUserServices(true);
				Collections.sort(filledup, String.CASE_INSENSITIVE_ORDER);
				if(s_option!=null&&!s_option.equals("-1")&&!s_option.equalsIgnoreCase("Not Applicable"))
				{
					v_comps=new Vector();
					v_comps=compUtil.getServiceComponents(s_option);
					v_componentType=new Vector();
					if(type!=null&&type.equalsIgnoreCase("intersnap"))
					{
						//------------
						if(isForceSubmit!=null && isForceSubmit.equals("true"))
						{
							if(s_component==null) {
									v_component=new Vector();
									v_componentType=compUtil.getAllComponentType() ;
									v_component=v_availComps;
						
									default_select="selected";
									if(v_availComps.size()>0)
									{
										if(s_componentType==null || s_componentType.equalsIgnoreCase("All"))
										{
											if(v_componentType.size()==1)
											{
												s_componentType=(String)v_componentType.get(0);
											}
										} else {
											 v_component=new Vector();
											for(int i=0;v_availComps.size()>i;i++)
											{
												String s_com = v_availComps.get(i).toString();
												String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
												if(s_componentType.equalsIgnoreCase(strCompType))
												{
													v_component.add(v_availComps.get(i));
												}
											}
										}
										if(s_componentType != null && !s_componentType.trim().equals(""))
										{
											Collections.sort(v_component,String.CASE_INSENSITIVE_ORDER);
											s_component=(String)v_component.get(0);
											String  comType=s_component.substring(s_component.lastIndexOf(":")+1);
											String s_tests[] = egSpecsInfo.getTestsForServer(comType);
											if(s_tests != null)
											{
												List list=Arrays.asList(s_tests);
												for (int i=0;list.size()>i;i++ )
												{
													String str_test=(String)list.get(i);
													if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(i)))
													{
														v_testForComp.add(str_test);
													}
												}
												if(v_testForComp!=null && v_testForComp.size()>0)
												s_test=(String)v_testForComp.get(0);
											}
										}
									}
								}
							
						}
						//---------------
						if((s_test!=null&&!s_test.equals("-1")&&!s_test.equalsIgnoreCase("Not Applicable"))	
							|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
						{
							v_test=new Vector();
							Vector v_componentTypes1=compUtil.getComponentType(v_comps);
							for(int i=0;v_componentTypes1.size()>i;i++)
							{
								String s_tests[] = egSpecsInfo.getTestsForServer((String)v_componentTypes1.get(i));
								List list=Arrays.asList(s_tests);
								for (int k=0;list.size()>k;k++ )
								{
									String str_test=(String)list.get(k);
									if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(k)))
									{
										if(!v_test.contains(str_test) && User_tests.containsKey(str_test) )
										v_test.add(str_test);
									}
								}
							}
							if((s_componentType!=null&&!s_componentType.equalsIgnoreCase("-1")&&!s_componentType.equalsIgnoreCase("Not Applicable"))
								|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
							{
								if(isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All"))
									s_test = (String) v_test.get(0);
								Vector 	v_componentTypes=compUtil.getComponentType(v_comps);
								for(int j=0;v_componentTypes.size()>j;j++)
								{
									if(egSpecsInfo.isTestRelevantForServer((String)v_componentTypes.get(j),s_test))
									{		
										v_componentType.add(v_componentTypes.get(j));
									}
								}
								if((s_component!=null&&!s_component.equalsIgnoreCase("-1")&&!s_component.equalsIgnoreCase("Not Applicable"))
									|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
								{
									if(s_componentType.equalsIgnoreCase("All"))
									{
										for(int j=0;v_componentTypes.size()>j;j++)
										{
											String str_type=v_componentTypes.get(j).toString();
											if(egSpecsInfo.isTestRelevantForServer(str_type,s_test))
											{
												for(int k=0;v_comps.size()>k;k++)
												{
													String s_com = v_comps.get(k).toString();
													String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
													if(str_type.equalsIgnoreCase(strCompType))
														v_compForTest.add(v_comps.get(k));
												}
											}
										}
									}
									else
									{	
										for(int i=0;v_comps.size()>i;i++)
										{
											String s_com = v_comps.get(i).toString();
											String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
											if(s_componentType.equalsIgnoreCase(strCompType))
												v_compForTest.add(v_comps.get(i));
										}
									}
								}
							}
						}
					}
					else if (type!=null&&type.equalsIgnoreCase("intrasnap"))
					{
						//-------------
						if(s_component==null) {
								v_component=new Vector();
								v_componentType=compUtil.getAllComponentType() ;
								v_component=v_availComps;
								
								default_select="selected";
								if(v_availComps.size()>0)
								{
									if(s_componentType==null || s_componentType.equalsIgnoreCase("All"))
									{
										if(v_componentType.size()==1)
										{
											s_componentType=(String)v_componentType.get(0);
										}
									} else {
										 v_component=new Vector();
										for(int i=0;v_availComps.size()>i;i++)
										{
											String s_com = v_availComps.get(i).toString();
											String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
											if(s_componentType.equalsIgnoreCase(strCompType))
											{
												v_component.add(v_availComps.get(i));
											}
										}
									}
									if(s_componentType != null && !s_componentType.trim().equals(""))
									{
										Collections.sort(v_component,String.CASE_INSENSITIVE_ORDER);
										s_component=(String)v_component.get(0);
										String  comType=s_component.substring(s_component.lastIndexOf(":")+1);
										String s_tests[] = egSpecsInfo.getTestsForServer(comType);
										if(s_tests != null)
										{
											List list=Arrays.asList(s_tests);
											for (int i=0;list.size()>i;i++ )
											{
												String str_test=(String)list.get(i);
												if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(i)))
												{
													v_testForComp.add(str_test);
												}
											}
											if(v_testForComp!=null && v_testForComp.size()>0)
											s_test=(String)v_testForComp.get(0);
										}
									}
								}
							}
							//------------
						if((s_componentType!=null&&!s_componentType.equalsIgnoreCase("-1")&&!s_componentType.equalsIgnoreCase("Not Applicable"))
							|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
						{
							v_componentType=compUtil.getComponentType(v_comps);
							if((s_component!=null&&!s_component.equalsIgnoreCase("-1")&&!s_component.equalsIgnoreCase("Not Applicable"))
								|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
							{
								if(s_componentType.equalsIgnoreCase("All"))
								{
									v_component=compUtil.getServiceComponents(s_option);
								}
								else
								{
									v_component=new Vector();
									for(int i=0;v_comps.size()>i;i++)
									{
										String s_com = v_comps.get(i).toString();
										String strCompType = s_com.substring(s_com.lastIndexOf(":")+1);
										if(s_componentType.equalsIgnoreCase(strCompType))
										{			
											v_component.add(v_comps.get(i));
										}
									}
								}
								if((s_test!=null&&!s_test.equalsIgnoreCase("-1")&&!s_test.equalsIgnoreCase("Not Applicable"))
									|| (isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All")))
								{
									if(isForceSubmit!=null && isForceSubmit.equals("true") && s_componentType.equalsIgnoreCase("All"))
										s_component = (String) v_component.get(0);
									String  comType=s_component.substring(s_component.lastIndexOf(":")+1);
									String s_tests[] = egSpecsInfo.getTestsForServer(comType);
									List list=Arrays.asList(s_tests);
									for (int i=0;list.size()>i;i++ )
									{
										String str_test=(String)list.get(i);
										if(!str_test.endsWith("_cf")&&v_availTest.contains(list.get(i)))
										{
											v_testForComp.add(str_test);
										}
									}
								}
							}
						}
					}
				}
			}
			if(erd.s_gtype==null)
			{
				session.setAttribute("errmsg","Illegal Access");
			//	application.getRequestDispatcher("/reporter/ErError.jsp").forward(request,response);
				return;
			}
			else if("intrasnap".equalsIgnoreCase(erd.s_gtype))
			{
				session.setAttribute("Source","Intracomponent"); // for eg help
				s_singleSelectLabel = "Component";
				s_multiSelectLabel = "Test";
			}
			else if("intersnap".equalsIgnoreCase(erd.s_gtype))
			{
				session.setAttribute("Source","Intercomponent");//for eg help 
				s_singleSelectLabel = "Test";
				s_multiSelectLabel = "Component";
			}
			
			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 startMin  = request.getParameter("startmin");
			String endMin    = request.getParameter("endmin");
			String er_timeline = request.getParameter("er_timeline");
			String trendenable = request.getParameter("er_trenddata");
			String strQry_st_time = request.getParameter("startdate");
			String strQry_en_time = request.getParameter("enddate");

			if(er_timeline==null || er_timeline.equals(" "))
			{
				er_timeline="1 day";
			}

			//Date calculation according to time select
			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","1 week","2 weeks","3 weeks","4 weeks","1 month"};
			String[] lstWeeksArr = new String[]{"Last week", "Last month"};	
			List alist = Arrays.asList(options);

			String startDateTime="";
			String endDateTime="";
			String uiFile = "eg_ui.ini";
			String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
			IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
			 currentDateFormat = strUserDateFormat;
			long msecsPerHour = (long) 1000 * 60 * 60;

			String dispDate = null;
			String comFormat = null;
			String loginName = usr.getLoginID();
			String strUsrTimeline = er_rpthelper.getUserTimeline(loginName);

			if(trendenable==null)
			{
				trendenable="No";
			}
		
			int len;
			if(strUsrTimeline != null && !strUsrTimeline.equalsIgnoreCase("-1"))
			{
				len = alist.indexOf(strUsrTimeline)+1;
				alist = alist.subList(0,len);
				options = (String[])alist.toArray(new String[len]);
			}
		
			if(er_timeline!=null&&!er_timeline.equals("Any"))
			{
				int blankSpaceIndex = er_timeline.indexOf(DateTimeTokenizer.BLANK_SPACE);
				if (blankSpaceIndex > 0)
				{
					SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm");
					java.util.Date today = egDt.egetRealDate();
					endDateTime = sdf.format(today);
					long value = Integer.parseInt(er_timeline.substring(0, blankSpaceIndex));
					String unit = er_timeline.substring(blankSpaceIndex+1).toLowerCase();
					if(unit.startsWith("mi"))
					{
						value *= (60);
					}
					else if (unit.startsWith("h"))
					{//hours
						value *= 3600;
					}
					else if (unit.startsWith("d"))
					{//days
						value *= (24 * 3600);
					}
					else if (unit.startsWith("w"))
					{
						if(unit.endsWith("last")){
							//last week
							int weekCount = (int) value;
							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 = usr.getUserDateFormat();
							String curFormatDate = DateUtil.changeDateFormat(currentDate,"MM/dd/yyyy", userFormat); 
							EgTimeZoneConverter realDateTime = new EgTimeZoneConverter(curFormatDate+" "+currentHr+":"+currentMin,usr);
							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("ErSanpshotJson Last Week Start Date-->"+startDateTime+ "    End Time-->"+endDateTime);
						}else{
							//weeks
							value *= (7 * 24 * 3600);
						}
					}
					else if (unit.startsWith("mo"))
					{
						if(unit.endsWith("last"))
						{//last month
							int monthCount = (int) value;
							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 = usr.getUserDateFormat();
							String curFormatDate = DateUtil.changeDateFormat(currentDate,"MM/dd/yyyy", userFormat); 
							EgTimeZoneConverter realDateTime = new EgTimeZoneConverter(curFormatDate+" "+currentHr+":"+currentMin,usr);
							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("ErSanpshotJson Last Month Start Date-->"+startDateTime+ "    End Time-->"+endDateTime);
						}else{
							//months
							//int  totalDays=ErUtils.getMaxDaysInMonth();
							//value *= (ErUtils.getMaxDaysInMonth() * 24 * 3600);
							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)( (value*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() - (value * 1000));
						startDateTime = sdf.format(start);
					}else if (unit.endsWith("last")){
						String usrStartDateTime = startDateTime +" 00:00";
						String usrEndDateTime = endDateTime +" 23:59";
						//System.out.println("ErSanpshotJson 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("ErSanpshotJson 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));

					if(trendenable!=null && trendenable.equals("Yes"))
					{
						s_st_hr="0";
						s_en_hr="0";
						startMin="0";
						endMin="0";
					}else
					{
						s_st_hr = String.valueOf(shr);
						s_en_hr = String.valueOf(en_hr);
						startMin = String.valueOf(startDateTime.substring(startDateTime.indexOf(":")+1));
						endMin = String.valueOf(endDateTime.substring(endDateTime.indexOf(":")+1));
					}
				}
			}

			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(trendenable!=null && trendenable.equals("Yes"))
				{
					s_st_hr="0";
					s_en_hr="0";
					startMin="0";
					endMin="0";
				}
				else
				{*/
				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(startMin==null)
				{
					startMin = StrDate.substring(StrDate.indexOf(":")+1);
				}
				if(endMin==null)
				{
					endMin = StrDate.substring(StrDate.indexOf(":")+1);
				}
			//}
			}

			String onload="";
			String co=request.getParameter("er_component");
			if(type!=null && type.equals("intrasnap"))
			{
				if(co!=null && !co.equals("-1"))
				{
					//onload="onload=\"body_onLoadnew('"+co+"');\"";
				}
				else
				{
					onload="onload=\"body_onLoad();\"";
				}
			}
			String graphmode = request.getParameter("er_mode");
			if(graphmode==null || graphmode.equals(""))
			{
				if(iniui.use3DGraphs(IniUI.REPORTER))
					graphmode="3D";
				else
					graphmode="2D";
			}

			/* CSV block starts */
			session.removeAttribute("auditLogHashtable");
			AuditLogHashtable superAuditLogHashtable = new AuditLogHashtable();
			AuditLogHashtable headerInfoAuditLogHashtable = new AuditLogHashtable();
			String title_temp="";
			if(!st_dataFrom.equalsIgnoreCase("Component"))
				{
			title_temp="\n"+","+"Report For : "+mappingInfo.getTextDescription("reporter.common."+st_dataFrom.toUpperCase())+","+mappingInfo.getTextDescription("reporter.common."+st_dataFrom)+"  Name  : "+s_option;
				}
				else
				{
				title_temp="\n"+","+"Report For : "+mappingInfo.getTextDescription("reporter.common."+st_dataFrom.toUpperCase());
				}
				
				if (!StringUtils.isNull(titleToDisplay)){ 
	 				headerInfoAuditLogHashtable.put("title",titleToDisplay);
                    		}
           			else
				{
					headerInfoAuditLogHashtable.put("title",mappingInfo.getTextDescription("reporter.common.SNAPSHOT REPORTS") +" - " + mappingInfo.getTextDescription("reporter.common."+s_singleSelectLabel.toUpperCase()+"S")+title_temp);
				}
			String startDate = "\"" + mappingInfo.getTextDescription("reporter.common.Start Date") + " : " + erd.s_stdate + " " + erd.s_sthr+":"+erd.s_startmin+" Hrs" +"\"";
			String endDate = "\"" + mappingInfo.getTextDescription("reporter.common.End Date") + " : " + erd.s_enddate +" " +erd.s_endhr +":"+erd.s_endmin+ " Hrs" + "\"";

			headerInfoAuditLogHashtable.put("dateInfo",startDate + "," + endDate);
			AuditLogHashtable innerKeyAuditLogHahstable = new AuditLogHashtable();
			innerKeyAuditLogHahstable.put("headerInfo",headerInfoAuditLogHashtable);
			/* CSV block ends */

			String confrimation = rptInfo.getValue("BACKGROUND_PROCESS","NeedConfirmation");
			String strbgrepportName = rptInfo.getValue("BACKGROUND_PROCESS","EnableBackgroundReport");
			String limitforbg = rptInfo.getValue("BACKGROUND_PROCESS","MinDurationForReport");

		//	session.setAttribute("PDF_URL", mngrIProc+"/final/servlet/com.eg.ErSnapshotC");

			String er_bgreportfrom = "";

			if(s_singleSelectLabel != null && s_singleSelectLabel.equalsIgnoreCase("Test"))
			{
				er_bgreportfrom = "Snapshot_Tests";
			}
			else
			{
				er_bgreportfrom = "Snapshot_Components";
			}

			screenLabels.put("pageTitle",mappingInfo.getTextDescription("reporter.common.SNAPSHOT REPORTS")+" - "+s_singleSelectLabel);

			screenLabels.put("reporter.comparison.Include SubZones",mappingInfo.getTextDescription("reporter.comparison.Include SubZones"));

			hiddenParams.put("selectedLanguage",thisLanguage);
			hiddenParams.put("printPageUrl","");
		//	hiddenParams.put("selectedComponents","");
		//	hiddenParams.put("selectedTests","");
		//	hiddenParams.put("selectedTimeline","");
		//	hiddenParams.put("startdate",request.getParameter("startdate"));
			hiddenParams.put("enlarged","");
			hiddenParams.put("userID",urs);
		//	hiddenParams.put("er_gtype",erd.s_gtype);
			hiddenParams.put("inidate",currentDateFormat);
			hiddenParams.put("er_trenddata",trendenable);
			hiddenParams.put("fromSchedule",reqFromSchedule);
			if(fromScheduleModify!=null)
				hiddenParams.put("fromScheduleModify",fromScheduleModify);
			else
				hiddenParams.put("fromScheduleModify","null");

			hiddenParams.put("schedule_id",schedule_id);
			hiddenParams.put("er_usertimeline",strUsrTimeline);
			hiddenParams.put("getMaxDaysInMonth",ErUtils.getMaxDaysInMonth());
			hiddenParams.put("bgenabled",strbgrepportName);
			hiddenParams.put("limitforbg",limitforbg);
//			hiddenParams.put("forwardto","ErSnapshot");
			hiddenParams.put("er_bgreportfrom",er_bgreportfrom);
			hiddenParams.put("ReportFrom",er_bgreportfrom);
			hiddenParams.put("servletName","com.eg.ErSnapshotC");
			hiddenParams.put("savereport","save");
			hiddenParams.put("er_ViewName","ErSnapshot.jsp");
			hiddenParams.put("count",ctr);
			hiddenParams.put("er_rtype","SnapShot");
		//	hiddenParams.put("enddate",request.getParameter("enddate"));
		//	hiddenParams.put("starthr",s_st_hr);
		//	hiddenParams.put("endhr",s_en_hr);
		//	hiddenParams.put("startmin",startMin);
		//	hiddenParams.put("endmin",endMin);
			hiddenParams.put("divStatus",divStatus);
			hiddenParams.put("s_singleSelectLabel",s_singleSelectLabel);	
			if(fromFavoriteModify!=null)
				hiddenParams.put("fromFavoriteModify",fromFavoriteModify);
			else
				hiddenParams.put("fromFavoriteModify","null");
			hiddenParams.put("favorite_id", favorite_id);
			hiddenParams.put("er_favorite", er_favorite);

			String strwidth = "90%";
			if(backreqMap == null || backreqMap != null && backreqMap.size() == 0)
				strwidth="100%";

			
			screenLabels.put("reporter.snapshot.SNAPSHOT REPORTS",mappingInfo.getTextDescription("reporter.snapshot.SNAPSHOT REPORTS")+" - "+mappingInfo.getTextDescription("reporter.common."+s_singleSelectLabel.toUpperCase()+"S"));
			screenLabels.put("reporter.common.Back",mappingInfo.getTextDescription("reporter.common.Back"));
			screenLabels.put("reporter.common.Report For",mappingInfo.getTextDescription("reporter.uptime.Analyze by"));
			screenLabels.put("reporter.common.ComponentType",mappingInfo.getTextDescription("reporter.common.ComponentType"));
			screenLabels.put("reporter.comparison.Tests",mappingInfo.getTextDescription("reporter.comparison.Tests"));
			screenLabels.put("reporter.common.Not Applicable",mappingInfo.getTextDescription("reporter.common.Not Applicable"));
			screenLabels.put("admin.common.Select",mappingInfo.getTextDescription("admin.common.Select"));
			screenLabels.put("reporter.common.Descriptor Search",mappingInfo.getTextDescription("reporter.common.Descriptor Search"));
			screenLabels.put("reporter.comparison.Components",mappingInfo.getTextDescription("reporter.comparison.Components"));
			screenLabels.put("reporter.common.State",mappingInfo.getTextDescription("reporter.common.State"));
			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.Min",mappingInfo.getTextDescription("reporter.common.Min"));
			screenLabels.put("reporter.common.To",mappingInfo.getTextDescription("reporter.common.To"));
			screenLabels.put("reporter.consolidated.Report Generation",mappingInfo.getTextDescription("reporter.consolidated.Report Generation"));
			screenLabels.put("reporter.consolidated.Report Name",mappingInfo.getTextDescription("reporter.consolidated.Report Name"));
			
				//hiddenParams.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
				json.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
			
			pageParams.put("selectedReportFor",st_dataFrom);


			JSONArray reportForJSON =  new JSONArray();
			if(v_compareOptions!=null && !v_compareOptions.isEmpty())
			{
				Iterator itrCompareOptions = v_compareOptions.iterator();
				while (itrCompareOptions.hasNext())
				{
					String value = (String) itrCompareOptions.next();
					JSONObject jObj =  new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common."+value));
					jObj.put("valueField",value);
					reportForJSON.add(jObj);
				}
			}
			json.put("reportForJSON",reportForJSON);
		/*	if(st_dataFrom!=null&&st_dataFrom.equalsIgnoreCase("Zone"))
			{*/
			String includezone="yes";
			JSONArray v_include=new JSONArray();
			JSONObject yesNoOptionObj =  new JSONObject();
			yesNoOptionObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Yes"));
			yesNoOptionObj.put("valueField","yes");

			v_include.add(yesNoOptionObj);

			yesNoOptionObj =  new JSONObject();
			yesNoOptionObj.put("displayField",mappingInfo.getTextDescription("reporter.common.No"));
			yesNoOptionObj.put("valueField","no");
			v_include.add(yesNoOptionObj);

			pageParams.put("selectedSubZone",s_subZone);
			json.put("includeZoneOptions",v_include);
		//	}
			if(st_dataFrom!=null && !st_dataFrom.equalsIgnoreCase("Component"))
			{
				screenLabels.put("selectedReportLbl",mappingInfo.getTextDescription("reporter.common."+st_dataFrom));
				if(s_option==null || StringUtils.isNull(s_option))
				{
					pageParams.put("selectedInfraTypeOption","-1");
				}
				else
				{
					pageParams.put("selectedInfraTypeOption",s_option);
				}

				JSONArray infraTypeJSON =  new JSONArray();
				JSONObject jObj1 =  new JSONObject();
				jObj1.put("displayField",mappingInfo.getTextDescription("reporter.common.Please choose a "+st_dataFrom));
				jObj1.put("valueField","-1");
				infraTypeJSON.add(jObj1);
				if(filledup!=null && !filledup.isEmpty())
				{
					Iterator itrFilledUp = filledup.iterator();
					while (itrFilledUp.hasNext())
					{
						String value = (String) itrFilledUp.next();
						JSONObject jObj =  new JSONObject();
						if(value.equals("--Default--"))
							jObj.put("displayField",mappingInfo.getTextDescription("reporter.common."+value));
						else
							jObj.put("displayField",value);
						jObj.put("valueField",value);
						infraTypeJSON.add(jObj);
					}
				}
				json.put("infraTypeJSON",infraTypeJSON);
			}

			screenLabels.put("singleSelectBoxLabel",mappingInfo.getTextDescription("reporter.common."+s_singleSelectLabel));
			screenLabels.put("multiSelectBoxLabel",mappingInfo.getTextDescription("reporter.snapshot."+s_multiSelectLabel+"s"));

			if(type!=null && type.equals("intrasnap"))
			{
				ArrayList ar_avail_comptype=new ArrayList();
				ar_avail_comptype=sorter.getSortedCompTypeList(v_componentType);

				JSONArray compTypeJSON=new JSONArray();

				if(ar_avail_comptype==null||ar_avail_comptype.size()==0)
				{
					JSONObject jObj =  new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Not Applicable"));
					jObj.put("valueField","Not Applicable");
					compTypeJSON.add(jObj);
					pageParams.put("selectedCompType","Not Applicable");
				}
				else
				{
					String str=null;
					JSONObject jObj =  new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Please choose the  Component Type"));
					jObj.put("valueField","-1");
					compTypeJSON.add(jObj);

					if(s_componentType!=null && !s_componentType.equals("Not Applicable"))
					{
						pageParams.put("selectedCompType",s_componentType);
					}
					else
					{
						pageParams.put("selectedCompType","-1");
					}


					if(ar_avail_comptype.size()>1)
					{
						jObj =  new JSONObject();
						jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.All"));
						jObj.put("valueField","All");
						compTypeJSON.add(jObj);
					}
					for( int i=0;i<ar_avail_comptype.size();i++)
					{
						str="";
						EgName nameObj =(EgName) ar_avail_comptype.get(i);
						String strCompType = nameObj.getActualName();

						jObj =  new JSONObject();
						jObj.put("displayField",nameObj.getLocalName());
						jObj.put("valueField",strCompType);
						compTypeJSON.add(jObj);
					}
				}

				json.put("compTypeJSON",compTypeJSON);

				v_component=compUtil.getIntnlSupportComponent(v_component,"#");
				JSONArray componentsArray =  new JSONArray();
				if(v_component==null||v_component.size()==0)
				{
					JSONObject jObj =  new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Not Applicable"));
					jObj.put("valueField","Not Applicable");
					componentsArray.add(jObj);
					pageParams.put("selectedComponent","Not Applicable");
				}
				else
				{
					

					JSONObject jObj =  new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Please choose a Component"));
					jObj.put("valueField","-1");
					if(s_component!=null && !s_component.equals("Not Applicable"))
						pageParams.put("selectedComponent",s_component);
					else
						pageParams.put("selectedComponent","-1");
					componentsArray.add(jObj);
						for( int i=0;i<v_component.size();i++)	
					{
						String comp=(String)v_component.get(i);
						ArrayList aListData = tokInfo.egTokenizer(comp,"#");
						String comp_disp=(String)aListData.get(0);
						String comp_value=(String)aListData.get(1);
						comp_disp=comp_disp.replaceAll(":",": ");
						jObj =  new JSONObject();
						jObj.put("displayField",comp_disp);
						jObj.put("valueField",comp_value);
						componentsArray.add(jObj);
						if(isForceSubmit!=null && isForceSubmit.equals("true") && i==0)
							pageParams.put("selectedComponent",comp_value);
					}
					if(v_component.size()>1)
						{
						jObj =  new JSONObject();
						jObj.put("displayField","ALL");
						jObj.put("valueField","All");
						//componentsArray.add(jObj);//We are not viewing all the components data
						}
				}

				json.put("componentsArray",componentsArray);

				JSONArray testsArray = new JSONArray();
				ArrayList arr_testForComp=new ArrayList();
				arr_testForComp=sorter.getSortedTestList(v_testForComp);	
				if(arr_testForComp==null||arr_testForComp.size()==0)	
				{
					JSONObject jObj =  new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Not Applicable"));
					jObj.put("valueField","Not Applicable");
					testsArray.add(jObj);
					v_test_popup.add("Not Applicable");
					v_test_popup_disp.add("Not Applicable !");
					pageParams.put("selectedTests","Not Applicable");
				}
				else
				{
					String str_tests[]=erd.getTests();
					List list=new ArrayList();
					boolean isTestsSelected = false;
					if(str_tests!=null)
					{
						isTestsSelected = true;
						list=Arrays.asList(str_tests);
					}
					StringBuffer sbSelectedTest = new StringBuffer();

					if(isTestsSelected)
					{
						if(list!=null && list.size()>0)
						{
							Iterator itrSelectedTests = list.iterator();
							while(itrSelectedTests.hasNext())
							{
								String selTest = (String)itrSelectedTests.next();
								sbSelectedTest.append(","+selTest);
							}
						}
					}
					
					for(int i=0;i<arr_testForComp.size();i++)
					{
						EgName nameObj =(EgName) arr_testForComp.get(i);
						String strTest = nameObj.getActualName();

						JSONObject jObj =  new JSONObject();
						jObj.put("displayField",nameObj.getLocalName());
						jObj.put("valueField",strTest);
						testsArray.add(jObj);

						if(!isTestsSelected)
						{
							sbSelectedTest.append(","+strTest);
						}
					}
					String selectedTests = "null";
					if( sbSelectedTest!=null )
					{
						selectedTests = sbSelectedTest.toString();
						if(selectedTests!=null)
						{
							int commaIdx = selectedTests.indexOf(",");
							if(commaIdx == 0)
								selectedTests = selectedTests.substring(1,selectedTests.length());
						}
					}
					pageParams.put("selectedTests",selectedTests);
				}
				json.put("testsArray",testsArray);
				pageParams.put("descriptorSearchValue",infosearch);
			}
			else if (type!=null && type.equals("intersnap"))
			{

				JSONArray testsArray = new JSONArray();
				ArrayList ar_avail_test=new ArrayList();
				ar_avail_test=sorter.getSortedTestList(v_test);		
				if(ar_avail_test==null||ar_avail_test.size()==0)
				{
					JSONObject jObj =  new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Not Applicable"));
					jObj.put("valueField","Not Applicable");
					testsArray.add(jObj);
					pageParams.put("selectedTest","Not Applicable");
				}
				else
				{
					JSONObject jObj =  new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Please choose a  Test"));
					jObj.put("valueField","-1");
					testsArray.add(jObj);

					pageParams.put("selectedTest",s_test);

					for( int i=0;i<ar_avail_test.size();i++)	
					{
						EgName nameObj =(EgName) ar_avail_test.get(i);
						String strTest = nameObj.getActualName();

						jObj =  new JSONObject();
						jObj.put("displayField",nameObj.getLocalName());
						jObj.put("valueField",strTest);
						testsArray.add(jObj);
						//if(isForceSubmit!=null && isForceSubmit.equals("true") && i==0)
							//pageParams.put("selectedTest",strTest);
					}
				}

				json.put("testsArray",testsArray);

				ArrayList ar_avail_comptype=new ArrayList();
				ar_avail_comptype=sorter.getSortedCompTypeList(v_componentType);

				JSONArray compTypeJSON =  new JSONArray();

				if(ar_avail_comptype==null||ar_avail_comptype.size()==0)
				{
					JSONObject jObj =  new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Not Applicable"));
					jObj.put("valueField","Not Applicable");
					compTypeJSON.add(jObj);
					pageParams.put("selectedCompType","Not Applicable");
				}
				else
				{
					pageParams.put("selectedCompType",s_componentType);
					JSONObject jObj =  new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Please choose the Component Type"));
					jObj.put("valueField","-1");
					compTypeJSON.add(jObj);
					if(ar_avail_comptype.size()>1)
					{
						jObj =  new JSONObject();
						jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.All"));
						jObj.put("valueField","All");
						compTypeJSON.add(jObj);
					}
					for( int i=0;i<ar_avail_comptype.size();i++)
					{
						EgName nameObj =(EgName) ar_avail_comptype.get(i);
						String strCompType = nameObj.getActualName();
						jObj =  new JSONObject();
						jObj.put("displayField",nameObj.getLocalName());
						jObj.put("valueField",strCompType);
						compTypeJSON.add(jObj);
					}
				}

				json.put("compTypeJSON",compTypeJSON);

				JSONArray componentsArray =  new JSONArray();
				if(_search!=null)
				{
					v_compForTest=compUtil.getComponentsForSearch(v_compForTest, _search);
				}
				v_compForTest=compUtil.getIntnlSupportComponent(v_compForTest,"#");
				if(v_compForTest==null||v_compForTest.size()==0)	
				{
					JSONObject jObj =  new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Not Applicable"));
					jObj.put("valueField","Not Applicable");
					componentsArray.add(jObj);
				}
				else
				{
					String str_comps[]=erd.getComponents();
					List list=new ArrayList();
					boolean isComponentsSelected = false;
					if(str_comps!=null)
					{
						isComponentsSelected = true;
						list=Arrays.asList(str_comps);
					}
					
					StringBuffer sbComps = new StringBuffer();
					if(isComponentsSelected)
					{
						if(list!=null && list.size()>0)
						{
							Iterator itrComps = list.iterator();
							while(itrComps.hasNext())
							{
								String selComps = (String)itrComps.next();
								sbComps.append(","+selComps);
							}	
						}
					}

					for(int i=0;i<v_compForTest.size();i++)
					{
						String str_temp=(String)v_compForTest.get(i);
						ArrayList aListData = tokInfo.egTokenizer(str_temp,"#");
						String comp_disp=(String)aListData.get(0);
						String comp_value=(String)aListData.get(1);
						comp_disp=comp_disp.replaceAll(":",": ");
						JSONObject jObj =  new JSONObject();
						jObj.put("displayField",comp_disp);
						jObj.put("valueField",comp_value);
						componentsArray.add(jObj);

						if(!isComponentsSelected)
						{
							sbComps.append(","+comp_value);
						}
					}
					String selectedComps = "null";
					if( sbComps!=null )
					{
						selectedComps = sbComps.toString();
						if(selectedComps!=null)
						{
							int commaIdx = selectedComps.indexOf(",");
							if(commaIdx == 0)
								selectedComps = selectedComps.substring(1,selectedComps.length());
						}
					}
					pageParams.put("selectedComps",selectedComps);
				}

				json.put("componentsArray",componentsArray);
			} //finished here

			if(prior_type != null)
				pageParams.put("prior_type",prior_type);
			JSONArray stateJSON = new JSONArray();
			for(int z=0;z<v_prior_type.size();z++)
			{
				String prior = (String)v_prior_type.get(z);
				String prior_value = (String)v_prior_type_value.get(z);
				JSONObject jObj = new JSONObject();
				jObj.put("displayField",mappingInfo.getTextDescription("reporter.common."+prior));
				jObj.put("valueField",prior_value);
				stateJSON.add(jObj);
			}
			json.put("stateJSON",stateJSON);

			if (type!=null && type.equals("intersnap"))
			{
				pageParams.put("descriptorSearchValue",infosearch);

			}

			if(trackerLanguage!=null && (trackerLanguage.equals("en_US") || trackerLanguage.equals("ch_CH") || trackerLanguage.equals("ja_JP") || trackerLanguage.equals("ko_KR")) || trackerLanguage.equals("th_TH"))
			{

			}
			else if(trackerLanguage!=null && (trackerLanguage.equals("fr_FR") || trackerLanguage.equals("de_DE") || trackerLanguage.equals("es_ES") || trackerLanguage.equals("it_IT") || trackerLanguage.equals("pt_BR")))
			{

			}

			String erg=request.getParameter("er_graphtype");
			String val=request.getQueryString();

			EgTimeZoneConverter timeZoneConverterStart = null;
			EgTimeZoneConverter timeZoneConverterEnd = null;
			String startDateForDisplay = null;
			String startHourForDisplay = null;
			String endDateForDisplay = null;
			String endHourForDisplay = null;
			String startMinForDisplay = null;
			String endMinForDisplay = null;

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

			JSONArray timelineJSON = new JSONArray();
			for(int e_ctr=0; e_ctr < options.length;e_ctr++)
			{
				if(options[e_ctr].equalsIgnoreCase("Any"))
				{
					JSONObject jObj = new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common."+options[e_ctr]));
					jObj.put("valueField",options[e_ctr]);
					timelineJSON.add(jObj);
				}
				else
				{
					String numstr=options[e_ctr].substring(0,options[e_ctr].indexOf(" "));
					String strextra=options[e_ctr].substring(options[e_ctr].indexOf(" ")+1);
					JSONObject jObj = new JSONObject();
					jObj.put("displayField",numstr+" "+mappingInfo.getTextDescription("reporter.common."+strextra));
					jObj.put("valueField",options[e_ctr]);
					timelineJSON.add(jObj);
				}
			}			
				List lastDataList = new ArrayList();
				JSONArray lastDataJSON = null;
				int lastWeekCount = 1;		
				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++){
							timelineJSON.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++){
							timelineJSON.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++){
							timelineJSON.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++){
							timelineJSON.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++){
							timelineJSON.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++){
							timelineJSON.add(lastDataJSON.get(i));
						}		
					}	
				}
			json.put("timelineJSON",timelineJSON);

			if(er_timeline!=null&& !er_timeline.equals("Any"))
			{
				if(DateUtil.isDate(s_st_time,"MM/dd/yyyy"))
				{
					comFormat = "MM/dd/yyyy";
				}
				else
				{
					comFormat = currentDateFormat;
				}
				dispDate = DateUtil.changeDateFormat(s_st_time,comFormat,currentDateFormat);
			}
			else
			{
				dispDate = s_st_time;
			}


			if(dispDate!=null)
				pageParams.put("selectedStartDate",dispDate);

			JSONArray hrJSON = new JSONArray();

			if(s_st_hr!=null)
			{
				s_st_hr = s_st_hr.trim();
				pageParams.put("selectedFromHr",s_st_hr);
			}

			for(int s_ctr=0; s_ctr < 24 ;s_ctr++)
			{
				JSONObject hrObj = new JSONObject();
				hrObj.put("displayField",String.valueOf(s_ctr));
				hrObj.put("valueField",String.valueOf(s_ctr));

				hrJSON.add(hrObj);
			}

			json.put("hrJSON",hrJSON);

			JSONArray minJSON = new JSONArray();

			if(startMin!=null)
			{
				startMin = startMin.trim();
				pageParams.put("selectedFromMinutes",startMin);
			}

			timeZoneConverterStart = new EgTimeZoneConverter(dispDate + " "
				+ s_st_hr + ":" + startMin, thisuser);
			startDateForDisplay = (String) timeZoneConverterStart.getDate(false);
			startHourForDisplay = timeZoneConverterStart.getHour();
			startMinForDisplay = timeZoneConverterStart.getMinute();

			for(int s_ctr=0; s_ctr < 60 ;s_ctr++)
			{
				String c=String.valueOf(s_ctr);
				if(s_ctr<=9)
				{
						c="0"+c;
				}

				JSONObject minObj = new JSONObject();
				minObj.put("displayField",""+c);
				minObj.put("valueField",""+c);

				minJSON.add(minObj);
			}

			json.put("minJSON",minJSON);

			if(er_timeline!=null&& !er_timeline.equals("Any"))
			{
				if(DateUtil.isDate(s_en_time,"MM/dd/yyyy"))
				{
					comFormat = "MM/dd/yyyy";
				}
				else
				{
					comFormat = currentDateFormat;
				}
				dispDate = 	DateUtil.changeDateFormat(s_en_time,comFormat,currentDateFormat);
			}
			else
			{
				dispDate = s_en_time;
			}

			if(dispDate!=null)
				pageParams.put("selectedEndDate",dispDate);

			if(s_en_hr!=null)
			{
				s_en_hr = s_en_hr.trim();
				pageParams.put("selectedToHr",s_en_hr);
			}

			if(endMin!=null)
			{
				endMin = endMin.trim();
				pageParams.put("selectedToMinutes",endMin);
			}
			timeZoneConverterEnd = new EgTimeZoneConverter(dispDate + " "
				+ s_en_hr + ":" + endMin, thisuser);
			endDateForDisplay = (String) timeZoneConverterEnd.getDate(false);
			endHourForDisplay = timeZoneConverterEnd.getHour();
			endMinForDisplay = timeZoneConverterEnd.getMinute();

			//User TimeZone changes
			pageParams.put("startDateForDisplay",startDateForDisplay);
			pageParams.put("startHourForDisplay",startHourForDisplay);
			pageParams.put("startMinForDisplay",startMinForDisplay);
			pageParams.put("endDateForDisplay",endDateForDisplay);
			pageParams.put("endHourForDisplay",endHourForDisplay);
			pageParams.put("endMinForDisplay",endMinForDisplay);

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

			if (er_reportgenration != null && er_reportgenration.equals("background"))
			{
				pageParams.put("er_reportgenration",er_reportgenration);
			}
			if (er_reportgenration != null && er_reportgenration.equals("background-csv"))
			{
				pageParams.put("er_reportgenration",er_reportgenration);
			}
			else
			{
				pageParams.put("er_reportgenration","foreground");
			}

			
			String bg_reportname = request.getParameter("bg_reportname");
			if(bg_reportname == null)
			{
				bg_reportname = "";
			}

			pageParams.put("bg_reportname",bg_reportname);

			JSONArray repGenOptions = new JSONArray();

			JSONObject repGenObj = new JSONObject();

			repGenObj.put("displayField",strforeground);
			repGenObj.put("valueField","foreground");
			repGenOptions.add(repGenObj);

			repGenObj = new JSONObject();
			repGenObj.put("displayField",strbackground);
			repGenObj.put("valueField","background");
			repGenOptions.add(repGenObj);

			repGenObj = new JSONObject();
			repGenObj.put("displayField",mappingInfo.getTextDescription("reporter.common.Background Save - CSV"));
			repGenObj.put("valueField","background-csv");
			repGenOptions.add(repGenObj);


			json.put("repGenOptions",repGenOptions);

			if(bg_reportname!=null)
				pageParams.put("bg_reportname",bg_reportname);

			
			if(reqFromSchedule!=null && reqFromSchedule.equalsIgnoreCase("Yes"))
			{
				screenLabels.put("submitButtonLbl",mappingInfo.getTextDescription("reporter.common.SAVE"));
			}
			else
			{
				screenLabels.put("submitButtonLbl",mappingInfo.getTextDescription("reporter.common.SUBMIT"));
			}
		}
		else if(action!=null && action.equals("changeTimeline"))
		{
			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 startMin  = request.getParameter("startmin");
			String endMin    = request.getParameter("endmin");
			String er_timeline = request.getParameter("er_timeline");
			String trendenable = request.getParameter("er_trenddata");
			String strQry_st_time = request.getParameter("startdate");
			String strQry_en_time = request.getParameter("enddate");			
			if(trendenable==null)
			{
				trendenable="No";
			}
			if(er_timeline==null || er_timeline.equals(" "))
			{
				er_timeline="1 day";
			}

			//Date calculation according to time select
			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","1 week","2 weeks","3 weeks","4 weeks","1 month"};

			List alist = Arrays.asList(options);
			IniUI iniui = IniUI.getInstance();
			ErReportHelper er_rpthelper = new ErReportHelper();
			EgDateInfo egDt = new EgDateInfo();

			User usr = UserRegistry.getInstance().getUser(session.getId());
			String thisLanguage = iniui.getDefaultLanguage();
			if (usr!=null)
			{
				String userLang = usr.getLanguage();
				if (userLang!=null && !userLang.equalsIgnoreCase("NULL"))
				{
					thisLanguage = userLang;
				}
			}
			EgMappingInfo mappingInfo = new EgMappingInfo(thisLanguage);
			String loginName = usr.getLoginID();
			String strUsrTimeline = er_rpthelper.getUserTimeline(loginName);
			int len;
			if(strUsrTimeline != null && !strUsrTimeline.equalsIgnoreCase("-1"))
			{
				len = alist.indexOf(strUsrTimeline)+1;
				alist = alist.subList(0,len);
				options = (String[])alist.toArray(new String[len]);
			}
			String startDateTime="";
			String endDateTime="";
			String uiFile = "eg_ui.ini";
			String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
			IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
			 currentDateFormat = egUI.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");
			long msecsPerHour = (long) 1000 * 60 * 60;

			String dispDate = null;
			String comFormat = null;
			if(er_timeline!=null&&!er_timeline.equals("Any"))
			{
				int blankSpaceIndex = er_timeline.indexOf(DateTimeTokenizer.BLANK_SPACE);
				if (blankSpaceIndex > 0)
				{
					SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm");
					java.util.Date today = egDt.egetRealDate();
					endDateTime = sdf.format(today);
					long value = Integer.parseInt(er_timeline.substring(0, blankSpaceIndex));
					String unit = er_timeline.substring(blankSpaceIndex+1).toLowerCase();
					if(unit.startsWith("mi"))
					{
						value *= (60);
					}
					else if (unit.startsWith("h"))
					{//hours
						value *= 3600;
					}
					else if (unit.startsWith("d"))
					{//days
						value *= (24 * 3600);
					}
					else if (unit.startsWith("w"))
					{//weeks
						value *= (7 * 24 * 3600);
					}
					else if (unit.startsWith("mo"))
					{//months
						//int  totalDays=ErUtils.getMaxDaysInMonth();
						//value *= (ErUtils.getMaxDaysInMonth() * 24 * 3600);
						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)( (value*totalDays * msecsPerHour)));
						startDateTime = DateUtil.changeDateFormat(startDateTime,
						"dd/MM/yyyy HH:mm","MM/dd/yyyy HH:mm");
					}
					if (unit!=null&&!unit.startsWith("mo"))
					{
						java.util.Date start = new java.util.Date();
						start.setTime(today.getTime() - (value * 1000));
						startDateTime = sdf.format(start);
					}
				}
				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));

					if(trendenable!=null && trendenable.equals("Yes"))
					{
						s_st_hr="0";
						s_en_hr="0";
						startMin="0";
						endMin="0";
					}else
					{
						s_st_hr = String.valueOf(shr);
						s_en_hr = String.valueOf(en_hr);
						startMin = String.valueOf(startDateTime.substring(startDateTime.indexOf(":")+1));
						endMin = String.valueOf(endDateTime.substring(endDateTime.indexOf(":")+1));
					}
				}
			}

			
			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(trendenable!=null && trendenable.equals("Yes"))
				{
					s_st_hr="0";
					s_en_hr="0";
					startMin="0";
					endMin="0";
				}
				else
				{*/
				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(startMin==null)
				{
					startMin = StrDate.substring(StrDate.indexOf(":")+1);
				}
				if(endMin==null)
				{
					endMin = StrDate.substring(StrDate.indexOf(":")+1);
				}
			//}
			}

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

			JSONArray timelineJSON = new JSONArray();
			for(int e_ctr=0; e_ctr < options.length;e_ctr++)
			{
				if(options[e_ctr].equalsIgnoreCase("Any"))
				{
					JSONObject jObj = new JSONObject();
					jObj.put("displayField",mappingInfo.getTextDescription("reporter.common."+options[e_ctr]));
					jObj.put("valueField",options[e_ctr]);
					timelineJSON.add(jObj);
				}
				else
				{
					String numstr=options[e_ctr].substring(0,options[e_ctr].indexOf(" "));
					String strextra=options[e_ctr].substring(options[e_ctr].indexOf(" ")+1);
					JSONObject jObj = new JSONObject();
					jObj.put("displayField",numstr+" "+mappingInfo.getTextDescription("reporter.common."+strextra));
					jObj.put("valueField",options[e_ctr]);
					timelineJSON.add(jObj);
				}
			}

			json.put("timelineJSON",timelineJSON);

			if(er_timeline!=null&& !er_timeline.equals("Any"))
			{
				if(DateUtil.isDate(s_st_time,"MM/dd/yyyy"))
				{
					comFormat = "MM/dd/yyyy";
				}
				else
				{
					comFormat = currentDateFormat;
				}
				dispDate = DateUtil.changeDateFormat(s_st_time,comFormat,currentDateFormat);
			}
			else
			{
				dispDate = s_st_time;
			}

			if(dispDate!=null)
				pageParams.put("selectedStartDate",dispDate);

			JSONArray hrJSON = new JSONArray();

			if(s_st_hr!=null)
			{
				s_st_hr = s_st_hr.trim();
				pageParams.put("selectedFromHr",s_st_hr);
			}

			for(int s_ctr=0; s_ctr < 24 ;s_ctr++)
			{
				JSONObject hrObj = new JSONObject();
				hrObj.put("displayField",String.valueOf(s_ctr));
				hrObj.put("valueField",String.valueOf(s_ctr));

				hrJSON.add(hrObj);
			}

			json.put("hrJSON",hrJSON);

			JSONArray minJSON = new JSONArray();

			if(startMin!=null)
			{
				startMin = startMin.trim();
				pageParams.put("selectedFromMinutes",startMin);
			}

			for(int s_ctr=0; s_ctr < 60 ;s_ctr++)
			{
				String c=String.valueOf(s_ctr);
				if(s_ctr<=9)
				{
						c="0"+c;
				}

				JSONObject minObj = new JSONObject();
				minObj.put("displayField",""+c);
				minObj.put("valueField",""+c);

				minJSON.add(minObj);
			}

			json.put("minJSON",minJSON);

			if(er_timeline!=null&& !er_timeline.equals("Any"))
			{
				if(DateUtil.isDate(s_en_time,"MM/dd/yyyy"))
				{
					comFormat = "MM/dd/yyyy";
				}
				else
				{
					comFormat = currentDateFormat;
				}
				dispDate = 	DateUtil.changeDateFormat(s_en_time,comFormat,currentDateFormat);
			}
			else
			{
				dispDate = s_en_time;
			}

			if(dispDate!=null)
				pageParams.put("selectedEndDate",dispDate);

			if(s_en_hr!=null)
			{
				s_en_hr = s_en_hr.trim();
				pageParams.put("selectedToHr",s_en_hr);
			}

			if(endMin!=null)
			{
				endMin = endMin.trim();
				pageParams.put("selectedToMinutes",endMin);
			}

			hiddenParams.put("startdate",request.getParameter("startdate"));
			hiddenParams.put("enddate",request.getParameter("enddate"));
			hiddenParams.put("starthr",s_st_hr);
			hiddenParams.put("endhr",s_en_hr);
		}
		String isSubmit= request.getParameter("isSubmit");
		if(isSubmit!=null && isSubmit.equals("true"))
		{
			IniFile uiIni = new IniFile(EgInstallInfo.getInstallDir()+"/manager/config/eg_ui.ini");
			String stateIcons = uiIni.getValue("STATE_ICONS","Default");
			String optClassName = "";
			if ( stateIcons != null && stateIcons.equalsIgnoreCase("no") )
			{
				optClassName = "_optional";
			}
			String er_reportgenration = request.getParameter("er_reportgenration");

			if(er_reportgenration!=null && er_reportgenration.equals("background"))
			{
				String selectedLanguage = request.getParameter("selectedLanguage");
				EgMappingInfo mappingInfo = new EgMappingInfo(selectedLanguage);
				JSONObject responseJson =  new JSONObject();
				String strStatusMeassage = (String) request.getAttribute("bggroundStr");
				String strStatusstr = (String) request.getAttribute("status");
				String strReportName = (String) request.getParameter("er_bgreportfrom");
				responseJson.put("bgGroundMsg",strStatusMeassage);
				responseJson.put("status",strStatusstr);
				String bglinkMsg=mappingInfo.getTextDescription("reporter.common.Click here to see a list of generated and processing reports");
				if(strStatusstr != null && (strStatusstr.equalsIgnoreCase("duplicate") || strStatusstr.equalsIgnoreCase("exceedLimit")))
				{
					strReportName = "All Report Types";
					strReportName = EgURLEncoder.encode(strReportName,"UTF-8");
				}
				if(strStatusstr != null && !strStatusstr.equalsIgnoreCase("exceedLimit"))
				{
					responseJson.put("langSupportString",erbgreport.getlangsupportedString(strStatusMeassage,"'",userID));
				}
				else
				{
					responseJson.put("langSupportString",strStatusMeassage);
				}
				String bgreporturl="/final/servlet/com.eg.ErStartBackGroundReportC?back=true&er_bgreportfrom="+strReportName+"&userID="+com.eg.EgURLEncoder.encode(userID, "UTF-8")+"&savereport=search&er_filterby=Report_Name&forwardto=ErBackGoundProcess";
				responseJson.put("bgReportUrl",bgreporturl);
				responseJson.put("bgreportlinkMsg",bglinkMsg);
				json.put("responseJson",responseJson);
			}
			else
			{
				boolean isContainSameKey = false;
				EgDiagnosisBean dd = new EgDiagnosisBean();
				String selectedLanguage = request.getParameter("selectedLanguage");
				EgMappingInfo mappingInfo = new EgMappingInfo(selectedLanguage);
				IniFile egFormat = new IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_format.ini");
				session.setAttribute("PDF_URL", mngrIProc+"/final/servlet/com.eg.ErSnapshotC");
				Hashtable ht_snapData = (Hashtable) request.getAttribute("snapData");
				if(ht_snapData !=null)
				{
					Map printParameters = new HashMap(request.getParameterMap());
					printParameters.put("option","print");
					String printQueryString = (String)ErUtils.prepareQueryString(printParameters);
					session.setAttribute("printQueryString",printQueryString);
					Map printParamVal = new HashMap(request.getParameterMap());
					printParamVal.put("option","print");
					if(type!=null && type.equalsIgnoreCase("intersnap"))
					{
						printParamVal.remove("er_component");
					}

					
					if(printParamVal!=null && printParamVal.containsKey("er_test"))
						printParamVal.remove("er_test");
					
					String printParamQString = (String)ErUtils.prepareQueryString(printParamVal);
					session.setAttribute("printParamVal",printParamVal);
					pageParams.put("printParamQString",printParamQString);
					if(ht_snapData.isEmpty())
					{
						pageParams.put("dataAvailable","false");
						screenLabels.put("reporter.common.No measures available for the current selection",mappingInfo.getTextDescription("reporter.common.No measures available for the current selection"));
					}
					else
					{ 
						String strQry_st_time = request.getParameter("startdate");
						String strQry_en_time = request.getParameter("enddate");
						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 startMin  = request.getParameter("startmin");
						String endMin    = request.getParameter("endmin");
						String er_timeline = request.getParameter("er_timeline");
						String graphmode = request.getParameter("graphmode");
						String s_test = request.getParameter("er_test");
						String st_dataFrom=request.getParameter("er_dataFrom");
						String s_option=request.getParameter("er_option");
						String s_singleSelectLabel = "";
						String s_multiSelectLabel = "";
						//prakash
						String s_componentTypeTemp = request.getParameter("er_componentType");
						//

						if(request.getParameter("er_componentType")!=null)
						selectionDetails.put(mappingInfo.getTextDescription("reporter.common.Component Type"),mappingInfo.getComponentTypeDescription(request.getParameter("er_componentType")));

						if(st_dataFrom==null || st_dataFrom.equals(""))		
						{
							st_dataFrom="Component" ;
						}
						boolean ddEnabled = EgMemInfo.ddEnabled;
						ErReqData erd = new ErReqData(request);

						if(erd!=null && erd.s_gtype!=null)
						{
							if(erd!=null && erd.s_gtype!=null && ("intrasnap".equalsIgnoreCase(erd.s_gtype)))
							{
								s_singleSelectLabel = "Component";
								s_multiSelectLabel = "Test";
							}
							else if("intersnap".equalsIgnoreCase(erd.s_gtype))
							{
								s_singleSelectLabel = "Test";
								s_multiSelectLabel = "Component";
							}
						}
						String s_component = request.getParameter("er_component");
						String s_final = new String();
						String s_good="",s_high="",s_medium="",s_low="",s_unknown="";
						//taken from eg_ui.ini for state label
						IniUI iniui = IniUI.getInstance();
						if(iniui.getStateDisplayLabel("GOOD")!=null)
							s_good = iniui.getStateDisplayLabel("GOOD");
						else
							s_good = "Good";

						if(iniui.getStateDisplayLabel("HIGH")!=null)
							s_high = iniui.getStateDisplayLabel("HIGH");
						else
							s_high = "Bad_High";

						if(iniui.getStateDisplayLabel("INTERMEDIATE")!=null)
							s_medium = iniui.getStateDisplayLabel("INTERMEDIATE");
						else
							s_medium = "Bad_Medium";

						if(iniui.getStateDisplayLabel("LOW")!=null)
							s_low = iniui.getStateDisplayLabel("LOW");
						else
							s_low = "Bad_Low";

						if(iniui.getStateDisplayLabel("UNKNOWN")!=null)
							s_unknown = iniui.getStateDisplayLabel("UNKNOWN");
						else
							s_unknown = "Unknown";

						String sHideView = s_test;
						if (s_singleSelectLabel != null && s_singleSelectLabel.equals("Component")
							&& s_component !=null && !s_component.equals(""))
						{
							if (!s_component.equalsIgnoreCase("ALL") ) {
							if (s_component.indexOf(":NULL") > -1) {
								sHideView = s_component.substring(0,s_component.indexOf(":"));
							} else {
								sHideView = s_component.substring(0,s_component.lastIndexOf(":"));
							}
							sHideView += ":" + mappingInfo.getComponentTypeDescription (
								s_component.substring( s_component.lastIndexOf(":")+1));
								selectionDetails.put(mappingInfo.getTextDescription("reporter.common.Component "),sHideView);
							}else
							{

								sHideView =mappingInfo.getTextDescription("reporter.common.All Components");
								selectionDetails.put(mappingInfo.getTextDescription("reporter.common.Component "),sHideView);
							}

						}
						else
							selectionDetails.put(mappingInfo.getTextDescription("reporter.common.Test "),mappingInfo.getTestDescription(sHideView));


	// by karthikeyan

	String strStartTimee = erd.s_stdate+" "+erd.s_sthr+":"+erd.s_startmin+":00";
	String strEndTimee = erd.s_enddate+" "+erd.s_endhr+":"+erd.s_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();

		String	timeline1="<span class='font_bold'></span>"+startDateForDisplay+" "+startHourForDisplay+":"+startMinForDisplay+"  "+mappingInfo.getTextDescription("reporter.common.hrs")+" <span class='font_bold'>  "+mappingInfo.getTextDescription("reporter.common.to")+" </span> "+endDateForDisplay+" "+endHourForDisplay+":"+endMinForDisplay+" "+mappingInfo.getTextDescription("reporter.common.hrs");

	selectionDetails.put(mappingInfo.getTextDescription("reporter.common.Timeline"),timeline1);
		
				//



						
					


						
						screenLabels.put("HIGH",mappingInfo.getTextDescription("reporter.common."+s_high));
						screenLabels.put("MEDIUM",mappingInfo.getTextDescription("reporter.common."+s_medium));
						screenLabels.put("LOW",mappingInfo.getTextDescription("reporter.common."+s_low));
						screenLabels.put("GOOD",mappingInfo.getTextDescription("reporter.common."+s_good));
						screenLabels.put("UNKNOWN",mappingInfo.getTextDescription("reporter.common."+s_unknown));
						screenLabels.put("reporter.common.From",mappingInfo.getTextDescription("reporter.common.From"));
						screenLabels.put("reporter.common.To",mappingInfo.getTextDescription("reporter.common.To"));
						screenLabels.put("reporter.common.Hrs",mappingInfo.getTextDescription("reporter.common.Hrs"));
						screenLabels.put("reporter.common.Timeline",mappingInfo.getTextDescription("reporter.common.Timeline"));

						screenLabels.put("reporter.common.Measure",mappingInfo.getTextDescription("reporter.common.Measure")+" ("+mappingInfo.getTextDescription("reporter.common.Unit")+")");
						screenLabels.put("reporter.common.Min",mappingInfo.getTextDescription("reporter.common.Min"));
						screenLabels.put("reporter.common.Max",mappingInfo.getTextDescription("reporter.common.Max"));
						screenLabels.put("reporter.common.Avg",mappingInfo.getTextDescription("reporter.common.Avg"));
						screenLabels.put("reporter.common.Total Measures",mappingInfo.getTextDescription("reporter.common.Total Measures"));
						screenLabels.put("reporter.common.DD",mappingInfo.getTextDescription("reporter.common.DD"));
						screenLabels.put("reporter.common.Graph",mappingInfo.getTextDescription("reporter.common.Graph"));
						screenLabels.put("reporter.common.Data",mappingInfo.getTextDescription("reporter.common.Data"));

						screenLabels.put("reporter.common.Selection Details for",mappingInfo.getTextDescription("reporter.common.Selection Details for")+"&nbsp;"+sHideView);

						pageParams.put("start_date_details",erd.s_stdate+" "+erd.s_sthr+":"+erd.s_startmin);
						pageParams.put("end_date_details",erd.s_enddate+" "+erd.s_endhr+":"+erd.s_endmin);

						AuditLogHashtable headerInfoAuditLogHashtable = new AuditLogHashtable();
						String title_temp="";
						if(!st_dataFrom.equalsIgnoreCase("Component"))
						{
							title_temp="\n"+","+"Report For : "+mappingInfo.getTextDescription("reporter.common."+st_dataFrom.toUpperCase())+","+mappingInfo.getTextDescription("reporter.common."+st_dataFrom)+"  Name  : "+s_option;
						}
						else
						{
							title_temp="\n"+","+"Report For : "+mappingInfo.getTextDescription("reporter.common."+st_dataFrom.toUpperCase());
						}
							
						if (!StringUtils.isNull(titleToDisplay)){ 
							 headerInfoAuditLogHashtable.put("title",titleToDisplay);
						}
						else
						{

						 headerInfoAuditLogHashtable.put("title",mappingInfo.getTextDescription("reporter.common.SNAPSHOT REPORTS") +" - " + mappingInfo.getTextDescription("reporter.common."+s_singleSelectLabel.toUpperCase()+"S")+title_temp);

						}
		String startDate = "\"" + mappingInfo.getTextDescription("reporter.common.Start Date") + " : " + startDateForDisplay + " " + startHourForDisplay+":"+startMinForDisplay+" Hrs" +"\"";
			String endDate = "\"" + mappingInfo.getTextDescription("reporter.common.End Date") + " : " + endDateForDisplay +" " +endHourForDisplay +":"+endMinForDisplay+ " Hrs" + "\"";

						headerInfoAuditLogHashtable.put("dateInfo",startDate + "," + endDate);
						//prakash for csv
							String s_componentTemp = s_component;
							if(s_componentTemp!=null && s_componentTemp.indexOf(":") > -1)
							{
								s_componentTemp = s_componentTemp.substring(0,s_componentTemp.indexOf(":"));
							}
							headerInfoAuditLogHashtable.put("titleInfo", ""+mappingInfo.getTextDescription("reporter.common.Snapshot Report for")+" "+"ComponentType"+" "+":"+mappingInfo.getComponentTypeDescription(s_componentTypeTemp) +" "+"and Component"+":"+s_componentTemp);
						//
						AuditLogHashtable innerKeyAuditLogHahstable = new AuditLogHashtable();
						innerKeyAuditLogHahstable.put("headerInfo",headerInfoAuditLogHashtable);


						

						String dd_link = "&firsttime=true&comeFrom=Reporter&newWindow=true&flag=1&starttime="+strQry_st_time+"&endtime="+strQry_en_time+"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&startmin="+startMin+"&timeline=Any&endmin="+endMin+"&msmt_host=&inidate="+request.getParameter("inidate");
						String data_link = "&option=data&er_rtype=SnapShot&er_gtype=intrasnap&startdate="+strQry_st_time+"&enddate="+strQry_en_time+"&startmin="+request.getParameter("startmin")+"&endmin="+request.getParameter("endmin")+"&starthr="+request.getParameter("starthr")+"&endhr="+request.getParameter("endhr")+"&er_timeline="+URLDecoder.decode(request.getParameter("er_timeline"))+"&er_mode="+graphmode+"&userID="+urs+"&inidate="+request.getParameter("inidate");
						String graph_link = "&option=graph&er_rtype=SnapShot&er_gtype=intrasnap&&startdate="+strQry_st_time+"&enddate="+strQry_en_time+"&startmin="+request.getParameter("startmin")+"&endmin="+request.getParameter("endmin")+"&starthr="+request.getParameter("starthr")+"&endhr="+request.getParameter("endhr")+"&er_timeline="+URLDecoder.decode(request.getParameter("er_timeline"))+"&er_mode="+graphmode+"&userID="+urs+"&er_trenddata=No&snaptime=Yes&inidate="+request.getParameter("inidate");

					//	StringBuffer sbMeasTable =  new StringBuffer(512);
						JSONArray reportTableArr = new JSONArray();
					/*	sbMeasTable.append("<table border='0' cellspacing='0' cellpadding='0' width='100%'>");
							sbMeasTable.append("<tr>");
								sbMeasTable.append("<td>");*/


						Hashtable mappingData = new Hashtable();
						Vector mappingVec = null;
						Iterator itr =(new TreeMap(ht_snapData)).keySet().iterator();
						while(itr.hasNext())
						{
							String innerKey = "";
							String skey = (String)itr.next();
							if(skey ==null || skey.equals(""))
							{
								continue;
							}
							innerKey = skey;
							Vector v_tmp = (Vector)ht_snapData.get(skey);
							if(v_tmp == null || v_tmp.isEmpty())
							{
								continue;
							}
							if(!isContainSameKey && skey.indexOf("(") > -1) {
								//skey = skey.substring(0,skey.lastIndexOf("("));
							}


							JSONObject measureTableObject =  new JSONObject();
							String str=StringUtils.split(skey,100);
							str=str.replaceAll(":",": ");
							measureTableObject.put("tableTitle",str);

							JSONArray measureTable = new JSONArray();

						/*	sbMeasTable.append("<div class='x-table dataPanel'>");
							sbMeasTable.append("<div style='padding:5px 0px 5px 10px;font-size:12px' class='x-panel-header'>");
							
							sbMeasTable.append(str);
							sbMeasTable.append("</div>");
							sbMeasTable.append("<table cellspacing='0' cellpadding='0' border='0' class='x-grid-table x-grid-table-resizer' nowwrap >");
							sbMeasTable.append("<thead>");
							
							sbMeasTable.append("<tr class='x-grid-row'>");
								sbMeasTable.append("<th class='x-grid-cell' width='25%' ><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.Measure"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='5%' ><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.Min"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='5%'><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.Max"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='5%'><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.Avg"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='10%'><div class='x-grid-cell-inner' style='overflow:visible;'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.Total Measures"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='6%'><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.Normal"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='6%' ><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.Critcal"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='6%' ><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.Major"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='6%' ><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.Minor"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='6%' ><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.UnKnown"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='4%'><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.DD"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='5%'><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.Graph"));
								sbMeasTable.append("</div></th>");
								sbMeasTable.append("<th class='x-grid-cell' width='4%'><div class='x-grid-cell-inner' style='overflow:visible'>");
									sbMeasTable.append(mappingInfo.getTextDescription("reporter.common.Data"));
								sbMeasTable.append("</div></th>");
							sbMeasTable.append("</tr>");
							sbMeasTable.append("</thead>");
							sbMeasTable.append("<tbody>");*/
							mappingVec = new Vector();
							mappingVec.addAll(v_tmp);
							Vector label = new Vector();
							label.add(mappingInfo.getTextDescription("reporter.common.State"));
							label.add(mappingInfo.getTextDescription("reporter.common.Min"));
							label.add(mappingInfo.getTextDescription("reporter.common.Max"));
							label.add(mappingInfo.getTextDescription("reporter.common.Avg"));
							label.add(mappingInfo.getTextDescription("reporter.common.Total Measures"));
							label.add(mappingInfo.getTextDescription("reporter.common.Normal"));
							label.add(mappingInfo.getTextDescription("reporter.common.Critical"));
							label.add(mappingInfo.getTextDescription("reporter.common.Major"));
							label.add(mappingInfo.getTextDescription("reporter.common.Minor"));
							label.add(mappingInfo.getTextDescription("reporter.common.Unknown"));

							AuditLogHashtable innerMost = new AuditLogHashtable();
							innerMost.put("Measure (Unit) ",label);
							for(int i =0;i<v_tmp.size();i+=12)
							{
								String state = (String) v_tmp.get(i);
								String dispMeas = (String)v_tmp.get(i+1);
								String s_QS = (String)v_tmp.get(i+11);
								HashMap qsParam = ErUtils.parseQueryString(s_QS);
								String s_ddEnable = (String)qsParam.get("er_ddEnable");

								String stateCSSClass="stateSymbol_UNKNOWN";

								Vector csv = new Vector();
								if(state != null && !state.equalsIgnoreCase("null"))
								{
									if(state.equalsIgnoreCase("rcircle.gif"))
									{
										stateCSSClass = "state_HIGH";
										csv.add("Critical");
									}
									else if(state.equalsIgnoreCase("ocircle.gif"))
									{
										stateCSSClass = "state_INTERMEDIATE";
										csv.add("Major");
									}
									else if(state.equalsIgnoreCase("pcircle.gif"))
									{
										stateCSSClass = "state_LOW";
										csv.add("Minor");
									}
									else if(state.equalsIgnoreCase("gcircle.gif"))
									{
										stateCSSClass = "state_GOOD";
										csv.add("Normal");
									}
									else if(state.equalsIgnoreCase("bcircle.gif"))
									{
										stateCSSClass = "state_UNKNOWN";
										csv.add("Unknown");
									}
									else
									{
										csv.add(state);
									}
								}
								
								JSONObject jObj = new JSONObject();
								jObj.put("cssClass",stateCSSClass+optClassName);
								jObj.put("Measure",dispMeas);
							/*	sbMeasTable.append("<tr class='x-grid-row'>");
									sbMeasTable.append("<td class='x-grid-cell'><div class='x-grid-cell-inner' style='float:left;postion:relative;'><div style='float:left;postion:relative;height:20px'><div style='postion:relative;top:1px' class='"+stateCSSClass+optClassName+"'></div></div><div style='postion:relative;width:250px' >"+dispMeas+"</div></div></td>");*/
									
								ArrayList colNames = new ArrayList();
								colNames.add("Min");
								colNames.add("Max");
								colNames.add("Avg");
								colNames.add("Total_Measures");
								colNames.add("Normal");
								colNames.add("Critical");
								colNames.add("Major");
								colNames.add("Minor");
								colNames.add("Unknown");
								
								int dynamicColumnCount = 0 ;
								String test = (String)qsParam.get("er_test");
								String measure = (String)qsParam.get("er_disp_meas");
								String testMeas_Name=test.trim()+":"+measure.trim();
								String convert_Days=dashboardConfigIni.getValue("Convert_To_Days",testMeas_Name);
								for(int j = i+2; j<i+11; j++)
								{
									String colVal = (String) v_tmp.get(j);
									String colName = (String) colNames.get(dynamicColumnCount);
									if (colName.equals("Min") || colName.equals("Max") || colName.equals("Avg"))
									{
										if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
										{
											String dateDiff="";
											String currentValue=colVal;	
											try
											{
												if(currentValue!=null && !currentValue.trim().equals(""))
												{
													long minutes=0;
													int seconds=0;
													if(currentValue!=null && currentValue.indexOf(".")>0)
													{
														minutes=Long.parseLong(currentValue.substring(0,currentValue.indexOf(".")));
														if(currentValue.substring(currentValue.indexOf(".")+1).length()>2)
														{
															seconds=Integer.parseInt(currentValue.substring(currentValue.indexOf(".")+1,currentValue.indexOf(".")+3));
														}
														else
														{
															seconds=Integer.parseInt(currentValue.substring(currentValue.indexOf(".")+1));
														}
													}
													else
													{
														minutes=Long.parseLong(currentValue);
													}
													long valueInSecond=(minutes*60)+seconds;
													dateDiff=egDashboard.getDateDifferenceStringforUptime(valueInSecond);
													if(dispMeas!=null && dispMeas.indexOf("(")>-1)
													{
														dispMeas = dispMeas.substring(0,dispMeas.indexOf("("));
														jObj.put("Measure",dispMeas);
													}
												}			
												colVal=dateDiff;
											}
											catch(Exception e)
											{
												colVal=colVal;
											}
										}
									}
									csv.add(colVal);
									String tdWidth = "30";
									if(j==5)
										tdWidth ="90";

									jObj.put("col"+dynamicColumnCount,colVal);

/*									sbMeasTable.append("<td class='x-grid-cell'><div class='x-grid-cell-inner'>");
										sbMeasTable.append(colVal);
									sbMeasTable.append("</div></td>");*/
									dynamicColumnCount++;
								}
								innerMost.put(dispMeas,csv);
								if (ddEnabled && s_ddEnable.equals("Yes"))
								{
									//String test = (String)qsParam.get("er_test");
									String site = (String)qsParam.get("er_site");
									//String measure = (String)qsParam.get("er_disp_meas");
									if (site == null || site.equals("")) {
										site = "NULL";
									}
									String strTemp =  EgURLDecoder.decode((String)qsParam.get("er_component"),"UTF-8");
									//fix for display infos in DD
									String comptype=strTemp.substring(strTemp.lastIndexOf(":")+1);
									//end
									StringTokenizer st = new StringTokenizer(strTemp,":");
									String comp = st.nextToken();
									String port = st.nextToken();
									String sid = (st.countTokens() == 2) ? st.nextToken() : "";

									String info = sid + "*" + EgURLDecoder.decode((String)qsParam.get("er_info_list"),"UTF-8");
									if(type!=null && type.equalsIgnoreCase("intersnap"))
									{
										ErComponentsUtils compUtil = new ErComponentsUtils(thisuser.getLoginID());
										com.eg.EgDiscInfo discInfo = new com.eg.EgDiscInfo("manager");
										List aList = compUtil.getServerTypeForNick(comp);
										if(aList!=null && aList.size()>0)
											comptype = (String)aList.get(0);
									}
									if(comptype!=null && comptype.equalsIgnoreCase("Host_system"))
									{
										String s_componentType=request.getParameter("er_componentType");
										if(s_componentType!=null && !s_componentType.equalsIgnoreCase("ALL"))
											comptype=s_componentType;

									}
									//String dd_url = "/final/monitor/EgDispDD.jsp?site="+site+"&host="+EgURLEncoder.encode(comp,"UTF-8")+"&port="+port+"&test="+test+"&info="+info+"&from=0&measure="+measure+dd_link+"&comptype="+comptype;
															
								//	String dd_url = "/final/monitor/EventsGraph.jsp?pageToShow=diagnosis&url=EgDiagnosis.jsp?site="+site+"&host="+EgURLEncoder.encode(comp,"UTF-8")+"&port="+port+"&test="+test+"&info="+info+"&from=0&measure="+measure+dd_link+"&comptype="+comptype+"&popup=true&newWindow=true";
									
									
						
								
									
	//String dd_url = "/final/monitor/componentMeasureTabSet.jsp?type="+EgURLEncoder.encode(comptype,"UTF-8")+"&site="+site+"&host="+EgURLEncoder.encode(comp,"UTF-8")+"&port="+port+"&info="+EgURLEncoder.encode(info,"UTF-8")+"&messy="+measure+"&msmt_host=&from=0&dd=yes&userID="+EgURLEncoder.encode(s_user_id,"UTF-8")+"&test="+ test+"&clicked=dd&newWindow=true&fromReporterHis=true&popup=true&fromPage=eveHist&comptype="+comptype+"&firsttime=true&comeFrom=Reporter&flag=1&starttime="+strQry_st_time+"&endtime="+strQry_en_time+"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&startmin="+startMin+"&timeline=Any&endmin="+endMin+"&inidate="+request.getParameter("inidate");
								
	String dd_url = "/final/monitor/componentMeasureTabSet.jsp?type="+EgURLEncoder.encode(comptype,"UTF-8")+"&site="+site+"&host="+EgURLEncoder.encode(comp,"UTF-8")+"&port="+port+"&info="+EgURLEncoder.encode(info,"UTF-8")+"&state=&messy="+measure+"&msmt_host=&userID="+EgURLEncoder.encode(urs,"UTF-8")+"&test="+ test+"&comptype="+comptype+"&measureDisp="+measure+"&starttime="+strQry_st_time+"&endtime="+strQry_en_time+"&starthr="+s_st_hr+"&endhr="+s_en_hr+"&startmin="+startMin+"&endmin="+endMin+"&from=measurespage&dd=yes&clicked=dd&newWindow=true&fromReporterHis=true&popup=true&fromPage=eveHist";
									


									StringBuffer key = new StringBuffer(32);
									key.append(test);
									key.append(":");
									key.append(measure);
									String tm = key.toString();
									String s_infovalue = info;
									String disInfo = egFormat.getValue("Tests_For_DDWithoutInfos",tm);
									if(disInfo!=null && disInfo.equalsIgnoreCase("Yes"))
									{
										s_infovalue = "+";
									}
									else
									{
										if(s_infovalue!=null && s_infovalue.indexOf("*")>-1)
										{
											int numChar=s_infovalue.length();
											char[] charArray=new char[numChar];
											s_infovalue.getChars(0, numChar, charArray,0);
											for(int j=0;j<charArray.length;j++)
											{
												if(charArray[j]=='*')
												{
													charArray[j]='+';
													break;
												}
											}
											s_infovalue = new String(charArray);
										}
									}
									if(dd.ShowDDData(site,comp,test,measure,s_infovalue,""))
									{
										/*sbMeasTable.append("<td class='x-grid-cell'>");
											sbMeasTable.append("<div class='x-grid-cell-inner' style='position:relative;height:20px;'><div class='iconDiagnosis' onClick='javascript:loadPopup(\""+dd_url+"\");' style='argin:0px;padding:0px;width:20px;height:20px;position:absolute;display:block;top:4px;left:11px;cursor:pointer'></div></div>");
										sbMeasTable.append("</td>");*/
										jObj.put("ddLink",dd_url);
									}
									else
									{
										/*sbMeasTable.append("<td class='x-grid-cell' align='center'><div class='-grid-cell-inner'>");
											sbMeasTable.append("-");
										sbMeasTable.append("</div></td>");*/
										jObj.put("ddLink","NA");
									}
								}
								else
								{
									/*sbMeasTable.append("<td class='x-grid-cell' align='center'><div class='x-grid-cell-inner' >");
										sbMeasTable.append("-");
									sbMeasTable.append("</div></td>");*/
									jObj.put("ddLink","NA");
								}
								String grpLinkUrl = "/final/reporter/ErMeasureDrillDown.jsp?"+s_QS+graph_link;
							/*	sbMeasTable.append("<td class='x-grid-cell'>");
											sbMeasTable.append("<div class='x-grid-cell-inner' style='position:relative;height:20px;'><div class='iconLineChart' onClick='javascript:loadUrlInDrillDown(\""+grpLinkUrl+"\");' style='argin:0px;padding:0px;width:20px;height:20px;position:absolute;display:block;left:11px;top:3px;cursor:pointer'></div></div>");
								sbMeasTable.append("</td>");*/

								String dataLinkUrl = "/final/servlet/com.eg.ErSnapshotC?"+s_QS+data_link;
							/*	sbMeasTable.append("<td class='x-grid-cell'>");
											sbMeasTable.append("<div class='x-grid-cell-inner' style='position:relative;height:20px;'><div class='iconDb' onClick='javascript:loadPopup(\""+dataLinkUrl+"\");' style='argin:0px;padding:0px;width:20px;height:20px;left:11px;position:absolute;display:block;top:3px;cursor:pointer'></div></div>");
								sbMeasTable.append("</td>");

								sbMeasTable.append("</tr>");*/
								jObj.put("graphLink",grpLinkUrl);
								jObj.put("dataLink","/final/servlet/com.eg.ErSnapshotC?"+s_QS+data_link);
								measureTable.add(jObj);
							}
							measureTableObject.put("measureTable",measureTable);
						//	sbMeasTable.append("</table></div>");
							mappingData.put(skey,mappingVec);
						
							innerKeyAuditLogHahstable.put(innerKey,innerMost);
							reportTableArr.add(measureTableObject);
						}
				/*		sbMeasTable.append("</td>");
						sbMeasTable.append("</tr>");
						sbMeasTable.append("</table>");*/
					
						//String sbMeasTableStr = sbMeasTable.toString();
						if(reportTableArr!=null && !reportTableArr.isEmpty())
						{
							session.setAttribute("SnapshotReportSubmitData",reportTableArr);
							JSONArray snapShotDataViewData=new JSONArray();
							int recLimit=10;
							if(reportTableArr.size()<10)
							{
								recLimit = reportTableArr.size();
							}
							for(int s=0;s<recLimit;s++)
							{
								JSONObject measureTableData = (JSONObject) reportTableArr.get(s);
								snapShotDataViewData.add(measureTableData);
							}
							json.put("snapShotDataViewData",snapShotDataViewData);
						}
					/*	if(!StringUtils.isNull(sbMeasTableStr))
						{
							json.put("snapShotTableStr",sbMeasTableStr);
						}*/
						HashMap param =new HashMap();
						param.put("REPORT_PARAM",ErUtils.parseQueryString(ErUtils.prepareQueryString(request.getParameterMap())));
						param.put("REPORT_DATA",mappingData);
						session.setAttribute("parameters", param);
						session.setAttribute("auditLogHashtable",innerKeyAuditLogHahstable);
						pageParams.put("dataAvailable","true");
					}
				}
			}
		}

		if((isSubmit!=null && isSubmit.equals("true")) || (action!=null && action.equalsIgnoreCase("defaultLoad")))
		{
			Map printParameters = new HashMap(request.getParameterMap());
			printParameters.put("option","print");
			if(type!=null && type.equalsIgnoreCase("intersnap"))
			{
				printParameters.remove("er_component");
			}
			String printQueryString = (String)ErUtils.prepareQueryString(printParameters);
			String printQry = "";
			if(printQueryString!=null)
			{
				StringTokenizer strtok = new StringTokenizer(printQueryString,"&");
				while(strtok.hasMoreTokens())
				{
					String param = strtok.nextToken();
					int ind = param.indexOf("=");
					if (ind < 0)
						continue;
					String reqparam = param.substring(0,ind);
					String value = param.substring(ind+1);

					//
					if(type!=null&&type.equalsIgnoreCase("intersnap")) // snapshot by test
					{
						if(reqparam!=null&&reqparam.equals("er_component"))
							continue;
						else if(reqparam!=null&&reqparam.equals("selectedComponents"))
							continue;

					}

					if(type!=null && type.equals("intrasnap")) // snapshot by component
					{
						if(reqparam!=null&&reqparam.equals("er_test"))
							continue;
						else if(reqparam!=null&&reqparam.equals("selectedComponents"))
							continue;

					}


					//
					if(reqparam!=null&&reqparam.equals("er_timeline"))
					{
						value = com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("startdate"))
					{
						value = com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("enddate"))
					{
						value = com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("er_info_list"))
					{
						value = com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("inidate"))
					{
						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_component"))
					{
						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("prior_type"))
					{
						value = com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					printQry = printQry+reqparam+"="+value+"&";
				}
			}

			String dataProcess = mngrIProc+"/final/servlet/com.eg.ErSnapshotC;jsessionid="+ session.getId()+"?"+printQry.toString()+"&isPdf=true";
			session.setAttribute("MAIL_URL",dataProcess);
			Map parameters = new HashMap();
			parameters = request.getParameterMap();
			String queryString = (String)ErUtils.prepareQueryString(request.getParameterMap());
			String Qstring="";
			if(queryString!=null)
			{
				StringTokenizer strtok = new StringTokenizer(queryString,"&");
				while(strtok.hasMoreTokens())
				{
					String param = strtok.nextToken();
					int ind = param.indexOf("=");
					if (ind < 0)
						continue;
					String reqparam = param.substring(0,ind);
					String value = param.substring(ind+1);
					if(reqparam!=null&&reqparam.equals("er_component"))
					{
						value = com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("userID"))
					{
						value = com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("startdate"))
					{
						value = com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("enddate"))
					{
						value = com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("inidate"))
					{
						value = com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					if(reqparam!=null&&reqparam.equals("prior_type"))
					{
						value = com.eg.EgURLEncoder.encode(value, "UTF-8");
					}
					Qstring = Qstring+reqparam+"="+value+"&";
				}
			}

			//Back Button - Start
			HashMap backreqMap = (HashMap)session.getAttribute("backQuery");
			String backQnumber = request.getParameter("backQnumber");
			String servlet2 = request.getParameter("backServletName");

			ErHelperUtils erhelputils = null;

			if( servlet2!=null && !servlet2.equals(""))
				erhelputils = new ErHelperUtils(backreqMap,backQnumber,servlet2);
			else
				erhelputils = new ErHelperUtils(backreqMap,backQnumber);


			//Back button - Start
			ArrayList listbackvar = new  ArrayList();
			if(isSubmit!=null)
			{
				session.setAttribute("reportLastAccessedURL","/final/reporter/ErSnapshot.jsp?"+"enableBack=false&"+Qstring);

				listbackvar.add("/reporter/ErSnapshot.jsp?");
				listbackvar.add(queryString);
	//				listbackvar.add("option=snap&status="+status+"&bggroundStr="+bggroundStr+"&"+queryString);
				session.setAttribute("favSchBackDisplay","Yes");
			}
			else
			{
				session.setAttribute("reportLastAccessedURL","/final/reporter/ErSnapshot.jsp?"+Qstring);

				listbackvar.add("ErSnapshot.jsp");
				listbackvar.add(queryString);
				session.setAttribute("favSchBackDisplay","No");
			}
			String backadded = erhelputils.getBackID();
			backreqMap = erhelputils.setBackQueryMap(backreqMap,backadded,listbackvar);
			session.setAttribute("backQuery",backreqMap);
			//Back button - End
		}

		json.put("screenLabels",screenLabels);
		json.put("pageParams",pageParams);
		json.put("hiddenParams",hiddenParams);
		json.put("selectionDetails",selectionDetails);


		response.setContentType("application/json");
		response.getWriter().write(json.toString());
	}
	catch(Exception t)
	{
		t.printStackTrace();
	}
%>
<%! 
	public JSONArray getLastCalenJson(List weekList, EgMappingInfo mappingInfo) {
		JSONArray tmpJsonArr=new JSONArray();
		JSONObject timelineJSON = null;	
		String tmpTimeLine = null;
		String viewField=null;			
		for(int x=0;x<weekList.size();x++){
			tmpTimeLine = (String)weekList.get(x);	
			int spaceCount = 0;	
			for(int y=0; y<tmpTimeLine.length();y++){				
				char ch = tmpTimeLine.charAt(y);
				if(ch== ' '){
				   spaceCount++; 
				}
			}
			if(spaceCount > 1){
				//Last 2 weeks    weeks_last 2
				String countStr = tmpTimeLine.substring(tmpTimeLine.indexOf(DateTimeTokenizer.BLANK_SPACE)+1,tmpTimeLine.lastIndexOf(DateTimeTokenizer.BLANK_SPACE));
				String end = tmpTimeLine.substring(tmpTimeLine.lastIndexOf(DateTimeTokenizer.BLANK_SPACE)+1,tmpTimeLine.length());
				String last = tmpTimeLine.substring(0, tmpTimeLine.indexOf(DateTimeTokenizer.BLANK_SPACE));
				viewField = countStr +" "+ end + "_" + last;				
			}else{
				viewField = "1 "+tmpTimeLine.substring(tmpTimeLine.lastIndexOf(" ")+1, tmpTimeLine.length())  + "_" + tmpTimeLine.substring(0, tmpTimeLine.indexOf(" "));				
			}
			timelineJSON = new JSONObject();	
			timelineJSON.put("displayField", mappingInfo.getTextDescription("reporter.common."+tmpTimeLine));
			timelineJSON.put("valueField", viewField.toLowerCase());
			tmpJsonArr.add( timelineJSON );		
		}		
		return tmpJsonArr;
   } 
%>