package wenrgise.hrms.ejb.business;

import java.rmi.RemoteException;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Iterator;
import javax.ejb.CreateException;
import wenrgise.common.bean.BaseHeaderBean;
import wenrgise.common.bean.LOVBean;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.common.utility.DateUtility;
import wenrgise.common.utility.EnrgiseUtil;
import wenrgise.common.utility.RecordMetaInfo;
import wenrgise.common.utility.ServiceLocator;
import wenrgise.common.utility.UserInfo;
import wenrgise.common.vo.LovQueryVO;
import wenrgise.common.vo.LovVO;
import wenrgise.ejb.common.helper.DBObject;
import wenrgise.ejb.common.helper.QueryRow;
import wenrgise.ejb.common.helper.QueryValue;
import wenrgise.ejb.common.utility.DBUtilitiesBean;
import wenrgise.hrms.bean.HrmLvLedgerDtlBean;
import wenrgise.hrms.bean.HrmLvLedgerHdrBean;
import wenrgise.hrms.bean.HrmLvLedgerTransDtlBean;
import wenrgise.hrms.ejb.facade.HrmFacade;
import wenrgise.hrms.ejb.facade.HrmFacadeHome;
import wenrgise.hrms.vo.HrmLvLedgerQVO;

public class HrmLvLedgerBO extends HrmBaseBO {
  public HrmLvLedgerBO() {}
  
  public HrmLvLedgerBO(UserInfo oUserInfo) {
    super(oUserInfo);
  }
  
