package main_package;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

@ManagedBean(name="logDetail")
@ViewScoped
public class LogDetailBean implements Serializable
{
	ArrayList<EmployeeInfo> empList;
	int total;
	Date startDate=new Date(), endDate=new Date();
	DataBaseMethods obj=new DataBaseMethods();
	public LogDetailBean()
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId=(int) ss.getAttribute("branchId");
		startDate.setDate(startDate.getDate()-7);
		empList=obj.logReportByDate(startDate, endDate,branchId);
		total=empList.size();
	}
	
	public void show()
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId=(int) ss.getAttribute("branchId");
		total=0;
		empList=obj.logReportByDate(startDate, endDate,branchId);
		total=empList.size();
	}

	public ArrayList<EmployeeInfo> getEmpList() {
		return empList;
	}

	public void setEmpList(ArrayList<EmployeeInfo> empList) {
		this.empList = empList;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	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;
	}
	
	
}
