package main_package;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

@ManagedBean(name="editViewActiveGroupLoan")
@ViewScoped
public class EditViewActiveGroupLoanBean implements Serializable
{DataBaseMethods obj=new DataBaseMethods();
	private static final long serialVersionUID = 1L;
	ArrayList<LoanInfo> grpActList,grpCloseList,grpPendingList;
	LoanInfo selectedLoan;
	
	public EditViewActiveGroupLoanBean()
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		 int branchId = (int) ss.getAttribute("branchId");
		Connection con=DataBaseConnection.JAVAConnection();
		
		grpActList = obj.groupActList(branchId,con);
		grpCloseList=obj.groupCloseList(branchId,con);
		grpPendingList=obj.groupPendingList(branchId,con);
		
		try {
			con.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public String viewGroupLoan()
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		ss.setAttribute("selectedLoan", selectedLoan);
		ss.setAttribute("pageName","editViewGroupLoan.xhtml");
		return "viewGroupLoan";
	}
	
	public String editGroupLoan()
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		ss.setAttribute("selectedLoan", selectedLoan);
		return "editGroupLoan";
	}

	public LoanInfo getSelectedLoan() {
		return selectedLoan;
	}

	public void setSelectedLoan(LoanInfo selectedLoan) {
		this.selectedLoan = selectedLoan;
	}

	public ArrayList<LoanInfo> getGrpActList() {
		return grpActList;
	}

	public void setGrpActList(ArrayList<LoanInfo> grpActList) {
		this.grpActList = grpActList;
	}

	public ArrayList<LoanInfo> getGrpCloseList() {
		return grpCloseList;
	}

	public void setGrpCloseList(ArrayList<LoanInfo> grpCloseList) {
		this.grpCloseList = grpCloseList;
	}

	public ArrayList<LoanInfo> getGrpPendingList() {
		return grpPendingList;
	}

	public void setGrpPendingList(ArrayList<LoanInfo> grpPendingList) {
		this.grpPendingList = grpPendingList;
	}

}
