/*
 * MosP - Mind Open Source Project         http://www.mosp.jp/
 * Copyright (C) 1987-2009 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.payroll.common.vo;



import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import jp.mosp.common.common.MospConst;
import jp.mosp.common.common.MospException;
import jp.mosp.payroll.base.PayrollConst;
import jp.mosp.payroll.base.PayrollVo;

public class FirmBankingOutputVo extends PayrollVo{
	private static final long serialVersionUID = 3281945937471826907L;
	
	// URL、CSS
	private static final String RETURN_URL = "/jsp/payroll/common/firmBankingOutput.jsp";
	private static final String EXTRA_JS   = "/pub/payroll/common/js/firmBankingOutput.js";
	private static final String EXTRA_CSS  = "/pub/payroll/common/css/firmBankingOutput.css";
	
	// 画面サブタイトル
	public final String SUB_TITLE = PayrollConst.TTL_FIRM_BANKING;
	
	public static final String PRM_PLT_OUTPUT_DETAIL  = "pltOutputDetail" ;	// 出力内容
	public static final String PRM_PLT_SPECIFY_YEAR   = "pltSpecifyYear"  ;	// 指定年月(年)
	public static final String PRM_PLT_SPECIFY_MONTH  = "pltSpecifyMonth" ;	// 指定年月(月)
	public static final String PRM_PLT_SPECIFY_DAY    = "pltSpecifyDay"   ;	// 指定年月(日)
	public static final String PRM_PLT_CODE_TYPE      = "pltCodeType"     ;	// コード区分 
	public static final String PRM_PLT_RECORD_TYPE    = "pltRecordType"   ;	// レコード区分区切
	public static final String PRM_PLT_END_RECORD     = "pltEndRecord"    ;	// エンドレコード区分区切
	public static final String PRM_PLT_DEADLINE_YEAR  = "pltDeadlineYear" ;	// 納期限(年)
	public static final String PRM_PLT_DEADLINE_MONTH = "pltDeadlineMonth";	// 納期限(月)
	public static final String PRM_PLT_DEADLINE_DAY   = "pltDeadlineDay"  ;	// 納期限(日)
	public static final String PRM_PLT_COBANK_CODE    = "pltCobankCode"   ;	// 会社銀行コード
	
	public static final String PRM_TXT_COMPANY_CODE   = "txtCompanyCode"  ;	// 会社コード
	public static final String PRM_TXT_RECORD_LENGTH  = "txtRecordLength" ;	// レコード長
	public static final String PRM_TXT_TYPE_CODE      = "txtTypeCode"     ;	// 種別コード
	public static final String PRM_TXT_CO_ADDRESS     = "txtCoAddress"    ;	// 会社住所
	public static final String PRM_TXT_COMPANY_NAME   = "txtCompanyName"  ;	// 会社名
	
	
	public final String CMD_MENU_PAYROLL = "P1910";
	
	// 定数
	public static final int MODE_SHOW = 0;
	public static final int MODE_SELECT = 1;
	
	// モード(0：表示、1：検索)
	private int mode;

	
	// フィールド
	private String pltOutputDetail ;
	private String pltSpecifyYear  ;
	private String pltSpecifyMonth ;
	private String pltSpecifyDay   ;
	private String pltCodeType     ;
	private String pltRecordType   ;
	private String pltEndRecord    ;
	private String pltDeadlineYear ;
	private String pltDeadlineMonth;
	private String pltDeadlineDay  ;
	private String pltCoBankCode   ;

	private String txtCompanyCode  ;
	private String txtRecordLength ;
	private String txtTypeCode     ;
	private String txtCoAddress    ;
	private String txtCompanyName  ;
	
	private String key1;
	
	// フィールド名及び制限
	public static final String NAM_OUTPUT_DETAIL = PayrollConst.NAM_OUTPUT_DETAIL    ;
	public static final String NAM_SPECIFY_MONTH = PayrollConst.NAM_SPECIFY_MONTH    ;
	public static final String NAM_PAYDAY       = PayrollConst.NAM_PAYDAY            ;
	public static final String NAM_CO_BANK_CODE   = PayrollConst.NAM_CO_BANK_CODE    ;
	public static final String NAM_COMPANY_CODE  = PayrollConst.NAM_COMPANY_CODE     ;
	public static final String NAM_RECORD_LENGTH = PayrollConst.NAM_RECORD_LENGTH    ;
	public static final String NAM_TYPE_CODE     = PayrollConst.NAM_TYPE_CODE        ;
	public static final String NAM_CODE_TYPE     = PayrollConst.NAM_CODE_TYPE        ;
	public static final String NAM_RECORD_TYPE   = PayrollConst.NAM_RECORD_TYPE      ;
	public static final String NAM_END_RECORD    = PayrollConst.NAM_END_RECORD       ;
	public static final String NAM_DEADLINE_DATE = PayrollConst.NAM_DEADLINE_DATE    ;
	public static final String NAM_CO_ADDRESS    = PayrollConst.NAM_CO_ADDRESS       ;
	public static final String NAM_COMPANY_NAME  = PayrollConst.NAM_COMPANY_NAME     ;

	public static final int LEN_FB_COMPANY_CODE  = PayrollConst.LEN_FB_COMPANY_CODE ;
	public static final int LEN_FB_RECORD_LENGTH = PayrollConst.LEN_FB_RECORD_LENGTH;
	public static final int LEN_FB_TYPE_CODE     = PayrollConst.LEN_FB_TYPE_CODE    ;

	public static final int LEN_FB_CO_ADDRESS    = PayrollConst.LEN_FB_CO_ADDRESS   ;
	public static final int LEN_FB_COMPANY_NAME  = PayrollConst.LEN_FB_COMPANY_NAME ;

	
	// プルダウンリスト
	public String[][] aryPltOutputDetail ;
	public String[][] aryPltSpecifyYear  ;
	public String[][] aryPltSpecifyMonth ;
	public String[][] aryPltSpecifyDay   ;
	public String[][] aryPltCodeType     ;
	public String[][] aryPltRecordType   ;
	public String[][] aryPltEndRecord    ;
	public String[][] aryPltDeadlineYear ;
	public String[][] aryPltDeadlineMonth;
	public String[][] aryPltDeadlineDay  ;
	public String[][] aryPltCoBankCode   ;
	
	//	 フィールド
	Date calcDate;

	
	// パラメータ名
	
	/**
	 * コンストラクタ
	 */
	public FirmBankingOutputVo() {
		super();
		setRetUrl(RETURN_URL);
		setExtraJs(EXTRA_JS);
		setExtraCss(EXTRA_CSS);
	}
	
	/**
	 * パラメータ設定
	 */
	public void setParams(HttpServletRequest request) {
		pltOutputDetail = request.getParameter(PRM_PLT_OUTPUT_DETAIL );
		pltSpecifyYear  = request.getParameter(PRM_PLT_SPECIFY_YEAR  );
		pltSpecifyMonth = request.getParameter(PRM_PLT_SPECIFY_MONTH );
		pltSpecifyDay   = request.getParameter(PRM_PLT_SPECIFY_DAY   );
		pltCodeType     = request.getParameter(PRM_PLT_CODE_TYPE     );
		pltRecordType   = request.getParameter(PRM_PLT_RECORD_TYPE   );
		pltEndRecord    = request.getParameter(PRM_PLT_END_RECORD    );
		pltDeadlineYear = request.getParameter(PRM_PLT_DEADLINE_YEAR );
		pltDeadlineMonth= request.getParameter(PRM_PLT_DEADLINE_MONTH);
		pltDeadlineDay  = request.getParameter(PRM_PLT_DEADLINE_DAY  );
		pltCoBankCode   = request.getParameter(PRM_PLT_COBANK_CODE   );

		txtCompanyCode  = request.getParameter(PRM_TXT_COMPANY_CODE  );
		txtRecordLength = request.getParameter(PRM_TXT_RECORD_LENGTH );
		txtTypeCode     = request.getParameter(PRM_TXT_TYPE_CODE     );
		txtCoAddress    = request.getParameter(PRM_TXT_CO_ADDRESS    );
		txtCompanyName  = request.getParameter(PRM_TXT_COMPANY_NAME  );
	}

	/**
	 * フィールドの妥当性確認
	 * @throws MospException
	 */
	public void validate() throws MospException {
		// 妥当性確認開始時処理
		startValidation();
		// 必須確認
		// カナ確認
		// 種別コード必須確認
		checkRequired(txtTypeCode    , NAM_TYPE_CODE    , PRM_TXT_TYPE_CODE );
		// 会社コード必須確認
		checkRequired(txtCompanyCode , NAM_COMPANY_CODE , PRM_TXT_COMPANY_CODE );
		// 会社住所必須確認
		checkRequired(txtCoAddress   , NAM_CO_ADDRESS   , PRM_TXT_CO_ADDRESS );
		// 会社カナ必須確認
		checkRequired(txtCompanyName , NAM_COMPANY_NAME , PRM_TXT_COMPANY_NAME );
		// レコード長必須確認
		checkRequired(txtRecordLength, NAM_RECORD_LENGTH, PRM_TXT_RECORD_LENGTH );
		// 種別コード数値確認
		checkNumeric(txtTypeCode     , NAM_TYPE_CODE    , PRM_TXT_TYPE_CODE );
		// 会社コード数値確認
		checkNumeric(txtCompanyCode  , NAM_COMPANY_CODE , PRM_TXT_COMPANY_CODE );
		// レコード長数値確認
		checkNumeric(txtRecordLength , NAM_RECORD_LENGTH, PRM_TXT_RECORD_LENGTH );
		// 妥当性確認終了時処理
		endValidation();
	}
	
	/**
	 * 計算年月を取得する。
	 * @return 計算年月
	 */
	public Date getCalcDate() {
		return getDateField(calcDate);
	}

	/**
	 * 計算年月を設定する。
	 * @param calcDate 設定する計算年月
	 */
	public void setCalcDate(Date calcDate) {
		this.calcDate = getDateField(calcDate);
	}
	
	/**
	 * サブタイトル取得
	 * @param subTitle サブタイトル
	 * @param cmdMenu  メニューコマンド
	 * @return サブタイトルHTML文字列
	 */
	public String getSubTitle(String subTitle, String cmdMenu) {
		String buttonName = "給与計算メニューへ";
		String cmd = "P1001";
		if (getFirmBankOutputType().equals("1")) {
			buttonName = "賞与計算へ";
			cmd = "P2001";
		}
		StringBuffer sb = new StringBuffer();
		sb.append("<div class=\"Header\">");
		sb.append("<div class=\"MenuButtonBar\">");
		sb.append("<button type=\"button\" ");
		sb.append("onclick=\"doSubmit(document.form, '");
		sb.append(cmd);
		sb.append("')\">" + buttonName + "</button>");
		sb.append("<button type=\"button\" ");
		sb.append("onclick=\"doSubmit(document.form, '");
		sb.append(cmdMenu);
		sb.append("')\">メニューへ</button>");
		sb.append("<button type=\"button\" id=\"btnLogout\" ");
		sb.append("onclick=\"doSubmit(document.form, '");
		sb.append(MospConst.CMD_LOGOUT);
		sb.append("')\">ログアウト</button>");
		sb.append("</div>");
		sb.append("<div class=\"SubTitleBar\">");
		sb.append(subTitle);
		sb.append("</div>");
		sb.append("</div>");
		return sb.toString();
	}
	
	/**
	 * JavaScript設定
	 * @param cls 情報取得クラス
	 * @throws IllegalAccessException
	 */
	@Override
	public String getDirectJs(Class cls) throws IllegalAccessException {
		StringBuffer sb = new StringBuffer();
		sb.append(super.getDirectJs(cls));
		sb.append("var MODE = ");
		sb.append(mode);
		sb.append(";");
		return sb.toString();
	}

	// アクセサメソッド
	public String getPltOutputDetail () { return pltOutputDetail ; }
	public String getPltSpecifyYear  () { return pltSpecifyYear  ; }
	public String getPltSpecifyMonth () { return pltSpecifyMonth ; }
	public String getPltSpecifyDay   () { return pltSpecifyDay   ; }
	public String getPltCodeType     () { return pltCodeType     ; }
	public String getPltRecordType   () { return pltRecordType   ; }
	public String getPltEndRecord    () { return pltEndRecord    ; }
	public String getPltDeadlineYear () { return pltDeadlineYear ; }
	public String getPltDeadlineMonth() { return pltDeadlineMonth; }
	public String getPltDeadlineDay  () { return pltDeadlineDay  ; }
	public String getPltCoBankCode   () { return pltCoBankCode   ; }

	public String getTxtCompanyCode  () { return txtCompanyCode  ; }
	public String getTxtRecordLength () { return txtRecordLength ; }
	public String getTxtTypeCode     () { return txtTypeCode     ; }
	public String getTxtCoAddress     () { return txtCoAddress     ; }
	public String getTxtCompanyName   () { return txtCompanyName   ; }

	public String getEscTxtCompanyCode  () { return escapeHTML(txtCompanyCode  ); }
	public String getEscTxtRecordLength () { return escapeHTML(txtRecordLength ); }
	public String getEscTxtTypeCode     () { return escapeHTML(txtTypeCode     ); }
	public String getEscTxtCoAddress    () { return escapeHTML(txtCoAddress    ); }
	public String getEscTxtCompanyName  () { return escapeHTML(txtCompanyName  ); }
	
	public String getFirmBankOutputType () { return key1; }
	
	public void setPltOutputDetail (String pltOutputDetail  ) { this.pltOutputDetail  = pltOutputDetail ; }
	public void setPltSpecifyYear  (String pltSpecifyYear   ) { this.pltSpecifyYear   = pltSpecifyYear  ; }
	public void setPltSpecifyMonth (String pltSpecifyMonth  ) { this.pltSpecifyMonth  = pltSpecifyMonth ; }
	public void setPltSpecifyDay   (String pltSpecifyDay    ) { this.pltSpecifyDay    = pltSpecifyDay   ; }
	public void setPltCodeType     (String pltCodeType      ) { this.pltCodeType      = pltCodeType     ; }
	public void setPltRecordType   (String pltRecordType    ) { this.pltRecordType    = pltRecordType   ; }
	public void setPltEndRecord    (String pltEndRecord     ) { this.pltEndRecord     = pltEndRecord    ; }
	public void setPltDeadlineYear (String pltDeadlineYear  ) { this.pltDeadlineYear  = pltDeadlineYear ; }
	public void setPltDeadlineMonth(String pltDeadlineMonth ) { this.pltDeadlineMonth = pltDeadlineMonth; }
	public void setPltDeadlineDay  (String pltDeadlineDay   ) { this.pltDeadlineDay   = pltDeadlineDay  ; }
	public void setPltCoBankCode   (String pltCoBankCode    ) { this.pltCoBankCode    = pltCoBankCode   ; }

	public void setTxtCompanyCode  (String txtCompanyCode   ) { this.txtCompanyCode   = txtCompanyCode  ; }
	public void setTxtRecordLength (String txtRecordLength  ) { this.txtRecordLength  = txtRecordLength ; }
	public void setTxtTypeCode     (String txtTypeCode      ) { this.txtTypeCode      = txtTypeCode     ; }
	public void setTxtCoAddress    (String txtCoAddress     ) { this.txtCoAddress     = txtCoAddress    ; }
	public void setTxtCompanyName  (String txtCompanyName   ) { this.txtCompanyName   = txtCompanyName  ; }
	
	public void setFirmBankOutputType (String key1) { this.key1 = key1 ;}
	
	public void setMode(int mode) { this.mode = mode; }
	public int getMode() { return mode; }


}
