<% System.out.println(" *****WoStockButton.jsp***** "); %>
<%@page import = "java.util.*"%>
<%@page import ="ibase.webitm.utility.*"%>
<%@page import = "ibase.webitm.ejb.mfg.adv.*"%>
<%@page import = "java.sql.*"%>
<%@page import = "java.text.DecimalFormat"%>
<%@page import = "ibase.webitm.utility.GenericUtility"%>

<jsp:useBean id="WoStkBean" scope="session" class="ibase.webitm.ejb.mfg.adv.WoStockBean"/>
<html>
<head>
	<title>Work order Stock</title>
	<script type="text/javascript">
	
		function callValidate() 
		{
			var woOrd = document.form1.work_order.value;		
			if( woOrd == "" )
			{
				alert("Please enter work Order.");
				document.form1.work_order.focus();
				return false;
			}
		}
		function CloseWindow()
		{
			var win=window.open("about:blank","_self");
			win.close();
		}
    </script>
</head>

<body>

<a style="position:absolute;top:10;left:0;height:50;width:1200;background:url(/ibase/webitm/images/title_bar_bg_blue.jpg);font-family:Verdana"></a>
<%
	GenericUtility genericUtility = GenericUtility.getInstance(); 
	DecimalFormat df = new DecimalFormat( "##.000" );
	if((request.getParameter("form") == null ) || (request.getParameter("form").equals("2")))
	{
		%>
		<Form name = "form1" action = "WoStockButton.jsp?form=2" method = "post">
		<%
		//String bom = request.getParameter("PK_VALUES");
		String workOrder = request.getParameter("work_order");
		System.out.println("workOrder of bean ==>"+workOrder);
		
		if (workOrder == null)
		{
			workOrder = request.getParameter("work_order") == null ? "" : request.getParameter("work_order");
		}
		System.out.println("workOrderQuantity [" + workOrder+ "]");
		%>
		<br/><br/><br/><br/>
		<table align = "center">
			<tr>
				<td> Work Order:</td>
				<td> <input type = "text" name = "work_order" size = "10" value = "<%= workOrder %>" onChange = "javascript: this.value = this.value.toUpperCase();"/></td>
			</tr>
			<tr>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tr>
			<tr>
				<td></td>
				<td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type = "submit" VALUE = "Retrieve"  onClick = "return callValidate();" /></td>
				</td>
				<td></td>
			</tr>
		</table>	  	
		</FORM>
		<%
	}
	if((request.getParameter("form") != null ) &&(request.getParameter("form").equals("2")))
	{
		%>
		<Form name = "form2" action = "WoStockButton.jsp" method = "POST">
		<%
			String workOrder = request.getParameter("work_order");
			System.out.println("workOrder of bean ==>"+workOrder);
			WoStkBean.setWorkOrder( workOrder.toUpperCase() );
				
			ArrayList WoStockHelpList = WoStkBean.getDetails();
			if( WoStockHelpList.size() > 0 )
			{
				%>
				<br/>
				<DIV ID="TableBorder" class="tableborderDiv">
					<TABLE name="main" border = "1" id="main" CLASS="sort-table" STYLE="class:header_css;POSITION:relative;TOP:20;left:10;width:790" >
					<thead>	
				
						<TH WIDTH=66><P>Work Order</P></TH>
						<TH WIDTH=59><P>Item Code</P></TH>
						<TH WIDTH=128><P>Item Description</P></TH>
						<TH WIDTH=97><P>Stock Usable Quantity</P></TH>
						<TH WIDTH=126><P>Stock NonUsable Quantity</P></TH>
						<TH WIDTH=66><P>Allocated Quantity</P></TH>

					</thead>
				
					<%
						for(int i=0;i<WoStockHelpList.size();i++)
						{
							WoStkBean = ( ibase.webitm.ejb.mfg.adv.WoStockBean)(WoStockHelpList.get(i));
							%>
			
							<tr BGCOLOR="#FFFFFF">	
								<td align = "right"><font size="-1"><%= workOrder %></font></td>					
								<td align = "right"><font size="-1"><%=(WoStkBean.itemCode != null && WoStkBean.itemCode.equals("")) ? "-" : WoStkBean.itemCode%></font></td>
								<td align = "right"><font size="-1"><%=(WoStkBean.descr != null && WoStkBean.descr.equals("")) ? "-" : WoStkBean.descr%></font></td>
								<td align = "right"><font size="-1"><%=df.format(WoStkBean.stkQty)%></font></td>
								<td align = "right"><font size="-1"><%=df.format(WoStkBean.nonStkQty)%></font></td>
								<td align = "right"><font size="-1"><%= WoStkBean.allockQty %></font></td>
							</tr>
							<%
						}
						%>
					</TABLE>
				</DIV>
				<%
			}
			else
			{
				System.out.println("Inside else");
				%>			
				<BR/><BR/><BR/><BR/>
				<p><b><center><h2>
				No any stock detail found for entered data.
				</h2></center></b></p>
				<%	
			}
			%>
		
			<BR/><BR/>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<!-- <input type = "button" VALUE = "Back" onClick = "history.back()"/> -->
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<!--input type = "button" value = "Close" onclick="return CloseWindow();"/-->
			
			<!--<a href="javascript:window.opener='x';window.close();">Close me</a>-->
			<!-- Running code in mozilla 1.5 -->
			<!-- <a href="javascript:window.open('','_parent','');window.close();">
			<input type="button" value="Close Window"/></a> -->
		</FORM>
		<%
	}
	%>
</body>
</html>
