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

import javax.servlet.http.HttpServletRequest;

import jp.mosp.common.CommonConst;
import jp.mosp.common.MosPVo;
import jp.mosp.common.utils.DateUtil;
import jp.mosp.common.utils.StringUtil;
import jp.mosp.kintai.kintai.dto.MSyukkinboDto;

/**
 * @author yoshida
 *
 */
public abstract class AttendanceMenuVo extends MosPVo {
	
	private static final long	serialVersionUID	= 3059406656261478934L;
	
	// パラメータ名
	/**
	 * hidKCode
	 */
	public static final String	PRM_HID_K_CODE		= "hidKCode";
	/**
	 * hidYear
	 */
	public static final String	PRM_HID_YEAR		= "hidYear";
	/**
	 * hidMonth
	 */
	public static final String	PRM_HID_MONTH		= "hidMonth";
	/**
	 * hidDay
	 */
	public static final String	PRM_HID_DAY			= "hidDay";
	
	// 編集モードフラグ
	/**
	 * 0
	 */
	public static final int		MODE_INSERT			= 0;
	/**
	 * 1
	 */
	public static final int		MODE_EDIT			= 1;
	/**
	 * 2
	 */
	public static final int		MODE_APPROVED		= 2;
	
	// 編集モード名称
	/**
	 * 
	 */
	public static final String	NAM_MODE_INSERT		= CommonConst.NAM_MODE_INSERT;
	/**
	 * 
	 */
	public static final String	NAM_MODE_EDIT		= CommonConst.NAM_MODE_EDIT;
	/**
	 * [承認済]
	 */
	public static final String	NAM_MODE_APPROVED	= CommonConst.NAM_MODE_APPROVED;
	
	// フィールド
	private String				lblDate;
	private String				lblDayOfWeek;
	
	// フィールド(画面遷移用)
	private String				hidKCode;
	private String				hidYear;
	private String				hidMonth;
	private String				hidDay;
	private String				hidDate;
	
	private String				hidFormerDate;
	private String				hidNextDate;
	private String				lblFormerDate;
	private String				lblNextDate;
	
	// 編集モード(0：新規登録、1：更新、2:承認済)
	private int					mode;
	
	// サブタイトルメニューコマンド
	private String				cmdMenuButton;
	private String				cmdListButton;
	private String				namListButton;
	
	// 編集モード名称
	/**
	 * 
	 */
	public String				NAM_OVER_TIME_REQUEST;
	/**
	 * 
	 */
	public String				NAM_HOLIDAY_REQUEST;
	/**
	 * 
	 */
	public String				NAM_OVER_TIME;
	/**
	 * 
	 */
	public String				NAM_REQUEST_STATUS;
	
	// 残業申請情報
	private String				lblOverTimeRequest;
	private String				lblOverTimeRequestStatus;
	private String[]			aryHolidayRequestStatus;
	
	private boolean				isDraft;
	private String				dayOfWeekColorClass;
	
	private boolean				isCaution;
	private boolean				isWarning;
	

	/**
	 * コンストラクタ
	 */
	public AttendanceMenuVo() {
		super();
		isDraft = true;
	}
	
	@Override
	protected void setFieldsName() {
		NAM_OVER_TIME_REQUEST = CommonConst.NAM_OVER_TIME_REQUEST;
		NAM_HOLIDAY_REQUEST = CommonConst.NAM_HOLIDAY_REQUEST;
		NAM_OVER_TIME = CommonConst.NAM_OVERTIME + CommonConst.NAM_COMMON_TIME;
		NAM_REQUEST_STATUS = CommonConst.NAM_APPROVAL_STATE;
	}
	
	@Override
	public void setParams(HttpServletRequest request) {
		hidKCode = request.getParameter(PRM_HID_K_CODE);
		hidYear = request.getParameter(PRM_HID_YEAR);
		hidMonth = request.getParameter(PRM_HID_MONTH);
		hidDay = request.getParameter(PRM_HID_DAY);
		hidDate = DateUtil.convStringDateFormatted(hidYear, hidMonth, hidDay);
	}
	
	/**
	 * フィールド設定(DTOに対するVO情報のセット)
	 * @param dto	対象DTO
	 */
	public void setDtoFields(MSyukkinboDto dto) {
		dto.setKCode(getHidKCode());
		dto.setHizuke(DateUtil.convStringDateFormatted(getHidYear(), getHidMonth(), getHidDay()));
		dto.setNen(Integer.parseInt(getHidYear()));
		dto.setTuki(Integer.parseInt(getHidMonth()));
		dto.setHi(Integer.parseInt(getHidDay()));
	}
	
	/**
	 * メニューボタン設定
	 * @param addListButton メニューボタン追加フラグ
	 */
	public void setAryMenu(boolean addListButton) {
		aryMenu = new String[][]{ { getCmdMenuButton(), CommonConst.NAM_TO_MENU }, };
		if (addListButton) {
			aryMenu = StringUtil.addArrayLastRowValue(aryMenu, getCmdListButton(), getNamListButton());
		}
	}
	
