<%@ page contentType="text/html"%>
<%@ page import="javax.xml.parsers.DocumentBuilderFactory,javax.xml.parsers.DocumentBuilder,org.w3c.dom.*"%>
<%@page import="ibase.dashboard.mfg.ejb.*"%>
<%@page import="ibase.utility.CommonConstants"%>
<%@ page import="javax.naming.InitialContext"%>
<%@page import="javax.naming.Context"%>
<%@page import="org.w3c.dom.Node"%>
<%@page import="org.w3c.dom.NodeList"%>
<%@page import="ibase.webitm.utility.GenericUtility"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.*"%>
<%@page import="java.text.SimpleDateFormat"%>
<jsp:useBean id="machineUtDetailBean"  class="ibase.dashboard.mfg.bean.MachineUtlDetailsBean"></jsp:useBean>

<%!GenericUtility genericUtility = GenericUtility.getInstance();	
	String user="1313";
	String siteCode="";
	
	String toDate=""; 
	String fromDate="";	
	List wrkDList =new ArrayList<String>() ; 
	int ctr = 0;	
	String xmlDataString="";
	Document dom = null;
	NodeList dtlList = null;
	NodeList wrkDateList = null;
	Node parentNode = null;
	NodeList childNodeList = null;
	Node currDetailNode = null;
	String childNodeName = "";
	String mc_code="";
	String pre_mCode="";
	String descr="";
	String work_date="";
	String work_ctr = "";
	String shift="";
	String load_date="";
	int workDateLength=0;
	HashSet hs = new HashSet();
	NodeList workDateChildList=null;
	Node workshiftDetailNode=null;
	boolean status=false;	
	String load_mc_code="";
	String load_shift="";
	String item_code="";
	String item_descr="";
	String worder="";
	String start_date="";
	String end_date="";
	Calendar calendar=null;
	 NodeList detailNodeList=null;
	 NodeList wrkCenterList=null;
	 NodeList descrList=null;
	 NodeList shiftList=null;
	 Node detailNode=null;
	 Node workCenterNode=null;
	 Node descrNode=null;
	 Node shifNode=null;
	 String pre_workDate="";
	//Add new field here
	String rptTitle="";
	String xmlsiteCodeList="";
	
	String sitedescr="";
	String currentMonth="";
	String currentYear="";
	String xmlFormatData="";
	 int month=13;
	 int year=0;
	
%>
<%
    response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
	response.setHeader("Cache-Control", "no-store, no-cache,must-revalidate");
	response.addHeader("Cache-Control", "post-check=0, pre-check=0");
	response.setHeader("Pragma", "no-cache");	
	CommonConstants.setAPPLICATION_CONTEXT(config.getServletContext().getRealPath("/"));
%>
<html>
<head>
<link href="/ibase/jquery/css/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="/ibase/jquery/js/jquery.min.js"></script> <script src="/ibase/jquery/js/jquery-ui.min.js"></script>
<script src="/ibase/jquery/js/jquery-1.9.1.js"></script>
<script src="/ibase/jquery/js/jquery-ui.js"></script>
<style type="text/css">

.container {
	overflow: auto;
}

.section1Div {
	height: 50px;
	float: left;
	overflow: auto;
}

.leftDiv {
	height: 100%;
	width: 100% px;
	float: left;
	overflow: auto;
}

.detailTable {
	font-size: 10px;
	font-family: Arial;
	border-collapse: collapse;
}

.detailTableHeadingTr {
	font-size: 10pt;
	border-bottom: 1px solid black;
	font-weight: bold;
	vertical-align: top;
	text-align: center;
}

.detailTableTr {
	border-bottom: 1px solid black;
}

.detailTableTd {
	border: 1px solid black;
	vertical-align: top;
	font-size: 10px;
	font-family: Arial;
}

.wrkordrtbl {
	FONT-FAMILY: Arial;
	FONT-SIZE: 10pt;
	width: 400px;
	font: Arial, sans-serif, courier;
	font-size: 9pt;
	margin-left: 5;
	margin-top: 4;
}

