<%@ 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="levyId" data-map="LEVY_ID" />
                <input type="hidden" name="rcvmtId" data-map="RCVMT_ID" />

                <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="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-4">
                        <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-40" name="vhrno" data-map="VHRNO" 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="crdnSttsNm">단속상태</label>
                        <input is="id-input" type="text" class="form-control w-50" name="crdnSttsNm" data-map="CRDN_STTS_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="deptCd">부서코드</label>
                        <input is="id-input" type="text" class="form-control w-30" name="deptCd" data-map="DEPT_CD" readonly />
                        <input is="id-input" type="text" class="form-control w-20" name="spclBizCd" data-map="SPCL_BIZ_CD" 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="acntgSeCd">회계세목코드</label>
                        <input is="id-input" type="text" class="form-control w-px-40" name="acntgSeCd" data-map="ACNTG_SE_CD" readonly />
                        <input is="id-input" type="text" class="form-control w-px-80" name="txitmCd" data-map="TXITM_CD" readonly />
                        <input is="id-input" type="text" class="form-control w-px-50" name="operItemCd" data-map="OPER_ITEM_CD" 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="txitmCd">세목명</label>
                        <input is="id-input" type="text" class="form-control w-50" name="txitmNm" data-map="TXITM_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="fyr">회계연도</label>
                        <input is="id-input" type="text" class="form-control w-20" name="fyr" data-map="FYR" 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="levyNo">부과번호</label>
                        <input is="id-input" type="text" class="form-control w-30" name="levyNo" data-map="LEVY_NO" 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="txitmCd">분납일련번호</label>
                        <input is="id-input" type="text" class="form-control w-15" name="ispySn" data-map="ISPY_SN" 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="levyPcptax">부과본세</label>
                        <input is="id-input" type="text" class="form-control w-px-120" name="levyPcptax" data-map="LEVY_PCPTAX" data-fmt-type="number" 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="levyAdamt">부과가산금</label>
                        <input is="id-input" type="text" class="form-control w-px-120" name="levyAdamt" data-map="LEVY_ADAMT" data-fmt-type="number" 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="lastAmt">최종금액</label>
                        <input is="id-input" type="text" class="form-control w-px-120" name="lastAmt" data-map="LAST_AMT" data-fmt-type="number" readonly />
                    </div>

                    <p></p>

                    <div class="col-md-4">
                        <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end required" for="rcvmtYmd">수납일자</label>
                        <input is="id-input" type="text" class="form-control form-date" name="rcvmtYmd" data-map="RCVMT_YMD"
                            data-fmt-type="day" autocomplete="off" title="날짜 선택" maxlength="10" required />
                        <button type="button" class="bx bx-lg bx-calendar bg-white" name="btnRcvmtYmd"></button>
                    </div>
                    <div class="col-md-4">
                        <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end required" for="acntgYmd">회계일자</label>
                        <input is="id-input" type="text" class="form-control form-date" name="acntgYmd" data-map="ACNTG_YMD"
                            data-fmt-type="day" autocomplete="off" title="날짜 선택" maxlength="10" required />
                        <button type="button" class="bx bx-lg bx-calendar bg-white" name="btnAcntgYmd"></button>
                    </div>
                    <div class="col-md-4">
                        <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end required" for="tsfYmd">이체일자</label>
                        <input is="id-input" type="text" class="form-control form-date" name="tsfYmd" data-map="TSF_YMD"
                            data-fmt-type="day" autocomplete="off" title="날짜 선택" maxlength="10" required />
                        <button type="button" class="bx bx-lg bx-calendar bg-white" name="btnTsfYmd"></button>
                    </div>
                    <div class="col-md-4">
                        <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end required" for="rcvmtSeCd">수납구분</label>
                        <select is="id-select" class="form-select" name="rcvmtSeCd" data-map="RCVMT_SE_CD" required>
                            <option value="">선택하세요</option>
                            <c:forEach items="${FIM041List}" var="item">
                                <option value="${item.code}">${item.value}</option>
                            </c:forEach>
                        </select>
                    </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="rcvmtBankNm">수납은행</label>
                        <input is="id-input" type="text" class="form-control w-45" name="rcvmtBankNm" data-map="RCVMT_BANK_NM" autocomplete="off" />
                    </div>
                    <div class="col-md-4">
                        <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end required" for="rcvmtAmt">수납금액</label>
                        <input is="id-input" type="text" class="form-control w-35" name="rcvmtAmt" data-map="RCVMT_AMT" data-fmt-type="number" autocomplete="off" required />
                    </div>
                    <div class="col-md-8">
                        <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end required" for="payMthdSeCd">납부매체</label>
                        <select is="id-select" class="form-select" name="payMthdSeCd" data-map="PAY_MTHD_SE_CD" required>
                            <option value="">선택하세요</option>
                            <c:forEach items="${FIM045List}" var="item">
                                <option value="${item.code}">${item.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
            </form>
            <!-- 입력 영역 -->

        <!-- 업무 버튼 및 건수 표시 -->
        <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("rcvm01020Script", wctx.url("/resources/js/fims/rcvm/rcvm01020.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 = newRcvm01020Control("${pageName}", "[data-doctx=${pageName}]");

        /**************************************************************************
         * 사용자 함수
         **************************************************************************/


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

            // 수납금액 확인
            let rcvmtAmt = $P.$findn("rcvmtAmt").val();
            if (Number(rcvmtAmt || "0") < 10)
            	return dialog.alert("수납금액은 10원 이상으로 입력되어야 합니다.");

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

                    // 등록이라면..
                    if (!params.rcvmtId) {
                    	params.rcvmtInptSeCd = "03";                            // 수납 입력 구분 코드(FIM044) : 03 수기
                    }

                    $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("rcvmtYmd").datepicker("setDate", TODAY());               // 수납 일자
            $P.$findn("acntgYmd").datepicker("setDate", TODAY());               // 회계 일자
            $P.$findn("tsfYmd").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("btnRcvmtYmd").prop("disabled", true);                // 수납 일자 달력 버튼
                $P.$findn("btnAcntgYmd").prop("disabled", true);                // 회계 일자 달력 버튼
                $P.$findn("btnTsfYmd").prop("disabled", true);                  // 이체 일자 달력 버튼
                $P.$findn("btnSave").prop("disabled", true);                    // 저장 버튼
            }
        }

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

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

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

</script>
