/*
 * 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.payroll.vo;

import java.util.List;

import jp.mosp.common.CommonConst;
import jp.mosp.common.MosPMenuConst;
import jp.mosp.common.MosPVo;
import jp.mosp.common.common.FileUploadUtility;
import jp.mosp.common.utils.StringUtil;
import jp.mosp.kintai.payroll.dto.KdWorkDto;

import org.apache.commons.fileupload.FileItem;

/**
 * @author nakamura
 *
 */
public class WorkCompileImportCardVo extends MosPVo {
	
	private static final long	serialVersionUID	= -5921622593478797532L;
	
	// 定数
	/**
	 * 表示モード
	 */
	public static final int		MODE_VIEW			= 0;
	/**
	 * アップロードモード
	 */
	public static final int		MODE_UPLOAD			= 1;
	/**
	 * レポートモード
	 */
	public static final int		MODE_REPORT			= 2;
	
	/**
	 * 旧勤怠モード
	 */
	public static final int		TABLE_OLD			= 1;
	/**
	 * 新勤怠モード
	 */
	public static final int		TABLE_NEW			= 2;
	
	// パラメーター名
	/**
	 * アップロードファイル
	 */
	public static final String	PRM_FIL_UPLOAD_FILE	= "filUploadFile";
	
	// フィールド
	private FileItem			filUploadFile;
	private String[][]			aryKintai;
	
	private List<KdWorkDto>		newImportList;
	private StringBuffer		errorReport;
	
	private String[]			aryColumnName;
	
	// モード
	private int					mode;
	private int					table;
	
	// フィールド名及び制限
	/**
	 * 社員コード
	 */
	public String				NAM_K_CODE;
	/**
	 * 
	 */
	public String				NAM_SIKYU_YM;
	/**
	 * 
	 */
	public String				NAM_S_YMD;
	/**
	 * 
	 */
	public String				NAM_S_NISSU;
	/**
	 * 
	 */
	public String				NAM_S_KAISU;
	/**
	 * 
	 */
	public String				NAM_KINMU_JI;
	/**
	 * 
	 */
	public String				NAM_KYUKEI_JI;
	/**
	 * 
	 */
	public String				NAM_YUKYU;
	/**
	 * 
	 */
	public String				NAM_TOKUKYU;
	/**
	 * 
	 */
	public String				NAM_KEKKIN;
	/**
	 * 
	 */
	public String				NAM_S_KEKKIN;
	/**
	 * 
	 */
	public String				NAM_DAIKYU;
	/**
	 * 
	 */
	public String				NAM_FURIKAE;
	/**
	 * 
	 */
	public String				NAM_KK_RIYUU_6;
	/**
	 * 
	 */
	public String				NAM_KK_RIYUU_7;
	/**
	 * 
	 */
	public String				NAM_KK_RIYUU_8;
	/**
	 * 
	 */
	public String				NAM_KK_RIYUU_9;
	/**
	 * 
	 */
	public String				NAM_SONOTA;
	/**
	 * 
	 */
	public String				NAM_TI_SO_KAI;
	/**
	 * 
	 */
	public String				NAM_TI_JIKAN;
	/**
	 * 
	 */
	public String				NAM_ZA_JIKAN;
	/**
	 * 
	 */
	public String				NAM_KS_JIKAN;
	/**
	 * 
	 */
	public String				NAM_SN_JIKAN;
	/**
	 * 
	 */
	public String				NAM_KAIKIN;
	/**
	 * 
	 */
	public String				NAM_SYOKUJI_KAISU;
	/**
	 * 
	 */
	public String				NAM_CYOKU_KAISU_1;
	/**
	 * 
	 */
	public String				NAM_CYOKU_KAISU_2;
	/**
	 * 
	 */
	public String				NAM_CYOKU_KAISU_3;
	/**
	 * 
	 */
	public String				NAM_HOKA_KAISU_1;
	/**
	 * 
	 */
	public String				NAM_HOKA_KAISU_2;
	/**
	 * 
	 */
	public String				NAM_HOKA_KAISU_3;
	/**
	 * 
	 */
	public String				NAM_HOKA_KAISU_4;
	/**
	 * 
	 */
	public String				NAM_HOKA_KAISU_5;
	/**
	 * 
	 */
	public String				NAM_SINSEI_GAKU;
	/**
	 * 
	 */
	public String				NAM_WARIMASI;
	/**
	 * 
	 */
	public String				NAM_WEEK_DAY_OVER_TIME;
	/**
	 * 
	 */
	public String				NAM_WEEK_HOLIDAY_OVER_TIME;
	/**
	 * 
	 */
	public String				NAM_MONTHLY_OVER_TIME;
	/**
	 * 
	 */
	public String				NAM_MONTHLY_WEEK_HOLIDAY;
	/**
	 * 
	 */
	public String				NAM_HOUR_HOLIDAY;
	/**
	 * 
	 */
	public String				NAM_SUBSTITUTE_HOLIDAY;
	/**
	 * 
	 */
	public String				NAM_AMEND_FLAG;
	

	/**
	 * コンストラクター
	 */
	public WorkCompileImportCardVo() {
		super();
		setViewPath(getClassName());
		aryKintai = new String[0][0];
		aryColumnName = StringUtil.getBlankArrayOneDimension(44);
		mode = MODE_VIEW;
		table = 0;
	}
	
