package com.reallinkbilling.jspRedirect;

import java.util.Calendar;
import java.util.Date;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class CutomerCreditReportJsp extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 4452079905704723458L;
	
	private HttpSession session;
	private String startDate;
	private String endDate;
	
	public String execute(){
		
		String result = "login";
		session=ServletActionContext.getRequest().getSession(false); 
		 
	        if(session==null || session.getAttribute("login")==null){ 
	        	addActionMessage("Please Login First !!!");
	        	result = "login";
	        }  
	        else{
	        	
	        	Date today = new Date(); // Fri Jun 17 14:54:28 PDT 2016 
	        	
	        	Calendar cal = Calendar.getInstance(); cal.setTime(today); // don't forget this if date is arbitrary e.g. 01-01-2014
	        	int year = cal.get(Calendar.YEAR);
	        	
	        	
	        	this.setStartDate("01-04-"+(year-1));
	        	this.setEndDate(endDate = "31-03-"+(year));
	        	
	        	
	        	result = "success";
	        }
	        
	        return  result ;
}
	
	
	public String getStartDate() {
		return startDate;
	}


	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}


	public String getEndDate() {
		return endDate;
	}


	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}


	public HttpSession getSession() {
		return session;
	}
	public void setSession(HttpSession session) {
		this.session = session;
	}

}
