package main_package;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

import report_package.DataBaseReportMethods;

@ManagedBean(name="printSalarySlip")
@ViewScoped
public class PrintSalarySlipBean implements Serializable
{
	EmployeeInfo employeeInfo;
	SalaryInfo salInfo;
	String selectedYear,selectedMonth,type,monthName,selectedEmployee, amountInWords;
	double totalEarning, totalDeduction;
	
	public PrintSalarySlipBean() 
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
		salInfo= (SalaryInfo) ss.getAttribute("salInfo");
		employeeInfo=(EmployeeInfo) ss.getAttribute("employeeInfo");
		selectedEmployee=(String) ss.getAttribute("selectedEmployee");
		monthName=(String) ss.getAttribute("monthName");
		monthName=monthName.toUpperCase();
		selectedYear=(String) ss.getAttribute("selectedYear");
		
		totalDeduction=totalEarning=0;
		
		totalDeduction=totalDeduction+(salInfo.getPf()+salInfo.getEsi()+salInfo.getTds());
		totalEarning=totalEarning+(salInfo.getSalary()+salInfo.getAllowance());
		amountInWords=new DataBaseReportMethods().numberToWords((int)salInfo.getFinalSalary());
		
	}

	public EmployeeInfo getEmployeeInfo() {
		return employeeInfo;
	}

	public void setEmployeeInfo(EmployeeInfo employeeInfo) {
		this.employeeInfo = employeeInfo;
	}

	public SalaryInfo getSalInfo() {
		return salInfo;
	}

	public void setSalInfo(SalaryInfo salInfo) {
		this.salInfo = salInfo;
	}

	public String getSelectedYear() {
		return selectedYear;
	}

	public void setSelectedYear(String selectedYear) {
		this.selectedYear = selectedYear;
	}

	public String getSelectedMonth() {
		return selectedMonth;
	}

	public void setSelectedMonth(String selectedMonth) {
		this.selectedMonth = selectedMonth;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getMonthName() {
		return monthName;
	}

	public void setMonthName(String monthName) {
		this.monthName = monthName;
	}

	public String getSelectedEmployee() {
		return selectedEmployee;
	}

	public void setSelectedEmployee(String selectedEmployee) {
		this.selectedEmployee = selectedEmployee;
	}

	public double getTotalEarning() {
		return totalEarning;
	}

	public void setTotalEarning(double totalEarning) {
		this.totalEarning = totalEarning;
	}

	public double getTotalDeduction() {
		return totalDeduction;
	}

	public void setTotalDeduction(double totalDeduction) {
		this.totalDeduction = totalDeduction;
	}

	public String getAmountInWords() {
		return amountInWords;
	}

	public void setAmountInWords(String amountInWords) {
		this.amountInWords = amountInWords;
	}
}
