package com.reallinkbilling.jspRedirect;


import java.util.ArrayList;
import java.util.Map;

import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.reallinkbilling.DAO.CustomerPaymentReminderDetailsDAO;



public class ShowCustomerPaymentReminderNotificationsJsp extends ActionSupport implements SessionAware{

	/**
	 * 
	 */
	private static final long serialVersionUID = 6208411094853732491L;
	private SessionMap<String,Object> sessionMap;

	 ArrayList<CustomerPaymentReminderDetailsDAO> customerPaymentReminderList;
	 
	 private double totalCreditAmount;
	 
	@SuppressWarnings("unchecked")
	public String execute() {
		 
		String result = "login";
	
		
	        if(this.getSessionMap()==null || this.getSessionMap().get("login")==null){ 
	        	addActionMessage("Please Logout and Login again !");
	        	result = "error";
	        }  
	        else{
	        	
	        	
				
	        	try
				{
					
					this.setCustomerPaymentReminderList((ArrayList<CustomerPaymentReminderDetailsDAO>) this.getSessionMap().get("customerpaymentnotificationlist"));
					
					totalCreditAmount = 0;
					
					if(customerPaymentReminderList != null  ) {
						for ( CustomerPaymentReminderDetailsDAO dao : customerPaymentReminderList) {
							totalCreditAmount += dao.getOutstandingAmount();
						}
					}
					
					result = SUCCESS;
				}
				catch (Exception e) {
						result = "error";
					
					addActionError(e.getMessage() +" || Notification Details not found !");
				}
				
	        	
	        }
	        return result;
	}
	
	
	public ArrayList<CustomerPaymentReminderDetailsDAO> getCustomerPaymentReminderList() {
		return customerPaymentReminderList;
	}


	public void setCustomerPaymentReminderList(ArrayList<CustomerPaymentReminderDetailsDAO> customerPaymentReminderList) {
		this.customerPaymentReminderList = customerPaymentReminderList;
	}


	public static long getSerialversionuid() {
		return serialVersionUID;
	}


	public SessionMap<String, Object> getSessionMap() {
		return sessionMap;
	}

	public void setSessionMap(SessionMap<String, Object> sessionMap) {
		this.sessionMap = sessionMap;
	}

	@Override  
	public void setSession(Map<String, Object> map) {  
	    sessionMap=(SessionMap<String, Object>)map;  
	}


	public double getTotalCreditAmount() {
		return totalCreditAmount;
	}


	public void setTotalCreditAmount(double totalCreditAmount) {
		this.totalCreditAmount = totalCreditAmount;
	}
	
	
	

}