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

import javax.servlet.http.HttpServletRequest;
import kr.co.kihyun.beans.entity.TotDoc;
import kr.co.kihyun.beans.entity.TotReport;
import kr.co.kihyun.beans.totsys.doc.Doc;
import kr.co.kihyun.moumi.doc.table.MTable;

public class ReportModifyManager {

    /**
     * ******* insert form: doc, table, javascript *********
     */
    private String docName = "";
    private int tableType = 0;
    private String tableTypes = "";
    private int rowCount = 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 ReportModifyer reportModifyer = null;

    public ReportModifyManager(HttpServletRequest req, TotDoc totDoc, String deptID, String userID, int rowCount) {
        /**
         * ********* Doc & Table vlaues **********
         */
        Doc doc = new Doc();
        tableType = doc.getTableType(totDoc.getId());
        tableTypes = doc.getTableTypes(totDoc.getId());

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

        reportModifyer = new DynaReportModifyer(req, totDoc, deptID, userID, rowCount);

        docName = reportModifyer.getDocName();
        setInsertForm();
        reportModifyer.initDes();
        reportModifyer = null;

    }

    public ReportModifyManager(HttpServletRequest req, TotDoc totDoc, String deptID, String userID, int rowCount,
            String tableRows) {
        /**
         * ********* Doc & Table vlaues **********
         */
        Doc doc = new Doc();
        tableType = doc.getTableType(totDoc.getId());
        tableTypes = doc.getTableTypes(totDoc.getId());

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

        reportModifyer = new DynaReportModifyer(req, totDoc, deptID, userID, rowCount, tableRows);

        docName = reportModifyer.getDocName();
        setInsertForm();
        reportModifyer.initDes();
        reportModifyer = null;
    }

/**
 * 제출자료의 ID를 조회하여 동일부서의 동일사용자가 제출한 데이타를 구분하여 처리하도록 개선 
 * 2015.02.04 jskim
**/
    public ReportModifyManager(HttpServletRequest req, TotReport totReport, TotDoc totDoc, String deptID, String userID, int rowCount,
            String tableRows) {
        /**
         * ********* Doc & Table vlaues **********
         */
        Doc doc = new Doc();
        tableType = doc.getTableType(totDoc.getId());
        tableTypes = doc.getTableTypes(totDoc.getId());

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

        reportModifyer = new DynaReportModifyer(req, totReport, totDoc, deptID, userID, rowCount, tableRows);

        docName = reportModifyer.getDocName();
        setInsertForm();
        reportModifyer.initDes();
        reportModifyer = null;
    }

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

         rowCount = getReportModifyer().getRowCount();
         addJavaScript = getReportModifyer().getAddJavaScript();
         inDataJavaScript = getReportModifyer().getInDataJavaScript();
         hiddenData = getReportModifyer().getHiddenData();
         insertInputCellName = getReportModifyer().getInsertInputCellName();
         * */
        insertForm = reportModifyer.getInsertForm();
        reportModifyer.getBaseInsertForm();
        putValScript = reportModifyer.getPutValScript();
        changeAllScript = reportModifyer.getChangeAllScript();

        rowCount = reportModifyer.getRowCount();
        addJavaScript = reportModifyer.getAddJavaScript();
        inDataJavaScript = reportModifyer.getInDataJavaScript();
        hiddenData = reportModifyer.getHiddenData();
        insertInputCellName = reportModifyer.getInsertInputCellName();

    }

    public String getDocName() {
        return docName;
    }

    public int getTableType() {
        return tableType;
    }

    public String getTableTypes() {
        return tableTypes;
    }

    public int getRowCount() {
        return rowCount;
    }

    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;
    }

    /**
     * @return the reportModifyer
     *
     * public ReportModifyer getReportModifyer() { return reportModifyer; }
     */
    /**
     * @param reportModifyer the reportModifyer to set
     */
    public void setReportModifyer(ReportModifyer reportModifyer) {
        this.reportModifyer = reportModifyer;
    }
}
