<?php

if ($_SERVER['SERVER_ADDR'] == '192.168.10.237') {
    $server_addr = 'http://test-admin.confirms.co.kr';
} else {
    $server_addr = 'https://admin.confirms.co.kr';
}

$usr_level = session('usr_level');

if (!empty($data['cert_register']) && $data['cert_register_save_yn'] != 'Y') {	//등기url있고 등기api이미지 저장여부가 Y가 아닐때 
    $arr_cert_register = explode('|', $data['cert_register']);
    $file_pdf = substr($data['cert_register'], -4);
    $file_pdf = str_replace(".", "", $file_pdf);
    $regi_pdf_path = $arr_cert_register[0];

    // $ext = end(explode('.', $arr_cert_register[0]));
    $tmp = explode('.', $arr_cert_register[0]);
    $ext = end($tmp);
    if (strpos($ext, 'pdf') === false) {
        $file_pdf = $ext;
    } else {
        $file_pdf = 'pdf';
    }
    $regi_pdf_path = $arr_cert_register[0];

} else {
    $file_pdf = substr($regist['file_name'] ?? '', -3);
    $regi_pdf_path = ($regist['file_path'] ?? '') . ($regist['file_name'] ?? '');
}
?>
<?= $this->extend('layouts/main') ?>

<?= $this->section('content') ?>
<link rel="stylesheet" href="/common/css/custom.css">
<style>
    table th {
        vertical-align: middle;
        line-height: 1.2;
    }

    .tbl_basic2 th {
        padding: 0 10px;
        height: 27px;
        line-height: 27px;
        vertical-align: middle;
        border: solid 1px #d8d9de;
        background-color: #eff0f4;
        letter-spacing: -1px;
        font-weight: normal;
        color: #5a5f69;
        text-align: left;
    }

    .blockUI {
        z-index: 1500 !important;
    }

    .ellipsis {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 180px;
    }

    .table-scroll {
        max-height: 300px;
        overflow-y: scroll;
        min-height: 100px;
    }

    /* 정보변경 이력 테이블 깜박임 방지 */
    .apt-info-table {
        table-layout: fixed;
        width: 100%;
    }

    .swal2-cancel {
        background-color: #ff0000 !important;
        color: #fff !important;
    }

    .num {
        color: #b68556;
        font-size: 19px;
    }

    .table th,
    .table td {
        vertical-align: top;
        box-sizing: border-box;
    }
</style>

