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

<c:set var="prefixName" scope="request">안내문 상세 정보</c:set>

<!-- inner page html -->
<div class="content-pop" data-doctx="${pageName}">
    <!-- Content -->
    <div class="container flex-grow-1 px-0">
        <div class="card">
            <!-- 입력 영역 -->
            <form name="frmEdit">
                <!-- hidden -->
                <input type="hidden" name="sggCd" data-map="SGG_CD" />
                <input type="hidden" name="taskSeCd" data-map="TASK_SE_CD" />
                <input type="hidden" name="gdntcId" data-map="GDNTC_ID" />

                <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 required" for="sndngSeCdsndngSeCd">발송구분</label>
                        <select is="id-select" class="form-select" name="sndngSeCd" data-map="SNDNG_SE_CD" required>
                            <option value="">선택하세요</option>
                            <c:forEach items="${FIM047List}" var="item">
                                <option value="${item.code}">${item.value}</option>
                            </c:forEach>
                        </select>
                    </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="ttlNm">제목</label>
                        <input is="id-input" type="text" class="form-control w-70" name="ttlNm" data-map="TTL_NM" required autocomplete="off" />
                    </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="wordsCn">문구내용</label>
                    </div>
                    <div class="col-md-12">
                        <textarea is="id-textarea" class="form-control w-100" name="wordsCn" data-map="WORDS_CN" rows="15" data-maxlengthb="4000" autocomplete="off"></textarea>
                    </div>
                </div>
            </form>
            <!-- 입력 영역 -->
        </div> <!-- <div class="card"> -->

        <!-- 업무 버튼 및 건수 표시 -->
        <div>
            <span class="container-page-btn">
                <!-- 업무 버튼 -->
                <span class="container-window-btn-right">
                    <button type="button" class="btn btn-primary w-px-120" name="btnSave" title="저장">
                        저장
                    </button>
                </span>
            </span>
        </div>
        <!-- 업무 버튼 및 건수 표시 -->
    </div> <!-- <div class="container flex-grow-1 px-0"> -->
    <!-- Content -->
</div>
<!-- / inner page html <div class="content-pop"> -->

<script>
    LoadScript("epst02020Script", wctx.url("/resources/js/fims/epst/epst02020.js?ver=${ver}"));

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

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

        // URL
        $P.prefixUrl = "${prefixUrl}";
        // infoDialog 호출 용도(view 조회(편집불가), create 등록, update 수정, delete 삭제, restore 복구)
        $P.callPurpose = "${callPurpose}";
        // datasetControl
        $P.ctrl = newEpst02020Control("${pageName}", "[data-doctx=${pageName}]");

        /**************************************************************************
         * 사용자 함수(function)
         **************************************************************************/


        /**************************************************************************
         * 버튼 clickEvent
         **************************************************************************/
        // 저장
        $P.fnSave = () => {
            // validate 확인
            if (!AppSupport.customValidate($P.$findn("frmEdit").find("input,select,textarea"))) return;

            // formFields
            let params = new FimsFormFields($P.selectorn("frmEdit")).get();

            dialog.alert({
                  content: "현재 " + $P.ctrl.prefixName + " 정보를 저장하시겠습니까?"
                , init: () => { AppSupport.setDialogZindex(); }
                , onOK: () => { $P.ctrl.save(params); }                         // formFields
            });
        }

        /**************************************************************************
         * 초기 셋팅
         **************************************************************************/
        // 이벤트 설정
        $P.setEvent = () => {
            // 버튼 이벤트
            $P.$findn("btnSave").on("click", () => $P.fnSave());                // 저장
        }

        // 초기 화면 설정
        $P.fnReset = () => {
            // View로 호출
            if ($P.callPurpose == "view") {
                // input 요소들을 disabled
                $P.$findn("frmEdit").find("input,textarea,select").prop("disabled", true);

                // button 요소들을 disabled
                $P.$findn("btnSave").prop("disabled", true);                    // 저장 버튼
            } else if ($P.callPurpose == "update") {
                $P.$findn("sndngSeCd").prop("disabled", true);                  // 발송 구분 코드
            }
        }

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

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

        // 3. Dataset 설정
        $P.ctrl.setData([${Info}]);
    });

</script>
