package ibase.webitm.ejb.mfg.adv;

import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.*;
import ibase.system.config.AppConnectParm;
import javax.naming.InitialContext;
import java.sql.*;
import java.util.*;
import javax.ejb.*;

public class WoStockBean
{
	public String itemCode = "",descr = "",workOrder = "",allockQty = "";
	public double stkQty = 0.0,nonStkQty = 0.0;
	
	public void setWorkOrder(String workOrderJsp)
	{
		this.workOrder = workOrderJsp;
	}
	/*public void setWoQty(String woQtyJsp)
	{
		this.woQty = woQtyJsp;
	}
	*/
	
	public ArrayList getDetails() throws Exception
	{
		ArrayList stkWoRetArr = new ArrayList();
		ArrayList thisBeanArray = new ArrayList();
		InitialContext ctx = null;
		WOrderIssueAct.woStockDtlParams stkParms = null;
		WoStockBean stkWoBean = null;
		AppConnectParm appConnect = null;
		WOrderIssueActLocal homeObj = null;
		try
		{			
			appConnect = new AppConnectParm();
			ctx = new InitialContext(appConnect.getProperty());
			homeObj = (WOrderIssueActLocal)ctx.lookup("ibase/WOrderIssueAct/local"); // for BaseInfo ejb3
			stkWoRetArr = homeObj.getDetails(this.workOrder);
			if(stkWoRetArr.size() > 0)
			{
				for (int i=0; i<stkWoRetArr.size(); i++ )
				{
					stkParms = (WOrderIssueAct.woStockDtlParams)(stkWoRetArr.get(i));
					stkWoBean = new WoStockBean();
													
					stkWoBean.itemCode = stkParms.itemCode;
					stkWoBean.workOrder = stkParms.woCode;
					stkWoBean.descr = stkParms.descr;
					stkWoBean.stkQty = stkParms.stkQty;
					stkWoBean.nonStkQty = stkParms.nonStkQty;
					stkWoBean.allockQty = stkParms.allockQty;
					
					thisBeanArray.add(stkWoBean);
				}
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
			throw new ITMException(e);
		}
		finally
		{
			appConnect = null;
			ctx = null;
			homeObj = null;
			stkWoRetArr = null;
			stkParms = null;
		}
		return thisBeanArray;
	}
}