	@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 isDraft = ");
		sb.append(isDraft);
		sb.append(";");
		sb.append("var CAUTION = ");
		sb.append(isCaution);
		sb.append(";");
		sb.append("var WARNING = ");
		sb.append(isWarning);
		sb.append(";");
		return sb.toString();
	}
	
	// アクセサメソッド
	/**
	 * @return lblDate
	 */
	public String getEscLblDate() {
		return escapeHTML(lblDate);
	}
	
	/**
	 * @return hidKCode
	 */
	public String getEscHidKCode() {
		return escapeHTML(hidKCode);
	}
	
	/**
	 * @return hidYear
	 */
	public String getEscHidYear() {
		return escapeHTML(hidYear);
	}
	
	/**
	 * @return hidMonth
	 */
	public String getEscHidMonth() {
		return escapeHTML(hidMonth);
	}
	
	/**
	 * @return hidDay
	 */
	public String getEscHidDay() {
		return escapeHTML(hidDay);
	}
	
	/**
	 * @return hidDate
	 */
	public String getEscHidDate() {
		return escapeHTML(hidDate);
	}
	
	/**
	 * @return lblOverTimeRequest
	 */
	public String getEscLblOverTimeRequest() {
		return escapeHTML(lblOverTimeRequest);
	}
	
	/**
	 * @return lblOverTimeRequestStatus
	 */
	public String getEscLblOverTimeRequestStatus() {
		return escapeHTML(lblOverTimeRequestStatus);
	}
	
	/**
	 * @return hidFormerDate
	 */
	public String getHidFormerDate() {
		return escapeHTML(hidFormerDate);
	}
	
	/**
	 * @return hidNextDate
	 */
	public String getHidNextDate() {
		return escapeHTML(hidNextDate);
	}
	
	/**
	 * @return lblFormerDate
	 */
	public String getEscLblFormerDate() {
		return escapeHTML(lblFormerDate);
	}
	
	/**
	 * @return lblNextDate
	 */
	public String getEscLblNextDate() {
		return escapeHTML(lblNextDate);
	}
	
	/**
	 * 勤怠入力画面メニュー用CSS
	 */
	protected void addAttendanceMenuCss() {
		addExtraCss("/pub/kintai/kintai/css/attendanceMenu.css");
	}
	
	/**
	 * 勤怠入力画面メニュー用JS
	 */
	protected void addAttendanceMenuJs() {
		addExtraJs("/pub/kintai/kintai/js/attendanceMenu.js");
	}
	
	/**
	 * @return lblDayOfWeek
	 */
	public String getEscLblDayOfWeek() {
		return escapeHTML(lblDayOfWeek);
	}
	
	/**
	 * @return dayOfWeekColorClass
	 */
	public String getEscDayOfWeekColorClass() {
		return escapeHTML(dayOfWeekColorClass);
	}
	
	/**
	 * @return lblDate
	 */
	public String getLblDate() {
		return lblDate;
	}
	
	/**
	 * @return lblDayOfWeek
	 */
	public String getLblDayOfWeek() {
		return lblDayOfWeek;
	}
	
	/**
	 * @return hidKCode
	 */
	public String getHidKCode() {
		return hidKCode;
	}
	
	/**
	 * @return hidYear
	 */
	public String getHidYear() {
		return hidYear;
	}
	
	/**
	 * @return hidMonth
	 */
	public String getHidMonth() {
		return hidMonth;
	}
	
	/**
	 * @return hidDay
	 */
	public String getHidDay() {
		return hidDay;
	}
	
	/**
	 * @return hidDate
	 */
	public String getHidDate() {
		return hidDate;
	}
	
	/**
	 * @return lblFormerDate
	 */
	public String getLblFormerDate() {
		return lblFormerDate;
	}
	
	/**
	 * @return lblNextDate
	 */
	public String getLblNextDate() {
		return lblNextDate;
	}
	
	/**
	 * @return mode
	 */
	public int getMode() {
		return mode;
	}
	
	/**
	 * @return cmdMenuButton
	 */
	public String getCmdMenuButton() {
		return cmdMenuButton;
	}
	
	/**
	 * @return cmdListButton
	 */
	public String getCmdListButton() {
		return cmdListButton;
	}
	
	/**
	 * @return namListButton
	 */
	public String getNamListButton() {
		return namListButton;
	}
	
	/**
	 * @return lblOverTimeRequest
	 */
	public String getLblOverTimeRequest() {
		return lblOverTimeRequest;
	}
	
	/**
	 * @return lblOverTimeRequestStatus
	 */
	public String getLblOverTimeRequestStatus() {
		return lblOverTimeRequestStatus;
	}
	
	/**
	 * @return aryHolidayRequestStatus
	 */
	public String[] getAryHolidayRequestStatus() {
		return aryHolidayRequestStatus.clone();
	}
	
	/**
	 * @return isDraft
	 */
	public boolean isDraft() {
		return isDraft;
	}
	
	/**
	 * @return dayOfWeekColorClass
	 */
	public String getDayOfWeekColorClass() {
		return dayOfWeekColorClass;
	}
	
	/**
	 * @return isCaution
	 */
	public boolean isCaution() {
		return isCaution;
	}
	
	/**
	 * @return isWarning
	 */
	public boolean isWarning() {
		return isWarning;
	}
	
	/**
	 * @param lblDate セットする lblDate
	 */
	public void setLblDate(String lblDate) {
		this.lblDate = lblDate;
	}
	
	/**
	 * @param lblDayOfWeek セットする lblDayOfWeek
	 */
	public void setLblDayOfWeek(String lblDayOfWeek) {
		this.lblDayOfWeek = lblDayOfWeek;
	}
	
	/**
	 * @param hidKCode セットする hidKCode
	 */
	public void setHidKCode(String hidKCode) {
		this.hidKCode = hidKCode;
	}
	
	/**
	 * @param hidYear セットする hidYear
	 */
	public void setHidYear(String hidYear) {
		this.hidYear = hidYear;
	}
	
	/**
	 * @param hidMonth セットする hidMonth
	 */
	public void setHidMonth(String hidMonth) {
		this.hidMonth = hidMonth;
	}
	
	/**
	 * @param hidDay セットする hidDay
	 */
	public void setHidDay(String hidDay) {
		this.hidDay = hidDay;
	}
	
	/**
	 * @param hidDate セットする hidDate
	 */
	public void setHidDate(String hidDate) {
		this.hidDate = hidDate;
	}
	
	/**
	 * @param hidFormerDate セットする hidFormerDate
	 */
	public void setHidFormerDate(String hidFormerDate) {
		this.hidFormerDate = hidFormerDate;
	}
	
	/**
	 * @param hidNextDate セットする hidNextDate
	 */
	public void setHidNextDate(String hidNextDate) {
		this.hidNextDate = hidNextDate;
	}
	
	/**
	 * @param lblFormerDate セットする lblFormerDate
	 */
	public void setLblFormerDate(String lblFormerDate) {
		this.lblFormerDate = lblFormerDate;
	}
	
	/**
	 * @param lblNextDate セットする lblNextDate
	 */
	public void setLblNextDate(String lblNextDate) {
		this.lblNextDate = lblNextDate;
	}
	
	/**
	 * @param mode セットする mode
	 */
	public void setMode(int mode) {
		this.mode = mode;
	}
	
	/**
	 * @param cmdMenuButton セットする cmdMenuButton
	 */
	public void setCmdMenuButton(String cmdMenuButton) {
		this.cmdMenuButton = cmdMenuButton;
	}
	
	/**
	 * @param cmdListButton セットする cmdListButton
	 */
	public void setCmdListButton(String cmdListButton) {
		this.cmdListButton = cmdListButton;
	}
	
	/**
	 * @param namListButton セットする namListButton
	 */
	public void setNamListButton(String namListButton) {
		this.namListButton = namListButton;
	}
	
	/**
	 * @param lblOverTimeRequest セットする lblOverTimeRequest
	 */
	public void setLblOverTimeRequest(String lblOverTimeRequest) {
		this.lblOverTimeRequest = lblOverTimeRequest;
	}
	
	/**
	 * @param lblOverTimeRequestStatus セットする lblOverTimeRequestStatus
	 */
	public void setLblOverTimeRequestStatus(String lblOverTimeRequestStatus) {
		this.lblOverTimeRequestStatus = lblOverTimeRequestStatus;
	}
	
	/**
	 * @param aryHolidayRequestStatus セットする aryHolidayRequestStatus
	 */
	public void setAryHolidayRequestStatus(String[] aryHolidayRequestStatus) {
		this.aryHolidayRequestStatus = aryHolidayRequestStatus.clone();
	}
	
	/**
	 * @param isDraft セットする isDraft
	 */
	public void setDraft(boolean isDraft) {
		this.isDraft = isDraft;
	}
	
	/**
	 * @param dayOfWeekColorClass セットする dayOfWeekColorClass
	 */
	public void setDayOfWeekColorClass(String dayOfWeekColorClass) {
		this.dayOfWeekColorClass = dayOfWeekColorClass;
	}
	
	/**
	 * @param isCaution セットする isCaution
	 */
	public void setCaution(boolean isCaution) {
		this.isCaution = isCaution;
	}
	
	/**
	 * @param isWarning セットする isWarning
	 */
	public void setWarning(boolean isWarning) {
		this.isWarning = isWarning;
	}
	
}
