<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>

<!-- Page Body -->
<div class="content-pop" data-doctx="${pageName}">
    <!-- 입력 영역 -->
    <form name="frmOpnn">
        <!-- hidden -->
        <input type="hidden" name="opnnId" data-map="OPNN_ID" />

        <div class="d-flex flex-row justify-content-evenly">
            <!-- 의견제출 정보 -->
            <div class="col-xl-9 mx-1">
                <div class="card">
                    <!-- 업무 버튼 -->
                    <div class="container-page-btn">
                        <label class="col-form-label bg-label-danger pe-2 w-px-120 text-sm-center">의견제출 정보</label>
                        <!-- 버튼 우측 정렬 -->
                        <span class="container-window-btn-right">
                            <button type="button" class="btn btn-primary w-px-120" name="btnCreateOpnnSbmsn" title="의견제출 등록" disabled>
                                의견제출 등록
                            </button>
                            <button type="button" class="btn btn-primary w-px-120" name="btnUpdateOpnnSbmsn" title="의견제출 수정" disabled>
                                의견제출 수정
                            </button>
                            <button type="button" class="btn btn-primary w-px-120" name="btnRemoveOpnnSbmsn" title="의견제출 삭제" disabled>
                                의견제출 삭제
                            </button>
                            <button type="button" class="btn btn-primary w-px-120" name="btnPrintDlbrDecsn" title="심의의결서 출력" disabled>
                                심의의결서 출력
                            </button>
                        </span> <!-- <span class="container-window-btn-right"> -->
                    </div> <!-- <div class="container-page-btn"> -->

                    <div class="row g-1">
                        <div class="col-md-4">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="rcptNoMask">접수번호</label>
                            <input is="id-input" type="text" class="form-control w-35" name="rcptNoMask" data-map="RCPT_NO_MASK" readonly />
                        </div>
                        <div class="col-md-4">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="rcptYmd">접수일자</label>
                            <input is="id-input" type="text" class="form-control w-30" name="rcptYmd" data-map="RCPT_YMD" data-fmt-type="day" readonly />
                        </div>
                        <div class="col-md-4">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="rcptSeNm">접수구분</label>
                            <input is="id-input" type="text" class="form-control w-35" name="rcptSeNm" data-map="RCPT_SE_NM" readonly />
                        </div>
                        <div class="col-md-4">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="sttrNm">성명</label>
                            <input is="id-input" type="text" class="form-control w-35" name="sttrNm" data-map="STTR_NM" readonly />
                        </div>
                        <div class="col-md-4">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="sttrBrdtMask">생년월일</label>
                            <input is="id-input" type="text" class="form-control w-30" name="sttrBrdtMask" data-map="STTR_BRDT_MASK" readonly />
                        </div>
                        <div class="col-md-4">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="ownrRelNm">소유주관계</label>
                            <input is="id-input" type="text" class="form-control w-35" name="ownrRelNm" data-map="OWNR_REL_NM" readonly />
                        </div>
                        <div class="col-md-12">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="sttrAddr">주소</label>
                            <input is="id-input" type="text" class="form-control w-80" name="sttrAddr" data-map="STTR_ADDR" readonly />
                            <input is="id-input" type="text" class="form-control w-px-75" name="sttrZip" data-map="STTR_ZIP" readonly />
                        </div>
                        <div class="col-md-12">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="sttrDaddr">상세주소</label>
                            <input is="id-input" type="text" class="form-control w-87" name="sttrDaddr" data-map="STTR_DADDR" readonly />
                        </div>
                        <div class="col-md-4">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="sttrCttpc">연락처</label>
                            <input is="id-input" type="text" class="form-control w-35" name="sttrCttpc" data-map="STTR_CTTPC" readonly />
                        </div>
                        <div class="col-md-8">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="sttrEml">이메일</label>
                            <input is="id-input" type="text" class="form-control w-35" name="sttrEml" data-map="STTR_EML" readonly />
                        </div>
                        <div class="col-md-12">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end align-top" for="opnnSbmsnCn">의견제출내용</label>
                            <textarea is="id-textarea" type="text" class="form-control w-87" name="opnnSbmsnCn" data-map="OPNN_SBMSN_CN" rows="4" data-maxlengthb="4000" readonly></textarea>
                        </div>
                        <div class="col-md-4">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="opnnSbmsnSeNm">의견제출구분</label>
                            <input is="id-input" type="text" class="form-control w-55" name="opnnSbmsnSeNm" data-map="OPNN_SBMSN_SE_NM" readonly />
                        </div>
                        <div class="col-md-8">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="opnnSbmsnGist">의견제출요지</label>
                            <input is="id-input" type="text" class="form-control w-80" name="opnnSbmsnGist" data-map="OPNN_SBMSN_GIST" data-maxlengthb="300" readonly />
                        </div>
                        <div class="col-md-12">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end align-top" for="picRvwOpnn">검토의견</label>
                            <textarea is="id-textarea" type="text" class="form-control w-87" name="picRvwOpnn" data-map="PIC_RVW_OPNN" rows="2" data-maxlengthb="1000" readonly></textarea>
                        </div>
                        <div class="col-md-6">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="regDt">등록일시</label>
                            <input is="id-input" type="text" class="form-control w-30" name="regDt" data-map="REG_DT" data-fmt-type="dt" readonly />
                            <input is="id-input" type="text" class="form-control w-25" name="rgtrNm" data-map="RGTR_NM" readonly />
                        </div>
                        <div class="col-md-6">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="mdfcnDt">수정일시</label>
                            <input is="id-input" type="text" class="form-control w-30" name="mdfcnDt" data-map="MDFCN_DT" data-fmt-type="dt" readonly />
                            <input is="id-input" type="text" class="form-control w-25" name="mdfrNm" data-map="MDFR_NM" readonly />
                        </div>
                        <!-- 첨부 파일 테이블 -->
                        <div class="table-responsive">
                            <table class="table table-bordered table-hover table-striped" name="fileList">
                                <thead>
                                    <th class="text-center" style="width: 24px">No.</th>
                                    <th class="text-center" style="width: 200px">파일번호</th>
                                    <th class="text-center">파일이름</th>
                                    <th class="text-center" style="width: 200px">파일크기</th>
                                    <th class="text-center" style="width: 120px">다운로드</th>
                                </thead>
                                <tbody name="tbodyFileList">
                                </tbody>
                            </table>
                        </div> <!-- 첨부 파일 테이블 <div class="table-responsive"> -->
                    </div> <!-- <div class="row g-1"> -->
                </div> <!-- <div class="card"> -->
            </div> <!-- <div class="col-xl-9 mx-1"> -->
            <!-- 의견제출 정보 -->

            <!-- 심의 정보 -->
            <div class="col-xl-3 mx-0">
                <div class="card">
                    <!-- 업무 버튼 -->
                    <div class="container-page-btn">
                        <label class="w-px-120 bg-label-danger pe-2 col-form-label text-sm-center">심의 정보</label>
                        <!-- 버튼 우측 정렬 -->
                        <span class="container-window-btn-right">
                            <button type="button" class="btn btn-primary w-px-120" name="btnUpdateOpnnSbmsnDlbrt" title="심의" disabled>
                                의견제출 심의
                            </button>
                        </span>
                    </div> <!-- <div class="container-page-btn"> -->

                    <div class="row g-1">
                        <div class="col-md-12">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="docNo">문서번호</label>
                            <input is="id-input" type="text" class="form-control w-45" name="docNo" data-map="DOC_NO" readonly />
                        </div>
                        <div class="col-md-12">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="ntfctnSeNm">통보구분</label>
                            <input is="id-input" type="text" class="form-control w-30" name="ntfctnSeNm" data-map="NTFCTN_SE_NM" readonly />
                        </div>
                        <div class="col-md-12">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="opnnSbmsnSttsNm">심의결과</label>
                            <input is="id-input" type="text" class="form-control w-30" name="opnnSbmsnSttsNm" data-map="OPNN_SBMSN_STTS_NM" readonly />
                            <input is="id-input" type="hidden" name="opnnSbmsnSttsCd" data-map="OPNN_SBMSN_STTS_CD" />
                        </div>
                        <div class="col-md-12">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="ansYmdTm">심의일시</label>
                            <input is="id-input" type="text" class="form-control w-45" name="ansYmdTm" data-map="ANS_YMD_TM" data-fmt-type="dt" readonly />
                        </div>
                        <div class="col-md-12">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="ansCn">심의내용</label>
                        </div>
                        <div class="col-md-12">
                            <textarea is="id-textarea" type="text" class="form-control w-100" name="ansCn" data-map="ANS_CN" rows="14" data-maxlengthb="4000"></textarea>
                        </div>
                    </div>
                </div> <!-- <div class="card"> -->
            </div> <!-- <div class="col-xl-3 mx-0"> -->
            <!-- 심의 정보 -->
        </div> <!-- <div class="d-flex flex-row justify-content-evenly"> -->
    </form>
    <!-- 입력 영역 -->
