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

<!-- Page Body -->
<div class="content-pop" data-doctx="${pageName}">
    <!-- 입력 영역 -->
    <form name="frmEditLevy">
        <!-- hidden -->
        <input type="hidden" name="levyId" data-map="LEVY_ID" />

        <div class="d-flex flex-row justify-content-evenly">
            <!-- 부과 정보 -->
            <div class="col-xl-9 mx-1">
                <div class="card">
                    <!-- 업무 버튼 -->
                    <div class="container-page-btn">
                        <label class="col-form-label bg-label-danger pe-2 w-px-120 text-sm-center">부과 정보</label>
                        <!-- 버튼 우측 정렬 -->
                        <span class="container-window-btn-right">
<!--                             <button type="button" class="btn btn-primary w-px-120" name="btnCreateLevy" title="부과 등록" disabled> -->
<!--                                 부과 등록 -->
<!--                             </button> -->
                            <button type="button" class="btn btn-primary w-px-120" name="btnCreateLevyExcl" title="부과 취소" disabled>
                                부과 취소
                            </button>
                        </span> <!-- <span class="container-window-btn-right"> -->
                    </div> <!-- <div class="container-page-btn"> -->

                    <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="acntgSeCd">회계구분</label>
                            <input is="id-input" type="text" class="form-control w-15" name="acntgSeCd" data-map="ACNTG_SE_CD" readonly />
                            <input is="id-input" type="text" class="form-control w-50" name="acntgSeNm" data-map="ACNTG_SE_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="txitmCd">회계세목</label>
                            <input is="id-input" type="text" class="form-control w-20" name="txitmCd" data-map="TXITM_CD" readonly />
                            <input is="id-input" type="text" class="form-control w-45" 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="operItemCd">운영항목</label>
                            <input is="id-input" type="text" class="form-control w-15" name="operItemCd" data-map="OPER_ITEM_CD" readonly />
                            <input is="id-input" type="text" class="form-control w-45" name="operItemNm" data-map="OPER_ITEM_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-20" 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="ispySn">분납일련번호</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="txtnThing">과세물건</label>
                            <input is="id-input" type="text" class="form-control w-40" name="txtnThing" data-map="TXTN_THING" 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="levySeNm">부과구분</label>
                            <input is="id-input" type="text" class="form-control w-30" name="levySeNm" data-map="LEVY_SE_NM" readonly />
                            <input type="hidden" name="levySeCd" data-map="LEVY_SE_CD" />
                        </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="untySeNm">통합구분</label>
                            <input is="id-input" type="text" class="form-control w-30" name="untySeNm" data-map="UNTY_SE_NM" readonly />
                            <input type="hidden" name="untySeCd" data-map="UNTY_SE_CD" />
                        </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="rdctSeNm">감경구분</label>
                            <input is="id-input" type="text" class="form-control w-30" name="rdctSeNm" data-map="RDCT_SE_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="ispySeNm">분납구분</label>
                            <input is="id-input" type="text" class="form-control w-30" name="ispySeNm" data-map="ISPY_SE_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="ispyInt">분납이자</label>
                            <input is="id-input" type="text" class="form-control w-30 text-end" name="ispyInt" data-map="ISPY_INT" 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="levyYmd">부과일자</label>
                            <input is="id-input" type="text" class="form-control w-30" idname="levyYmd" data-map="LEVY_YMD" data-fmt-type="day" 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="frstDudtYmd">최초납기일자</label>
                            <input is="id-input" type="text" class="form-control w-30" name="frstDudtYmd" data-map="FRST_DUDT_YMD" data-fmt-type="day" 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="dudtYmd">납기일자</label>
                            <input is="id-input" type="text" class="form-control w-30" name="dudtYmd" data-map="DUDT_YMD" data-fmt-type="day" 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-30 text-end" 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="rcvmtPcptax">수납본세</label>
                            <input is="id-input" type="text" class="form-control w-30 text-end" name="rcvmtPcptax" data-map="RCVMT_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="rdamtPcptax">감액본세</label>
                            <input is="id-input" type="text" class="form-control w-30 text-end"  name="rdamtPcptax" data-map="RDAMT_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-30 text-end" 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="rcvmtAdamt">수납가산금</label>
                            <input is="id-input" type="text" class="form-control w-30 text-end" name="rcvmtAdamt" data-map="RCVMT_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="rdamtAdamt">감액가산금</label>
                            <input is="id-input" type="text" class="form-control w-30 text-end" name="rdamtAdamt" data-map="RDAMT_ADAMT" data-fmt-type="number" readonly />
                        </div>
                        <!--  -->
                        <div class="col-md-4">
                        </div>
                        <!--  -->
                        <div class="col-md-4">
                        </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-30 text-end fw-bold text-red" name="lastAmt" data-map="LAST_AMT" 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="mngItem1">관리항목1</label>
                            <input is="id-input" type="text" class="form-control w-65" name="mngItem1" data-map="MNG_ITEM1" 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="mngItem2">관리항목2</label>
                            <input is="id-input" type="text" class="form-control w-65" name="mngItem2" data-map="MNG_ITEM2" 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="mngItem3">관리항목3</label>
                            <input is="id-input" type="text" class="form-control w-65" name="mngItem3" data-map="MNG_ITEM3" 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="mngItem4">관리항목4</label>
                            <input is="id-input" type="text" class="form-control w-65" name="mngItem4" data-map="MNG_ITEM4" 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="mngItem5">관리항목5</label>
                            <input is="id-input" type="text" class="form-control w-65" name="mngItem5" data-map="MNG_ITEM5" 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="mngItem6">관리항목6</label>
                            <input is="id-input" type="text" class="form-control w-65" name="mngItem6" data-map="MNG_ITEM6" 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="npmntSeNm">체납구분</label>
                            <input is="id-input" type="text" class="form-control w-40" name="npmntSeNm" data-map="NPMNT_SE_NM" readonly />
                        </div>
                        <div class="col-md-8">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="npmntRsn">체납사유</label>
                            <input is="id-input" type="text" class="form-control w-80" name="npmntRsn" data-map="NPMNT_RSN" 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="szrYmd">압류일자</label>
                            <input is="id-input" type="text" class="form-control w-30" name="szrYmd" data-map="SZR_YMD" data-fmt-type="day" 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="rpmSzrVhrno">대체압류차량</label>
                            <input is="id-input" type="text" class="form-control w-35" name="rpmSzrVhrno" data-map="RPM_SZR_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="szrThing">압류물건</label>
                            <input is="id-input" type="text" class="form-control w-60" name="szrThing" data-map="SZR_THING" 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="szrRmvYmd">압류해제일자</label>
                            <input is="id-input" type="text" class="form-control w-30" name="szrRmvYmd" data-map="SZR_RMV_YMD" data-fmt-type="day" readonly />
                        </div>
                        <div class="col-md-8">
                            <label is="name-label" class="col-form-label bg-lighter pe-2 w-px-120 text-sm-end" for="szrRmvRsn">압류해제사유</label>
                            <input is="id-input" type="text" class="form-control w-80" name="szrRmvRsn" data-map="SZR_RMV_RSN" readonly />
                        </div>
                    </div> <!-- <div class="row g-1"> -->
                </div> <!-- <div class="card"> -->
            </div> <!-- <div class="col-xl-9 mx-1"> -->
            <!-- 부과 정보 -->

            <!-- 납부 안내 정보 -->
            <div class="col-xl-3 mx-0">
                <div class="card">
                    <!-- 업무 버튼 -->
                    <div class="container-page-btn">
                        <label class="col-form-label bg-label-danger pe-2 w-px-120 text-sm-center">납부 안내 정보</label>
                    </div> <!-- <div class="container-page-btn"> -->

                    <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="epaynoMask">전자납부번호</label>
                            <input is="id-input" type="text" class="form-control w-65" name="epaynoMask" data-map="EPAYNO_MASK" 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="vrActno">가상계좌번호</label>
                        </div>
                        <div class="col-md-12">
                            <textarea is="id-textarea" type="text" class="form-control w-100" name="vrActno" data-map="VR_ACTNO" rows="15"></textarea>
                        </div>
                    </div>
                </div> <!-- <div class="card"> -->
            </div> <!-- <div class="col-xl-3 mx-0"> -->
            <!-- 납부 안내 정보 -->
        </div> <!-- <div class="d-flex flex-row justify-content-evenly"> -->
    </form>
    <!-- 입력 영역 -->