  public RecordMetaInfo getEmpLeaveLedgerDetailMetaInfo(HrmLvLedgerQVO oHrmLvLedgerQVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String lvType = oHrmLvLedgerQVO.getLeaveCode();
    String empNo = oHrmLvLedgerQVO.getEmployeeNo();
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, empNo));
    arylstParam.add(new DBObject(2, 1, 12, lvType));
    arylstParam.add(new DBObject(3, 2, -5));
    arylstParam.add(new DBObject(4, 2, 93));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 12));
    arylstParam.add(new DBObject(7, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLEDGER.proc_HrLeaveLedgerDtlCount(?,?,?,?,?,?,?)");
    RecordMetaInfo oRecordMetaInfo = new RecordMetaInfo();
    DBObject oTotalRecord = arylstOutArray.get(0);
    oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue());
    DBObject oTimeObject = arylstOutArray.get(1);
    oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject());
    return oRecordMetaInfo;
  }
  
  public ArrayList getHrEmpLeaveLedgerDetail(HrmLvLedgerQVO oHrmLvLedgerQVO, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    String lvType = oHrmLvLedgerQVO.getLeaveCode();
    String empNo = oHrmLvLedgerQVO.getEmployeeNo();
    QueryRow oRow = null;
    QueryValue oValue = null;
    ArrayList arylstList = null;
    Iterator itrBean = null;
    ArrayList oEmpLeaveLedgerDetail = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, -5, new Long(lDetailFirstPosition)));
    arylstParam.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition)));
    arylstParam.add(new DBObject(3, 1, 12, empNo));
    arylstParam.add(new DBObject(4, 1, 12, lvType));
    arylstParam.add(new DBObject(5, 2, -10));
    arylstParam.add(new DBObject(6, 2, 12));
    arylstParam.add(new DBObject(7, 2, 12));
    arylstParam.add(new DBObject(8, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLEDGER.proc_HrLeaveLedgerDtl(?,?,?,?,?,?,?,?)");
    arylstList = (ArrayList)((DBObject)arylstOutArray.get(0)).getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    count = 0;
    itrBean = arylstList.iterator();
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    while (itrBean.hasNext()) {
      if (count == 0)
        oEmpLeaveLedgerDetail = new ArrayList(); 
      count++;
      oRow = itrBean.next();
      HrmLvLedgerDtlBean oHrmLvLedgerDtlBean = new HrmLvLedgerDtlBean();
      oHrmLvLedgerDtlBean.setTxtEmpNo(oRow.get("EMP_NO").getString());
      oHrmLvLedgerDtlBean.setTxtleaveTypes(oRow.get("LEAVE_TYPE").getString());
      oHrmLvLedgerDtlBean.setDetailId(oRow.get("ID").getString());
      oHrmLvLedgerDtlBean.setTxtCreditDate(EnrgiseUtil.convertToString(oRow.get("FROM_DATE").getDate()));
      oHrmLvLedgerDtlBean.setTxtOpeningBalance(oRow.get("OPENING_BAL").getString());
      oHrmLvLedgerDtlBean.setTxtLeavesCredited(oRow.get("LEAVES_CREDITED").getString());
      oHrmLvLedgerDtlBean.setTxtLeavesTaken(oRow.get("LEAVES_TAKEN").getString());
      oHrmLvLedgerDtlBean.setTxtLeavesEncashed(oRow.get("LEAVES_ENCASHED").getString());
      oHrmLvLedgerDtlBean.setTxtLeaveBalance(oRow.get("LEAVE_BALANCE").getString());
      oHrmLvLedgerDtlBean.setTxtLeavesPending(oRow.get("lvPending").getString());
      oEmpLeaveLedgerDetail.add(oHrmLvLedgerDtlBean);
    } 
    return oEmpLeaveLedgerDetail;
  }
  
  public String getHrEmpLeaveLedgerTxnDetail(String sDtlId) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    int count = 0;
    String fromDate = null;
    QueryRow oRow = null;
    QueryValue oValue = null;
    ArrayList arylstList = null;
    Iterator itrBean = null;
    ArrayList oEmpLeaveLedgerTxnDetail = null;
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sDtlId));
    arylstParam.add(new DBObject(2, 2, -10));
    arylstParam.add(new DBObject(3, 2, 12));
    arylstParam.add(new DBObject(4, 2, 12));
    arylstParam.add(new DBObject(5, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLEDGER.proc_HrLeaveLedgerTxnDateDtl(?,?,?,?,?)");
    arylstList = (ArrayList)((DBObject)arylstOutArray.get(0)).getObject();
    if (arylstList.size() == 0)
      throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
    itrBean = arylstList.iterator();
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    oRow = itrBean.next();
    String calId = oRow.get("CAL_ID").getString();
    String cdDate = formatter.format(oRow.get("CREDITDATE").getDate());
    try {
      HrmFacadeHome oHome = (HrmFacadeHome)ServiceLocator.getLocator().getService("HrmFacade");
      HrmFacade oHrmFacade = oHome.create();
      fromDate = oHrmFacade.getHrmCalStartDate(calId, cdDate);
    } catch (RemoteException oRe) {
      throw new EnrgiseSystemException(oRe);
    } catch (CreateException oCrt) {
      throw new EnrgiseSystemException(oCrt);
    } 
    return fromDate;
  }
  
  public ArrayList getHrEmpLeaveLedgerTxnDetail(HrmLvLedgerQVO oHrmLvLedgerQVO, long lDetailFirstPosition, long lDetailLastPosition) throws EnrgiseApplicationException, EnrgiseSystemException {
    ArrayList oEmpLeaveLedgerTxnDetail = null;
    String sId = oHrmLvLedgerQVO.getHdnDetailId();
    HrmLvLedgerBO oHrmLvLedgerBO = new HrmLvLedgerBO();
    String sFromDate = oHrmLvLedgerBO.getHrEmpLeaveLedgerTxnDetail(sId);
    DateUtility d = new DateUtility();
    Date d1 = new Date(d.getDateLong(sFromDate));
    String sLvTaken = oHrmLvLedgerQVO.getLeavesTaken();
    String sLvEncashed = oHrmLvLedgerQVO.getLeavesEncashed();
    String sLvType = oHrmLvLedgerQVO.getLeavesType();
    String sEmpNo = oHrmLvLedgerQVO.getEmployeeNo();
    if (EnrgiseUtil.checkString(sLvTaken))
      if (Integer.parseInt(sLvTaken) > 0) {
        ArrayList arylstParam = new ArrayList();
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        int count = 0;
        QueryRow oRow = null;
        QueryValue oValue = null;
        ArrayList arylstList = null;
        Iterator itrBean = null;
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, -5, new Long(lDetailFirstPosition)));
        arylstParam.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition)));
        arylstParam.add(new DBObject(3, 1, 12, sEmpNo));
        arylstParam.add(new DBObject(4, 1, 12, sLvType));
        arylstParam.add(new DBObject(5, 1, 91, d1));
        arylstParam.add(new DBObject(6, 2, -10));
        arylstParam.add(new DBObject(7, 2, 12));
        arylstParam.add(new DBObject(8, 2, 12));
        arylstParam.add(new DBObject(9, 2, 4));
        ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLEDGER.proc_HrLedgerTxnLvTakenDtl(?,?,?,?,?,?,?,?,?)");
        arylstList = (ArrayList)((DBObject)arylstOutArray.get(0)).getObject();
        if (arylstList.size() == 0)
          throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
        count = 0;
        itrBean = arylstList.iterator();
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
        while (itrBean.hasNext()) {
          if (count == 0)
            oEmpLeaveLedgerTxnDetail = new ArrayList(); 
          count++;
          oRow = itrBean.next();
          HrmLvLedgerTransDtlBean oTrnsDtlBean = new HrmLvLedgerTransDtlBean();
          oTrnsDtlBean.setTxtNoOfDays(oRow.get("NO_OF_DAYS").getString());
          oTrnsDtlBean.setTxtFromDate(EnrgiseUtil.convertToString(oRow.get("FROM_DATE").getDate()));
          oTrnsDtlBean.setTxtToDate(EnrgiseUtil.convertToString(oRow.get("to_date").getDate()));
          oTrnsDtlBean.setTxtApplicationDate(EnrgiseUtil.convertToString(oRow.get("DATE_APPLIED").getDate()));
          oTrnsDtlBean.setTxtAction(oRow.get("LEAVESTAKEN").getString());
          oEmpLeaveLedgerTxnDetail.add(oTrnsDtlBean);
        } 
      }  
    if (EnrgiseUtil.checkString(sLvEncashed))
      if (Integer.parseInt(sLvEncashed) > 0) {
        ArrayList arylstParam = new ArrayList();
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        int count = 0;
        QueryRow oRow = null;
        QueryValue oValue = null;
        ArrayList arylstList = null;
        Iterator itrBean = null;
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, -5, new Long(lDetailFirstPosition)));
        arylstParam.add(new DBObject(2, 1, -5, new Long(lDetailLastPosition)));
        arylstParam.add(new DBObject(3, 1, 12, sEmpNo));
        arylstParam.add(new DBObject(4, 1, 12, sLvType));
        arylstParam.add(new DBObject(5, 1, 91, d1));
        arylstParam.add(new DBObject(6, 2, -10));
        arylstParam.add(new DBObject(7, 2, 12));
        arylstParam.add(new DBObject(8, 2, 12));
        arylstParam.add(new DBObject(9, 2, 4));
        ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLEDGER.proc_HrLedgerTxnLvEncashedDtl(?,?,?,?,?,?,?,?,?)");
        arylstList = (ArrayList)((DBObject)arylstOutArray.get(0)).getObject();
        if (arylstList.size() == 0)
          throw new EnrgiseApplicationException("wenrgise.hrms.norecordfound", "M"); 
        count = 0;
        itrBean = arylstList.iterator();
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
        while (itrBean.hasNext()) {
          if (count == 0)
            oEmpLeaveLedgerTxnDetail = new ArrayList(); 
          count++;
          oRow = itrBean.next();
          HrmLvLedgerTransDtlBean oTrnsDtlBean = new HrmLvLedgerTransDtlBean();
          String datenewformat = formatter.format(oRow.get("APPLICATION_DATE").getDate());
          oTrnsDtlBean.setTxtApplicationDate(datenewformat);
          oTrnsDtlBean.setTxtPayrollMonth(oRow.get("PAYROLL_YYYYMM").getString());
          oTrnsDtlBean.setTxtNoOfDays(oRow.get("DAYS_ENCASHED").getString());
          oTrnsDtlBean.setTxtAction(oRow.get("LEAVESENCASHED").getString());
          oEmpLeaveLedgerTxnDetail.add(oTrnsDtlBean);
        } 
      }  
    return oEmpLeaveLedgerTxnDetail;
  }
  
  public RecordMetaInfo getHrEmpLeaveLedgerTxnDetail(HrmLvLedgerQVO oHrmLvLedgerQVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    RecordMetaInfo oRecordMetaInfo = null;
    String sId = oHrmLvLedgerQVO.getHdnDetailId();
    HrmLvLedgerBO oHrmLvLedgerBO = new HrmLvLedgerBO();
    String sFromDate = oHrmLvLedgerBO.getHrEmpLeaveLedgerTxnDetail(sId);
    DateUtility d = new DateUtility();
    Date d1 = new Date(d.getDateLong(sFromDate));
    String sLvTaken = oHrmLvLedgerQVO.getLeavesTaken();
    String sLvEncashed = oHrmLvLedgerQVO.getLeavesEncashed();
    String sLvType = oHrmLvLedgerQVO.getLeavesType();
    String sEmpNo = oHrmLvLedgerQVO.getEmployeeNo();
    if (EnrgiseUtil.checkString(sLvTaken))
      if (Integer.parseInt(sLvTaken) >= 0) {
        ArrayList arylstParam = new ArrayList();
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, sEmpNo));
        arylstParam.add(new DBObject(2, 1, 12, sLvType));
        arylstParam.add(new DBObject(3, 1, 91, d1));
        arylstParam.add(new DBObject(4, 2, -5));
        arylstParam.add(new DBObject(5, 2, 93));
        arylstParam.add(new DBObject(6, 2, 12));
        arylstParam.add(new DBObject(7, 2, 12));
        arylstParam.add(new DBObject(8, 2, 4));
        ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLEDGER.proc_HrLdgrTxnLvTakenDtlCount(?,?,?,?,?,?,?,?)");
        oRecordMetaInfo = new RecordMetaInfo();
        DBObject oTotalRecord = arylstOutArray.get(0);
        oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue());
        DBObject oTimeObject = arylstOutArray.get(1);
        oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject());
      }  
    if (EnrgiseUtil.checkString(sLvEncashed))
      if (Integer.parseInt(sLvEncashed) > 0) {
        ArrayList arylstParam = new ArrayList();
        DBUtilitiesBean oBean = new DBUtilitiesBean();
        arylstParam = new ArrayList();
        arylstParam.add(new DBObject(1, 1, 12, sEmpNo));
        arylstParam.add(new DBObject(2, 1, 12, sLvType));
        arylstParam.add(new DBObject(3, 1, 91, d1));
        arylstParam.add(new DBObject(4, 2, -5));
        arylstParam.add(new DBObject(5, 2, 93));
        arylstParam.add(new DBObject(6, 2, 12));
        arylstParam.add(new DBObject(7, 2, 12));
        arylstParam.add(new DBObject(8, 2, 4));
        ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLEDGER.proc_HrLdgrTxnLvEncshDtlCount(?,?,?,?,?,?,?,?)");
        oRecordMetaInfo = new RecordMetaInfo();
        DBObject oTotalRecord = arylstOutArray.get(0);
        oRecordMetaInfo.setRecordCount(((Long)oTotalRecord.getObject()).longValue());
        DBObject oTimeObject = arylstOutArray.get(1);
        oRecordMetaInfo.setOWhenPicked((Timestamp)oTimeObject.getObject());
      }  
    return oRecordMetaInfo;
  }
  
  public void initializeBOImpl() {
    this.headerTable = "HRM_EMP_PERS";
  }
  
  public String saveHeaderImpl(BaseHeaderBean oBaseHeaderBean, String ScreenMode) throws EnrgiseSystemException {
    String returnString = null;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    DateUtility d = new DateUtility();
    HrmLvLedgerHdrBean oHrmLvLedgerHdrBean = (HrmLvLedgerHdrBean)oBaseHeaderBean;
    if (ScreenMode.equalsIgnoreCase("N")) {
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, "i"));
      arylstParam.add(new DBObject(2, 1, 12, oHrmLvLedgerHdrBean.getEmployeeNo()));
      arylstParam.add(new DBObject(3, 1, 12, oHrmLvLedgerHdrBean.getEmployeeName()));
      arylstParam.add(new DBObject(4, 1, 12, this.oUserInfo.getUserTypeId()));
      arylstParam.add(new DBObject(5, 1, 12, this.oUserInfo.getSiteId()));
      arylstParam.add(new DBObject(6, 1, 12, null));
      arylstParam.add(new DBObject(7, 2, 12));
      arylstParam.add(new DBObject(8, 2, 12));
      arylstParam.add(new DBObject(9, 2, 12));
      arylstParam.add(new DBObject(10, 2, 4));
      ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLEDGER.proc_UpsertHrLvLdgrHdr(?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = (String)oOutObject.getObject();
    } else if (ScreenMode.equalsIgnoreCase("U")) {
      arylstParam = new ArrayList();
      arylstParam.add(new DBObject(1, 1, 12, "u"));
      arylstParam.add(new DBObject(2, 1, 12, oHrmLvLedgerHdrBean.getEmployeeNo()));
      arylstParam.add(new DBObject(3, 1, 12, oHrmLvLedgerHdrBean.getEmployeeName()));
      arylstParam.add(new DBObject(4, 1, 12, this.oUserInfo.getUserTypeId()));
      arylstParam.add(new DBObject(5, 1, 12, this.oUserInfo.getSiteId()));
      arylstParam.add(new DBObject(6, 1, 12, oHrmLvLedgerHdrBean.getHeaderPrimaryKey()));
      arylstParam.add(new DBObject(7, 2, 12));
      arylstParam.add(new DBObject(8, 2, 12));
      arylstParam.add(new DBObject(9, 2, 12));
      arylstParam.add(new DBObject(10, 2, 4));
      ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLEDGER.proc_UpsertHrLvLdgrHdr(?,?,?,?,?,?,?,?,?,?)");
      DBObject oOutObject = arylstOutArray.get(0);
      returnString = (String)oOutObject.getObject();
    } 
    return returnString;
  }
  
  public void saveDetailImpl(String sHeaderPrimaryKey, String sScreenName, ArrayList oDetailBeanArray) throws EnrgiseSystemException {}
  
  public void updateHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {}
  
  public String saveNewHeaderImpl(BaseHeaderBean oBaseHeaderBean) throws EnrgiseSystemException {
    return new String();
  }
  
  public void additionalFieldValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {}
  
  public void additionalTimestampValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {}
  
  public void additionalBusinessValidationImpl(BaseHeaderBean param1, Timestamp param2, String param3, String param4, boolean param5, ArrayList param6, boolean param7, Timestamp param8) {}
  
  public LovVO getHrmEmployeeNumberLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("ID");
    arylstHeaderList.add("hrm.HrmLeaveLedger.employeeNo");
    arylstHeaderList.add("hrm.HrmLeaveLedger.employeeName");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    String sQuerySearch2 = new String();
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    if (oLovQueryVO.getSearchField2() != null)
      sQuerySearch2 = oLovQueryVO.getSearchField2(); 
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParam.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParam.add(new DBObject(3, 2, -10));
    arylstParam.add(new DBObject(4, 2, 12));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLOV.proc_GetHrmEmployeeNoLOVdata(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = new ArrayList(); 
      count++;
      oRow = iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("EMP_NO").getString());
      oLOVBean.setDetailField3(oRow.get("EMPNAME").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getHrmLeaveCodesLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("ID");
    arylstHeaderList.add("hrm.HrmLeaveLedger.leaveCode");
    arylstHeaderList.add("hrm.HrmLeaveLedger.leaveDescription");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    String sQuerySearch2 = new String();
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    if (oLovQueryVO.getSearchField2() != null)
      sQuerySearch2 = oLovQueryVO.getSearchField2(); 
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParam.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParam.add(new DBObject(3, 2, -10));
    arylstParam.add(new DBObject(4, 2, 12));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLOV.proc_GetHrmLeaveCodesLOVdata(?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = new ArrayList(); 
      count++;
      oRow = iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("LEAVE_DESCRIPTION").getString());
      oLOVBean.setDetailField3(oRow.get("NAME").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public LovVO getEmpCodeLOVdata(LovQueryVO oLovQueryVO) throws EnrgiseSystemException {
    LovVO oLovVO = new LovVO();
    ArrayList arylstHeaderList = new ArrayList();
    arylstHeaderList.add("ID");
    arylstHeaderList.add("hrm.HrmLeaveLedger.employeeNo");
    arylstHeaderList.add("hrm.HrmLeaveLedger.employeeName");
    oLovVO.setHeaderList(arylstHeaderList);
    ArrayList arylstVisibility = new ArrayList();
    arylstVisibility.add("H");
    arylstVisibility.add("V");
    arylstVisibility.add("V");
    oLovVO.setVisibilityList(arylstVisibility);
    int count = 0;
    ArrayList arylstParam = new ArrayList();
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    String sQuerySearch1 = new String();
    String sQuerySearch2 = new String();
    String sEmpId = new String();
    if (oLovQueryVO.getSearchField1() != null)
      sQuerySearch1 = oLovQueryVO.getSearchField1(); 
    if (oLovQueryVO.getSearchField2() != null)
      sQuerySearch2 = oLovQueryVO.getSearchField2(); 
    if (oLovQueryVO.getProperty("empId") != null)
      sEmpId = oLovQueryVO.getProperty("empId"); 
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, sQuerySearch1));
    arylstParam.add(new DBObject(2, 1, 12, sQuerySearch2));
    arylstParam.add(new DBObject(3, 1, 12, sEmpId));
    arylstParam.add(new DBObject(4, 2, -10));
    arylstParam.add(new DBObject(5, 2, 12));
    arylstParam.add(new DBObject(6, 2, 12));
    arylstParam.add(new DBObject(7, 2, 4));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLEDGER.getEmpCode(?,?,?,?,?,?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    ArrayList arylstList = (ArrayList)oOutObject.getObject();
    QueryRow oRow = null;
    Iterator iter = arylstList.iterator();
    while (iter.hasNext()) {
      if (count == 0)
        arylstList = new ArrayList(); 
      count++;
      oRow = iter.next();
      LOVBean oLOVBean = new LOVBean();
      oLOVBean.setDetailField1(oRow.get("ID").getString());
      oLOVBean.setDetailField2(oRow.get("empNo").getString());
      oLOVBean.setDetailField3(oRow.get("empName").getString());
      arylstList.add(oLOVBean);
    } 
    oLovVO.setDetailList(arylstList);
    return oLovVO;
  }
  
  public String getGroupInfo(String oUserTypeId) throws EnrgiseSystemException {
    ArrayList arylstParam = new ArrayList();
    int count = 0;
    String groupStatus = null;
    DBUtilitiesBean oBean = new DBUtilitiesBean();
    arylstParam = new ArrayList();
    arylstParam.add(new DBObject(1, 1, 12, oUserTypeId));
    arylstParam.add(new DBObject(2, 2, 12));
    ArrayList arylstOutArray = oBean.callProc(arylstParam, "HRMLVLEDGER.getGroupId(?,?)");
    DBObject oOutObject = arylstOutArray.get(0);
    groupStatus = (String)oOutObject.getObject();
    QueryRow oRow = null;
    return groupStatus;
  }
}