.workorderdtltbl {
	background: none repeat scroll 0 0 #EFF5FB;
	FONT-FAMILY: Arial;
	FONT-SIZE: 10pt;
	width: 420px;
	font: Arial, sans-serif, courier;
	font-size: 9pt;
	/* border: 1px solid;*/
}

.shiftTableTd {
	border: 1px solid black;
	vertical-align: top;
	font-size: 10px;
	font-family: Arial;
}

.whiteColorTd {
	border: 1px solid black;
	vertical-align: top;
	font-size: 10px;
	font-family: Arial;
	height: 17px;
	width: 18px;
}
</style>

	<script>
	var xmlDatInScript;
	
	function setDateNYear()
	{
		  selectedSiteCode=document.getElementById("sitecode").value;
		  currentMonth=document.getElementById("month").value;
		  currentYear=document.getElementById("year").value;
		if(currentMonth !=null )
			{
		  window.location.replace("MachineUtlDetails.jsp?month="+currentMonth+"&year="+currentYear+"&siteCode="+selectedSiteCode);
		  <%
		    xmlDataString="";
		   currentMonth=request.getParameter("month");
		   currentYear=request.getParameter("year");
		   siteCode=request.getParameter("siteCode");
		
		    	   if( machineUtDetailBean !=null  && currentMonth !=null )
					{
				    	xmlDataString = machineUtDetailBean.getMachineUtlDetailsBySiteCode(siteCode,currentMonth,currentYear);	
					    System.out.println("in item change xmlDataString "+xmlDataString); 
					    xmlDataString = xmlDataString.replaceAll("\"", "'");
					}	
		    	   
		 %>
		 
		 xmlDatInScript="<%=xmlDataString%>";
			
			}
	}
	
