<%@ 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="crdnId" data-map="CRDN_ID" />
                <input type="hidden" name="levyExclId" data-map="LEVY_EXCL_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" for="crdnYmdTm">단속일시</label>
                        <input is="id-input" type="text" class="form-control w-px-160" name="crdnYmdTm" data-map="CRDN_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="vhrno">차량번호</label>
                        <input is="id-input" type="text" class="form-control w-px-120" name="vhrno" data-map="VHRNO" 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 required" for="levyExclSeNm">등록구분</label>
                        <input is="id-input" type="text" class="form-control w-px-120" name="levyExclSeNm" data-map="LEVY_EXCL_SE_NM" readonly />
                        <input type="hidden" name="levyExclSeCd" data-map="LEVY_EXCL_SE_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 required" for="levyExclYmd">등록일자</label>
                        <input is="id-input" type="text" class="form-control form-date" name="levyExclYmd" data-map="LEVY_EXCL_YMD"
                            data-fmt-type="day" autocomplete="off" title="날짜 선택" maxlength="10" required />
                        <button type="button" class="bx bx-lg bx-calendar bg-white" name="btnLevyExclYmd"></button>
                    </div>
                    <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="levyExclRsnCd">등록사유</label>
                        <select is="id-select" class="form-select" name="levyExclRsnCd" data-map="LEVY_EXCL_RSN_CD" required>
                            <option value="">선택하세요</option><c:forEach items="${FIM022List}" 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 align-top" for="etcCn">기타내용</label>
                        <textarea is="id-textarea" class="form-control w-70" 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("excl01020Script", wctx.url("/resources/js/fims/excl/excl01020.js?ver=${ver}"));

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

    // 공통 코드
    var FIM021 = new CommonCodes(${FIM021}, true);
    var FIM022 = new CommonCodes(${FIM022}, true);

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

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

        //
        $P.saveCallbackFuncName = "${saveCallbackFuncName}";
        $P.savedCallbackFuncName = "${savedCallbackFuncName}";

        /**************************************************************************
         * 사용자 함수(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 params = new FimsFormFields($P.selectorn("frmEdit")).get(); // 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("levyExclYmd").datepicker("setDate", TODAY());            // 부과 제외 일자

            // 화면 호출(callPurpose)이 view라면 버튼 비활성화 disabled = true
            if ($P.callPurpose == "view") {
                // input 요소들을 disabled
                $P.$findn("frmEdit").find("input,textarea,select").prop("disabled", true);

                // button 요소들을 disabled
                $P.$findn("btnLevyExclYmd").prop("disabled", true);             // 부과제외 일자 달력 버튼
                $P.$findn("btnSave").prop("disabled", true);                    // 저장 버튼
            }
        }

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

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

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

</script>
