<%@ 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="svbtcId" data-map="SVBTC_ID" />

                <div class="row g-1">
                    <!-- 총건수 -->
                    <div class="col-md-12 text-end">
                        <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for=tnocs" >총건수</label>
                        <input is="id-input" type="text" class="form-control w-px-120 text-end" name="tnocs" data-map="TNOCS" 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">공시송달일자</label>
                        <span class="form-search-linebox">
                            <input type="text" class="form-control form-date" name="svbtcYmd" data-map="SVBTC_YMD"
                                data-fmt-type="day" autocomplete="off" title="시작 날짜 선택" />
                            <button type="button" class="bx bx-lg bx-calendar bg-white" name="btnSvbtcYmd"></button>
                            ~
                            <input type="text" class="form-control form-date" name="svbtcEndYmd" data-map="SVBTC_END_YMD"
                                data-fmt-type="day" autocomplete="off" title="종료 날짜 선택" />
                            <button type="button" class="bx bx-lg bx-calendar bg-white" name="btnSvbtcEndYmd"></button>
                        </span>
                    </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="docNo">문서번호</label>
                        <input is="id-input" type="text" class="form-control w-60" name="docNo" data-map="DOC_NO" utocomplete="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="ttlNm">제목</label>
                        <input is="id-input" type="text" class="form-control w-87" name="ttlNm" data-map="TTL_NM" utocomplete="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="etcCn">기타내용</label>
                        <textarea is="id-textarea" class="form-control w-87" name="etcCn" data-map="ETC_CN" rows="3" data-maxlengthb="1000" 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("sndb01260Script", wctx.url("/resources/js/fims/sndb/sndb01260.js?ver=${ver}"));

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

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

        // URL
        $P.prefixUrl = "${prefixUrl}";
        // datasetControl
        $P.ctrl = newSndb01260Control("${pageName}", "[data-doctx=${pageName}]");
        // 공통 코드
        $P.FIM047 = new CommonCodes(${FIM047}, true);
        $P.FIM054 = new CommonCodes(${FIM054}, true);
        // infoDialog 호출 용도(view 조회(편집불가), create 등록, update 수정)
        $P.callPurpose = "${callPurpose}";
        // main 의 검색 조건을 그대로 유지
        $P.mainQuery = ${mainQuery};

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


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

            dialog.alert({
                  content: "현재 " + $P.ctrl.prefixName + " 정보를 저장하시겠습니까?"
                , init: () => { AppSupport.setDialogZindex(); }
                , onOK: () => {
                    let formFields = new FimsFormFields($P.selectorn("frmEdit")).get();
                	// 검색조건과 저장 파라미터 객체를 합친다.
                    let params = $.extend({}, $P.mainQuery, formFields);

                    $P.ctrl.save(params);
                }
            });
        }

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

        // 초기 화면 설정
        $P.fnReset = () => {
            // 초기화
            $P.findn("frmEdit").reset();                                        // 화면 초기화
            AppSupport.initDatepicker($P.findn("frmEdit"));                     // 달력 초기화

            // 기본 데이터 설정
            $P.$findn("svbtcYmd").datepicker("setDate", TODAY());               // 공시송달 일자
            $P.$findn("svbtcEndYmd").datepicker("setDate", TODAY());            // 공시송달 일자

            if ($P.callPurpose == "view") {                                     // view
                // input 요소들을 disabled
                $P.$findn("frmEdit").find("input,textarea,select").prop("disabled", true);

                // button 요소들을 disabled
                $P.$findn("btnSvbtcYmd").prop("disabled", true);                // 공시송달 일자
                $P.$findn("btnSvbtcEndYmd").prop("disabled", true);             // 공시송달 일자
                $P.$findn("btnSave").prop("disabled", true);                    // 저장 버튼
            }

            // 검색 조건
            $P.ctrl.query = $P.mainQuery;
        }

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

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

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

</script>