function getOnclickData(wrkCenter,wrkdate,shift)
{	
	
	//alert("wrkCenter = "+wrkCenter +"wotkdate = "+wrkdate +"shift= "+shift);
 	  var newTable,startTag,endTag;		  
     	 startTag="<TABLE id='wrkOrdertbl' class='wrkordrtbl' border='1'><TBODY>"
     	 endTag="</TBODY></TABLE>"
     	 <%
     	 xmlDataString = xmlDataString.replaceAll("\"", "'");
	      %>
	     var data="<%=xmlDataString%>"; 
	     
   if (window.DOMParser)
   {
   parser=new DOMParser();
   xmlDoc=parser.parseFromString(data,"text/xml");
   }
 else 
   {
   xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
   xmlDoc.async=false;
   xmlDoc.loadXML(data);
   }  
   
   if (xmlDoc != null && xmlDoc != "")
	   {
	     x=xmlDoc.getElementsByTagName("Root")[0];
	      detailNodeList = x.childNodes;
  		    for (i = 0; i < detailNodeList.length; i++) 
				 {
  		             detailNode=detailNodeList[i];
  		              wrkCtrList= detailNode.childNodes;
  		              
	                  if(wrkCtrList[0].attributes !=null)
	                	{ 
	  		 	          workCenter=wrkCtrList[0].attributes.getNamedItem("wrkcenter").nodeValue;
	  		 	     
	  		 	          if(wrkCenter==workCenter)
			  		 	     {
			  		  		    for (j = 0; j < wrkCtrList.length; j++) 
			  					  {
			  		  		           wrkctrNode= wrkCtrList[j];
			  		  		           workDateNodeList= wrkctrNode.childNodes;
			  		  		           
			  		  		           
				  		  		       for (k= 0; k< workDateNodeList.length; k++) 
					  					  {
				  		  		             dayNode=workDateNodeList[k];
				  		  		    		   
				  		  		    	 if(k !=0)
				  		  		    	      {
				  		  		    		   if(dayNode.attributes!=null)
				  		  		    			 {
					  		  		    		       workDate=dayNode.attributes.getNamedItem("date").nodeValue;
						  		  		    		   if(workDate==wrkdate)
						  		  		    		   {
						  		  		    			  shiftNodeList=dayNode.childNodes;
						  		  		    			  for (l= 0; l< shiftNodeList.length; l++) 
									  					  {
						  		  		    				shiftNode=shiftNodeList[l];
						  		  		    			    selectedShift= shiftNode.attributes.getNamedItem("shift").nodeValue;
									  					 
						  		  		    			   if(selectedShift==shift)
						  		  		    				   {
						  		  		    				    newTable=startTag;	
						  		  		    				    actualUsedList=shiftNode.childNodes;
								  		  		    		      for (l= 0; l< actualUsedList.length; l++) 
												  					{
								  		  		    		    	    dtlNode=actualUsedList[l];
								  		  		    		    	     itmDtlList= dtlNode.childNodes;
								  		  		    		    	     
															  		      newTable+="<TR>";
									    	                	    	  newTable+="<TD>";
									    	                	    	  newTable+="<TABLE id='workOrderDtlTbl' class='workorderdtltbl'>";
								    		            	    		         	                  
								  		  		    		    	     
								  		  		    		    	     for (m= 0; m< itmDtlList.length; m++) 
														  					{
										  		  		    		    		itemDtlNode=itmDtlList[m];
										  		  		    		    		if(m==0)
								         	                          	    		{
								         	                          	    		   newTable+="<TR><TD> Work Order :" +itemDtlNode.childNodes[0].nodeValue; +"<TD></TR>";
								         	                          	    		}
												  		  		    		      if(m==1)
									         	                          	    	{
									         	                          	           newTable+="<TR><TD> Item Code :" +itemDtlNode.childNodes[0].nodeValue; +"<TD>";
								         	                          	    		}
												  		  		    		      if(m==2)
							         	                          	    	        {
							         	                          	               newTable+="<TD> Description :" +itemDtlNode.childNodes[0].nodeValue; +"<TD></TR>";
						         	                          	    		       }
												  		  		    		      
												  		  		    		  if(m==3)
						         	                          	    	        {
						         	                          	               newTable+="<TR><TD> Work Center :" +itemDtlNode.childNodes[0].nodeValue; +"<TD></TR>";
					         	                          	    		         }
												  		  		    	  if(m==4)
					         	                          	    	        {
					         	                          	               newTable+="<TR><TD> Start Date :" +itemDtlNode.childNodes[0].nodeValue; +"<TD></TR>";
				         	                          	    		         }
												  		  		      if(m==5)
				         	                          	    	        {
				         	                          	               newTable+="<TR><TD> End Date :" +itemDtlNode.childNodes[0].nodeValue; +"<TD></TR>";
			         	                          	    		         }
														  					
														  					}
								  		  		    		    	  newTable+="</TABLE>";
													    		      newTable+="</TD>";
														              newTable+="</TR>";  
												  					}
								  		  		    		  newTable+=endTag;
						  		  		    				   }
									  					  }
						  		  		    			      
						  		  		    		   }
						  		  		    		   
						  		  		    		   
					  		  		    		  }
				  		  		    	       }
				  		  		    	   
					  					  }
			  		  		           		  		  		             
  						          }
  		  		              }
  		 	            
                	    }
				  }
 	   }
	    	 
   if(typeof(newTable) !="undefined")
	 {/*   
	   document.getElementById('worderDetailDiv').innerHTML=newTable;
	   $("#worderDetailDiv").dialog({width:440,height:350});   
	   $('#worderDetailDiv').css({
	 	  width: '440px',
	 	}); */
	 }
    if(typeof(shift) =="undefined" || typeof(newTable)=="undefined")
	   {
    	 $('#worderDetailDiv').dialog('close');
	   }  

}
</script>
	<script type="text/javascript">
