<%@ 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="cvlcptDscsnId" data-map="CVLCPT_DSCSN_ID" />
                <input type="hidden" name="vhrno" data-map="VHRNO" />

                <div class="row g-1">
                    <div class="col-md-6">
                        <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-160" name="vhrno" data-map="VHRNO" 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="rtpyrNo">납부자번호</label>
                        <input is="id-input" type="text" class="form-control w-px-160" name="rtpyrNo" data-map="RTPYR_NO" 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 required" for="cvlcptRcptSeCd">접수구분</label>
                        <select is="id-select" class="form-select" name="cvlcptRcptSeCd" data-map="CVLCPT_RCPT_SE_CD" required>
                            <option value="">선택하세요</option>
                            <c:forEach items="${FIM065List}" var="item">
                                <option value="${item.code}">${item.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                    <div class="col-md-6">
                        <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end required" for="dscsnYmd">상담일자</label>
                        <input is="id-input" type="text" class="form-control form-date" name="dscsnYmd" data-map="DSCSN_YMD"
                            data-fmt-type="day" autocomplete="off" title="날짜 선택" maxlength="10" required />
                        <button type="button" class="bx bx-lg bx-calendar bg-white" name="btnDscsnYmd"></button>
                    </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="cvlprNm">민원인명</label>
                        <input is="id-input" type="text" class="form-control w-px-160" name="cvlprNm" data-map="CVLPR_NM" autocomplete="off" />
                    </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="cvlprCttpc">연락처</label>
                        <input is="id-input" type="text" class="form-control w-px-160" name="cvlprCttpc" data-map="CVLPR_CTTPC" 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 align-top" for="dscsnCn">상담내용</label>
                        <textarea is="id-textarea" type="text" class="form-control w-85" name="dscsnCn" data-map="DSCSN_CN" rows="5" data-maxlengthb="4000"></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("sprt04020Script", wctx.url("/resources/js/fims/sprt/sprt04020.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 수정)
        $P.callPurpose = "${callPurpose}";
        // datasetControl
        $P.ctrl = newSprt04020Control("${pageName}", "[data-doctx=${pageName}]");

        /**************************************************************************
         * 사용자 함수(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("dscsnYmd").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("btnDscsnYmd").prop("disabled", true);                // 상담일자 달력 버튼
                $P.$findn("btnSave").prop("disabled", true);                    // 저장 버튼
            } else if ($P.callPurpose == "update") {
                $P.$findn("cvlcptRcptSeCd").prop("disabled", true);             // 민원 접수 구분 코드
            }
        }

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

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

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

</script>