<form name="rcptFrm" id="rcptFrm" method="post" action="" enctype="multipart/form-data" autocomplete="off"
    onsubmit="return false;">
    <input type="hidden" name="address_code" id="address_code" value="<?= $data['address_code'] ?>" />
    <input type="hidden" name="chTotal" id="chTotal" value="" />
    <input type="hidden" name="rcpt_key" value="<?= $data['vr_sq'] ?>" />
    <input type="hidden" name="reg_chk_val" value="<?= $data['rgbk_confirm'] ?>" />
    <input type="hidden" name="price_ignore" id="price_ignore" value="" />
    <input type="hidden" name="atcl_no" value="<?= $data['atcl_no'] ?>" />
    <input type="hidden" name="vrfcMthdTpCd" value="<?= $data['vrfcMthdTpCd'] ?>" />

    <div class="col-md-12 col-xl-12">
        <div class="col-lg-12">
            <div class="main-card mb-2 card">
                <div class="card-header bg-white border-bottom shadow-sm">
                    <div class="d-flex flex-wrap align-items-center w-100 justify-content-between card-header-tab">
                        <h4 class="mb-0 fw-bold text-dark">확인매물 상세 내용</h4>
                        <div class="d-flex align-items-center flex-nowrap gap-4 ms-auto" style="white-space:nowrap;">
                            <span class="text-muted me-2">매물ID:</span>
                            <span class="fw-bold text-primary fs-6 me-4"> <?= $data['atcl_no'] ?> </span>
                            <span class="text-muted me-2">CP ID:</span>
                            <span class="fw-bold text-primary fs-6 me-4"> <?= $data['cpid'] ?> </span>
                            <span class="text-muted me-2">현재 상태:</span>
                            <span class="fw-bold text-danger fs-6"> <?= $data['pre_stat'] ?> </span>
                        </div>
                    </div>
                </div>
                <div class="card-body">
                    <h5 class="card-title">공인 중개사 정보</h5>
                    <table class="table table-bordered table-sm tbl_basic2 apt-info-table">
                        <colgroup>
                            <col width="15%" />
                            <col width="35%" />
                            <col width="15%" />
                            <col width="35%" />
                        </colgroup>
                        <tr>
                            <th>중개사명</th>
                            <td><?= $data['realtor_nm'] ?></td>
                            <th>대표전화</th>
                            <td><?= $data['realtor_tel_no'] ?></td>
                        </tr>

                    </table>
                </div>
            </div>

            <div class="main-card mb-2 card">
                <div class="card-body">
                    <h5 class="card-title">매물 정보</h5>
                    <div class="table-responsive">
                        <table class="table table-bordered table-sm tbl_basic2 align-middle mb-0 apt-info-table">
                            <colgroup>
                                <col width="15%" />
                                <col width="35%" />
                                <col width="15%" />
                                <col width="35%" />
                            </colgroup>

                            <tbody>
                                <tr>
                                    <th>등록일</th>
                                    <td><?= $data['rdate'] ?></td>

                                    <th>전화/서류 완료일시</th>
                                    <td>
                                        <select class="form-select form-select-sm" name="atcl_vrtc_way"
                                            id="atcl_vrtc_way" disabled>
                                            <option value="">-선택-</option>
                                            <?php foreach ($codes as $c): ?>
                                                <?php if ($c['category'] === "VRFCREQ_WAY"): ?>
                                                    <option value="<?= $c['cd'] ?>" <?= ($c['cd'] === $data['vrfc_type_cd']) ? 'selected' : '' ?>>
                                                        <?= $c['cd_nm'] ?>
                                                    </option>
                                                <?php endif; ?>
                                            <?php endforeach; ?>
                                        </select>
                                        <?= $data['update_res_tm'] ?>
                                    </td>
                                </tr>

                                <tr>
                                    <th>등기부등본 확인완료</th>
                                    <td><?= $data['result_tm'] ?></td>

                                    <th>의뢰인(매도자)</th>
                                    <td>
                                        <?php if (in_array($data['stat_cd'], ['19', '60', '69'])): ?>
                                            ***
                                        <?php else: ?>
                                            <?= $data['seller_nm'] ?>
                                        <?php endif; ?>
                                    </td>
                                </tr>

                                <tr>
                                    <th>매물구분</th>
                                    <td><?= $data['atcl_nm'] ?></td>

                                    <th>거래구분</th>
                                    <td>
                                        <div class="d-flex flex-wrap gap-3">
                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="trade_type_cd"
                                                    id="trade_type_1" value="B1" <?= ($data['trade_type_cd'] === 'B1') ? 'checked' : '' ?> disabled>
                                                <label class="form-check-label" for="trade_type_1">전세</label>
                                            </div>

                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="trade_type_cd"
                                                    id="trade_type_2" value="B2" <?= ($data['trade_type_cd'] === 'B2') ? 'checked' : '' ?> disabled>
                                                <label class="form-check-label" for="trade_type_2">월세</label>
                                            </div>

                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="trade_type_cd"
                                                    id="trade_type_4" value="B3" <?= ($data['trade_type_cd'] === 'B3') ? 'checked' : '' ?> disabled>
                                                <label class="form-check-label" for="trade_type_4">단기임대</label>
                                            </div>

                                            <div class="form-check">
                                                <input class="form-check-input" type="radio" name="trade_type_cd"
                                                    id="trade_type_3" value="A1" <?= ($data['trade_type_cd'] === 'A1') ? 'checked' : '' ?> disabled>
                                                <label class="form-check-label" for="trade_type_3">매매</label>
                                            </div>
                                        </div>
                                    </td>
                                </tr>

                                <tr>
                                    <th rowspan="3">지역구분</th>
                                    <td rowspan="3"><?= $data['region_nm'] ?></td>

                                    <th>리 주소</th>
                                    <td>
                                        <input type="text" class="form-control form-control-sm" name="atcl_addr1a"
                                            id="atcl_addr1a" value="<?= $data['address2a'] ?>" disabled>
                                    </td>
                                </tr>

                                <tr>
                                    <th>상세주소</th>
                                    <td class="d-flex gap-1">
                                        <?php if (empty($data['address2b'])): ?>
                                            <input type="text" class="form-control form-control-sm"
                                                value="<?= $data['address2'] ?>" disabled>
                                            <input type="hidden" name="atcl_addr1b" id="atcl_addr1b" value=" ">
                                        <?php else: ?>
                                            <input type="hidden" name="atcl_addr1" id="atcl_addr1" value=" ">
                                            <input type="text" class="form-control form-control-sm"
                                                value="<?= $data['address2b'] ?>" disabled>
                                        <?php endif; ?>

                                        <input type="text" class="form-control form-control-sm"
                                            value="<?= $data['address3'] ?>" disabled>
                                    </td>
                                </tr>

                                <tr>
                                    <th>기타주소</th>
                                    <td>
                                        <input type="text" class="form-control form-control-sm" name="atcl_addr3"
                                            id="atcl_addr3" value="<?= $data['address4'] ?>" disabled>
                                    </td>
                                </tr>

                                <tr>
                                    <th>단지명</th>
                                    <td>
                                        <input type="hidden" name="atcl_hscp_nm" id="atcl_hscp_nm"
                                            value="<?= $data['hscp_nm'] ?>" />
                                        <select class="form-select" name="atcl_hscp_no" id="atcl_hscp_no" disabled>
                                            <option value="">-단지선택-</option>
                                            <?php
                                            foreach ($complexList['result'] as $complex): ?>
                                                <option value="<?= $complex['rletNo'] ?>"
                                                    <?= ($complex['rletNo'] === $data['hscp_no']) ? 'selected' : '' ?>>
                                                    <?= $complex['rletNm'] ?>
                                                <?php endforeach; ?>
                                        </select>

                                        <?php if ($data['sm_seq'] !== null): ?>
                                            <span style='color:#FF0000'>※ 특이단지</span>
                                        <?php endif; ?>
                                    </td>

                                    <th>가격</th>
                                    <td>
                                        <!-- 기본 가격 -->
                                        <div class="align-items-center gap-2 mb-0" id="div_trade_type_price"
                                            style="display: none;">
                                            <div class="input-group input-group-sm" style="max-width: 220px;">
                                                <input type="text" class="form-control text-end" name="atcl_amt1"
                                                    id="atcl_amt1" value="<?= $data['deal_amt'] ?>" disabled>
                                                <span class="input-group-text">만원</span>
                                            </div>

                                            <?php if (in_array($usr_level, [1, 2])): ?>
                                                <div class="form-check d-flex align-items-center mb-0">
                                                    <input class="form-check-input mt-0" type="checkbox" id="price_ignore1"
                                                        disabled>
                                                    <label class="form-check-label ms-1 small" for="price_ignore1">
                                                        가격무시
                                                    </label>
                                                </div>
                                            <?php endif; ?>
                                        </div>

                                        <div class="d-flex align-items-center gap-1 mb-0"
                                            id="div_trade_type_price_monthly" style="display: none;">
                                            <div class="input-group input-group-sm" style="max-width: 220px;">
                                                <input type="text" class="form-control text-end" name="atcl_amt2"
                                                    id="atcl_amt2" value="<?= $data['wrrnt_amt'] ?>" disabled>
                                                <span class="input-group-text">만원</span>
                                            </div> /
                                            <div class="input-group input-group-sm" style="max-width: 220px;">
                                                <input type="text" class="form-control text-end" name="atcl_amt3"
                                                    id="atcl_amt3" value="<?= $data['lease_amt'] ?>" disabled>
                                                <span class="input-group-text">만원</span>
                                            </div>


                                            <?php if (in_array($usr_level, [1, 2])): ?>
                                                <div class="form-check d-flex align-items-center mb-0">
                                                    <input class="form-check-input mt-0" type="checkbox" id="price_ignore2"
                                                        disabled>
                                                    <label class="form-check-label ms-1 small" for="price_ignore2">
                                                        가격무시
                                                    </label>
                                                </div>
                                            <?php endif; ?>
                                        </div>

                                        <!-- 분양가 / 프리미엄 -->
                                        <div id="div_trade_type_price2" style="display: none;">

                                            <div class="align-items-center gap-2 mb-2">
                                                <div class="input-group input-group-sm" style="max-width: 220px;">
                                                    <input type="text" class="form-control text-end" name="atcl_amt4"
                                                        id="atcl_amt4" value="<?= $data['deal_amt'] ?>" disabled>
                                                    <span class="input-group-text">만원</span>
                                                </div>

                                                <?php if (in_array($usr_level, [1, 2])): ?>
                                                    <div class="form-check d-flex align-items-center mb-0">
                                                        <input class="form-check-input mt-0" type="checkbox"
                                                            id="price_ignore1" disabled>
                                                        <label class="form-check-label ms-1 small" for="price_ignore1">
                                                            가격무시
                                                        </label>
                                                    </div>
                                                <?php endif; ?>



                                                <div class="row g-2 align-items-center">
                                                    <div class="col-md-6">
                                                        <label class="form-label small mb-1 text-muted">분양가</label>
                                                        <div class="input-group input-group-sm">
                                                            <input type="text" class="form-control text-end"
                                                                name="isale_amt" id="isale_amt"
                                                                value="<?= str_replace(',', '', $data['isale_amt']) ?>"
                                                                disabled>
                                                            <span class="input-group-text">만원</span>
                                                        </div>
                                                    </div>

                                                    <div class="col-md-6">
                                                        <label class="form-label small mb-1 text-muted">프리미엄</label>
                                                        <div class="input-group input-group-sm">
                                                            <input type="text" class="form-control text-end"
                                                                name="prem_amt" id="prem_amt"
                                                                value="<?= str_replace(',', '', $data['prem_amt']) ?>"
                                                                disabled>
                                                            <span class="input-group-text">만원</span>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>

                                <tr>
                                    <th>평형</th>
                                    <td>
                                        <input type="hidden" name="atcl_ptp_nm" id="atcl_ptp_nm"
                                            value="<?= $data['ptp_nm'] ?>">
                                        <?php if (!empty($ptpList['result'])): ?>
                                            <select class="form-select" name="atcl_hscp_no" id="atcl_hscp_no" disabled>
                                                <option value="">-단지선택-</option>
                                                <?php
                                                foreach ($ptpList['result'] as $ptp):
                                                    $isSelected = ($ptp['ptpNo'] === $data['ptp_no']);
                                                    ?>
                                                    <option value="<?= $ptp['ptpNo'] ?>" <?= $isSelected ? ' selected="selected"' : '' ?>>
                                                        <?= $ptp['ptpNm'] ?>
                                                    </option>
                                                <?php endforeach; ?>

                                            </select>
                                        <?php endif; ?>
                                    </td>

                                    <th>층 / 총층</th>
                                    <td>
                                        <div class="d-flex align-items-center gap-2">
                                            <input type="text" class="form-control form-control-sm"
                                                style="max-width:80px;" name="atcl_floor" id="atcl_floor"
                                                value="<?= $data['floor'] ?>" disabled>
                                            <span class="text-muted">/</span>
                                            <input type="text" class="form-control form-control-sm"
                                                style="max-width:80px;" name="atcl_floor2" id="atcl_floor2"
                                                value="<?= $data['floor2'] ?>" disabled>
                                        </div>
                                    </td>
                                </tr>

                                <?php if ($data['hscplqry_lv'] == '3'): ?>
                                    <tr>
                                        <th>공급면적</th>
                                        <td>
                                            <span style="color:#F21E1E"><?= $data['sply_spc'] ?></span>
                                        </td>
                                        <th>전용면적</th>
                                        <td>
                                            <span style="color:#F21E1E"><?= $data['excls_spc'] ?></span>
                                        </td>
                                    </tr>
                                <?php endif; ?>

                                <?php if (empty($data['hscp_no'])): ?>
                                    <?php if ($data['rlet_type_cd'] == 'C01' || $data['rlet_type_cd'] == 'C02' || ($data['rlet_type_cd'] == 'C03' and $data['trade_type_cd'] != 'A1') || $data['rlet_type_cd'] == 'D02' || $data['rlet_type_cd'] == 'D01' || $data['rlet_type_cd'] == 'E04'): ?>
                                        <tr>
                                            <th>공급면적</th>
                                            <td>
                                                <span style="color:#002EE7"><?= $data['sply_spc'] ?></span>
                                            </td>
                                            <th>전용면적</th>
                                            <td>
                                                <span style="color:#002EE7"><?= $data['excls_spc'] ?></span>
                                            </td>
                                        </tr>
                                    <?php elseif (
                                        ($data['rlet_type_cd'] == 'C03' and $data['trade_type_cd'] == 'A1') ||
                                        $data['rlet_type_cd'] == 'C04' ||
                                        ($data['rlet_type_cd'] == 'C05' and $data['trade_type_cd'] == 'A1') ||
                                        $data['rlet_type_cd'] == 'D03' ||
                                        $data['rlet_type_cd'] == 'D04' ||
                                        $data['rlet_type_cd'] == 'E01' ||
                                        $data['rlet_type_cd'] == 'E02' ||
                                        $data['rlet_type_cd'] == 'Z00'
                                    ): ?>
                                        <tr>
                                            <th>대지면적</th>
                                            <td>
                                                <span style="color:#002EE7"><?= $data['grnd_spc'] ?></span>
                                            </td>
                                            <th>연면적</th>
                                            <td>
                                                <span style="color:#002EE7"><?= $data['tot_spc'] ?></span>
                                            </td>
                                        </tr>
                                    <?php elseif ($data['rlet_type_cd'] == 'C04'): ?>
                                        <tr>
                                            <th>대지면적</th>
                                            <td>
                                                <span style="color:#002EE7"><?= $data['grnd_spc'] ?></span>
                                            </td>
                                            <th>건축면적</th>
                                            <td>
                                                <span style="color:#002EE7"><?= $data['bldg_spc'] ?></span>
                                            </td>
                                        </tr>
                                    <?php endif; ?>
                                <?php endif; ?>

                                <?php if ($data['vir_addr_yn'] == 'Y'): ?>
                                    <tr>
                                        <th>가주소 여부</th>
                                        <td><span><?= $data['vir_addr_yn'] ?></span></td>

                                        <th>검증참고란</th>
                                        <td><span><?= $data['registerBookUniqueNo'] ?></span></td>
                                    </tr>
                                <?php endif; ?>

                                <?php

                                switch ($data['ownerTypeCode']):
                                    case "0":
                                        $ownerTypeCode = "개인";
                                        break;
                                    case "1":
                                        $ownerTypeCode = "법인";
                                        break;
                                    case "2":
                                        $ownerTypeCode = "외국인";
                                        break;
                                    case "3":
                                        $ownerTypeCode = "위임장";
                                        break;
                                    default:
                                        $ownerTypeCode = "";
                                        break;
                                endswitch;

                                ?>
                                <tr>
                                    <th>소유자 구분</th>
                                    <td><span><?= $ownerTypeCode ?></span></td>

                                    <th>미등기 검증요청</th>
                                    <td><span><?= $data['noRgbkVrfcReqYn'] ?></span></td>
                                </tr>

                                <tr>
                                    <th>건축물대장 면적 검증요청</th>
                                    <td><span><?= $data['areaByBdbkVrfcReqYn'] ?></span></td>

                                    <th>등기부 고유번호</th>
                                    <td><span><?= $data['registerBookUniqueNumber'] ?></span></td>
                                </tr>

                            </tbody>
                        </table>
                    </div>
                </div>
                <?php if ($usr_level == '1'): ?>
                    <div class="card-footer d-flex justify-content-end gap-1">
                        <button class="mb-2 me-2 btn-transition btn btn-outline-secondary" id="priceModify"
                            onclick="priceChange();" style="display: none;">가격수정</button>
                        <button class="mb-2 me-2 btn-transition btn btn-outline-secondary" id="btnModify">수정</button>
                        <button class="mb-2 me-2 btn btn-primary" id="btnSave" onclick="modifyInfo();" disabled>저장</button>
                    </div>
                <?php endif; ?>
            </div>
        </div>

        <?php if (!empty($detail_hscp)): ?>
            <?php
            $apt_rlet_type_cd = ['A01', 'A02', 'A03', 'A04', 'B01', 'B02', 'B03'];
            $villa_rlet_type_cd = ['A05', 'A06'];
            if (isset($detail_hscp['aptType']) && in_array($detail_hscp['aptType'], $apt_rlet_type_cd)):
                ?>
                <div class="main-card mb-2 card">
                    <div class="card-body ">
                        <h5 class="card-title">단지 정보</h5>
                        <table class="table table-bordered table-sm tbl_basic2 apt-info-table">
                            <tr>
                                <th>단지명</th>
                                <td><?= $detail_hscp['aptName']; ?></td>
                                <th>소재주소</th>
                                <td><?= $detail_hscp['addr']; ?></td>
                                <th>상세주소</th>
                                <td><?= $detail_hscp['dtlAddr']; ?></td>
                                <th>사용승인일</th>
                                <td><?= $detail_hscp['useAprvYmd']; ?></td>
                                <th>단지 총 동수</th>
                                <td><?= $detail_hscp['dongCount']; ?></td>
                            </tr>
                        </table>
                    </div>
                </div>
            <?php endif; ?>

            <?php
            if (isset($detail_hscp['aptType']) && in_array($detail_hscp['aptType'], $villa_rlet_type_cd)):
                ?>
                <div class="main-card mb-2 card">
                    <div class="card-body ">
                        <h5 class="card-title">단지 정보</h5>
                        <table class="table table-bordered table-sm tbl_basic2 apt-info-table">
                            <tr>
                                <th>단지명</th>
                                <td><?= $detail_hscp['villaName']; ?></td>
                                <th>단지타입명</th>
                                <td colspan="3"><?= $detail_hscp['villaTypeName']; ?></td>
                                <th>단지 총 세대수</th>
                                <td><?= $detail_hscp['totHsehCnt']; ?></td>
                                <th>단지 총 동수 </th>
                                <td><?= $detail_hscp['totDongCnt']; ?></td>

                                <th>주소(광역시/도)</th>
                                <td><?= $detail_hscp['city']; ?></td>
                                <th>주소(시군구)</th>
                                <td><?= $detail_hscp['dvsn']; ?></td>

                                <th>주소(읍면동)</th>
                                <td><?= $detail_hscp['sec']; ?></td>
                                <th>소재 동이하 상세주소</th>
                                <td><?= $detail_hscp['dtlAddr']; ?></td>
                            </tr>
                            <tr>
                                <th>소재 주소(전체)</th>
                                <td colspan="17"><?= $detail_hscp['addr']; ?></td>
                            </tr>
                        </table>
                    </div>
                </div>
            <?php endif; ?>
        <?php endif; ?>

        <div class="main-card mb-2 card">
            <div class="card-body ">
                <h5 class="card-title">상태변경</h5>
                <?php foreach ($codes as $c): ?>
                    <?php if ($c['category'] === "STEP_VERIFICATION"): ?>
                        <button class="mb-2 me-2 btn btn-light"
                            onclick="fn_status_change(<?= $data['vr_sq'] ?>, '<?= $c['cd'] ?>', '<?= $c['cd_nm'] ?>');"><?= $c['cd_nm'] ?></button>
                    <?php endif; ?>
                <?php endforeach; ?>
            </div>
        </div>


        <div class="main-card mb-2 card" id="docu_chk" style="display: none;">
            <div class="card-body">
                <h5 class="card-title">서류확인 정보</h5>

                <table class="table table-bordered table-sm tbl_basic2 apt-info-table">
                    <colgroup>
                        <col width="60%">
                        <col>
                    </colgroup>

                    <tbody>
                        <tr>
                            <!-- 좌측 : 이미지 -->
                            <td>
                                <div id="douc_img_dis" class="py-2">
                                    <?php if (!empty($data['confirm_doc_img_url'])): ?>

                                        <?php if ($data['confirm_doc_img_url_save_yn'] == 'Y'):
                                            if (!empty($record)) {
                                                $img_path = $record['file_path'] . $record['file_name'];
                                                $ext = $record['file_ext'];
                                            } else {
                                                $img_path = '';
                                                $ext = '';
                                            }
                                            if (strtolower($ext) == '.pdf'):
                                                ?>
                                                <iframe src="<?= $server_addr ?><?= $img_path ?>" frameborder="0" loading="lazy"
                                                    style="padding: 10px 0;width:100%; height:800px;"></iframe><br>
                                            <?php elseif (!in_array($ext, ['.zip', '.ZIP', '.pdf', '.PDF'])): ?>
                                                <?php if (!empty($arrRecord) && is_array($arrRecord)): ?>
                                                    <?php foreach ($arrRecord as $row):
                                                        $arr_img_path = $row['file_path'] . $row['file_name'];
                                                    ?>
                                                        <a href="<?= $arr_img_path ?>">
                                                            <?php if (strcmp($img_path, $arr_img_path) == 0): ?>
                                                                <img id="photo-display" src="<?= $img_path ?>" alt="Image"
                                                                    style="width:100%;max-width:945px;min-width:100%;border:0;" />
                                                            <?php endif; ?>
                                                        </a>
                                                    <?php endforeach; ?>
                                                <?php endif; ?>
                                            <?php endif; ?>

                                        <?php else:
                                            $img_path = $data['confirm_doc_img_url'];
                                            $ext = strrchr($data['confirm_doc_img_url'], ".");	//맨뒤에.부터 자른다    
                                    
                                            if (strtolower($ext) == '.pdf'):
                                                ?>
                                                <iframe src="<?= $img_path ?>" frameborder="0" loading="lazy"
                                                    style="padding: 10px 0;width:100%; height:800px;"></iframe>
                                            <?php else: ?>

                                            <?php endif; ?>
                                            <img id="photo-display" src="<?= $img_path ?>" alt="Image" loading="lazy"
                                                style="width:100%;max-width:945px;min-width:100%;border:0;" />
                                        <?php endif; ?>
                                    <?php else: ?>

                                        <a href="#" rel="lightbox[gallery]">
                                            <img id="photo-display" src="/plugin/img/photo.gif" alt="Image" loading="lazy"
                                                style="width:100%; max-width:945px; border:0;">
                                        </a>


                                    <?php endif; ?>
                                </div>
                                <?php if (empty($data['confirm_doc_img_url'])): ?>
                                    <div id="div_fild_upload" class="text-end">
                                        <label class="btn btn-sm btn-outline-secondary mb-0">
                                            <i class="fa fa-upload me-1"></i> 업로드
                                            <input type="file" id="docu_file" name="docu_file" class="d-none"
                                                onchange="myfile_onchange(event)" />
                                        </label>
                                    </div>
                                <?php endif; ?>
                            </td>

                            <!-- 우측 : 정보 -->
                            <td valign="top" class="pt-2">
                                <table class="table table-sm tbl_basic2 table-bordered">
                                    <colgroup>
                                        <col width="30%">
                                        <col>
                                    </colgroup>

                                    <tbody>
                                        <tr>
                                            <th>확인담당자</th>
                                            <td>관리자</td>
                                        </tr>

                                        <tr>
                                            <th>확인여부</th>
                                            <td>
                                                <select class="form-select" id="fax_conf_res_d11"
                                                    name="fax_conf_res_d11">
                                                    <option value="">-선택-</option>
                                                    <?php foreach ($codes as $c): ?>
                                                        <?php if ($c['category'] === "CONFIRM_RESULT_D11"): ?>
                                                            <option value="<?= $c['cd'] ?>" <?= ($c['cd'] === $data['result_d11']) ? 'selected' : '' ?>>
                                                                <?= $c['cd_nm'] ?>
                                                            </option>
                                                        <?php endif; ?>
                                                    <?php endforeach; ?>
                                                </select>
                                            </td>
                                        </tr>

                                        <tr>
                                            <th>홍보확인서<br>미확인여부상세</th>
                                            <td>
                                                <table class="table tbl_basic2 table-bordered">
                                                    <tr>
                                                        <?php
                                                        $checks = explode('|', $data['comment']);
                                                        // if (in_array($confirm['code_d11'], ['20011', '20012'])) {
                                                        $disabled = '';
                                                        // } else {
                                                        $disabled = ' disabled="disabled"';
                                                        // }
                                                        
                                                        $attributes = [
                                                            'style' => 'font-weight:normal;',
                                                        ];

                                                        $nCnt = 0;
                                                        $code_comment = [];
                                                        foreach ($codes as $c) {
                                                            if ($c['category'] === "CONSULTANT_COMMENT") {
                                                                array_push($code_comment, $c);
                                                            }
                                                        }

                                                        foreach ($code_comment as $key => $value) {
                                                            if ($nCnt % 2 == 0 && $nCnt != 0) {
                                                                echo '</tr><tr>';
                                                            }

                                                            if (in_array($key, $checks)) {
                                                                $check = TRUE;
                                                            } else {
                                                                $check = FALSE;
                                                            }

                                                            ?>
                                                            <td style="border: 0; padding:2px 0 2px 0; height:18px;">
                                                                <div class="form-check d-flex align-items-center mb-0">
                                                                    <input class="form-check-input mt-0" type="checkbox"
                                                                        id="comment_<?= $key ?>" disabled>
                                                                    <label class="form-check-label ms-1 small"
                                                                        for="price_ignore1">
                                                                        <?= $value['cd_nm'] ?>
                                                                    </label>
                                                                </div>
                                                            </td>


                                                            <?php $nCnt++;
                                                        } ?>

                                                        <?php if ($nCnt > 0) { ?>
                                                        </tr>
                                                    <?php } ?>
                                                </table>
                                            </td>
                                        </tr>

                                        <tr>
                                            <th>확인 내용</th>
                                            <td>
                                                <select class="form-select" id="fax_conf_yn_1">
                                                    <option value="">-선택-</option>
                                                    <option value="1" <?php if ($data['success'] == '1')
                                                        echo "selected"; ?>>
                                                        전체일치</option>
                                                    <option value="2" <?php if ($data['success'] == '2')
                                                        echo "selected"; ?>>
                                                        전체불일치</option>
                                                </select>
                                            </td>
                                        </tr>

                                        <tr>
                                            <th>매물주소</th>
                                            <td class="d-flex gap-2">
                                                <select class="form-select" id="fax_conf_yn_2">
                                                    <option value="">-선택-</option>
                                                    <option value="10000" <?php if ($data['fax_conf_yn_2'] == '10000')
                                                        echo "selected"; ?>>일치</option>
                                                    <option value="20000" <?php if ($data['fax_conf_yn_2'] == '20000')
                                                        echo "selected"; ?>>불일치</option>
                                                </select>
                                                <input type="text" class="form-control" id="fax_conf_yn_info_2"
                                                    value="<?= str_replace(',', '', $data['fax_conf_yn_info_2']) ?>">
                                            </td>
                                        </tr>

                                        <tr>
                                            <th>가격 거래구분</th>
                                            <td class="d-flex gap-2">
                                                <select class="form-select" id="fax_conf_yn_3">
                                                    <option value="">-선택-</option>
                                                    <option value="10000">일치</option>
                                                    <option value="20000">불일치</option>
                                                </select>
                                                <input type="text" class="form-control" id="fax_conf_yn_info_3"
                                                    value="<?= str_replace(',', '', $data['fax_conf_yn_info_3']) ?>">
                                            </td>
                                        </tr>

                                        <tr>
                                            <th>의뢰인정보</th>
                                            <td class="d-flex gap-2">
                                                <select class="form-select" id="fax_conf_yn_4">
                                                    <option value="">-선택-</option>
                                                    <option value="10000">일치</option>
                                                    <option value="20000">불일치</option>
                                                </select>
                                                <input type="text" class="form-control" id="fax_conf_yn_info_4"
                                                    value="<?= str_replace(',', '', $data['fax_conf_yn_info_4']) ?>">
                                            </td>
                                        </tr>

                                        <tr>
                                            <th>메모</th>
                                            <td class="d-flex align-items-end gap-1">
                                                <textarea class="form-control" id="memo_fax" rows="2"
                                                    style="resize: none;"><?= $memo['memo'] ?></textarea>
                                                <button type="button" class="btn btn-sm btn-outline-secondary"
                                                    onclick="saveMemo('fax');" style="white-space: nowrap;">
                                                    저장
                                                </button>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="card-footer d-flex justify-content-end">
                <button type="button" class="btn btn-success btn-sm" onclick="saveDocu();">
                    저장
                </button>
            </div>
        </div>

        <div class="main-card mb-2 card" id="call_chk" style="display: none;">
            <div class="card-body">
                <h5 class="card-title">전화확인 정보</h5>

                <table class="table table-bordered table-sm tbl_basic2 apt-info-table">
                    <colgroup>
                        <col width="15%" />
                        <col width="35%" />
                        <col width="15%" />
                        <col width="35%" />
                    </colgroup>
                    <tr>
                        <th>의뢰인(매도자) 전화번호</th>
                        <td>
                            <?
                            if ($data['stat_cd'] == '19' || $data['stat_cd'] == '60' || $data['stat_cd'] == '69') {
                                echo ('***');
                            } else {
                                echo ($data['seller_tel_no']);
                            }
                            ?>
                        </td>
                        <th>개인정보 제공동의</th>
                        <td>
                            <select class="form-select" name="tel_agree" id="tel_agree">
                                <option value="">-선택-</option>
                                <?php foreach ($codes as $c): ?>
                                    <?php if ($c['category'] === "CONFIRM_RESULT_T11"): ?>
                                        <option value="<?= $c['cd'] ?>" <?php if ($c['cd'] === $data['tel_agree']) {
                                              echo "selected";
                                          } ?>><?= $c['cd_nm'] ?></option>
                                    <?php endif; ?>
                                <?php endforeach; ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>의뢰인(매도자) 이름</th>
                        <td>
                            <?php
                            if ($data['stat_cd'] == '19' || $data['stat_cd'] == '60' || $data['stat_cd'] == '69') {
                                echo ('***');
                            } else {
                                echo ($data['seller_nm']);
                            }
                            ?>
                        </td>
                        <th>확인담당자</th>
                        <td><?= $data['usr_nm'] ?></td>

                    </tr>
                    <tr>
                        <th rowspan="5">통화내용녹취파일</th>
                        <td rowspan="5" class="align-top">

                            <!-- 기존 업로드된 파일 정보 -->
                            <?php if (!empty($tel)) { ?>
                                <div class="mb-2 small">
                                    <div class="d-flex align-items-center gap-2 flex-wrap">
                                        <a href="<?= $tel['file_url'] ?? '#' ?>" class="text-decoration-none">
                                            <i class="fa fa-file-audio-o me-1"></i><?= $tel['file_name'] ?>
                                        </a>
                                        <span class="badge text-dark"><?= $tel['file_size'] ?>kb</span>
                                        <span class="text-muted"><?= $tel['insert_tm'] ?></span>
                                    </div>
                                </div>
                            <?php } ?>

                            <!-- 파일 업로드 -->
                            <div class="d-flex align-items-center gap-2 mb-2">
                                <input class="form-control form-control-sm" id="virtualFileTextBox1" readonly="readonly"
                                    placeholder="파일을 선택하세요" style="max-width:260px;" />

                                <label class="btn btn-sm btn-outline-secondary mb-0">
                                    <i class="fa fa-upload me-1"></i> 업로드
                                    <input type="file" id="rec_file" name="rec_file" class="d-none"
                                        onchange="cfSetFile(this, 'virtualFileTextBox1');" />
                                </label>
                            </div>

                            <!-- 확인 체크 -->
                            <div class="form-check mb-0">
                                <input class="form-check-input" type="checkbox" id="chk_telv" name="chk_telv">
                                <label class="form-check-label" for="chk_telv">녹취파일 확인</label>
                            </div>

                        </td>

                        <th>확인내용</th>
                        <td>
                            <select class="form-select form-select-sm" name="tel_suc" id="tel_suc" disabled>
                                <option value="">-선택-</option>
                                <option value="1" <?= ($data['tel_suc'] == '1') ? 'selected' : '' ?>>전체일치</option>
                                <option value="2" <?= ($data['tel_suc'] == '2') ? 'selected' : '' ?>>전체불일치</option>
                            </select>
                        </td>
                    </tr>

                    <tr>
                        <th>매물주소</th>
                        <td class="d-flex gap-2">
                            <select class="form-select" name="tel_conf_yn_2" id="tel_conf_yn_2" disabled="disabled">
                                <option value="">-선택-</option>
                                <option value="10000" <?php if ($data['tel_conf_yn_2'] == '10000')
                                    echo "selected"; ?>>일치
                                </option>
                                <option value="20000" <?php if ($data['tel_conf_yn_2'] == '20000')
                                    echo "selected"; ?>>불일치
                                </option>
                            </select>
                            <input type="text" class="form-control" name="tel_conf_yn_info_2" id="tel_conf_yn_info_2"
                                value="<?= str_replace(',', '', $data['tel_conf_yn_info_2']) ?>" size="20" />
                        </td>
                    </tr>
                    <tr>
                        <th>가격 거래구분</th>
                        <td class="d-flex gap-2">
                            <select class="form-select" name="tel_conf_yn_3" id="tel_conf_yn_3" disabled="disabled">
                                <option value="">-선택-</option>
                                <option value="10000" <?php if ($data['tel_conf_yn_3'] == '10000')
                                    echo "selected"; ?>>일치
                                </option>
                                <option value="20000" <?php if ($data['tel_conf_yn_3'] == '20000')
                                    echo "selected"; ?>>불일치
                                </option>
                            </select>
                            <input type="text" class="form-control" name="tel_conf_yn_info_3" id="tel_conf_yn_info_3"
                                value="<?= str_replace(',', '', $data['tel_conf_yn_info_3']) ?>" size="20" />
                        </td>
                    </tr>
                    <tr>
                        <th>의뢰인정보</th>
                        <td class="d-flex gap-2">
                            <select class="form-select" name="tel_conf_yn_4" id="tel_conf_yn_4" disabled="disabled">
                                <option value="">-선택-</option>
                                <option value="10000" <?php if ($data['tel_conf_yn_4'] == '10000')
                                    echo "selected"; ?>>일치
                                </option>
                                <option value="20000" <?php if ($data['tel_conf_yn_4'] == '20000')
                                    echo "selected"; ?>>불일치
                                </option>
                            </select>
                            <input type="text" class="form-control" name="tel_conf_yn_info_4" id="tel_conf_yn_info_4"
                                value="<?= str_replace(',', '', $data['tel_conf_yn_info_4']) ?>" size="20" />
                        </td>
                    </tr>
                    <tr>
                        <th>전화확인 1차 실패</th>
                        <td>
                            <div class="d-flex justify-content-start gap-3">

                                <div class="form-check d-flex align-items-center mb-0">
                                    <input class="form-check-input" type="checkbox" name="tel_conf_yn_5" id="fail_chk1"
                                        value="20040" onclick="check_only_fail(this)">
                                    <label class="form-check-label ms-1" for="fail_chk1">
                                        주소정보 오기재
                                    </label>
                                </div>

                                <div class="form-check d-flex align-items-center mb-0">
                                    <input class="form-check-input" type="checkbox" name="tel_conf_yn_5" id="fail_chk2"
                                        value="20041" onclick="check_only_fail(this)">
                                    <label class="form-check-label ms-1" for="fail_chk2">
                                        동일 번호 등록제한
                                    </label>
                                </div>

                            </div>
                        </td>
                    </tr>

                    <tr>
                        <th>메모</th>
                        <td>
                            <div class="d-flex flex-column gap-1" style="">
                                <textarea class="form-control" name="memo_tel" id="memo_tel" rows="2"
                                    style="resize: none;"><?= $memo['memo'] ?></textarea>

                                <div class="text-end">
                                    <button type="button" class="btn btn-sm btn-light" onclick="saveMemo('tel');">
                                        저장
                                    </button>
                                </div>
                            </div>
                        </td>
                        <th>통화실패사유</th>
                        <td class="d-flex gap-2">
                            <select class="form-select" name="tel_fail_cause" id="tel_fail_cause">
                                <?php foreach ($codes as $c): ?>
                                    <?php if ($c['category'] === "TEL_FAIL_CAUSE"): ?>
                                        <option value="<?= $c['cd'] ?>" <?php if ($c['cd'] === $data['tel_fail_cause']) {
                                              echo 'selected';
                                          } ?>><?= $c['cd_nm'] ?></option>
                                    <?php endif; ?>
                                <?php endforeach; ?>

                            </select>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="card-footer d-flex justify-content-end">
                <?php
                if ($usr_level == '1') {
                    ?>
                    <button class="btn btn-sm btn-light" style="white-space: nowrap;" onclick="saveTel();">
                        저장
                    </button>
                    <?php
                }
                ?>
            </div>
        </div>


        <div class="main-card mb-2 card" id="regibox">
            <div class="card-body">
                <h5 class="card-title">등기부등본확인 정보</h5>

                <table class="table table-bordered table-sm tbl_basic2 apt-info-table">
                    <colgroup>
                        <col width="60%">
                        <col>
                    </colgroup>

                    <tbody>
                        <tr>
                            <!-- 좌측 : 이미지 -->
                            <td>
                                <?php if (!empty($data['cert_register'])): ?>
                                    <?php if ($data['cert_register_save_yn'] == 'Y'): ?>
                                        <?php if (strtolower($file_pdf) == 'pdf') { ?>
                                            <iframe src="<?= $server_addr ?><?= $regi_pdf_path ?>" frameborder="0" loading="lazy"
                                                style="padding: 10px 0;width:100%; height:800px;"></iframe><br />
                                        <?php } else { ?>
                                            <div id="regi_file_dis" style="padding: 10px 0px; height: 730px; overflow-y: auto;">
                                                <?php if (empty($arrRegist)) { ?>
                                                    <img id="photo-display2" src="/img/photo.gif" alt="Image" loading="lazy"
                                                        style="width:100%;max-width:945px;min-width:100%;border:0;" />
                                                <?php } else {
                                                    foreach ($arrRegist as $row) {
                                                        $img_path = $row['file_path'] . $row['file_name']; ?>
                                                        <a href="<?= $img_path ?>" class="default_val" target="_blank"
                                                            rel="lightbox[gallery1]">
                                                            <img id="photo-display2" src="'.$img_path.'" alt="Image"
                                                                style="width:100%;max-width:945px;min-width:100%;border:0;" />
                                                        </a>
                                                    <?php }
                                                } ?>
                                            </div><br />
                                        <?php } ?>
                                    <?php else: ?>
                                        <?php if (strtolower($file_pdf) == 'pdf') { ?>
                                            <iframe src="<?= $regi_pdf_path ?>" frameborder="0" loading="lazy"
                                                style="padding: 10px 0;width:100%; height:800px;"></iframe><br>
                                        <?php } else { ?>
                                            <div id="regi_file_dis" style="padding: 10px 0px; height: 730px; overflow-y: auto;">
                                                <?php if (empty($arr_cert_register)) { ?>
                                                    <img id="photo-display2" src="/plugin/img/photo.gif" alt="Image" loading="lazy"
                                                        style="width:100%;max-width:945px;min-width:100%;border:0;" />
                                                <?php } else {
                                                    foreach ($arr_cert_register as $img_path) { ?>
                                                        <a href="<?= $img_path ?>" class="default_val" target="_blank"
                                                            rel="lightbox[gallery1]">
                                                            <img id="photo-display2" src="'.$img_path.'" alt="Image"
                                                                style="width:100%;max-width:945px;min-width:100%;border:0;" />
                                                        </a>
                                                    <?php }
                                                } ?>
                                            </div><br />
                                        <?php } ?>
                                    <?php endif; ?>

                                <?php else: ?>
                                    <?php if (empty($regist)) {
                                        $regi_img_path = '/plugin/img/photo.gif';
                                    } else {
                                        if (empty($regist['file_path']) || empty($regist['file_name'])) {
                                            $regi_img_path = '/plugin/img/photo.gif';
                                        } else {
                                            $regi_img_path = $regist['file_path'] . $regist['file_name'];

                                            if ($regist['cloud_upload_yn'] === "Y") {
                                                $regi_img_path = NCLOUD_OBJECT_STORAGE_URL . $regi_img_path;
                                            }
                                        }

                                    }
                                    ?>

                                    <div id="regi_file_dis" style="padding: 10px 0;">
                                        <img id="photo-display2" src="<?= $regi_img_path ?>" alt="Image" loading="lazy"
                                            style="width:100%;max-width:945px;min-width:100%;border:0;" />
                                    </div>
                                    <div id="regi_file_pdf" style="padding: 10px 0; display:none;">
                                        <a href="<?= $regi_pdf_path ?>" class="embed"></a>
                                    </div>
                                    <a href="<?= $regi_img_path ?>" class="default_val" target="_blank">등기부등본
                                        보기</a>&nbsp;&nbsp;&nbsp;
                                    <a href="" class="default_val" target="_blank" rel="lightbox" id="hongbo"
                                        onclick="chk_hongbo(event); return false;">홍보확인서 보기</a>
                                <?php endif; ?>
                            </td>

                            <!-- 우측 : 정보 -->
                            <td valign="top" class="pt-2">
                                <table class="table table-sm w-100 tbl_basic2 table-bordered">
                                    <colgroup>
                                        <col width="30%">
                                        <col>
                                    </colgroup>

                                    <tbody>
                                        <tr>
                                            <th>확인담당자</th>
                                            <td>
                                                <?= $data['reg_charger_nm'] ?>

                                                <input type="button" class="btn btn-sm btn-outline-light"
                                                    name="btnSilver" value="등기부등본 열람"
                                                    onClick="window.open('https://www.realtop.co.kr/cm/CMMBR01C2.asp2?cmInstCd=Z265&cmUserNo=<?= session('usr_id') ?>&cmKey=nxfT5VLGXg&cmName=<?= session('usr_id') ?>&cmDNm=confirms&cmAutoLogInYn=Y&cmUrl=/re/NVRET01R0&cmEncoding=UTF-8')">
                                            </td>
                                        </tr>

                                        <tr>
                                            <th>확인내용</th>
                                            <td>
                                                <select class="form-select" id="reg_conf_yn_1" name="reg_conf_yn_1">
                                                    <option value="">-선택-</option>
                                                    <option value="1" <?php if ($data['reg_conf_yn_1'] == '1')
                                                        echo "selected"; ?>>전체일치</option>
                                                    <option value="2" <?php if ($data['reg_conf_yn_1'] == '2')
                                                        echo "selected"; ?>>전체불일치</option>
                                                </select>
                                            </td>
                                        </tr>

                                        <tr>
                                            <th>매물주소</th>
                                            <td class="d-flex gap-2">
                                                <select class="form-select" name="reg_conf_yn_2" id="reg_conf_yn_2">
                                                    <option value="">-선택-</option>
                                                    <option value="10000" <?php if ($data['reg_conf_yn_2'] == '10000')
                                                        echo "selected"; ?>>일치</option>
                                                    <option value="20000" <?php if ($data['reg_conf_yn_2'] == '20000')
                                                        echo "selected"; ?>>불일치
                                                    </option>
                                                </select>
                                                <input type="text" class="form-control" name="reg_conf_yn_info_2"
                                                    id="reg_conf_yn_info_2"
                                                    value="<?= str_replace(',', '', $data['reg_conf_yn_info_2']) ?>"
                                                    size="20" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>의뢰인정보</th>
                                            <td class="d-flex gap-2">
                                                <select class="form-select" name="reg_conf_yn_3" id="reg_conf_yn_3">
                                                    <option value="">-선택-</option>
                                                    <option value="10000" <?php if ($data['reg_conf_yn_3'] == '10000')
                                                        echo "selected"; ?>>일치</option>
                                                    <option value="20000" <?php if ($data['reg_conf_yn_3'] == '20000')
                                                        echo "selected"; ?>>불일치
                                                    </option>
                                                </select>
                                                <input type="text" class="form-control" name="reg_conf_yn_info_3"
                                                    id="reg_conf_yn_info_3"
                                                    value="<?= str_replace(',', '', $data['reg_conf_yn_info_3']) ?>"
                                                    size="20" />
                                            </td>
                                        </tr>

                                        <?php if ($data['vrfc_type_cd'] == "N"): ?>
                                            <tr>
                                                <th>소유자명 확인</th>
                                                <td>
                                                    <select class="form-select" name="ownerVerifiable" id="ownerVerifiable">
                                                        <option value="">-선택-</option>
                                                        <option value="1" <?php if ($data['owner_verifiable'] == "1")
                                                            echo "selected"; ?>>일치</option>
                                                        <option value="0" <?php if ($data['owner_verifiable'] == "0")
                                                            echo "selected"; ?>>불일치</option>
                                                    </select>
                                                </td>
                                            </tr>
                                        <?php endif; ?>
                                        <tr>
                                            <th>메모</th>
                                            <td class="d-flex align-items-end gap-1">
                                                <textarea type="text" class="form-control" name="memo_reg" id="memo_reg"
                                                    style="width:300px; height:45px;resize: none;"><?= $memo['memo'] ?></textarea>

                                                <button class="btn btn-sm btn-light" style="white-space: nowrap;"
                                                    onclick="saveMemo();">
                                                    저장
                                                </button>

                                            </td>
                                        </tr>
                                        <tr>
                                            <th>소유자명</th>
                                            <td style="color:#FF0000">
                                                <?
                                                if ($data['stat_cd'] == '19' || $data['stat_cd'] == '60' || $data['stat_cd'] == '69') {
                                                    echo ("***");
                                                } else {
                                                    echo ($data['ownerNm']);
                                                }
                                                ?>
                                            </td>
                                        </tr>

                                        <?php
                                        $sty = '';
                                        if (in_array($data['vrfc_type_cd'], array('O', 'M'))) {
                                            $sty = 'style="display:none;"';
                                        }
                                        ?>
                                        <tr <?= $sty ?>>
                                            <th>소유자번호</th>
                                            <td style="color:#FF0000">
                                                <?php
                                                if ($data['stat_cd'] == '19' || $data['stat_cd'] == '60' || $data['stat_cd'] == '69') {
                                                    echo ('***');
                                                } else {
                                                    echo ($data['ownerTelNo']);
                                                }
                                                ?>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="card-footer d-flex align-items-center">

                <!-- 왼쪽 버튼 영역 -->
                <?php if (empty($data['cert_register'])): ?>
                    <div class="d-flex gap-1">
                        <button class="btn btn-sm btn-outline-success" id="btnUploadModal">
                            <i class="fa fa-fw" aria-hidden="true"></i> 파일업로드
                        </button>
                        <!-- <button class="btn btn-sm btn-outline-secondary">
                            저장
                        </button> -->
                    </div>
                <?php endif; ?>

                <!-- 오른쪽 버튼 영역 -->
                <div class="ms-auto d-flex gap-1">
                    <?php if (
                        ($data['stat_cd'] < '45'
                            && $data['stat_cd'] >= '35'
                            && $data['stat_cd'] != '39'
                            && $data['stat_cd'] != '49')
                        || $usr_level == '1'
                    ): ?>
                        <button type="button" class="btn btn-light btn-sm" onclick="saveFinalRegi();">
                            최종실패
                        </button>

                        <button type="button" class="btn btn-primary btn-sm" onclick="saveRegi();">
                            저장
                        </button>
                    <?php endif; ?>
                </div>

            </div>

        </div>




        <div class="main-card mb-2 card">
            <div class="card-body ">
                <h5 class="card-title">정보변경 이력</h5>
                <div class="table-scroll">
                    <table class="table table-bordered table-sm tbl_basic2 apt-info-table">
                        <tr>
                            <th width="120" style="text-align: center;">진행상태</th>
                            <th width="150" style="text-align: center;">변경내용</th>
                            <th width="90" style="text-align: center;">처리자(ID)</th>
                            <th width="120" style="text-align: center;">처리일시</th>
                            <th style="text-align: center;">세부내용</th>
                        </tr>
                        <?php if (!empty($history)) { ?>
                            <?php foreach ($history as $h) { ?>
                                <tr>
                                    <td style="text-align: center;"><?= $h['stat_cd_nm'] ?></td>
                                    <td style="text-align: center;"><?= $h['chg_type'] ?></td>
                                    <td style="text-align: center;"><?= $h['insert_id'] ?></td>
                                    <td style="text-align: center;"><?= $h['insert_tm'] ?></td>
                                    <td><?= $h['memo'] ?></td>

                                <?php } ?>
                            <?php } ?>
                    </table>
                </div>
            </div>
        </div>
    </div>