function setMonthNYearSelected() 
{
	
	var selectedMonth ="<%=request.getParameter("month")%>";
	var selectedYear ="<%=request.getParameter("year")%>";
	var selectedSiteCode ="<%=request.getParameter("siteCode")%>";

	var monthDropDwn = document.getElementById("month");
	var yearDropDwn = document.getElementById("year");
	var siteCodeDropDwn = document.getElementById("sitecode");

	
	
	var opts = monthDropDwn.options.length;
	for ( var i = 0; i < opts; i++) 
	{
		if (monthDropDwn.options[i].value == selectedMonth)
		{
			monthDropDwn.options[i].selected = true;
			break;
		}
     } 
	
	var opts = yearDropDwn.options.length;
	for ( var i = 0; i < opts; i++) 
	{
		if (yearDropDwn.options[i].value == selectedYear)
		{
			yearDropDwn.options[i].selected = true;
			break;
		}
     } 
	
	var opts = monthDropDwn.options.length;
	for ( var i = 0; i < opts; i++) 
	{
		if (siteCodeDropDwn.options[i].value == selectedSiteCode)
		{
			siteCodeDropDwn.options[i].selected = true;
			break;
		}
     } 
 }

</script>
</head>
<body>
	<form name="form1" id="form1" >
		<div id="container" class="container">
			<%
	try
	{
		 rptTitle   = request.getParameter("rtitle");
			if (rptTitle == null || rptTitle.trim().length() == 0)
			{
				rptTitle =" " ;
			} 
			else
			{
				if(rptTitle.equalsIgnoreCase("Y") && rptTitle.trim().length()!= 0)
				{
					rptTitle ="Machine Utilization Details";
			    }
				else
				{
					rptTitle =" " ;
				}
			}
	
			//End of block for report title display	 
			
	    
	        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MMM-yy");
            calendar = Calendar.getInstance();
            calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
	        int lastDayOfMonth=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            String lastDateOfMoth = simpleDateFormat.format(calendar.getTime());
	       
	        calendar=null;
	    
	        calendar=Calendar.getInstance();
	        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
	        String frstDate = simpleDateFormat.format(calendar.getTime());
	      
	      
		 Context context = new InitialContext();
		if (user != null && user.trim().length() != 0)
		{
			xmlsiteCodeList=machineUtDetailBean.getSiteCodeList();
			System.out.println("CurrentMonth--> "+currentMonth);
			System.out.println("Current Year--> "+currentYear);
			System.out.println("siteCode  after--> "+siteCode);
			if(currentMonth !=null && currentYear!=null && siteCode !=null && machineUtDetailBean !=null )
			{
				if(xmlDataString !=null && xmlDataString.length()<=0)
				{
			    xmlDataString = machineUtDetailBean.getMachineUtlDetailsBySiteCode(siteCode,currentMonth,currentYear);			
		        System.out.println("xmlDataString-->"+xmlDataString);	
		        }
			}
			else
			{ 
				if(xmlsiteCodeList !=null  && xmlsiteCodeList.trim().length() > 0)
				{
					if(currentMonth ==null && siteCode==null && machineUtDetailBean!=null && currentYear==null )
					{
						dom = genericUtility.parseString(xmlsiteCodeList);
						dtlList = dom.getElementsByTagName("Detail");
						for (int cntr = 0; cntr <1 ; cntr++) 
						{
							parentNode = dtlList.item(cntr);
							childNodeList = parentNode.getChildNodes();
							if(childNodeList.getLength()>0)
                              {
								siteCode = childNodeList.item(0).getTextContent();
								calendar=Calendar.getInstance();
								
									month =	  calendar.get(Calendar.MONTH);
							       //year= calendar.get(Calendar.YEAR);
                                      year= 2011;
							       out.print("month is= "+month +" Year is  after modification="+year);
							       xmlDataString = machineUtDetailBean.getMachineUtlDetailsBySiteCode(siteCode,""+month,""+year);			
                              }
						}
					}
				}
			 }
	    }
		  //----------------------------------------------------------
%>
			<div id="section1Div" class="section1Div">
				<table>
					<tr>
						<td class="tdLabel">Site Code :</td>
						<td><select id="sitecode" name="sitecode">
								<%		
				if (xmlsiteCodeList!= null && xmlsiteCodeList.trim().length() > 0) 
				{
					dom = genericUtility.parseString(xmlsiteCodeList);
					if (dom != null)
					{
						dtlList = dom.getElementsByTagName("Detail");
						for (int cntr = 0; cntr < dtlList.getLength(); cntr++) 
						{
							parentNode = dtlList.item(cntr);

							childNodeList = parentNode.getChildNodes();

							if(childNodeList.getLength()>0)
                              {
								siteCode  = childNodeList.item(0).getTextContent();
                                sitedescr     = childNodeList.item(1).getTextContent();
                               
                                %>
								<option value="<%=siteCode%>"><%=sitedescr%></option>
								<%
                            }
						}
					}
				}
%>
						</select></td>
						<td class="tdLabel">Month:</td>
						<td>
						<select id="month" name="month" onchange="setDateNYear()">
								<% 
								
								if(month!=13 && month==0) 
								{%>
								<option value='00' selected="selected">January</option>
									<%
								}else
								{
									%>
								<option value='00'>January</option>
									<%
								}
								
								if(month!=13 && month==1) 
								{%>
								<option value='01' selected="selected">February</option>
									<%
								}else
								{
									%>
								<option value='01'>February</option>
									<%
								}
								
								if(month!=13 && month==2) 
								{%>
								<option value='02' selected="selected">March</option>
									<%
								}else
								{
									%>
								<option value='02'>March</option>
									<%
								}
								
								if(month!=13 && month==3) 
								{%>
							<option value='03' selected="selected" >April</option>
									<%
								}else
								{
									%>
							<option value='03'>April</option>
									<%
								}
								if(month!=13 && month==4) 
								{%>
								<option value='04' selected="selected">May</option>
									<%
								}else
								{
									%>
								<option value='04'>May</option>
									<%
								}
								if(month!=13 && month==5) 
								{%>
								<option value='05' selected="selected">June</option>
									<%
								}else
								{
									%>
							<option value='05'>June</option>
									<%
								}

								if(month!=13 && month==6) 
								{
								%>
								<option value='06' selected="selected">July</option>
								<%
								}else
								{
									%>
								<option value='06'>July</option>
									<%
								}
								
								if(month!=13 && month==7) 
								{
								%>
								<option value='07' selected="selected">August</option>
								<%
								}else
								{
									%>
								<option value='07'>August</option>
									<%
								}
								
								
								if(month!=13 && month==8) 
								{
								%>
							<option value='08' selected="selected">September</option>
								<%
								}
								else
								{
								%>
							<option value='08'>September</option>
								<%
								}
								
								if(month!=13 && month==9) 
								{
								%>
								<option value='09' selected="selected">October</option>
								<%
								}else
								{
									%>
								<option value='09'>October</option>
									<%
								}
								
								if(month!=13 && month==10) 
								{
								%>
								<option value='10' selected="selected">November</option>
								<%
								}else
								{
									%>
								<option value='10'>November</option>
									<%
								}
								
								if(month!=13 && month==11) 
								{
								%>
								<option value='11' selected="selected">December</option>
								<%
								}else
								{
									%>
								<option value='11'>December</option>
									<%
								}
								%>
						</select>
						</td>
						<td class="tdLabel">Year:</td>
						<td><select id="year" name="year" onchange="setDateNYear()">
								<option value="2000">2000</option>
								<option value="2001">2001</option>
								<option value="2002">2002</option>
								<option value="2003">2003</option>
								<option value="2004">2004</option>
								<option value="2005">2005</option>
								<option value="2006">2006</option>
								<option value="2007">2007</option>
								<option value="2008">2008</option>
								<option value="2009">2009</option>
								<option value="2010">2010</option>
								<option value="2011">2011</option>
								<option value="2012">2012</option>
								<%
								if(year!=0 && year==2013) 
								{
									%>
									<!-- <option value="2013" selected="selected">2013</option> -->
									<%
								}else
								{
									%>
									<option value="2013">2013</option>
									<%
								}
								
								if(year!=0 && year==2014) 
								{
									%>
									<option value="2014" selected="selected">2014</option>
									<%
								}else
								{
									%>
									<option value="2014">2014</option>
									<%
								}
								
								if(year!=0 && year==2015) 
								{
									%>
									<option value="2015" selected="selected">2015</option>
									<%
								}else
								{
									%>
									<option value="2015">2015</option>
									<%
								}
								
								if(year!=0 && year==2016) 
								{
									%>
									<option value="2016" selected="selected">2016</option>
									<%
								}else
								{
									%>
									<option value="2016">2016</option>
									<%
								}
								if(year!=0 && year==2017) 
								{
									%>
									<option value="2017" selected="selected">2017</option>
									<%
								}else
								{
									%>
									<option value="2017">2017</option>
									<%
								}
								if(year!=0 && year==2018) 
								{
									%>
									<option value="2018" selected="selected">2018</option>
									<%
								}else
								{
									%>
									<option value="2018">2018</option>
									<%
								}
								
								if(year!=0 && year==2019) 
								{
									%>
									<option value="2019" selected="selected">2019</option>
									<%
								}else
								{
									%>
									<option value="2019">2019</option>
									<%
								}
								if(year!=0 && year==2020) 
								{
									%>
									<option value="2020" selected="selected">2020</option>
									<%
								}else
								{
									%>
									<option value="2020">2020</option>
									<%
								}
								
								if(year!=0 && year==2021) 
								{
									%>
									<option value="2021" selected="selected">2021</option>
									<%
								}else
								{
									%>
									<option value="2021">2021</option>
									<%
								}
								if(year!=0 && year==2022) 
								{
									%>
									<option value="2022" selected="selected">2022</option>
									<%
								}else
								{
									%>
									<option value="2022">2022</option>
									<%
								}
								
								%>
						</select></td>
					</tr>
				</table>
			</div>
			<%    
  if(xmlDataString.indexOf("<work_ctr>") > -1)
	 { %>
			<div id="leftDiv" class="leftDiv"> <table class="detailTable"> <tr class="detailTableHeadingTr"> <td class="shiftTableTd">Work Center</td> <td class="shiftTableTd">Description</td>
						<%
 //xmlDataString="<?xml version='1.0'?><Root><Detail><work_ctr>GAVIS</work_ctr><mc_code>HVIB18    </mc_code><descr>VISUAL INSPECTION BOOTH</descr><work_date date='2013-07-01 00:00:00.0'><shift>MG1</shift><shift>TG1</shift><shift>WG1</shift></work_date><work_date date='2013-07-02 00:00:00.0'><shift>TG1</shift></work_date><work_date date='2013-07-03 00:00:00.0'><shift>WG1</shift></work_date><work_date date='2013-07-04 00:00:00.0'><shift>HG1</shift></work_date><load_details><shift_details><load_mc_code>HVIB18    </load_mc_code><load_date>2013-07-01 00:00:00.0</load_date><load_shift>MG1</load_shift></shift_details><shift_details><load_mc_code>HVIB18    </load_mc_code><load_date>02-JAN-13</load_date><load_shift>TG1</load_shift></shift_details><shift_details><load_mc_code>HVIB18    </load_mc_code><load_date>2013-07-04 00:00:00.0</load_date><load_shift>HG1</load_shift></shift_details></load_details></Detail></Root>";
 
 dom = genericUtility.parseString(xmlDataString);
 if(dom !=null )
 {
   detailNodeList = dom.getElementsByTagName("Detail");	
    for(int dltCnt=0; dltCnt<1; dltCnt++)
	{
	        detailNode= detailNodeList.item(dltCnt);
	        wrkCenterList =detailNode.getChildNodes();
	       
	       for(int wrkListCnt=0; wrkListCnt<1; wrkListCnt++)
	        {
	     	             workCenterNode=wrkCenterList.item(wrkListCnt);
	     	             descrList= workCenterNode.getChildNodes();
                        int cntr=0;
                        for(int descrListCnt=0; descrListCnt<descrList.getLength(); descrListCnt++)
            	         {
                        	  descrNode=descrList.item(descrListCnt);
                                   if(descrListCnt >0)
                                   	 {
				                        	  cntr++;
											  shiftList=descrNode.getChildNodes();
											  %>
						<td class="shiftTableTd"><%=cntr %>
							<table>
								<tr>
									<%
											  
                                   		 for(int shiftCnt=0; shiftCnt<shiftList.getLength(); shiftCnt++)
                                	         { 
                                   			     shifNode=  shiftList.item(shiftCnt);
                                   			     if(shifNode!=null)
                                   			     {
                                   			    	 %>
									<td class="shiftTableTd"><%=shifNode.getAttributes().item(0).getNodeValue()%>
									</td>
									<%
                                   			     }
                                	         }
											    %>
								</tr>
							</table></td>
						<%
                                   	 }
            	        }
	        }
	 }
    }
%>
					</tr>
					<% 			
 String color="";
 String workCentr="";
 int length=0;
			
			if(dom !=null )
			{	
			   detailNodeList = dom.getElementsByTagName("Detail");	
               for(int dltCnt=0; dltCnt<detailNodeList.getLength(); dltCnt++)
				{
            	        detailNode= detailNodeList.item(dltCnt);
            	        wrkCenterList =detailNode.getChildNodes();
            	       
            	       for(int wrkListCnt=0; wrkListCnt<wrkCenterList.getLength(); wrkListCnt++)
            	        {
            	     	              workCenterNode=wrkCenterList.item(wrkListCnt);
            	     	             descrList= workCenterNode.getChildNodes();
            	     	      
            	     	            %>
					<tr class="detailTableTr">
						<td class="detailTableTd"><%= workCenterNode.getAttributes().item(0).getNodeValue() %></td>
						<%
                                    
                                     for(int descrListCnt=0; descrListCnt<descrList.getLength(); descrListCnt++)
                         	         {
                                    	       descrNode=descrList.item(descrListCnt);
			                                    
			                                    if(descrListCnt <1)
			                                    	 {
			                                    	  %>
						<td class="detailTableTd"><%=descrNode.getTextContent()%></td>
						<%
			                                    	 }else
			                                    	 {
														  shiftList=descrNode.getChildNodes();
														  
														  %>
													<td class="shiftTableTd">
														<table>
															<tr>
																<%
																					  
			                                    		 for(int shiftCnt=0; shiftCnt<shiftList.getLength(); shiftCnt++)
			                                 	         {
			                                    			     shifNode=  shiftList.item(shiftCnt);
			                                    			     if(shifNode!=null)
			                                    			     {
			                                    			    	if(shifNode.getFirstChild()!=null)
			                                    			    	{
				                                    			         color=shifNode.getFirstChild().getAttributes().item(0).getNodeValue();
				                                    			         workCentr=shifNode.getFirstChild().getFirstChild().getTextContent();
				                                    			         length=workCentr.length();
		                                                                 if(color.equals("yellow") || color.equals("lightgreen"))
		                                                                 {  
		                                                                	 xmlDataString = xmlDataString.replaceAll("\"", "'");
		                                                                %>	
									 									  <td class="shiftTableTd" bgcolor="<%=color%>"  onclick="getOnclickData('<%=workCenterNode.getAttributes().item(0).getNodeValue()%>','<%=descrNode.getAttributes().item(0).getNodeValue()%>','<%= shifNode.getAttributes().item(0).getNodeValue()%>')"> <%=workCentr.subSequence(length-3,length) %></td>
																		<%
					                                    			     }
		                                                                 else 
					                                    			     {
		                                                                	%>
																			<td bgcolor="<%=color%>" class="whiteColorTd" onclick="getOnclickData()">&nbsp;</td>
									                                        <%
					                                    			     }
			                                    			    	} 
			                                    			    	else 
				                                    			     {
	                                                                	 %>
																			<td bgcolor="<%=color%>" class="whiteColorTd" onclick="getOnclickData()">&nbsp;</td>
									                                     <%
				                                    			     }
			                                    			     }
			                                 	           }
														    %>
								           </tr>
							         </table>
						         </td>
						           <%
			                           }
                         	        }
                                     %>
					         </tr>
					        <%
            	        }

				 }
			}
			%>
				</table>
				<div id="worderDetailDiv"></div>
			</div>
			<%
	 } 	
  
	} catch (Exception ex)
	{
		System.out.println("Exception in JSP ::" + ex.getMessage());
	}
%>
			<%
%>
		
	</form>
	<script>
	window.onload=setMonthNYearSelected;
	</script>
</body>
</html>