</div> <!-- <div class="content-pop"> -->

<script>
    LoadScript("sprt02030Script", wctx.url("/resources/js/fims/sprt/sprt02030.js?ver=${ver}"));

    /**************************************************************************
     * Global Variable
     **************************************************************************/
    pageObject["${pageName}"] = newDoctxFinder("${pageName}");

    /**************************************************************************
     * script 진입
     **************************************************************************/
    $(document).ready(function() {
        // pageObject
        let $P = pageObject["${pageName}"];

        // datasetControl
        $P.ctrlOpnn = newSprt02030Control("${pageName}", "[data-doctx=${pageName}]", "${pageNameMain}");
        // 파일 리스트
        $P.fileListArr = new Array();

        /**************************************************************************
         * 사용자 함수(function)
         **************************************************************************/
        // 심의 dialog
        $P.getOpnnSbmsnDlbrtInfo = (params) => {
            if (!params) return;

            ajax.get({
                  url: wctx.url("/excl/excl02/030/info.do")
                , data: params || {}
                , success: (resp) => {
                    let dialogName = $P.ctrlOpnn.prefixed("DlbrDialog");
                    let dialogId = dialogName + "-" + uuid();

                    dialog.open({
                          id: dialogId
                        , title: $P.ctrlOpnn.prefixName + " 정보 " + params.btnTitle
                        , size: "lg"
                        , content: resp
                        , init: () => {
                            $("#" + dialogId).attr("name", dialogName);
                            $("#" + dialogId).attr("data-ref-doctx", "${pageName}");

                            AppSupport.setDialogZindex();
                        }
                        , onClose: () => { $P.fnRefresh(); }                    // 정보 새로고침
                    });
                }
            });
        }

        // 삭제 사유 callback
        $P.callbackRsn = (obj) => {
            // 서버에 전송할 data(파라미터) 생성
            let params = {
                  callPurpose: "remove"
                , sggCd: $P.ctrlOpnn.getValue("SGG_CD")                         // 시군구 코드
                , taskSeCd: $P.ctrlOpnn.getValue("TASK_SE_CD")                  // 업무 구분 코드
                , opnnId: $P.ctrlOpnn.getValue("OPNN_ID")                       // 의견제출 ID
                , btnTitle: obj.btnTitle                                        // 버튼 title
                , delRsn: "[개별총정보-" + obj.btnTitle + "] " + obj.reason     // 삭제 사유
            };

            $P.ctrlOpnn.remove(params);
        }

        // 심의의결서 출력
        $P.makeHwpFileDlbrDecsn = (params) => {
            if (!params) return;

            let url = wctx.url("/excl/excl02/010/makeHwp.do")

            let parameter = toQuery({
                  opnnIds: params.opnnIds
                , taskSeCd: params.taskSeCd
            });

            document.location.href = url + "?" + parameter;
        }

        // 정보 새로고침
        $P.fnRefresh = () => {
            let ctrlMain = pageObject["${pageNameMain}"].ctrlMain;

            // 단속 ID 가 없다면.. return
            let crdnId = ctrlMain.getValue("CRDN_ID");                          // 단속 ID
            if (!crdnId) return;

            let params = {
                  callPurpose: "refresh"
                , sggCd: ctrlMain.getValue("SGG_CD")
                , taskSeCd: ctrlMain.getValue("TASK_SE_CD")
                , crdnId: ctrlMain.getValue("CRDN_ID")
                , delYn: "N"
            };

            ajax.get({
                  url: wctx.url("/sprt/sprt02/030/info.do")
                , headers: { Accept: "application/json; charset=utf-8" }        // json
                , data: params || {}
                , success: (resp) => {
                    // 초기화
                    $P.findn("frmOpnn").reset();                                // 의견진술 화면 초기화
                    $P.ctrlOpnn.dataset.clear();                                // 의견진술 Dataset 초기화

                    // sprt02010-main 단속 정보
                    ctrlMain.setData([resp.totalInfo]);

                    // 의견진술 정보
                    if (resp.opnnInfo) { $P.ctrlOpnn.setData([resp.opnnInfo]); }
                }
            });
        }

        /**************************************************************************
         * 버튼 clickEvent
         **************************************************************************/
        // 의견제출 등록 버튼 이벤트
        $P.fnCreateOpnnSbmsn = (btnTitle) => {
            // 의견제출 ID가 있다면.. return
            let opnnId = $P.ctrlOpnn.getValue("OPNN_ID");                       // 의견제출 ID
            if (opnnId)
                return dialog.alert({
                      content: "이미 등록된 의견제출 대장 정보가 있습니다."
                            + "<br><br>" + "[" + btnTitle + "]" + " 실행이 취소되었습니다."
                    , init: () => { AppSupport.setDialogZindex(); }
                    , onOK: () => { }
                });

        	// 단속 ID 가 없다면.. return
            let ctrlMain = pageObject["${pageNameMain}"].ctrlMain;              // sprt02010 control
            let crdnId = ctrlMain.getValue("CRDN_ID");                          // 단속 ID
            if (!crdnId) return;

            let params = {
                  callPurpose: "create"
                , btnTitle: btnTitle
                , sggCd: ctrlMain.getValue("SGG_CD")                            // 시군구 코드
                , taskSeCd: ctrlMain.getValue("TASK_SE_CD")                     // 업무 구분 코드
                , crdnId: ctrlMain.getValue("CRDN_ID")                          // 단속 ID
                , delYn: "N"
            };

            $P.ctrlOpnn.getInfo(params);
        }

        // 의견제출 수정 버튼 이벤트
        $P.fnUpdateOpnnSbmsn = (btnTitle) => {
            // 의견제출 ID 가 없다면.. return
            let opnnId = $P.ctrlOpnn.getValue("OPNN_ID");                       // 의견제출 ID
            if (!opnnId)
                return dialog.alert({
                      content: "조회된 의견제출 대장 정보가 없습니다."
                            + "<br><br>" + "[" + btnTitle + "]" + " 실행이 취소되었습니다."
                    , init: () => { AppSupport.setDialogZindex(); }
                    , onOK: () => { }
                });

            let params = {
                  callPurpose: "update"
                , btnTitle: btnTitle
                , sggCd: $P.ctrlOpnn.getValue("SGG_CD")                         // 시군구 코드
                , taskSeCd: $P.ctrlOpnn.getValue("TASK_SE_CD")                  // 업무 구분 코드
                , crdnId: $P.ctrlOpnn.getValue("CRDN_ID")                       // 단속 ID
                , opnnId: $P.ctrlOpnn.getValue("OPNN_ID")                       // 의견제출 ID
                , delYn: "N"
            };

            $P.ctrlOpnn.getInfo(params);
        }

        // 의견제출 삭제 버튼 이벤트
        $P.fnRemoveOpnnSbmsn = (btnTitle) => {
            // 의견제출 ID 가 없다면.. return
            let opnnId = $P.ctrlOpnn.getValue("OPNN_ID");                       // 의견제출 ID
            if (!opnnId)
                return dialog.alert({
                      content: "조회된 의견제출 대장 정보가 없습니다."
                            + "<br><br>" + "[" + btnTitle + "]" + " 실행이 취소되었습니다."
                    , init: () => { AppSupport.setDialogZindex(); }
                    , onOK: () => { }
                });

            // 의견제출 상태 코드
            let opnnSbmsnSttsCd = $P.ctrlOpnn.getValue("OPNN_SBMSN_STTS_CD");
            let opnnSbmsnSttsNm = $P.ctrlOpnn.getValue("OPNN_SBMSN_STTS_NM");

            // 의견제출 상태 코드 확인
            if (opnnSbmsnSttsCd != '00' && opnnSbmsnSttsCd != '03')
            	return dialog.alert({
                      content: "[" + btnTitle + "]" + " 작업은 심의결과가 '접수', '자진취하' 자료만 삭제 가능합니다."
                            + "<br>" + "심의결과 : " + opnnSbmsnSttsNm
                            + "<br><br>" + "[" + btnTitle + "]" + " 실행이 취소되었습니다."
                    , init: () => { AppSupport.setDialogZindex(); }
                    , onOK: () => { }
                });

            // 삭제 메세지 확인
            dialog.alert({
                  content: "선택하신 " + $P.ctrlOpnn.prefixName + " 정보를 삭제하시겠습니까?"
                , onOK: () => {
                    // 삭제 사유 입력
                    fetch(wctx.url("/resources/html/inputRsnDialog.html"))
                        .then(function(resp) { return resp.text(); })
                        .then(function(template) {
                            dialog.open({
                                  id: "inputDelRsnDialog"
                                , title: btnTitle
                                , size: "lg"
                                , content: template
                                , init: () => { AppSupport.setDialogZindex(); }
                                , onOK: () => {
                                    $P.callbackRsn({
                                          btnTitle: btnTitle                    // 버튼 title
                                        , reason: $("#reason").val()            // 삭제 사유
                                    });
                                }
                            });
                        });
                }
            });
        }

        // 심의의결서 출력 버튼 이벤트
        $P.fnPrintDlbrDecsn = (btnTitle) => {
            let opnnId = $P.ctrlOpnn.getValue("OPNN_ID");                       // 의견제출 ID
            if (!opnnId)
            	return dialog.alert({
                      content: "조회된 의견제출 대장 정보가 없습니다."
                            + "<br><br>" + "[" + btnTitle + "]" + " 실행이 취소되었습니다."
                    , init: () => { AppSupport.setDialogZindex(); }
                    , onOK: () => { }
                });

            let params = {
                  callPurpose: "download"
                , btnTitle: btnTitle
                , sggCd: $P.ctrlOpnn.getValue("SGG_CD")                         // 시군구 코드
                , taskSeCd: $P.ctrlOpnn.getValue("TASK_SE_CD")                  // 업무 구분 코드
                , opnnIds: $P.ctrlOpnn.getValue("OPNN_ID")                      // 의견제출 ID
            };

            $P.makeHwpFileDlbrDecsn(params);
        }

        // 의견제출 심의 버튼 이벤트
        $P.fnUpdateOpnnSbmsnDlbrt = (btnTitle) => {
            let opnnId = $P.ctrlOpnn.getValue("OPNN_ID");                       // 의견제출 ID

            // 의견제출 ID 가 없다면.. return
            if (typeof opnnId == "undefined" || opnnId == null || opnnId == "") {
                dialog.alert({
                      content: "조회된 의견제출 대장 정보가 없습니다."
                            + "<br><br>" + "[" + btnTitle + "]" + " 실행이 취소되었습니다."
                    , init: () => { AppSupport.setDialogZindex(); }
                    , onOK: () => { }
                });
                return;
            }

            // 단속 상태 코드
            let crdnSttsCd = $P.ctrlOpnn.getValue("CRDN_STTS_CD");
            let crdnSttsNm = $P.ctrlOpnn.getValue("CRDN_STTS_NM");

            // 단속 상태 코드 확인
            if ( (Number(crdnSttsCd) != 82 && Number(crdnSttsCd) != 87) && (Number(crdnSttsCd) < 21 || Number(crdnSttsCd) > 45) )
            	return dialog.alert({
                      content: "[" + btnTitle + "]" + " 작업은 단속상태가 '의견제출수용', '경찰서이첩', '부과 이전' 자료만 처리 가능합니다."
                            + "<br>" + "단속상태 : " + crdnSttsNm
                            + "<br><br>" + "[" + btnTitle + "]" + " 실행이 취소되었습니다."
                    , init: () => { AppSupport.setDialogZindex(); }
                    , onOK: () => { }
                });

            let params = {
                  callPurpose: "update"
                , btnTitle: btnTitle
                , sggCd: $P.ctrlOpnn.getValue("SGG_CD")                         // 시군구 코드
                , taskSeCd: $P.ctrlOpnn.getValue("TASK_SE_CD")                  // 업무 구분 코드
                , opnnId: $P.ctrlOpnn.getValue("OPNN_ID")                       // 의견제출 ID
            };

            $P.getOpnnSbmsnDlbrtInfo(params);
        }

        // 첨부파일 조회
        $P.fnSearchFileList = (opnnId) => {
            let tableFileList = $P.findn("fileList");                           // table element 찾기
            let fileLength = tableFileList.rows.length;

            // 기존 table에 자료가 존재하면 tableRow 삭제
            for (let iLoop = 1; iLoop < fileLength; iLoop++) {
                tableFileList.deleteRow(1);                                     // table 행(Row) 삭제
            }

            // 의견제출 ID 가 없다면 첨부파일을 조회하지 않는다..
            if (!opnnId) return;

            // 첨부파일 리스트
            ajax.get({
                  url: "file/list.do"
                , data: {
                      infoType: "110"
                    , infoKeys: opnnId
                    , fetchSize: 0
                }
                , success: (resp) => {
                    let fileNo = 0;
                    let fileList = resp.fileList;

                    fileList.forEach(function (item, index, array) {
                        fileNo = index + 1;

                        let innerHtml = "";
                        innerHtml += "<tr>";
                        innerHtml += "<td class='text-center'>" + fileNo + "</td>";
                        innerHtml += "<td class='text-center'>" + item.FILE_ID + "</td>";
                        innerHtml += "<td class='text-center'>" + item.FILE_NM + "</td>";
                        innerHtml += "<td class='text-center'>" + item.FILE_SIZE + " byte</td>";
                        innerHtml += "<td class='text-center'>" + "<button type='button' class='btn' onclick=";
                        innerHtml += "pageObject['${pageName}'].fnFileDownload(" + item.FILE_ID + ");" + "><i class='bx bx-download me-1'></i></button>" + "</td>";
                        innerHtml += "</tr>";

                        $P.$findn("tbodyFileList").append(innerHtml);
                    });
                }
            });
        }

        // 첨부파일 다운로드 버튼 이벤트
        $P.fnFileDownload = (fileID) => {
            if (pageObject["${pageNameMain}"].callPurpose == "view") return;

            top.location.href = "/file/download.do?fileID=" + fileID;
        }

        /**************************************************************************
         * 초기 셋팅
         **************************************************************************/
        // 이벤트 설정
        $P.setEvent = () => {
            // 업무 버튼 이벤트
            $P.$findn("btnCreateOpnnSbmsn").on("click", function() {
                $P.fnCreateOpnnSbmsn($P.$findn("btnCreateOpnnSbmsn").attr("title"));             // 의견제출 등록
            });
            $P.$findn("btnUpdateOpnnSbmsn").on("click", function() {
                $P.fnUpdateOpnnSbmsn($P.$findn("btnUpdateOpnnSbmsn").attr("title"));             // 의견제출 수정
            });
            $P.$findn("btnRemoveOpnnSbmsn").on("click", function() {
                $P.fnRemoveOpnnSbmsn($P.$findn("btnRemoveOpnnSbmsn").attr("title"));             // 의견제출 삭제
            });
            $P.$findn("btnPrintDlbrDecsn").on("click", function() {
                $P.fnPrintDlbrDecsn($P.$findn("btnPrintDlbrDecsn").attr("title"));               // 심의의결서 출력
            });
            $P.$findn("btnUpdateOpnnSbmsnDlbrt").on("click", function() {
                $P.fnUpdateOpnnSbmsnDlbrt($P.$findn("btnUpdateOpnnSbmsnDlbrt").attr("title"));   // 의견제출 심의
            });
        }

        // 초기 화면 설정
        $P.fnReset = () => {
            // 초기화
            $P.findn("frmOpnn").reset();                                        // 의견제출 화면 초기화
            $P.ctrlOpnn.dataset.clear();                                        // 의견제출 Dataset 초기화

            // 화면 호출(callPurpose)이 view가 아니라면 버튼 활성화 disabled = false
            if (pageObject["${pageNameMain}"].callPurpose != "view") {
                $P.$findn("btnCreateOpnnSbmsn").prop("disabled", false);
                $P.$findn("btnUpdateOpnnSbmsn").prop("disabled", false);
                $P.$findn("btnRemoveOpnnSbmsn").prop("disabled", false);
                $P.$findn("btnPrintDlbrDecsn").prop("disabled", false);
                $P.$findn("btnUpdateOpnnSbmsnDlbrt").prop("disabled", false);
            }
        }

        /**************************************************************************
         * 최초 실행 함수
         **************************************************************************/
        // 1. 이벤트 설정
        $P.setEvent();

        // 2. 초기 화면 설정
        $P.fnReset();

        // 3. Dataset 설정
        let opnnInfo = ${opnnInfo};                                             // 의견제출 정보
        if (opnnInfo) { $P.ctrlOpnn.setData([opnnInfo]); }
    });

</script>