</form>


<!-- 동영상 업로드 팝업 -->
<?= $this->section('modals') ?>
<div class="modal fade" id="uploadModal" tabindex="-1">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">파일 업로드</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body p-0">
                <form id="frm_file_info" method="post" enctype="multipart/form-data" onsubmit="return false;">
                    <input type="hidden" name="vr_sq" value="<?= $data['vr_sq'] ?>">

                    <!-- 버튼 툴바 -->
                    <div class="d-flex justify-content-end gap-2 mb-3" style="padding: 16px 10px 0 0;">
                        <button type="button" class="btn btn-primary" id="uploadPick">
                            <i class="pe-7s-up-arrow"></i> 파일선택
                        </button>

                        <button type="button" class="btn btn-success" id="btnUpload">
                            <i class="pe-7s-up-arrow"></i> 파일업로드
                        </button>

                        <button type="button" class="btn btn-danger" id="btnRemove">
                            <i class="pe-7s-less"></i> 업로드취소
                        </button>
                    </div>

                    <!-- Dropzone 영역 -->
                    <div id="myDropzone" class="dropzone border rounded-3 p-4"
                        style="max-height: 400px;overflow-y: scroll;">
                        <div class="dz-message dz-message-fixed needsclick text-center">
                            <i class="pe-7s-upload mb-2" style="font-size:42px;"></i><br>
                            <strong class="fs-6">파일을 드래그하거나 클릭해서 추가하세요</strong><br>
                            <small class="text-muted">
                                사진 여러 장 가능 / 동영상은 1개만
                            </small>
                        </div>
                    </div>

                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal" id="mapModal" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">지도 보기</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body p-0">
                <div id="modalMap" style="width:100%; height:70vh; min-height:500px;"></div>
            </div>
        </div>
    </div>
