<% 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"%>
<%@page import ="java.net.URLDecoder"%>
<%@page import="ibase.utility.UserInfoBean"%>

<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();
		}
		/*function getWordData()
		{
			var word = document.form1.work_order.value;
			alert("work order form function"+word);
			return false;
		}*/
    </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 param = null;
		  String paramvalue = null, workOrder = null;		
		  
		 Enumeration enum1 = request.getParameterNames();
		  while( enum1.hasMoreElements() )
		  {
			  param = (String)enum1.nextElement();
			  paramvalue = request.getParameter(param);
			 System.out.println("param ["+param+"] paramvalue ["+paramvalue+"]");    
		  } 
		String paramList[];
		if ( paramvalue.indexOf("~") != -1 )
		{
		  paramList = paramvalue.split("~");
		  workOrder = paramList[0];
		}
		else
		{
		  workOrder = paramvalue;
		}

		System.out.println("workOrder [" + 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">
		<body>
		<%
		//added by Dadaso pawar [10/01/14] [Start]
		  UserInfoBean userInfo = (UserInfoBean)session.getAttribute("USER_INFO");
			System.out.println("User Info----->>>>$%$%$ [["+userInfo+"]]");
			WoStkBean.setUserInfo(userInfo);
			//added by Dadaso pawar [10/01/14] [End]
			String workOrder = request.getParameter("work_order");
			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" >
				
				<tr><input type = "button" VALUE = "Back"  onClick = "history.back();" /></tr>
				
				<thead>	
				  <th colspan="7">&nbsp;</th>
				  <th colspan="3">Login Site [<%=userInfo.getSiteCode() %>]</th>
				
				</thead>	
				
					<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=60><P>Quantity</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>
						
						<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));
							System.out.println("WoStkBean.qtyPer [" + WoStkBean.qtyPer+ "]");
							System.out.println("WoStkBean.stkQty [" + WoStkBean.stkQty+ "]");
							System.out.println("WoStkBean.nonStkQty [" + WoStkBean.nonStkQty+ "]");
							System.out.println("WoStkBean.allockQty [" + WoStkBean.allockQty+ "]");
							%>
							<tr BGCOLOR="#FFFFFF">	
								<td align = "left"><font size="-1"><%= workOrder %></font></td>					
								<td align = "left"><font size="-1"><%=(WoStkBean.itemCode != null && WoStkBean.itemCode.equals("")) ? "-" : WoStkBean.itemCode%></font></td>
								<td align = "left"><font size="-1"><%=(WoStkBean.descr != null && WoStkBean.descr.equals("")) ? "-" : WoStkBean.descr%></font></td>
								<td align = "right"><font size="-1"><%=WoStkBean.qtyPer%></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>
								<!-- added by Dadaso pawar 10/01/14 -->
								<td align = "right"><font size="-1"><%= WoStkBean.stkQtyL %></font></td>
								<td align = "right"><font size="-1"><%= WoStkBean.nonStkQtyL %></font></td>
								<td align = "right"><font size="-1"><%= WoStkBean.allockQtyL %></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> -->
		</body>
		</FORM>
		<%
	}
	%>
</body>
</html>
