package report_package;

import java.io.Serializable;
import java.sql.Connection;
import java.util.ArrayList;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpSession;

import main_package.DataBaseConnection;
import main_package.FixedAssetsInfo;


@ManagedBean(name="depReport")
@ViewScoped
public class DepreciationReportBean implements Serializable
{
	ArrayList<ColumnModel> columns=new ArrayList<>();
	ArrayList<SelectItem> yearList=new ArrayList<>();
	ArrayList<FixedAssetsInfo> depList;
	DataBaseReportMethods obj1=new DataBaseReportMethods();
	public DepreciationReportBean() 
	{
		HttpSession ss0=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId = (int) ss0.getAttribute("branchId");
		Connection conn =DataBaseConnection.JAVAConnection();
		for(int i=2015; i<=2025; i++)
		{
			SelectItem ss=new SelectItem();
			
			ss.setLabel(String.valueOf(i));
			ss.setValue(i);
			
			yearList.add(ss);
		}
		
			
		for(SelectItem tt: yearList)
		{
			ColumnModel cc=new ColumnModel();
			
			cc.setYear(tt.getLabel());
			cc.setId(String.valueOf(tt.getValue()));
			
			columns.add(cc);
		}
		
		depList=obj1.allFixedAsset(branchId,conn);
		
		obj1.checkDepreciationAllFixedAssets(branchId,yearList, depList,conn);
		try {
			conn.close();
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	
	
	
	
	public class ColumnModel implements Serializable 
	{
		String year;
	    String id;
		
		public String getYear() {
			return year;
		}
		public void setYear(String year) {
			this.year = year;
		}
		public String getId() {
			return id;
		}
		public void setId(String id) {
			this.id = id;
		}
	}




	public ArrayList<ColumnModel> getColumns() {
		return columns;
	}




	public void setColumns(ArrayList<ColumnModel> columns) {
		this.columns = columns;
	}




	public ArrayList<SelectItem> getYearList() {
		return yearList;
	}




	public void setYearList(ArrayList<SelectItem> yearList) {
		this.yearList = yearList;
	}




	public ArrayList<FixedAssetsInfo> getDepList() {
		return depList;
	}




	public void setDepList(ArrayList<FixedAssetsInfo> depList) {
		this.depList = depList;
	}
	
	
}