</div>

<div class="modal" id="previewModal" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">미리보기</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body p-0">
                <img id="imgPreview" src="" alt="미리보기" width="100%" height="500px">
                <video id="vdoPreview" controls playsinline preload="metadata"
                    style="display: none;height: 500px;width: 100%;">
                    <source id="videoSource" src="" type="video/mp4">
                    브라우저가 video 태그를 지원하지 않습니다.
                </video>
            </div>
        </div>
    </div>
</div>
<?= $this->endSection() ?>

<style>
    #tbl-align-left {
        text-align: left;
    }
</style>
<script src="https://unpkg.com/dropzone@6.0.0-beta.1/dist/dropzone-min.js"></script>
<link href="https://unpkg.com/dropzone@6.0.0-beta.1/dist/dropzone.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">

    //거래구분에 따른 가격설정
    var but_ty = '<?= $data['trade_type_cd'] ?>';
    var regagre = '<?= $data['rgbk_confirm'] ?>';
    var telchkbox = '<?= $tel['file_name'] ?? '' ?>';

    var rlet_type_cd = '<?= $data['rlet_type_cd'] ?>';
    var failChk = '<?= $data['tel_conf_yn_5'] ?>';

    myfile_onchange = function (e) {
        var myfile = document.getElementById('docu_file');
        var holder = document.getElementById('douc_img_dis');

        e.preventDefault();

        var file = myfile.files[0];
        var reader = new FileReader();
        reader.onload = function (event) {
            var img = new Image();
            img.src = event.target.result;

            if (img.width > 560) {
                img.width = 560;
            }

            holder.innerHTML = '';
            holder.appendChild(img);
        };

        reader.readAsDataURL(file);
        return false;
    };

    regifile_onchange = function (e) {
        var myfile = document.getElementById('regi_file');
        var holder = document.getElementById('regi_file_dis');

        e.preventDefault();

        var file = myfile.files[0];
        var reader = new FileReader();
        reader.onload = function (event) {
            var img = new Image();
            img.src = event.target.result;

            if (img.width > 560) {
                img.width = 560;
            }

            holder.innerHTML = '';
            holder.appendChild(img);
        };

        reader.readAsDataURL(file);
        return false;
    };

    mobile1_onchange = function (e) {
        var myfile = document.getElementById('mobile1_file');
        var holder = document.getElementById('mobile1_file_dis');

        e.preventDefault();

        var file = myfile.files[0];
        var reader = new FileReader();
        reader.onload = function (event) {
            var img = new Image();
            img.src = event.target.result;

            if (img.width > 560) {
                img.width = 560;
            }

            holder.innerHTML = '';
            holder.appendChild(img);
        };

        reader.readAsDataURL(file);
        return false;
    };

    mobile2_onchange = function (e) {
        var myfile = document.getElementById('mobile2_file');
        var holder = document.getElementById('mobile2_file_dis');

        e.preventDefault();

        var file = myfile.files[0];
        var reader = new FileReader();
        reader.onload = function (event) {
            var img = new Image();
            img.src = event.target.result;

            if (img.width > 560) {
                img.width = 560;
            }

            holder.innerHTML = '';
            holder.appendChild(img);
        };

        reader.readAsDataURL(file);
        return false;
    };

    mobile3_onchange = function (e) {
        var myfile = document.getElementById('mobile3_file');
        var holder = document.getElementById('mobile3_file_dis');

        e.preventDefault();

        var file = myfile.files[0];
        var reader = new FileReader();
        reader.onload = function (event) {
            var img = new Image();
            img.src = event.target.result;

            if (img.width > 560) {
                img.width = 560;
            }

            holder.innerHTML = '';
            holder.appendChild(img);
        };

        reader.readAsDataURL(file);
        return false;
    };

    $(function () {

        // DOM Ready 시 즉시 blockUI 해제
        if (typeof blockUI !== 'undefined') {
            blockUI.unblockPage();
        }
        $('.blockUI').remove();
        $('body').css('overflow', '');
        
        // 페이지 완전 로드 후에도 다시 한번 해제
        $(window).on('load', function() {
            setTimeout(function() {
                if (typeof blockUI !== 'undefined') {
                    blockUI.unblockPage();
                }
                $('.blockUI').remove();
                $('.blockOverlay').remove();
                $('body').css('overflow', '');
                $('body').removeClass('modal-open');
            }, 100);
        });

        if (failChk == "20040") {
            $("#fail_chk1").attr("checked", true);
        } else if (failChk == "20041") {
            $("#fail_chk2").attr("checked", true);
        }

        if (regagre == "0") { //등기부등본 확인여부에 따라 등기부등본 div 표시여부 설정
            $("#regibox").hide();
        }

        if (telchkbox) {	//녹취파일 존재시 checked
            $("#chk_telv").attr("checked", true);
        }

        if (but_ty == "A1") {
            $("#buy_tra_cd3").show();
            $("#div_trade_type_price").show();

            if (rlet_type_cd == "B01" || rlet_type_cd == "B02" || rlet_type_cd == "B03") {
                $("#div_trade_type_price").hide();
                $("#div_trade_type_price2").show();
            }

        } else {
            $("#buy_tra_cd1").show();
            $("#buy_tra_cd2").show();
            $("#buy_tra_cd4").show();
            $("#div_trade_type_price_monthly").show();
        }

        //전화/서류 구분
        $("#atcl_vrtc_way").change(function () {
            if ($("#atcl_vrtc_way").val() == "T") {
                $("#docu_chk").hide();
                $("#call_chk").show();
            } else if ($("#atcl_vrtc_way").val() == "D") {
                $("#docu_chk").show();
                $("#call_chk").hide();
            }
        });

        if ($("#atcl_vrtc_way").val() == "T") {
            $("#docu_chk").hide();
            $("#call_chk").show();
        } else if ($("#atcl_vrtc_way").val() == "D") {
            $("#docu_chk").show();
            $("#call_chk").hide();
        }


        $("#btnModify").on("click", function () {

            $("#atcl_vrtc_way").prop("disabled", false);

            document.getElementById('atcl_amt1').disabled = false;
            document.getElementById('atcl_amt2').disabled = false;
            document.getElementById('atcl_amt3').disabled = false;
            document.getElementById('atcl_amt4').disabled = false;
            document.getElementById('prem_amt').disabled = false;
            document.getElementById('isale_amt').disabled = false;

            $("#price_ignore1").prop("disabled", false);
            $("#price_ignore2").prop("disabled", false);
            $("#priceModify").css("display", "");
            $("#btnSave").prop("disabled", false);

        });


        /**
         *  파일 Dropzone
         * */
        const dz = new Dropzone("#myDropzone", {
            url: "/m701/m701a/uploadFile",
            method: "post",
            paramName: "files",
            autoProcessQueue: false,   // 자동 업로드 끄기
            uploadMultiple: false,
            parallelUploads: 20,
            maxFilesize: 100,
            // acceptedFiles: '.ogg,.mp3,.wma,.wav,.au,.rm,.mid,.MP3,.OGG,.WMA,.WAV,.AU,.RM,.MID,.gsm',
            addRemoveLinks: true,
            dictRemoveFile: "삭제",
            dictDefaultMessage: "파일을 여기에 드래그하거나 클릭해서 추가하세요",
            dictFallbackMessage: "브라우저가 드래그앤드롭을 지원하지 않습니다.",
            dictFileTooBig: "파일이 너무 큽니다 (최대 {{maxFilesize}}MB)",
            dictInvalidFileType: "허용되지 않은 파일 형식입니다.",
            dictResponseError: "서버 오류가 발생했습니다.",
            dictCancelUpload: "업로드 취소",
            dictRemoveFile: "삭제",
            dictMaxFilesExceeded: "더 이상 파일을 추가할 수 없습니다.",
            init: function () {
                this.on("addedfile", function (file) {

                    if (this.files.length > 1) {
                        alert("파일은 1개만 업로드할 수 있습니다.");
                        this.removeFile(file);
                        return;
                    }
                });
            },
        });

        dz.on("addedfile", function (file) {
            const removeBtn = file.previewElement.querySelector(".dz-remove");

            if (removeBtn) {
                removeBtn.classList.add(
                    "btn",
                    "btn-sm",
                    "btn-outline-danger",
                    "mt-2"
                );
            }
        });


        let isFormDataAppended = false;
        dz.on("sending", function (file, xhr, formData) {
            if (isFormDataAppended) return;

            formData.append("vr_sq", $("#frm_file_info [name=vr_sq]").val());

            isFormDataAppended = true;
        });

        dz.on("queuecomplete", function () {
            location.reload();
        });

        dz.on("successmultiple", function () {
            isFormDataAppended = false;
        });
        dz.on("errormultiple", function () {
            isFormDataAppended = false;
        });
        dz.on("canceledmultiple", function () {
            isFormDataAppended = false;
        });
        dz.on("processingmultiple", function () { });

        // 업로드파일 선택
        $("#uploadPick").on("click", function () {
            isFormDataAppended = false;
            dz.hiddenFileInput.click();
        });

        $("#btnUpload").on("click", function () {
            dz.processQueue(); // 업로드 실행
            isFormDataAppended = false;
        });

        $("#btnRemove").on("click", function () {
            const files = dz.getAcceptedFiles();

            if (files.length === 0) {
                alert("삭제할 파일이 없습니다.");
                return;
            }

            files.forEach(function (file) {
                dz.removeFile(file);
            });
        });


        // 파일업로드 open
        $("#btnUploadModal").on("click", function () {

            $("#uploadModal").modal("show");
        });

    });

    /* 파일찾기 이미지 적용  */
    function cfSetFile(obj, id) {
        document.getElementById(id).value = obj.value;
    }


    // 가격수정
    function priceChange() {
        swal.fire({
            text: "가격을 수정하시겠습니까?",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "예",
            cancelButtonText: "아니오",
            closeOnConfirm: false,
            closeOnCancel: true,
            confirmButtonColor: "#3085d6",
            cancelButtonColor: "#d33",
        }).then((result) => {
            if (result.isConfirmed) {
                $.ajax({
                    url: '/m701/m701a/changePrice',
                    contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
                    method: 'POST',
                    data: $("#rcptFrm").serialize(),
                    beforeSend: function () {
                        blockUI.blockPage({
                            message: tpl
                        })
                    },
                    complete: function () {
                        blockUI.unblockPage()
                    },
                    error: function (xhr, error, thrown) {
                        blockUI.unblockPage()
                        var msg = "";
                        if (xhr.responseText != null) {
                            msg = xhr.responseText
                        } else {
                            msg = "잠시후 다시 시도해 주세요."
                        }

                        Swal.fire({
                            title: msg,
                            icon: "error"
                        })
                    },
                    success: function (result) {
                        if (result.code == '0') {
                            Swal.fire({
                                title: '정상 처리되었습니다.',
                                icon: "success"

                            })

                            location.reload();
                        } else {
                            Swal.fire({
                                title: result.msg,
                                icon: "error"
                            })
                        }
                    }
                });
            }
        });
    }


    // 상세정보수정
    function modifyInfo() {

        var rcptFrm = document.rcptFrm;
        var chkvrfc_hscp = '<?= $data['hscp_no'] ?>';
        var chkvrfc_ptp = '<?= $data['ptp_no'] ?>';
        var td_ty = '<?= $data['trade_type_cd'] ?>';
        var price_ignore1 = $('#price_ignore1').is(":checked");
        var price_ignore2 = $('#price_ignore2').is(":checked");
        var rlet_type_cd = '<?= $data['rlet_type_cd'] ?>';

        if (price_ignore1 == true || price_ignore2 == true) {
            console.log("in true function");
            $('#price_ignore').val('1');
        }

        // 검증구분
        var atcl_vrtc_way = $.trim($('#atcl_vrtc_way').val());
        if (atcl_vrtc_way == '') {
            swal.fire({
                text: '검증구분을 선택하세요.',
                icon: 'warning'
            });
            $("#atcl_vrtc_way").focus();
            return false;
        }

        if (chkvrfc_hscp != '' && chkvrfc_ptp != '') {

            var atcl_hscp_no = $("#atcl_hscp_no option:selected").val();
            if (atcl_hscp_no == '') {
                swal.fire({
                    text: '단지명을 선택해주세요.',
                    icon: 'warning'
                });
                $("#atcl_hscp_no").focus();
                return false;
            }

            var atcl_ptp_no = $("#atcl_ptp_no option:selected").val();
            if (atcl_ptp_no == '') {
                swal.fire({
                    text: '평형을 선택해주세요.',
                    icon: 'warning'
                });
                $("#atcl_ptp_no").focus();
                return false;
            }


            $("#atcl_hscp_nm").val($("#atcl_hscp_no option:selected").text());
            $("#atcl_ptp_nm").val($("#atcl_ptp_no option:selected").text());

        } else {

            // 거래구분
            var cntChecked = $('input[name="trade_type_cd"]:checked').length;

            if (cntChecked == 0) {
                swal.fire({
                    text: '거래구분을 선택하세요',
                    icon: 'warning'
                });
                return false;
            }

            // 상세주소
            var atcl_addr1 = $.trim($('#atcl_addr1').val());
            var atcl_addr1b = $.trim($('#atcl_addr1b').val());
            if (atcl_addr1b == '' && atcl_addr1 == '') {
                swal.fire({
                    text: '상세주소를 입력하세요.',
                    icon: 'warning'
                });
                //$("#atcl_addr1b").focus();
                return false;
            }

            var atcl_addr2 = $.trim($('#atcl_addr2').val());
        }
        //가격
        if (td_ty == 'A1') {		//매매일때

            var atcl_amt1 = $.trim($('#atcl_amt1').val());
            if (atcl_amt1 == '') {
                swal.fire({
                    text: '가격을 입력해주세요.',
                    icon: 'warning'
                });
                $("#atcl_amt1").focus();
                return false;
            }

            if (rlet_type_cd == "B01" || rlet_type_cd == "B02" || rlet_type_cd == "B03") {
                console.log('pass');
            } else {
                $("#atcl_amt4").val(atcl_amt1);
            }
        } else {					//전세나 월세일 때

            var atcl_amt2 = $.trim($('#atcl_amt2').val());
            if (atcl_amt2 == '') {
                swal.fire({
                    text: '가격을 입력해주세요.',
                    icon: 'warning'
                });
                $("#atcl_amt2").focus();
                return false;
            }

            var atcl_amt3 = $.trim($('#atcl_amt3').val());
            if (atcl_amt3 == '') {
                swal.fire({
                    text: '가격을 입력해주세요.',
                    icon: 'warning'
                });
                $("#atcl_amt3").focus();
                return false;
            }

        }

        //층
        var atcl_floor = $.trim($('#atcl_floor').val());
        if (atcl_floor == '') {
            swal.fire({
                text: '층을 입력해주세요.',
                icon: 'warning'
            });
            $("#atcl_floor").focus();
            return false;
        }


        swal.fire({
            text: "확인결과를 저장하시겠습니까?",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "예",
            cancelButtonText: "아니오",
            closeOnConfirm: false,
            closeOnCancel: true,
            confirmButtonColor: "#3085d6",
            cancelButtonColor: "#d33",
        }).then((result) => {
            if (result.isConfirmed) {
                $.ajax({
                    url: '/m701/m701a/modifyInfo',
                    contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
                    method: 'POST',
                    data: $("#rcptFrm").serialize(),
                    beforeSend: function () {
                        blockUI.blockPage({
                            message: tpl
                        })
                    },
                    complete: function () {
                        blockUI.unblockPage()
                    },
                    error: function (xhr, error, thrown) {
                        blockUI.unblockPage()
                        var msg = "";
                        if (xhr.responseText != null) {
                            msg = xhr.responseText
                        } else {
                            msg = "잠시후 다시 시도해 주세요."
                        }

                        Swal.fire({
                            title: msg,
                            icon: "error"
                        })
                    },
                    success: function (result) {
                        if (result.code == '0') {
                            Swal.fire({
                                title: '정상 처리되었습니다.',
                                icon: "success"

                            })

                            location.reload();
                        } else {
                            Swal.fire({
                                title: result.msg,
                                icon: "error"
                            })
                        }
                    }
                });
            }
        });
    }

    // 상태변경
    function fn_status_change(vr_sq, stat_cd, stat_nm) {

        swal.fire({
            text: "상태를 " + stat_nm + "로 변경 하시겠습니까?",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "예",
            cancelButtonText: "아니오",
            closeOnConfirm: false,
            closeOnCancel: true,
            confirmButtonColor: "#3085d6",
            cancelButtonColor: "#d33",
        }).then((result) => {
            if (result.isConfirmed) {
                $.ajax({
                    url: '/m701/m701a/chgArticleStatus',
                    contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
                    method: 'POST',
                    data: { 'vr_sq': vr_sq, 'stat_cd': stat_cd },
                    beforeSend: function () {
                        blockUI.blockPage({
                            message: tpl
                        })
                    },
                    complete: function () {
                        blockUI.unblockPage()
                    },
                    error: function (xhr, error, thrown) {
                        blockUI.unblockPage()
                        var msg = "";
                        if (xhr.responseText != null) {
                            msg = xhr.responseText
                        } else {
                            msg = "잠시후 다시 시도해 주세요."
                        }

                        Swal.fire({
                            title: msg,
                            icon: "error"
                        })
                    },
                    success: function (result) {
                        if (result.code == '0') {
                            Swal.fire({
                                title: '정상 처리되었습니다.',
                                icon: "success"

                            })

                            location.reload();
                        } else {
                            Swal.fire({
                                title: result.msg,
                                icon: "error"
                            })
                        }
                    }
                });
            }
        });


    }


    // 메모저장
    function saveMemo(type) {

        swal.fire({
            text: "저장 하시겠습니까?",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "예",
            cancelButtonText: "아니오",
            closeOnConfirm: false,
            closeOnCancel: true,
            confirmButtonColor: "#3085d6",
            cancelButtonColor: "#d33",
        }).then((result) => {
            if (result.isConfirmed) {
                var memo = "";
                if (type == "fax") {
                    memo = $("#memo_fax").val();
                } else if (type == "tel") {
                    memo = $("#memo_tel").val();
                } else {
                    memo = $("#memo_reg").val();
                }

                $.ajax({
                    url: '/m701/m701a/saveMemo',
                    contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
                    method: 'POST',
                    data: { 'vr_sq': vr_sq, 'memo': memo },
                    beforeSend: function () {
                        blockUI.blockPage({
                            message: tpl
                        })
                    },
                    complete: function () {
                        blockUI.unblockPage()
                    },
                    error: function (xhr, error, thrown) {
                        blockUI.unblockPage()
                        var msg = "";
                        if (xhr.responseText != null) {
                            msg = xhr.responseText
                        } else {
                            msg = "잠시후 다시 시도해 주세요."
                        }

                        Swal.fire({
                            title: msg,
                            icon: "error"
                        })
                    },
                    success: function (result) {
                        if (result.code == '0') {
                            Swal.fire({
                                title: '정상 처리되었습니다.',
                                icon: "success"

                            })

                            location.reload();
                        } else {
                            Swal.fire({
                                title: result.msg,
                                icon: "error"
                            })
                        }
                    }
                });
            }
        });

    }



    // 서류확인저장
    function saveDocu() {

        var frm = document.rcptFrm;

        if (frm.fax_conf_res_d11.value == "") {
            swal.fire({
                text: "확인여부를 선택해주세요",
                icon: "warning"
            });
            frm.fax_conf_res_d11.focus();
            return false;
        }

        var chValue = "";
        var i = 1;
        for (i = 1; i <= 14; i++) {
            if ($('#ch' + i).is(':checked') == true) {
                chValue = chValue + "|Y";
            } else {
                chValue = chValue + "|N";
            }
        }
        //alert(chValue);
        chValue = chValue.substr(1);
        $('#chTotal').val(chValue);

        if (frm.fax_conf_yn_2.value == "") {
            swal.fire({
                text: "매물주소 정보확인 결과를 선택해주세요",
                icon: "warning"
            });
            frm.fax_conf_yn_2.focus();
            return false;
        }

        if (frm.fax_conf_yn_3.value == "") {
            swal.fire({
                text: "가격 거래구분 정보확인 결과를 선택해주세요",
                icon: "warning"
            });
            frm.fax_conf_yn_3.focus();
            return false;
        }

        if (frm.fax_conf_yn_4.value == "") {
            swal.fire({
                text: "의뢰인 정보확인 결과를 선택해주세요",
                icon: "warning"
            });
            frm.fax_conf_yn_4.focus();
            return false;
        }

        if (frm.fax_conf_yn_2.value == "20000") {
            if (frm.fax_conf_yn_info_2.value == "") {
                swal.fire({
                    text: "매물주소 불일치에 대한 상세내용을 작성해주세요",
                    icon: "warning"
                });
                frm.fax_conf_yn_info_2.focus();
                return false;
            }
        }

        if (frm.fax_conf_yn_3.value == "20000") {
            if (frm.fax_conf_yn_info_3.value == "") {
                swal.fire({
                    text: "가격 거래구분 불일치에 대한 상세내용을 작성해주세요",
                    icon: "warning"
                });
                frm.fax_conf_yn_info_3.focus();
                return false;
            }
        }

        if (frm.fax_conf_yn_4.value == "20000") {
            if (frm.fax_conf_yn_info_4.value == "") {
                swal.fire({
                    text: "의뢰인정보 불일치에 대한 상세내용을 작성해주세요",
                    icon: "warning"
                });
                frm.fax_conf_yn_info_4.focus();
                return false;
            }
        }


        swal.fire({
            text: "저장 하시겠습니까?",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "예",
            cancelButtonText: "아니오",
            closeOnConfirm: false,
            closeOnCancel: true,
            confirmButtonColor: "#3085d6",
            cancelButtonColor: "#d33",
        }).then((result) => {
            if (result.isConfirmed) {
                $.ajax({
                    url: '/m701/m701a/saveDocu',
                    method: 'POST',
                    data: new FormData($("#rcptFrm")[0]),
                    processData: false,
                    contentType: false,
                    beforeSend: function () {
                        blockUI.blockPage({
                            message: tpl
                        })
                    },
                    complete: function () {
                        blockUI.unblockPage()
                    },
                    error: function (xhr, error, thrown) {
                        blockUI.unblockPage()
                        var msg = "";
                        if (xhr.responseText != null) {
                            msg = xhr.responseText
                        } else {
                            msg = "잠시후 다시 시도해 주세요."
                        }

                        Swal.fire({
                            title: msg,
                            icon: "error",
                            draggable: true
                        })
                    },
                    success: function (result) {

                        if (result.code == '0') {
                            location.reload();
                        } else {
                            Swal.fire({
                                title: result.msg,
                                icon: "error",
                                draggable: true
                            })
                        }
                    }
                });
            }
        });


    }


    // 전화정보저장
    function saveTel() {
        var frm = document.rcptFrm;
        var peo_Agr_val = $("#tel_agree").val();
        var fail_chk1 = $('#fail_chk1').is(":checked");
        var fail_chk2 = $('#fail_chk2').is(":checked");

        if (frm.tel_agree.value == "" && fail_chk1 == false && fail_chk2 == false) {
            swal.fire({
                text: "개인정보 제공동의 여부나 \n 전화확인 1차 실패를 선택해주세요",
                icon: "warning"
            });
            frm.tel_agree.focus();
            return false;
        }

        if (peo_Agr_val == '10000') {

            if (frm.tel_conf_yn_2.value == "") {
                swal.fire({
                    text: "매물주소 정보확인 결과를 선택해주세요",
                    icon: "warning"
                });
                frm.tel_conf_yn_2.focus();
                return false;
            }

            if (frm.tel_conf_yn_3.value == "") {
                swal.fire({
                    text: "가격 거래구분 정보확인 결과를 선택해주세요",
                    icon: "warning"
                });
                frm.tel_conf_yn_3.focus();
                return false;
            }

            if (frm.tel_conf_yn_4.value == "") {
                swal.fire({
                    text: "의뢰인 정보확인 결과를 선택해주세요",
                    icon: "warning"
                });
                frm.tel_conf_yn_4.focus();
                return false;
            }

            if (frm.tel_conf_yn_2.value == "20000") {
                if (frm.tel_conf_yn_info_2.value == "") {
                    swal.fire({
                        text: "매물주소 불일치에 대한 상세내용을 작성해주세요",
                        icon: "warning"
                    });
                    frm.tel_conf_yn_info_2.focus();
                    return false;
                }
            }

            if (frm.tel_conf_yn_3.value == "20000") {
                if (frm.tel_conf_yn_info_3.value == "") {
                    swal.fire({
                        text: "가격 거래구분 불일치에 대한 상세내용을 작성해주세요",
                        icon: "warning"
                    });
                    frm.tel_conf_yn_info_3.focus();
                    return false;
                }
            }

            if (frm.tel_conf_yn_4.value == "20000") {
                if (frm.tel_conf_yn_info_4.value == "") {
                    swal.fire({
                        text: "의뢰인정보 불일치에 대한 상세내용을 작성해주세요",
                        icon: "warning"
                    });
                    frm.tel_conf_yn_info_4.focus();
                    return false;
                }
            }

            if (frm.chk_telv.checked == false) {
                swal.fire({
                    text: "녹취파일 확인을 체크해주세요",
                    icon: "warning"
                });
                frm.chk_telv.focus();
                return false;
            }
        }


        swal.fire({
            text: "저장 하시겠습니까?",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "예",
            cancelButtonText: "아니오",
            closeOnConfirm: false,
            closeOnCancel: true,
            confirmButtonColor: "#3085d6",
            cancelButtonColor: "#d33",
        }).then((result) => {
            if (result.isConfirmed) {
                $.ajax({
                    url: '/m701/m701a/saveTel',
                    method: 'POST',
                    data: new FormData($("#rcptFrm")[0]),
                    processData: false,
                    contentType: false,
                    beforeSend: function () {
                        blockUI.blockPage({
                            message: tpl
                        })
                    },
                    complete: function () {
                        blockUI.unblockPage()
                    },
                    error: function (xhr, error, thrown) {
                        blockUI.unblockPage()
                        var msg = "";
                        if (xhr.responseText != null) {
                            msg = xhr.responseText
                        } else {
                            msg = "잠시후 다시 시도해 주세요."
                        }

                        Swal.fire({
                            title: msg,
                            icon: "error",
                            draggable: true
                        })
                    },
                    success: function (result) {

                        if (result.code == '0') {
                            location.replace('/board/notice/lists')
                        } else {
                            Swal.fire({
                                title: result.msg,
                                icon: "error",
                                draggable: true
                            })
                        }
                    }
                });
            }
        });
    }

    // 등기부등본 저장
    function saveRegi() {

        var atcl_vrtc_type = $("#atcl_vrtc_way option:selected").val();
        var frm = document.rcptFrm;

        if (atcl_vrtc_type != 'M') {
            if (mode != 'file') {
                mode = 'save';
                if (frm.reg_conf_yn_2.value == "") {
                    swal.fire({
                        text: "매물주소 정보확인 결과를 선택해주세요",
                        icon: "warning"
                    });
                    frm.reg_conf_yn_2.focus();
                    return false;
                }

                if (frm.reg_conf_yn_3.value == "") {
                    swal.fire({
                        text: "의뢰인정보 확인 결과를 선택해주세요",
                        icon: "warning"
                    });
                    frm.reg_conf_yn_3.focus();
                    return false;
                }

                <?php if ($data['vrfc_type_cd'] == "N") { ?>
                    if (frm.ownerVerifiable.value == "") {
                        swal.fire({
                            text: "소유자명 확인 결과를 선택해 주세요",
                            icon: "warning"
                        });
                        frm.ownerVerifiable.focus();
                        return false;
                    }
                <?php } ?>

                if (frm.reg_conf_yn_2.value == "20000") {
                    if (frm.reg_conf_yn_info_2.value == "") {
                        swal.fire({
                            text: "매물주소 불일치에 대한 상세내용을 작성해주세요",
                            icon: "warning"
                        });
                        frm.reg_conf_yn_info_2.focus();
                        return false;
                    }
                }

                if (frm.reg_conf_yn_3.value == "20000") {
                    if (frm.reg_conf_yn_info_3.value == "") {
                        swal.fire({
                            text: "의뢰인정보 불일치에 대한 상세내용을 작성해주세요",
                            icon: "warning"
                        });
                        frm.reg_conf_yn_info_3.focus();
                        return false;
                    }
                }
            }
        }

        swal.fire({
            text: "저장 하시겠습니까?",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "예",
            cancelButtonText: "아니오",
            closeOnConfirm: false,
            closeOnCancel: true,
            confirmButtonColor: "#3085d6",
            cancelButtonColor: "#d33",
        }).then((result) => {
            if (result.isConfirmed) {

                $.ajax({
                    url: '/m701/m701a/saveRegi?atcl_vrtc_type=' + atcl_vrtc_type,
                    contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
                    method: 'POST',
                    data: $("#rcptFrm").serialize(),
                    beforeSend: function () {
                        blockUI.blockPage({
                            message: tpl
                        })
                    },
                    complete: function () {
                        blockUI.unblockPage()
                    },
                    error: function (xhr, error, thrown) {
                        blockUI.unblockPage()
                        var msg = "";
                        if (xhr.responseText != null) {
                            msg = xhr.responseText
                        } else {
                            msg = "잠시후 다시 시도해 주세요."
                        }

                        Swal.fire({
                            title: msg,
                            icon: "error"
                        })
                    },
                    success: function (result) {
                        if (result.code == '0') {
                            Swal.fire({
                                title: '정상 처리되었습니다.',
                                icon: "success"

                            })

                            location.reload();
                        } else {
                            Swal.fire({
                                title: result.msg,
                                icon: "error"
                            })
                        }
                    }
                });
            }
        });
    }

    // 검증 최종실패 처리
    function saveFinalRegi() {
        var atcl_vrtc_type = $("#atcl_vrtc_way option:selected").val();
        var frm = document.rcptFrm;

        swal.fire({
            text: "버튼을 누르면 최종실패로 진행됩니다. \n최종실패 진행을 하려면 확인 버튼을 눌러 주세요.",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "예",
            cancelButtonText: "아니오",
            closeOnConfirm: false,
            closeOnCancel: true,
            confirmButtonColor: "#3085d6",
            cancelButtonColor: "#d33",
        }).then((result) => {
            if (result.isConfirmed) {

                $.ajax({
                    url: '/m701/m701a/saveFinalRegi?atcl_vrtc_type=' + atcl_vrtc_type,
                    contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
                    method: 'POST',
                    data: $("#rcptFrm").serialize(),
                    beforeSend: function () {
                        blockUI.blockPage({
                            message: tpl
                        })
                    },
                    complete: function () {
                        blockUI.unblockPage()
                    },
                    error: function (xhr, error, thrown) {
                        blockUI.unblockPage()
                        var msg = "";
                        if (xhr.responseText != null) {
                            msg = xhr.responseText
                        } else {
                            msg = "잠시후 다시 시도해 주세요."
                        }

                        Swal.fire({
                            title: msg,
                            icon: "error"
                        })
                    },
                    success: function (result) {
                        if (result.code == '0') {
                            Swal.fire({
                                title: '정상 처리되었습니다.',
                                icon: "success"

                            })

                            location.reload();
                        } else {
                            Swal.fire({
                                title: result.msg,
                                icon: "error"
                            })
                        }
                    }
                });
            }
        });
    }

</script>

<?= $this->endSection() ?>