/***********************************************************************************
 * @@ Program Name : ReportRegistManager.java Description :보고양식을 동적, 정적 페이지에 맞게 반환해줌 Author : 강원중 Create Date :
 *    2004-11-03 History :
 * @@
 ***********************************************************************************/
package kr.co.kihyun.beans.totsys.report;

import javax.servlet.http.HttpServletRequest;

import kr.co.kihyun.beans.entity.TotDoc;
import kr.co.kihyun.moumi.doc.table.MTable;

public class ReportRegistManager {

	/********* insert form: doc, table, javascript **********/
	private int tableType = 0;
	private String insertForm = "";
	private String putValScript = "";
	private String changeAllScript = "";
	/********* insert form: item values **********/
	private String addJavaScript = "";
	private String inDataJavaScript = "";
	private String hiddenData = "";
	private String insertInputCellName = "";
	private ReportRegister reportRegister = null;

	protected ReportRegistManager(TotDoc totDoc) {
		String tableTypes;
		if (totDoc.getTotTables().isEmpty()) {
			tableTypes = "";
		} else {
			tableTypes = totDoc.getTotTables().iterator().next().getTypes();
		}

		if (tableTypes.indexOf("1") == -1) {
			tableType = MTable.STATIC;
		} else {
			tableType = MTable.DYNA;
		}
	}

	public ReportRegistManager(HttpServletRequest req, TotDoc totDoc, int rowCount) {
		this(totDoc);

		reportRegister = new DynaReportRegister(req, totDoc, rowCount);
		setInsertForm();
                reportRegister.initDes();
                reportRegister=null;
	}

	public ReportRegistManager(HttpServletRequest req, TotDoc totDoc, int rowCount, String tableRows) {
		this(totDoc);

		reportRegister = new DynaReportRegister(req, totDoc, rowCount, tableRows);
		setInsertForm();
                reportRegister.initDes();
                reportRegister=null;
	}

	private void setInsertForm() {
		insertForm = reportRegister.getInsertForm();
		reportRegister.getBaseInsertForm();
		putValScript = reportRegister.getPutValScript();
		changeAllScript = reportRegister.getChangeAllScript();

		addJavaScript = reportRegister.getAddJavaScript();
		inDataJavaScript = reportRegister.getInDataJavaScript();
		hiddenData = reportRegister.getHiddenData();
		insertInputCellName = reportRegister.getInsertInputCellName();
	}

	public int getTableType() {
		return tableType;
	}

	public String getInsertForm() {
		return insertForm;
	}

	public String getPutValScript() {
		return putValScript;
	} // 기타 입력에 관련된 자바 스크립트

	public String getChangeAllScript() {
		return changeAllScript;
	} // 계산 수식 script

	public String getAddJavaScript() {
		return addJavaScript;
	} // 계산 수식 script

	public String getInDataJavaScript() {
		return inDataJavaScript;
	} // 계산 수식 script

	public String getHiddenData() {
		return hiddenData;
	} // 계산 수식 script

	public String getInsertInputCellName() {
		return insertInputCellName;
	}
}
