package com.tax.file.model;



public class PageModel {

	private int sEcho;
	private int iDisplayStart;
	private int iDisplayLength = 100;
	private int iTotalRecords;
	private int iTotalDisplayRecords;
	private int curPage;
	private int totalPages;
	private boolean isPage = false;
	private boolean isNextPage = false;
	
	private int tiTotalRecords;
	private int tiTotalDisplayRecords;
	private int tsEcho;
	
	public PageModel() {
		this.sEcho = 1;
		this.iDisplayStart = 0;
		this.iDisplayLength = 100;
		this.curPage = 0;
		this.totalPages = 1;
		this.iTotalRecords = 0;
		this.iTotalDisplayRecords = 0;
	}

	public int getsEcho() {
		return sEcho;
	}

	public void setsEcho(int sEcho) {
		this.sEcho = sEcho;
	}

	public int getiDisplayStart() {
		iDisplayStart = iDisplayLength * getCurPage();
		return iDisplayStart;
	}

	public void setiDisplayStart(int iDisplayStart) {
		this.iDisplayStart = iDisplayStart;
	}

	public int getiDisplayLength() {
		return iDisplayLength;
	}

	public void setiDisplayLength(int iDisplayLength) {
		if(iDisplayLength > 0) {
			this.iDisplayLength = iDisplayLength;
		}
	}

	public int getiTotalRecords() {
		return iTotalRecords;
	}

	public void setiTotalRecords(int iTotalRecords) {
		this.iTotalRecords = iTotalRecords;
	}

	public int getiTotalDisplayRecords() {
		return iTotalDisplayRecords;
	}

	public void setiTotalDisplayRecords(int iTotalDisplayRecords) {
		this.iTotalDisplayRecords = iTotalDisplayRecords;
	}

	public int getCurPage() {
		if(curPage>getTotalPages()){
            this.curPage = totalPages;
        }
        if(curPage<=0){
            this.curPage=0;
        }
		return curPage;
	}

	public void setCurPage(int curPage) {
		this.curPage = curPage;
	}

	public boolean isPage() {
		return isPage;
	}

	public void setPage(boolean isPage) {
		this.isPage = isPage;
	}

	public boolean isNextPage() {
		isNextPage = getTotalPages() > getCurPage();
		return isNextPage;
	}

	public void setNextPage(boolean isNextPage) {
		this.isNextPage = isNextPage;
	}

	public int getTotalPages() {
		totalPages = iTotalRecords%iDisplayLength==0? iTotalRecords/iDisplayLength : (iTotalRecords/iDisplayLength)+1;
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public int getTiTotalRecords() {
		return tiTotalRecords;
	}

	public void setTiTotalRecords(int tiTotalRecords) {
		this.tiTotalRecords = tiTotalRecords;
	}

	public int getTiTotalDisplayRecords() {
		return tiTotalDisplayRecords;
	}

	public void setTiTotalDisplayRecords(int tiTotalDisplayRecords) {
		this.tiTotalDisplayRecords = tiTotalDisplayRecords;
	}

	public int getTsEcho() {
		return tsEcho;
	}

	public void setTsEcho(int tsEcho) {
		this.tsEcho = tsEcho;
	}
	
	

}
