/*
 * MosP - Mind Open Source Project    http://www.mosp.jp/
 * Copyright (C) MIND Co., Ltd.       http://www.e-mind.co.jp/
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package jp.mosp.kintai.report.vo;

import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import jp.mosp.common.CommonConst;
import jp.mosp.common.MosPVo;
import jp.mosp.common.utils.StringUtil;
import jp.mosp.kintai.report.dto.MExportDto;

/**
 * 
 */
public class ExportCardVo extends MosPVo {
	
	private static final long	serialVersionUID	= -1964891218805898322L;
	
	// 定数
	/**
	 * 
	 */
	public static final int		SEARCH_OFF			= 0;
	/**
	 * 
	 */
	public static final int		SEARCH_ON			= 1;
	
	// パラメーター名
	/**
	 * 
	 */
	public static final String	PRM_PLT_YEAR		= "pltYear";
	/**
	 * 
	 */
	public static final String	PRM_PLT_MONTH		= "pltMonth";
	/**
	 * 
	 */
	public static final String	PRM_TXT_E_NAME		= "txtEName";
	/**
	 * 
	 */
	public static final String	PRM_TXT_E_FILE		= "txtEFile";
	
	// フィールド
	private String				pltYear;
	private String				pltMonth;
	
	private String[]			aryEName;
	private String[]			aryEFile;
	/*						
	 *  	2009/02/20	m.yoshida	エラー対応
	 */
	private String[]			aryENameKey;
	private String				txtEName;
	private String				txtEFile;
	
	// プルダウンリスト
	/**
	 * 
	 */
	public String[][]			aryPltYear;
	/**
	 * 
	 */
	public String[][]			aryPltMonth;
	
	// フィールド名及び制限
	/**
	 * 
	 */
	public String				NAM_E_NAME;
	/**
	 * 
	 */
	public String				NAM_E_FILE;
	/**
	 * 
	 */
	public String				NAM_KINTAI_INFO;
	/**
	 * 
	 */
	public String				NAM_PLT_YEAR;
	/**
	 * 
	 */
	public String				NAM_PLT_MONTH;
	/**
	 * 
	 */
	public int					LEN_E_NAME;
	
	// ソートキー
	/**
	 * 
	 */
	public final String			KEY_E_NAME			= "keyEName";
	
	// モード(0：検索なし、1：検索あり)
	private int					searchmode;
	

	/**
	 * コンストラクタ
	 */
	public ExportCardVo() {
		super();
		setViewPath(getClassName());
		pltYear = "";
		pltMonth = "";
		aryEName = new String[0];
		aryEFile = new String[0];
		setFormerKey(KEY_E_NAME);
		/*						
		 *  	2009/02/20	m.yoshida	エラー対応
		 */
		aryENameKey = new String[0];
	}
	
	@Override
	protected void setSubTitle() {
		subTitle = CommonConst.TTL_EXPORT_MASTER;
		aryMenu = new String[][]{ { CMD_MENU_PAYROLL, CommonConst.NAM_TO_MENU } };
	}
	
	@Override
	protected void setFieldsName() {
		NAM_E_NAME = CommonConst.NAM_COMMON_MEISYO;
		NAM_E_FILE = CommonConst.NAM_TABLE;
		NAM_KINTAI_INFO = CommonConst.NAM_TARGET_MONTH;
		NAM_PLT_YEAR = CommonConst.NAM_YEAR;
		NAM_PLT_MONTH = CommonConst.NAM_MONTH;
		LEN_E_NAME = 10;
	}
	
	@Override
	public void setParams(HttpServletRequest request) {
		pltYear = request.getParameter(PRM_PLT_YEAR);
		pltMonth = request.getParameter(PRM_PLT_MONTH);
	}
	
	@Override
	public void setFields(List<?> exportList) {
		//リストの設定
		list = exportList;
		//データ総数の取得
		count = exportList.size();
		//配列の初期化
		aryEName = new String[count];
		aryEFile = new String[count];
		/*						
		 *  	2009/02/20	m.yoshida	エラー対応
		 */
		aryENameKey = new String[count];
		//データの設定
		int i = 0;
		Iterator<?> it = exportList.iterator();
		while (it.hasNext()) {
			MExportDto dto = (MExportDto)it.next();
			String ename = "";
			String[] divName = StringUtil.divideByComma(dto.getEName());
			if (divName.length == 1) {
				ename = dto.getEName();
			} else {
				ename = divName[1];
			}
			aryEName[i] = escapeHTML(ename);
			aryEFile[i] = escapeHTML(dto.getEFile());
			aryENameKey[i] = escapeHTML(dto.getEName());
			i++;
		}
	}
	
	/**
	 * @return pltYear
	 */
	public String getPltYear() {
		return pltYear;
	}
	
	/**
	 * @return pltMonth
	 */
	public String getPltMonth() {
		return pltMonth;
	}
	
	/**
	 * @return aryEName
	 */
	public String[] getAryEName() {
		return aryEName.clone();
	}
	
	/**
	 * @return aryEFile
	 */
	public String[] getAryEFile() {
		return aryEFile.clone();
	}
	
	/**
	 * @return aryENameKey
	 */
	public String[] getAryENameKey() {
		return aryENameKey.clone();
	}
	
	/**
	 * @return txtEName
	 */
	public String getTxtEName() {
		return txtEName;
	}
	
	/**
	 * @return txtEFile
	 */
	public String getTxtEFile() {
		return txtEFile;
	}
	
	/**
	 * @return searchmode
	 */
	public int getSearchmode() {
		return searchmode;
	}
	
	/**
	 * @param pltYear セットする pltYear
	 */
	public void setPltYear(String pltYear) {
		this.pltYear = pltYear;
	}
	
	/**
	 * @param pltMonth セットする pltMonth
	 */
	public void setPltMonth(String pltMonth) {
		this.pltMonth = pltMonth;
	}
	
	/**
	 * @param aryEName セットする aryEName
	 */
	public void setAryEName(String[] aryEName) {
		this.aryEName = aryEName.clone();
	}
	
	/**
	 * @param aryEFile セットする aryEFile
	 */
	public void setAryEFile(String[] aryEFile) {
		this.aryEFile = aryEFile.clone();
	}
	
	/**
	 * @param aryENameKey セットする aryENameKey
	 */
	public void setAryENameKey(String[] aryENameKey) {
		this.aryENameKey = aryENameKey.clone();
	}
	
	/**
	 * @param txtEName セットする txtEName
	 */
	public void setTxtEName(String txtEName) {
		this.txtEName = txtEName;
	}
	
	/**
	 * @param txtEFile セットする txtEFile
	 */
	public void setTxtEFile(String txtEFile) {
		this.txtEFile = txtEFile;
	}
	
	/**
	 * @param searchmode セットする searchmode
	 */
	public void setSearchmode(int searchmode) {
		this.searchmode = searchmode;
	}
	
}
