package ibase.webitm.ejb.mfg.adv;

import ibase.utility.UserInfoBean;
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 = "",allockQtyL="";
	public double stkQty = 0.0,nonStkQty = 0.0, qtyPer = 0;
	public double stkQtyL=0.0,nonStkQtyL=0.0;
	
	public static UserInfoBean userInfo=null; //added by Dadaso pawar [MF3GSUN023]
	
	public void setWorkOrder(String workOrderJsp)
	{
		this.workOrder = workOrderJsp;
	}
	public void setUserInfo(UserInfoBean userInfo)
	{		
		this.userInfo=userInfo;
	}
	public UserInfoBean getUserInfo()
	{
		return this.userInfo;
	}
   //added by Dadaso pawar [End] [MF3GSUN023]
	/*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));
					System.out.println("stkParms.stkQty [" + stkParms.stkQty + "]");
					System.out.println("stkParms.nonStkQty [" + stkParms.nonStkQty + "]");
					System.out.println("stkParms.allockQty [" + stkParms.allockQty + "]");
					System.out.println("stkParms.qtyPer [" + stkParms.qtyPer + "]");
					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;
					stkWoBean.qtyPer = stkParms.qtyPer;
					
					//added by Dadaso
					
					stkWoBean.stkQtyL = stkParms.stkQtyL;
					stkWoBean.nonStkQtyL = stkParms.nonStkQtyL;
					stkWoBean.allockQtyL = stkParms.allockQtyL;
					System.out.println("Dadaso code called..............................");
					
					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;
	}
}