</div> <!-- <div class="content-pop"> -->

<script>
    LoadScript("sprt02060Script", wctx.url("/resources/js/fims/sprt/sprt02060.js?ver=${ver}"));

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

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

        // datasetControl
        $P.ctrlLevy = newSprt02060Control("${pageName}", "[data-doctx=${pageName}]", "${pageNameMain}");

        /**************************************************************************
         * 사용자 함수(function)
         **************************************************************************/
        // 부과제외 dialog
        $P.levyExclInfo = (params) => {
            if (!params) return;

            ajax.get({
                  url: wctx.url("/excl/excl01/020/info.do")
                , data: params || {}
                , success: resp => {
                    if ((typeof resp) != "string") {
                        if (resp.rtnMsg != "") {
                            dialog.alert(resp.rtnMsg);
                        }
                        return;
                    } else {
                        let dialogName = "levyExclDialog";
                        let dialogId = dialogName + "-" + uuid();

                        dialog.open({
                              id: dialogId
                            , title: params.btnTitle
                            , size: "md"
                            , content: resp
                            , init: () => {
                                $("#" + dialogId).attr("name", dialogName);
                                $("#" + dialogId).attr("data-ref-doctx", "${pageName}");

                                AppSupport.setDialogZindex();
                            }
                            , onClose: () => { $P.fnRefresh(); }                // 정보 새로고침
                        });
                    }
                }
            });
        }

        // 정보 새로고침
        $P.fnRefresh = () => {
            let ctrlMain = pageObject["${pageNameMain}"].ctrlMain;

            // 단속 ID 가 없다면.. return
            let crdnId = ctrlMain.getValue("CRDN_ID");                          // 단속 ID
            if (!crdnId) return;

            let params = {
                  callPurpose: "refresh"
                , sggCd: ctrlMain.getValue("SGG_CD")
                , taskSeCd: ctrlMain.getValue("TASK_SE_CD")
                , crdnId: ctrlMain.getValue("CRDN_ID")
                , delYn: "N"
            };

            ajax.get({
                  url: wctx.url("/sprt/sprt02/060/info.do")
                , headers: { Accept: "application/json; charset=utf-8" }        // json
                , data: params || {}
                , success: (resp) => {
                    // 초기화
                    $P.findn("frmEditLevy").reset();                            // 부과 화면 초기화
                    $P.ctrlLevy.dataset.clear();                                // 부과 Dataset 초기화

                    // sprt02010-main 단속 정보
                    ctrlMain.setData([resp.totalInfo]);

                    // 부과 정보
                    if (resp.levyInfo) { $P.ctrlLevy.setData([resp.levyInfo]); }
                }
            });
        }

        /**************************************************************************
         * 버튼 clickEvent
         **************************************************************************/
        // 부과 등록
        $P.fnCreateLevy = (btnTitle) => {
            //
        }

        // 부과 취소
        $P.fnCreateLevyExcl = (btnTitle) => {
            // 단속 ID 가 없다면.. return
            let ctrlMain = pageObject["${pageNameMain}"].ctrlMain;              // sprt02010 control
            let crdnId = ctrlMain.getValue("CRDN_ID");                          // 단속 ID
            if (!crdnId) return;

            let levyId = $P.ctrlLevy.getValue("LEVY_ID");                       // 부과 ID
            if (!levyId)
            	return dialog.alert({
                      content: "조회된 부과 대장 정보가 없습니다."
                            + "<br><br>" + "[" + btnTitle + "]" + " 실행이 취소되었습니다."
                    , init: () => { AppSupport.setDialogZindex(); }
                    , onOK: () => { }
                });

            let params = {
                  callPurpose: "create"
                , btnTitle: btnTitle
                , sggCd: ctrlMain.getValue("SGG_CD")                            // 시군구 코드
                , taskSeCd: ctrlMain.getValue("TASK_SE_CD")                     // 업무 구분 코드
                , crdnId: ctrlMain.getValue("CRDN_ID")                          // 단속 ID
                , levyExclSeCd: "3"
                , delYn: "N"
            };

            $P.levyExclInfo(params);
        }

        /**************************************************************************
         * 초기 셋팅
         **************************************************************************/
        // 이벤트 설정
        $P.setEvent = () => {
            // 업무 버튼 이벤트
            $P.$findn("btnCreateLevy").on("click", function() {
                $P.fnCreateLevy($P.$findn("btnCreateLevy").attr("title"));          // 부과 등록
            });
            $P.$findn("btnCreateLevyExcl").on("click", function() {
                $P.fnCreateLevyExcl($P.$findn("btnCreateLevyExcl").attr("title"));  // 부과 취소
            });
        }

        // 초기 화면 설정
        $P.fnReset = () => {
            // 초기화
            $P.findn("frmEditLevy").reset();                                    // 부과 화면 초기화
            $P.ctrlLevy.dataset.clear();                                        // 부과 Dataset 초기화

            // 화면 호출(callPurpose)이 view가 아니라면 버튼 활성화 disabled = false
            if (pageObject["${pageNameMain}"].callPurpose != "view") {
                // 주정차위반, 전용차로위반과태료 외에는 부과 기능이 없어야 한다.
                let taskSeCd = pageObject["${pageNameMain}"].ctrlMain.getValue("TASK_SE_CD");
                if ("BPV,PVS,RVS".indexOf("taskSeCd") != -1) {
                    $P.$findn("btnCreateLevy").prop("disabled", false);
                } else {
                    $P.$findn("btnCreateLevy").prop("disabled", true);
                }
                $P.$findn("btnCreateLevyExcl").prop("disabled", false);
            }
        }

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

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

        // 3. Dataset 설정
        let levyInfo = ${levyInfo};                                             // 부과 정보
        if (levyInfo) { $P.ctrlLevy.setData([levyInfo]); }
    });

</script>