	@Override
	protected void setSubTitle() {
		subTitle = "勤怠情報インポート";
		createAryMenu(CMD_MENU_PAYROLL, MosPMenuConst.getMenuAttendanceCalculate());
	}
	
	@Override
	protected void setFieldsName() {
		NAM_K_CODE = CommonConst.NAM_COMMON_CODE;
		NAM_SIKYU_YM = "年月";
		NAM_S_YMD = "年月日";
		NAM_S_NISSU = "出日";
		NAM_S_KAISU = "出回";
		NAM_KINMU_JI = "勤務";
		NAM_KYUKEI_JI = "休憩";
		NAM_YUKYU = "有休";
		NAM_TOKUKYU = "特休";
		NAM_KEKKIN = "欠勤";
		NAM_S_KEKKIN = "傷病";
		NAM_DAIKYU = "代休";
		NAM_FURIKAE = "振休";
		NAM_KK_RIYUU_6 = "休6";
		NAM_KK_RIYUU_7 = "休7";
		NAM_KK_RIYUU_8 = "休8";
		NAM_KK_RIYUU_9 = "休9";
		NAM_SONOTA = CommonConst.NAM_OTHER_SHORT;
		NAM_TI_SO_KAI = "遅早回";
		NAM_TI_JIKAN = "遅早時";
		NAM_ZA_JIKAN = "残業";
		NAM_KS_JIKAN = "休出";
		NAM_SN_JIKAN = "深夜";
		NAM_KAIKIN = "皆勤";
		NAM_SYOKUJI_KAISU = "食事";
		NAM_CYOKU_KAISU_1 = "1直";
		NAM_CYOKU_KAISU_2 = "2直";
		NAM_CYOKU_KAISU_3 = "3直";
		NAM_HOKA_KAISU_1 = "他1";
		NAM_HOKA_KAISU_2 = "他2";
		NAM_HOKA_KAISU_3 = "他3";
		NAM_HOKA_KAISU_4 = "他4";
		NAM_HOKA_KAISU_5 = "他5";
		NAM_SINSEI_GAKU = "支払";
		NAM_WARIMASI = "割増";
		NAM_WEEK_DAY_OVER_TIME = "平日外";
		NAM_WEEK_HOLIDAY_OVER_TIME = "所休外";
		NAM_MONTHLY_OVER_TIME = "60平外";
		NAM_MONTHLY_WEEK_HOLIDAY = "60休外";
		NAM_HOUR_HOLIDAY = "時休";
		NAM_SUBSTITUTE_HOLIDAY = "60代休";
		NAM_AMEND_FLAG = "修正";
	}
	
	/**
	 * @param kintaiList		勤怠情報
	 */
	@Override
	public void setFields(List<?> kintaiList) {
		// リストの設定
		list = kintaiList;
		// データ総数の取得
		count = list.size();
		// 配列の初期化
		aryKintai = new String[count][44];
		int i = 0;
		for (Object obj : kintaiList) {
			aryKintai[i] = escapeArray((String[])obj);
			i++;
		}
	}
	
	/**
	 * パラメータ設定
	 * @param list	リクエストリスト
	 * @throws Exception 例外処理
	 */
	public void setFilUploadFile(List<?> list) throws Exception {
		filUploadFile = FileUploadUtility.getMultipartFile(list, PRM_FIL_UPLOAD_FILE);
	}
	
	@Override
	public String getDirectJs(Class<?> cls, Object obj) throws IllegalAccessException {
		StringBuffer sb = new StringBuffer();
		sb.append(super.getDirectJs(cls, obj));
		sb.append(" var MODE = ");
		sb.append(mode);
		sb.append(";");
		sb.append(" var TABLE = ");
		sb.append(table);
		sb.append(";");
		return sb.toString();
	}
	
	// アクセサメソッド
	/**
	 * @return		アップロードファイル
	 */
	public FileItem getFilUploadFile() {
		return filUploadFile;
	}
	
	/**
	 * @return		勤怠情報
	 */
	public String[][] getEscAryKintai() {
		return aryKintai.clone();
	}
	
	/**
	 * @return		新旧勤怠モード
	 */
	public int getTable() {
		return table;
	}
	
	/**
	 * @param mode		モード
	 */
	public void setMode(int mode) {
		this.mode = mode;
	}
	
	/**
	 * @param table セットする table
	 */
	public void setTable(int table) {
		this.table = table;
	}
	
	/**
	 * @param newImportList セットする newImportList
	 */
	public void setNewImportList(List<KdWorkDto> newImportList) {
		this.newImportList = newImportList;
	}
	
	/**
	 * @return newImportList
	 */
	public List<KdWorkDto> getNewImportList() {
		return newImportList;
	}
	
	/**
	 * @param errorReport セットする errorReport
	 */
	public void setErrorReport(StringBuffer errorReport) {
		this.errorReport = errorReport;
	}
	
	/**
	 * @return errorReport
	 */
	public StringBuffer getErrorReport() {
		return errorReport;
	}
	
	/**
	 * @return aryColumnName
	 */
	public String[] getAryColumnName() {
		return aryColumnName.clone();
	}
	
	/**
	 * @param aryColumnName セットする aryColumnName
	 */
	public void setAryColumnName(String[] aryColumnName) {
		this.aryColumnName = aryColumnName.clone();
	}
}
