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.context.FacesContext;
import javax.faces.view.facelets.FaceletContext;
import javax.servlet.http.HttpSession;

import main_package.DataBaseMethodsHemant;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

@ViewScoped
@ManagedBean(name="insuranceReport")
public class InsuranceReportBean implements Serializable
{
	Date startDate, endDate;
	String loanType;
	ArrayList<CibilInfo> list;
	boolean show, showNominee;
	int branchId;
	DataBaseMethodsHemant dbmh = new DataBaseMethodsHemant();

	boolean disAll;
	String userType;

	
	public InsuranceReportBean() 
	{
		startDate=new Date();
		endDate=new Date();
		startDate.setDate(startDate.getMonth()-1);
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);

		
		String cc=(String) ss.getAttribute("companyName");

		userType= (String) ss.getAttribute("type");

		
	    disAll= dbmh.disAllByCompanyNameUserType(userType,cc);

	}
	
	public void search()
	{
		list=new DataBaseReportMethods().insuranceReport(startDate, endDate, loanType, showNominee, branchId);
		if(list.size()>0)
		{
			show=true;
			
		}
		else
		{
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("No Record Found!!!"));
		}
		
	}

	public void postProcessXLS(Object document)
	{
	    dbmh.postProcessXLS(document);
	}


	
	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getLoanType() {
		return loanType;
	}

	public void setLoanType(String loanType) {
		this.loanType = loanType;
	}

	public ArrayList<CibilInfo> getList() {
		return list;
	}

	public void setList(ArrayList<CibilInfo> list) {
		this.list = list;
	}

	public boolean isShow() {
		return show;
	}

	public void setShow(boolean show) {
		this.show = show;
	}

	public boolean isShowNominee() {
		return showNominee;
	}

	public void setShowNominee(boolean showNominee) {
		this.showNominee = showNominee;
	}

	public int getBranchId() {
		return branchId;
	}

	public void setBranchId(int branchId) {
		this.branchId = branchId;
	}

	public boolean isDisAll() {
		return disAll;
	}

	public void setDisAll(boolean disAll) {
		this.disAll = disAll;
	}

	public String getUserType() {
		return userType;
	}

	public void setUserType(String userType) {
		this.userType = userType;
	}

	

	
}
