package report_package;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpSession;

import main_package.UserInfo;

import org.primefaces.context.RequestContext;

@ManagedBean(name="userLoanRequestFromApp")
@ViewScoped
public class UserLoanRequestFromAppBean implements Serializable
{
	private static final long serialVersionUID = 1L;
	
	ArrayList<UserInfo>detailsList= new ArrayList<>();
	UserInfo selecteloan1;
	public UserLoanRequestFromAppBean()
	  {
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId = (int) ss.getAttribute("branchId");
			detailsList=new DataBaseReportMethods().LoanReqApp(branchId);
	  }

	public String delete()
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId = (int) ss.getAttribute("branchId");
		int val= new DataBaseReportMethods().deleteLoanReqByApp(selecteloan1.getId());
		if(val==0)
		{
			FacesContext fc=FacesContext.getCurrentInstance();
			fc.addMessage(null, new FacesMessage("Delete SuccessFully"));
			detailsList=new DataBaseReportMethods().LoanReqApp(branchId);
			return "userLoanRequestFromApp.xhtml";
		}
		else
		{
			FacesContext fc=FacesContext.getCurrentInstance();
			fc.addMessage(null, new FacesMessage("Some Error Occured"));
			detailsList=new DataBaseReportMethods().LoanReqApp(branchId);
			return "userLoanRequestFromApp.xhtml";
		}
		
		
	}
	
	
	
	
	public UserInfo getSelecteloan1() {
		return selecteloan1;
	}

	public void setSelecteloan1(UserInfo selecteloan1) {
		this.selecteloan1 = selecteloan1;
	}

	public ArrayList<UserInfo> getDetailsList() {
		return detailsList;
	}

	public void setDetailsList(ArrayList<UserInfo> detailsList) {
		this.detailsList = detailsList;
	}
	
}

