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

$regi_pdf_path = "";

if (!empty($data['cert_register']) && $data['cert_register_save_yn'] != 'Y') {	//등기url있고 등기api이미지 저장여부가 Y가 아닐때 

    // Array ( [0] => https://cdn.aipartner.com/offerings-doc/org/20260108/53268282/53268282_SMVZneFKli.pdf )
    $arr_cert_register = explode('|', $data['cert_register']);
    $yn = "true";
    $file_pdf = substr($data['cert_register'], -4);
    $file_pdf = str_replace(".", "", $file_pdf);
    $regi_pdf_path = $arr_cert_register[0];

    $parts = explode('.', $arr_cert_register[0]);
    $ext = end($parts);

    if (strpos($ext, 'pdf') === false) {
        $file_pdf = $ext;
    } else {
        $file_pdf = 'pdf';
    }
    $regi_pdf_path = $arr_cert_register[0];
    if ($regist['cloud_upload_yn'] == 'Y') {
        $regi_pdf_path = NCLOUD_OBJECT_STORAGE_URL . $regi_pdf_path;
    }

} else {
    if (empty($regist['file_name'])) {
        $yn = "false";
    } else {
        $yn = "true";

        $file_pdf = substr($regist['file_name'], -3);
        $regi_pdf_path = $regist['file_path'] . $regist['file_name'];	//등기부등본
        if ($regist['cloud_upload_yn'] == 'Y') {
            $regi_pdf_path = NCLOUD_OBJECT_STORAGE_URL . $regi_pdf_path;
        }
    }

}

$reco_pdf_path = "";
if (!empty($data['confirm_doc_img_url']) && $data['confirm_doc_img_url_save_yn'] != 'Y') {	//홍보 url있고 url저장여부가 Y아니면
    $reco_pdf_path = $data['confirm_doc_img_url'];
} else {
    if (!empty($record)) {
        $reco_pdf_path = $record['file_path'] . $record['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;
    }

    /* GLightbox z-index 설정 */
    .glightbox-container {
        z-index: 9999 !important;
    }

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

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

    .num {
        color: #b68556;
    }

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

    .form-check-label {
        margin-left: -2px;
    }
</style>

<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">매물번호:</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-primary fs-6"><?= $data['pre_stat'] ?></span>
                    </div>
                </div>
            </div>
            <div class="card-body">
                <form id="rcptFrm" name="rcptFrm" onsubmit="return false">
                    <input type="hidden" name="reg_chk_val" value="<?= $data['rgbk_confirm'] ?>" />
                    <input type="hidden" name="atcl_vrtc_type" id="atcl_vrtc_type"
                        value="<?= $data['vrfc_type_cd'] ?>" />
                    <input type="hidden" name="vrfc_type_sub" id="vrfc_type_sub"
                        value="<?= $data['vrfc_type_sub'] ?>" />
                    <input type="hidden" name="chk_trade_type" id="chk_trade_type" value="<?= $data['trade_type'] ?>" />
                    <input type="hidden" name="chk_hscp_no" id="chk_hscp_no" value="<?= $data['chk_hscp_no'] ?>" />
                    <input type="hidden" name="atcl_no" id="atcl_no" value="<?= $data['atcl_no'] ?>" />
                    <table class="table table-bordered table-sm tbl_basic2 align-middle mb-0" style="min-width: 900px;">
                        <colgroup>
                            <col style="width: 60%;">
                            <col style="width: 40%;">
                        </colgroup>

                        <tbody>
                            <tr>
                                <td class="align-top">
                                    <?php

                                    if (!empty($data['cert_register'])) {
                                        //	등기url있고
                                        if ($data['cert_register_save_yn'] == 'Y') {
                                            //등기api이미지 저장여부가 Y
                                            if (strtolower($file_pdf) == 'pdf') {
                                                echo '<iframe src="' . $server_addr . $regi_pdf_path . '" frameborder="0" style="padding: 10px 0;width:100%; height:1200px;"></iframe><br>';
                                            } else {
                                                echo '<div id="regi_file_dis" style="padding: 10px 0px; height: 730px; overflow-y: auto;">';
                                                if (empty($arrRegist)) {
                                                    echo '<img id="photo-display2" src="/plugin/img/photo.gif" alt="Image" style="width:100%;max-width:945px;min-width:100%;border:0;" />';
                                                } else {
                                                    foreach ($arrRegist as $row) {
                                                        $img_path = $row['file_path'] . $row['file_name'];
                                                        echo '<a href="' . $img_path . '" class="glightbox" data-gallery="gallery1" data-title="등기부등본">' .
                                                            '<img id="photo-display2" src="' . $img_path . '" alt="Image" style="width:100%;max-width:945px;min-width:100%;border:0;" />' .
                                                            '</a>';
                                                    }
                                                }
                                                echo '</div><br>';
                                            }
                                        } else {
                                            //등기api이미지 저장여부가 N
                                            if (strtolower($file_pdf) == 'pdf') {
                                                echo '<iframe src="' . $regi_pdf_path . '" frameborder="0" style="padding: 10px 0;width:100%; height:1200px;"></iframe><br>';
                                            } else {
                                                echo '<div id="regi_file_dis" style="padding: 10px 0px; height: 730px; overflow-y: auto;">';
                                                if (empty($arr_cert_register)) {
                                                    echo '<img id="photo-display2" src="/img/photo.gif" alt="Image" style="width:100%;max-width:945px;min-width:100%;border:0;" />';
                                                } else {
                                                    foreach ($arr_cert_register as $img_path) {
                                                        echo '<a href="' . $img_path . '" class="glightbox" data-gallery="gallery1" data-title="등기부등본">' .
                                                            '<img id="photo-display2" src="' . $img_path . '" alt="Image" style="width:100%;max-width:945px;min-width:100%;border:0;" />' .
                                                            '</a>';
                                                    }
                                                }
                                                echo '</div><br>';

                                            }
                                        }
                                    } else {
                                        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 {
                                                if ($regist['cloud_upload_yn'] == 'Y') {
                                                    $regi_img_path = NCLOUD_OBJECT_STORAGE_URL . $regist['file_path'] . $regist['file_name'];
                                                } else {
                                                    // 로컬에 저장된 이미지
                                                    $regi_img_path = $regist['file_path'] . $regist['file_name'];
                                                }
                                                // $regi_img_path = $regist['file_path'].$regist['file_name'];
                                            }
                                        }

                                        ?>

                                        <img src="<?= $regi_img_path ?>" alt="">
                                        <!-- <iframe src="<?= $regi_img_path ?>" frameborder="0"
                                            style="padding: 10px 0;width:100%; height:1200px;"></iframe><br> -->
                                        <br>
                                        <a href="<?= $regi_pdf_path ?>" class="default_val" target="_blank">등기부등본
                                            보기</a>&nbsp;&nbsp;&nbsp;
                                        <a href="<?= $reco_pdf_path ?>" class="glightbox" data-gallery="hongbo" data-title="홍보확인서"
                                            id="hongbo" onclick="chk_hongbo(event); return false;">홍보확인서 보기</a>
                                        <?php
                                    }
                                    ?>

                                </td>
                                <td class="align-top">
                                    <div class="main-card mb-3 card">
                                        <div class="card-header">
                                            <div class="d-flex align-items-center w-100">
                                                <span class="fw-semibold">기본 정보</span>
                                                <div class="ms-auto">
                                                    <span class="badge text-dark" id="span_current_stat"></span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="card-body p-2">
                                            <table class="table table-sm table-bordered mb-2 tbl_basic2 align-middle">
                                                <colgroup>
                                                    <col style="width: 120px;">
                                                    <col>
                                                </colgroup>
                                                <tbody>
                                                    <tr>
                                                        <th>매물번호</th>
                                                        <td>
                                                            <form method="post" id="frmSearchArticle"
                                                                name="frmSearchArticle" onsubmit="return false;">

                                                                <div class="input-group input-group-sm"
                                                                    style="max-width: 320px;">
                                                                    <input type="text" class="form-control"
                                                                        name="atcl_no" id="atcl_no"
                                                                        value="<?= $data['atcl_no'] ?>" maxlength="10"
                                                                        placeholder="매물번호 입력" readonly>
                                                                    <!-- <button type="button"
                                                                        class="btn btn-outline-primary"
                                                                        onclick="btnSilverAtclNo_onclick();">조회</button> -->
                                                                </div>
                                                            </form>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>CP ID</th>
                                                        <td><span class="num" id="span_cpid">
                                                                <?= $data['cpid'] ?>
                                                            </span></td>
                                                    </tr>
                                                    <tr>
                                                        <th>현재 상태</th>
                                                        <td><span class="num" id="span_pre_stat">
                                                                <?= $data['pre_stat'] ?>
                                                            </span>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <?php
                                                        $th = "등기부등본 불일치횟수";
                                                        $td = "";
                                                        if (empty($data['reg_try_cnt'])):
                                                            $td = "0";
                                                        else:
                                                            $td = $data['reg_try_cnt'];
                                                        endif; ?>
                                                        <th><?= $th ?></th>
                                                        <td><span>
                                                                <?= $td ?>
                                                            </span>
                                                        </td>
                                                    </tr>
                                                    <?php if (!empty($data['reference_file_url'])): ?>
                                                        <tr>
                                                            <th>참고용 파일</th>
                                                            <td>
                                                                <?php if (!empty($reference)): ?>
                                                                    <?php foreach ($reference as $f): ?>
                                                                        <?php if (strtolower($row['file_ext']) == '.pdf') { ?>
                                                                            <a href="<?= $filePath ?>" target="_blank">
                                                                                <img id="reference" src="/img/pdf.png" alt="Image"
                                                                                    style="height: 50px;" />
                                                                            </a>
                                                                        <?php } else if (strtolower($row['file_ext']) == '.zip') { ?>
                                                                                <a href="<?= $filePath ?>">
                                                                                    <img id="reference" src="/img/zip.png"
                                                                                        alt="Image" /></a>
                                                                        <?php } else { ?>
                                                                                <a href="<?= $filePath ?>" class="glightbox" data-gallery="gallery2" data-title="참고파일">
                                                                                    <img id="reference" src="<?= $filePath ?>" alt="Image"
                                                                                        style="padding-right: 10px; height: 150px;" /></a>
                                                                        <?php } ?>
                                                                    <?php endforeach; ?>
                                                                <?php else: ?>
                                                                    <?php
                                                                    $arr_reference = explode('|', $data['reference_file_url']);
                                                                    $ext = strrchr($data['reference_file_url'], ".");	//맨뒤에.부터 자른다
                                                            
                                                                    if (strtolower($ext) == '.zip') {
                                                                        ?>
                                                                        <a
                                                                            onclick="fn_preview('<?= esc($data['reference_file_url']) ?>')"><img
                                                                                id="reference" src="/img/zip.png" alt="Image" /></a>
                                                                    <?php } else if (strtolower($ext) == '.pdf') { ?>
                                                                        <?php foreach ($arr_reference as $row) { ?>
                                                                                <a href="<?= $row ?>" target="_blank">
                                                                                    <img id="reference" src="/plugin/img/pdf.png"
                                                                                        alt="Image" style="height: 50px;" /></a>
                                                                        <?php } ?>
                                                                    <?php } else { ?>
                                                                        <?php foreach ($arr_reference as $row) { ?>
                                                                                <a href="<?= esc($row) ?>" class="glightbox" data-gallery="gallery2" data-title="참고파일">
                                                                                    <img id="reference" src="<?= $row ?>" alt="Image"
                                                                                        style="padding-right: 10px; height: 150px;" /></a>
                                                                        <?php } ?>
                                                                    <?php } ?>
                                                                <?php endif; ?>
                                                            </td>
                                                        </tr>
                                                    <?php endif; ?>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>

                                    <!-- 매물 정보 -->
                                    <div class="main-card mb-3 card">
                                        <div class="card-header">
                                            <span class="fw-semibold">매물 정보</span>
                                        </div>
                                        <div class="card-body p-2">

                                            <table class="table table-sm table-bordered mb-0 tbl_basic2 align-middle">
                                                <colgroup>
                                                    <col style="width: 120px;">
                                                    <col>
                                                </colgroup>
                                                <tbody>
                                                    <tr>
                                                        <th>등록일시</th>
                                                        <td><span id="span_rdate"><?= $data['rdate'] ?></span></td>
                                                    </tr>
                                                    <tr>
                                                        <th>등기부 고유번호</th>
                                                        <td>
                                                            <?= $data['registerBookUniqueNumber'] ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>의뢰인(매도자)</th>
                                                        <td><span id="span_seller_nm"><?= $data['seller_nm'] ?></span>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>검증방식</th>
                                                        <td><span style="color:#FF0000">
                                                                <?= $data['vrfc_type']; ?>
                                                            </span></td>
                                                    </tr>
                                                    <tr>
                                                        <th>매물구분</th>
                                                        <td><span id="span_rlet_type_nm"><?= $data['atcl_nm'] ?></span>
                                                        </td>
                                                    </tr>
                                                    <?php if (!empty($detail_hscp)):
                                                        $apt_rlet_type_cd = ['A01', 'A02', 'A03', 'A04', 'B01', 'B02', 'B03'];
                                                        $villa_rlet_type_cd = ['A05', 'A06'];
                                                        ?>
                                                        <tr>
                                                            <th>단지 정보</th>
                                                            <td>
                                                                <?php if (in_array($detail_hscp['aptType'], $apt_rlet_type_cd)): ?>
                                                                    <table width="100%">
                                                                        <tr>
                                                                            <th>단지번호</th>
                                                                            <td>
                                                                                <?= $detail_hscp['aptNo'] ?>
                                                                            </td>
                                                                            <th>단지명</th>
                                                                            <td>
                                                                                <?= $detail_hscp['aptName'] ?>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <th>단지타입</th>
                                                                            <td>
                                                                                <?= $detail_hscp['aptType'] ?>
                                                                            </td>
                                                                            <th>단지타입명</th>
                                                                            <td>
                                                                                <?= $detail_hscp['aptTypeName'] ?>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <th>사용승인일</th>
                                                                            <td>
                                                                                <?= $detail_hscp['useAprvYmd'] ?>
                                                                            </td>
                                                                            <th>단지 총 세대수</th>
                                                                            <td>
                                                                                <?= $detail_hscp['totHsehCnt'] ?>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <th>단지 총 동수</th>
                                                                            <td>
                                                                                <?= $detail_hscp['dongCount'] ?>
                                                                            </td>
                                                                            <th>단지 총 평형수</th>
                                                                            <td>
                                                                                <?= $detail_hscp['planTypeCount'] ?>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                <?php endif; ?>
                                                                <?php if (!empty($detail_hscp['villaType'])): ?>
                                                                    <?php if (in_array($detail_hscp['villaType'], $villa_rlet_type_cd)): ?>
                                                                        <table width="100%">
                                                                            <tr>
                                                                                <th>단지명</th>
                                                                                <td>
                                                                                    <?= $detail_hscp['villaName']; ?>
                                                                                </td>
                                                                                <th>단지타입명</th>
                                                                                <td>
                                                                                    <?= $detail_hscp['villaTypeName']; ?>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                                <th>소재법정동번호</th>
                                                                                <td colspan="3">
                                                                                    <?= $detail_hscp['cortarNo']; ?>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                                <th>소재 주소(전체)</th>
                                                                                <td colspan="3">
                                                                                    <?= $detail_hscp['addr']; ?>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                                <th>주소(광역시/도)</th>
                                                                                <td>
                                                                                    <?= $detail_hscp['city']; ?>
                                                                                </td>
                                                                                <th>주소(시군구)</th>
                                                                                <td>
                                                                                    <?= $detail_hscp['dvsn']; ?>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                                <th>주소(읍면동)</th>
                                                                                <td>
                                                                                    <?= $detail_hscp['sec']; ?>
                                                                                </td>
                                                                                <th>소재 동이하 상세주소</th>
                                                                                <td>
                                                                                    <?= $detail_hscp['dtlAddr']; ?>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                                <th>단지 총 세대수</th>
                                                                                <td>
                                                                                    <?= $detail_hscp['totHsehCnt']; ?>
                                                                                </td>
                                                                                <th>단지 총 동수</th>
                                                                                <td>
                                                                                    <?= $detail_hscp['totDongCnt']; ?>
                                                                                </td>
                                                                            </tr>

                                                                        </table>
                                                                    <?php endif; ?>
                                                                <?php endif; ?>
                                                            </td>
                                                        </tr>

                                                    <?php endif; ?>
                                                    <tr>
                                                        <th>지역구분</th>
                                                        <td><span id="span_address1"><?= $data['address1'] ?></span>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>단지명</th>
                                                        <td><span id="span_hscp_nm">
                                                                <?= $data['hscp_nm'] ?>
                                                            </span></td>
                                                    </tr>



                                                    <tr>
                                                        <th>리 주소</th>
                                                        <td>
                                                            <?= $data['address2a'] ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>상세주소</th>
                                                        <td class="d-flex gap-1">
                                                            <?= $data['address2b'] ?>
                                                            <br />
                                                            <?= $data['address3'] ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>기타주소</th>
                                                        <td>
                                                            <?= $data['address4'] ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>거래구분/가격</th>
                                                        <td>
                                                            <?php if ($data['trade_type_cd'] == "A1"): ?>
                                                                <span style='color:#ff0000'>
                                                                    <?= $data['trade_type']; ?>
                                                                </span>
                                                            <?php else: ?>
                                                                <?= $data['trade_type']; ?>
                                                            <?php endif; ?>
                                                            /
                                                            <?= $data['deal_amt'] ?> 만원
                                                            <?= $data['wrrnt_amt'] ?> /
                                                            <?= $data['lease_amt'] ?>만원 (월)
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>평형</th>
                                                        <td>
                                                            <?= $data['ptp_nm'] ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>
                                                            <?php
                                                            $chk_product_nm = [
                                                                'C04',				// 전원주택
                                                                'D03',				// 빌딩,건물
                                                                'D04',				// 상가,건물
                                                                'E01',				// 숙박,콘도
                                                                'E02',				// 공장,창고
                                                                'Z00'				// 기타		
                                                            ];

                                                            $title = "";
                                                            if ($data['rlet_type_cd'] == 'C03' && $data['trade_type'] == '매매') {
                                                                // 단독,다가구 - 매매
                                                                $title = "지하층 / 지상층";
                                                            } else if ($data['rlet_type_cd'] == 'C05' && $data['trade_type'] == '매매') {
                                                                // 상가주택 - 매매
                                                                $title = "지하층 / 지상층";
                                                            } else if (in_array($data['rlet_type_cd'], $chk_product_nm)) {
                                                                $title = "지하층 / 지상층";
                                                            } else {
                                                                $title = "층 / 총층";
                                                            }

                                                            ?>
                                                            <?= $title ?>
                                                        </th>
                                                        <td><?= $data['floor'] . "/" . $data['floor2']; ?></td>
                                                    </tr>
                                                    <?php
                                                    if ($data['hscplqry_lv'] == '3'):
                                                        ?>
                                                        <tr>
                                                            <th>공급면적</th>
                                                            <td>
                                                                <span style="color:#F21E1E">
                                                                    <?= $data['sply_spc'] ?>
                                                                </span>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <th>전용면적</th>
                                                            <td>
                                                                <span style="color:#F21E1E">
                                                                    <?= $data['excls_spc'] ?>
                                                                </span>
                                                            </td>
                                                        </tr>
                                                    <?php endif; ?>
                                                    <?php if ($data['rlet_type_cd'] == 'A01' || $data['rlet_type_cd'] == 'A02'): ?>
                                                        <tr>
                                                            <th>단지명</th>
                                                            <td>
                                                                <?= $data['hscp_nm'] ?>
                                                                <?php if ($data['sm_seq'] !== null): ?>
                                                                    <span style='color:#FF0000'>※ 특이단지</span>
                                                                <?php endif; ?>
                                                            </td>
                                                        </tr>
                                                    <?php endif; ?>
                                                    <?php if ($data['rlet_type_cd'] == 'F01'): ?>
                                                        <tr>
                                                            <th>재개발구역명</th>
                                                            <td><?= $data['redvlp_area_nm'] ?></td>
                                                        </tr>
                                                        <tr>
                                                            <th>사업단계설명</th>
                                                            <td><?= $data['biz_stp_desc'] ?></td>
                                                        </tr>
                                                    <?php endif; ?>
                                                    <?php if (empty($data['hscp_no'])): ?>
                                                        <tr>
                                                            <th>공급면적</th>
                                                            <td>
                                                                <span style="color:#002EE7">
                                                                    <?= $data['sply_spc'] ?>
                                                                </span>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <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>
                                                        </tr>
                                                        <tr>
                                                            <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>
                                                        </tr>
                                                        <tr>
                                                            <th>건축면적</th>
                                                            <td>
                                                                <span style="color:#002EE7"><?= $data['bldg_spc'] ?></span>
                                                            </td>
                                                        </tr>
                                                    <?php endif; ?>
                                                    <?php
                                                    $vir_style = "";
                                                    if ($data['vir_addr_yn'] == 'Y') {
                                                        $vir_style = "style='color:#F21E1E;'";
                                                    }
                                                    ?>
                                                    <tr>
                                                        <th>가주소 여부</th>
                                                        <td>
                                                            <span <?= $vir_style ?>>
                                                                <?= $data['vir_addr_yn'] ?>
                                                            </span>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>미등기 검증요청</th>
                                                        <td>
                                                            <span <?= $vir_style ?>>
                                                                <?php echo $data['noRgbkVrfcReqYn'] ?>
                                                            </span>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>건축물대장 면적 검증요청</th>
                                                        <td>
                                                            <span <?= $vir_style ?>>
                                                                <?php echo $data['areaByBdbkVrfcReqYn'] ?>
                                                            </span>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>

                                    <!-- 확인처리 -->
                                    <div class="main-card mb-3 card">
                                        <div class="card-header">
                                            <span class="fw-semibold">확인 처리</span>
                                        </div>
                                        <div class="card-body p-2">

                                            <table class="table table-sm table-bordered mb-0 tbl_basic2 align-middle">
                                                <colgroup>
                                                    <col style="width: 120px;">
                                                    <col>
                                                </colgroup>
                                                <tbody>
                                                    <tr>
                                                        <th>확인담당자</th>
                                                        <td class="d-flex align-items-center gap-2">
                                                            <?= $data['reg_charger_nm'] ?>
                                                            <button type="button"
                                                                class="btn btn-sm btn-outline-secondary"
                                                                onClick="window.open('https://www.realtop.co.kr/cm/CMMBR01C2.asp2?cmInstCd=Z265&cmUserNo=<?= $usr_id ?>&cmKey=nxfT5VLGXg&cmName=<?= $usr_id ?>&cmDNm=confirms&cmAutoLogInYn=Y&cmUrl=/re/NVRET01R0&cmEncoding=UTF-8')">등기부등본
                                                                열람</button>
                                                        </td>
                                                    </tr>
                                                    <?php if ($data['vrfc_type_sub'] == 'M1' || $data['vrfc_type_sub'] == 'O1'): ?>
                                                        <tr>
                                                            <th>등기부등본 <br />미확인여부<br />상세</th>
                                                            <td>
                                                                <table class="w-100 tbl_basic2 table-bordered">
                                                                    <tr>
                                                                        <input type="hidden" name="arr_uncnfrm_status"
                                                                            id="arr_uncnfrm_status" />
                                                                        <?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'] === "CERT_UNCNFRM_STATUS") {
                                                                                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 chk-uncnfrm">
                                                                                    <input class="form-check-input mt-0"
                                                                                        type="checkbox"
                                                                                        id="c_u_s_<?= $value['cd'] ?>"
                                                                                        name="cert_uncnfrm_status[]"
                                                                                        value="<?= $value['cd'] ?>" />

                                                                                    <label class="form-check-label ms-1 small"
                                                                                        for="c_u_s_<?= $value['cd'] ?>">
                                                                                        <?= $value['cd_nm'] ?>
                                                                                    </label>
                                                                                </div>
                                                                            </td>


                                                                            <?php $nCnt++;
                                                                        } ?>

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

                                                    <tr>
                                                        <th>확인내용</th>
                                                        <td>
                                                            <select class="form-select" name="reg_conf_yn_1"
                                                                id="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 align-items-center gap-1">
                                                            <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 align-items-center gap-1">
                                                            <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_sub'] == 'D2'): ?>
                                                        <tr>
                                                            <th>실소유주 확인</th>
                                                            <td>
                                                                <input type="radio" name="owner_verifiable"
                                                                    id="owner_verifiable" value="true"
                                                                    style="vertical-align:middle;" <?php if ($data['owner_verifiable'] == 'true')
                                                                        echo 'checked="checked"';
                                                                    if (empty($regi_pdf_path) == true) {
                                                                        echo "disabled";
                                                                    } ?> />확인&nbsp;
                                                                <input type="radio" name="owner_verifiable"
                                                                    id="owner_verifiable" value="false"
                                                                    style="vertical-align:middle;" <?php if ($data['owner_verifiable'] == 'false')
                                                                        echo 'checked="checked"'; ?> />미확인
                                                            </td>
                                                        </tr>
                                                    <?php endif; ?>
                                                    <tr>
                                                        <th>소유자명</th>
                                                        <td style="color:blue;">
                                                            <?php if ($data['stat_cd'] == '19' || $data['stat_cd'] == '60' || $data['stat_cd'] == '69'): ?>
                                                                ***
                                                            <?php else: ?>
                                                                <?= $data['ownerNm'] ?>
                                                            <?php endif; ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>메모</th>
                                                        <td>
                                                            <textarea class="form-control" name="memo" id="memo"
                                                                style="width: 100%; height: 45px;resize: none;"
                                                                readonly><?= $memo['memo'] ?></textarea>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>등기부등본 확인</th>
                                                        <td class="text-nowrap">
                                                            <div class="d-flex flex-wrap gap-1">

                                                                <div class="form-check align-items-center mb-0"
                                                                    id="img_chk_chk3_area">
                                                                    <input class="form-check-input" type="checkbox"
                                                                        name="img_chk_chk" id="img_chk_chk3"
                                                                        onclick="check_only(this)">
                                                                    <label class="form-check-label"
                                                                        for="img_chk_chk3">열람</label>
                                                                </div>
                                                                <?php if ($data['vrfc_type_sub'] == 'D2'): ?>
                                                                    <div class="form-check align-items-center mb-0"
                                                                        id="img_chk_chk4_area">
                                                                        <input class="form-check-input" type="checkbox"
                                                                            name="img_chk_chk" id="img_chk_chk4"
                                                                            onclick="check_only(this)">
                                                                        <label class="form-check-label"
                                                                            for="img_chk_chk4">소유자명 확인</label>
                                                                    </div>
                                                                <?php endif; ?>
                                                                <?php if ($display['display_yn'] === 'Y'): ?>
                                                                    <div class="form-check align-items-center mb-0"
                                                                        id="img_chk_chk5_area">
                                                                        <input class="form-check-input" type="checkbox"
                                                                            name="img_chk_chk" id="img_chk_chk5"
                                                                            onclick="check_only(this)">
                                                                        <label class="form-check-label"
                                                                            for="img_chk_chk5">리얼탑 열람</label>
                                                                    </div>

                                                                    <div class="form-check align-items-center mb-0"
                                                                        id="img_chk_chk6_area">
                                                                        <input class="form-check-input" type="checkbox"
                                                                            name="img_chk_chk" id="img_chk_chk6"
                                                                            onclick="check_only(this)">
                                                                        <label class="form-check-label"
                                                                            for="img_chk_chk6">리얼탑 기열람</label>
                                                                    </div>

                                                                    <div class="form-check align-items-center mb-0"
                                                                        id="img_chk_chk2_area">
                                                                        <input class="form-check-input" type="checkbox"
                                                                            name="img_chk_chk" id="img_chk_chk2"
                                                                            onclick="check_only(this)">
                                                                        <label class="form-check-label"
                                                                            for="img_chk_chk2">등기소</label>
                                                                    </div>
                                                                <?php endif; ?>

                                                                <div class="form-check align-items-center mb-0"
                                                                    id="noimg_chk_chk_area">
                                                                    <input class="form-check-input mt-0" type="checkbox"
                                                                        name="noimg_chk_chk" id="noimg_chk_chk">
                                                                    <label class="form-check-label small"
                                                                        for="noimg_chk_chk">
                                                                        이미지 파일 없음
                                                                    </label>
                                                                </div>

                                                            </div>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>


                                    <!-- 기타 정보 -->
                                    <div class="main-card mb-3 card">
                                        <!-- <div class="card-header">
                                            <span class="fw-semibold">기타 정보</span>
                                        </div> -->
                                        <div class="card-body p-2">

                                            <table class="table table-sm table-bordered mb-0 tbl_basic2 align-middle">
                                                <colgroup>
                                                    <col style="width: 120px;">
                                                    <col>
                                                </colgroup>
                                                <tbody>
                                                    <?php if (in_array($data['vrfc_type_sub'], ['M1', 'O1', 'D2'])): ?>
                                                        <tr>
                                                            <th width="100">소유자명</th>
                                                            <td style="color:#ff0000;">
                                                                <?php
                                                                if ($data['stat_cd'] == '19' || $data['stat_cd'] == '60' || $data['stat_cd'] == '69') {
                                                                    echo ('***');
                                                                } else {
                                                                    echo ($data['ownerNm']);
                                                                }
                                                                ?>
                                                            </td>
                                                        </tr>
                                                    <?php endif; ?>
                                                    <?php
                                                    $sty = '';
                                                    if ($data['vrfc_type_cd'] == 'M') {
                                                        $sty = 'style="display:none;"';
                                                    }
                                                    ?>
                                                    <tr <?= $sty ?>>
                                                        <th>소유자 전화번호</th>
                                                        <td>
                                                            <?
                                                            if ($data['stat_cd'] == '19' || $data['stat_cd'] == '60' || $data['stat_cd'] == '69') {
                                                                echo ('***');
                                                            } else {
                                                                echo ($data['ownerTelNo']);
                                                            }
                                                            ?>
                                                        </td>
                                                    </tr>
                                                </tbody>

                                            </table>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <?php
                                    if (empty($data['cert_register']) && $data['stat_cd'] == "40") {
                                        ?>
                                        <button type="button" class="btn btn-sm btn-outline-secondary"
                                            onclick="faximage_rotate(90)">90˚</button>
                                        <button type="button" class="btn btn-sm btn-outline-secondary"
                                            onclick="faximage_rotate(180)">180˚</button>
                                        <button type="button" class="btn btn-sm btn-outline-secondary"
                                            onclick="faximage_rotate(270)">270˚</button>
                                        <button type="button" class="btn btn-sm btn-outline-success" id="btnUploadModal">
                                            <i class="pe-7s-up-arrow"></i> 파일업로드
                                        </button>
                                        <?php
                                    }
                                    if ($data['corp_own'] == 'Y') {
                                        echo '<span style="color: blue;">법인매물</span>';
                                    } else {
                                        echo '<a id="corp" onclick="saveCorp();" class="default_val" target="_blank" style="cursor:pointer">법인</a>';
                                    }
                                    ?>
                                </td>
                                <td class="d-flex justify-content-end gap-1">
                                    <?php if ($data['stat_cd'] == '40'): ?>
                                        <button type="button" class="btn btn-sm btn-outline-primary"
                                            onclick="saveRegi();">전송</button>
                                    <?php endif; ?>
                                    <button type="button" class="btn btn-sm btn-outline-light"
                                        onclick="nextRegi();">다음</button>
                                </td>
                            </tr>

                        </tbody>
                    </table>

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

<?= $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>
<?= $this->endSection() ?>

<?= $this->section('page_styles') ?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/glightbox/dist/css/glightbox.min.css">
<?= $this->endSection() ?>

<?= $this->section('page_scripts') ?>
<script src="https://cdn.jsdelivr.net/npm/glightbox/dist/js/glightbox.min.js"></script>
<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">
    $(function () {
        // GLightbox 초기화
        const lightbox = GLightbox({
            touchNavigation: true,
            loop: false,
            autoplayVideos: true,
            zoomable: true,
            draggable: true
        });

    const reg_status = '<?= $data['reg_status'] ?>';
    const filePdf = '<?= $file_pdf ?? '' ?>';

    $(function () {

        if (reg_status == 'Y') {
            // 등기부등본 없음 체크하기
            $("#noimg_chk_chk").attr("checked", true);
            $("#noimg_chk_chk").val("Y");
        } else if (reg_status == 'O') {
            // 등기부등본 열람
            $("#img_chk_chk3").attr("checked", true);
            $("#img_chk_chk3").val("O");
        } else if (reg_status == 'T') {
            // 등기소
            $("#img_chk_chk2").attr("checked", true);
            $("#img_chk_chk2").val("T");
        } else if (reg_status == 'R') {
            // 리얼탑 열람
            $("#img_chk_chk5").attr("checked", true);
            $("#img_chk_chk5").val("R");
        } else if (reg_status == 'G') {
            // 리얼탑 기열람
            $("#img_chk_chk6").attr("checked", true);
            $("#img_chk_chk6").val("G");
        }

        // 등기부등본 미확인여부 checkbox
        $(".chk-uncnfrm").on("change", function (e) {

            const labelText = $("label[for=" + e.target.id + "]").text().trim();
            const id = e.target.id;
            const value = e.target.value;

            if (value == 20099 && $("input:checkbox[id=" + id + "]").is(":checked")) {
                $("input:checkbox[name='cert_uncnfrm_status[]']").prop("checked", false);
                $("input:checkbox[id=" + id + "]").prop("checked", true);
                $("#reg_conf_yn_1").val("2").prop("selected", true);
                $("#reg_conf_yn_2").val("20000").prop("selected", true);
                $("#reg_conf_yn_3").val("20000").prop("selected", true);
                $("#reg_conf_yn_info_2").val('');
                $("#reg_conf_yn_info_3").val('');

            } else {
                var txt = "";
                var txt2 = "";
                var status = "";
                var cnt_juso = 0;	//매물주소
                var status_juso = "";
                var cnt_info = 0;	//의뢰인정보
                var status_info = "";
                var cnt_99 = 0;	//기타

                $('input:checkbox[name="cert_uncnfrm_status[]"]').each(function () {
                    if ($(this).is(':checked')) {
                        status = $(this).val();
                        switch (status) {
                            case '20099':
                                cnt_99++;
                                break;
                            case '20016':
                            case '20023':
                                cnt_info++;
                                status_info = status;
                                break;
                            default:
                                cnt_juso++;
                                status_juso = status;
                        }
                    }
                });

                if (cnt_juso > 0 && cnt_info > 0) {
                    $("#reg_conf_yn_1").val("20000").prop("selected", true);
                    $("#reg_conf_yn_2").val("20000").prop("selected", true);
                    $("#reg_conf_yn_3").val("20000").prop("selected", true);
                    txt = $('label[for="c_u_s_' + status_juso + '"]').text();
                    txt2 = $('label[for="c_u_s_' + status_info + '"]').text();
                    $("#reg_conf_yn_info_2").val(txt);
                    $("#reg_conf_yn_info_3").val(txt2);
                } else if (cnt_juso == 0 && cnt_info > 0) {
                    txt = $('label[for="c_u_s_' + status_info + '"]').text();
                    $("#reg_conf_yn_1").val("").prop("selected", true);
                    $("#reg_conf_yn_2").val("").prop("selected", true);
                    $("#reg_conf_yn_3").val("20000").prop("selected", true);
                    $("#reg_conf_yn_info_2").val('');
                    $("#reg_conf_yn_info_3").val(txt);
                    if (cnt_99 > 0) {
                        $("input:checkbox[id='c_u_s_20099']").prop("checked", false);
                        $("#reg_conf_yn_1").val("").prop("selected", true);
                    }
                } else if (cnt_juso > 0 && cnt_info == 0) {
                    txt = $('label[for="c_u_s_' + status_juso + '"]').text();
                    $("#reg_conf_yn_1").val("").prop("selected", true);
                    $("#reg_conf_yn_2").val("20000").prop("selected", true);
                    $("#reg_conf_yn_3").val("").prop("selected", true);
                    $("#reg_conf_yn_info_2").val(txt);
                    $("#reg_conf_yn_info_3").val('');
                    if (cnt_99 > 0) {
                        $("input:checkbox[id='c_u_s_20099']").prop("checked", false);
                        $("#reg_conf_yn_1").val("").prop("selected", true);
                    }
                } else if (cnt_juso == 0 && cnt_info == 0) {
                    $("#reg_conf_yn_1").val("").prop("selected", true);
                    $("#reg_conf_yn_2").val("").prop("selected", true);
                    $("#reg_conf_yn_3").val("").prop("selected", true);
                    $("#reg_conf_yn_info_2").val('');
                    $("#reg_conf_yn_info_3").val('');
                }
            }

        });


        //등기부등본확인 정보 : 확인 내용
        $("#reg_conf_yn_1").change(function () {
            if ($("#reg_conf_yn_1").val() == "1") {
                $("#reg_conf_yn_2").val("10000");
                $("#reg_conf_yn_3").val("10000");
            } else if ($("#reg_conf_yn_1").val() == "2") {
                $("#reg_conf_yn_2").val("20000");
                $("#reg_conf_yn_3").val("20000");
                $("#reg_conf_yn_info_3").val("소유주 불일치");
            }
        });


        //등기부등본 확인 정보
        $("#reg_conf_yn_2").change(function () {
            var reg2 = $("#reg_conf_yn_2").val();
            var reg3 = $("#reg_conf_yn_3").val();

            if (reg2 != reg3) {
                $("#reg_conf_yn_1").val('');
            }
        });

        $("#reg_conf_yn_3").change(function () {
            var reg2 = $("#reg_conf_yn_2").val();
            var reg3 = $("#reg_conf_yn_3").val();

            if (reg2 != reg3) {
                $("#reg_conf_yn_1").val('');
            }

            if ($("#reg_conf_yn_3").val() == "20000") {
                $("#reg_conf_yn_info_3").val("소유주 불일치");
            }

        });



        if (filePdf == 'pdf' || filePdf == 'PDF') {	//열람
            $('#noimg_chk_chk_area').hide();

            $('#img_chk_chk2_area').hide();
            $('#img_chk_chk5_area').hide();
            $('#img_chk_chk6_area').hide();
        } else if (filePdf == '' || filePdf == null) {	//이미지없음
            $('#img_chk_chk3_area').hide();
            $('#img_chk_chk2_area').hide();
            $('#img_chk_chk4_area').hide();
            $('#img_chk_chk5_area').hide();
            $('#img_chk_chk6_area').hide();
        } else {	//pdf이외 이미지 있음
            $('#noimg_chk_chk_area').hide();
            $('#img_chk_chk3_area').hide();
            $('#img_chk_chk4_area').hide();
        }


        /**
         *  파일 Dropzone
         * */
        const dz = new Dropzone("#myDropzone", {
            url: "/m705/m705a/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 check_only(chk) {
        var obj = document.getElementsByName("img_chk_chk");
        for (var i = 0; i < obj.length; i++) {
            if (obj[i] != chk) {
                obj[i].checked = false;
            }
        }
    }


    // 이미지회전
    function faximage_rotate(degress) {
        swal.fire({
            text: "현재 이미지를 회전시켜 저장하시겠습니까?",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "예",
            cancelButtonText: "아니오",
            closeOnConfirm: false,
            closeOnCancel: true,
            confirmButtonColor: "#3085d6",
            cancelButtonColor: "#d33",
        }).then((result) => {
            if (result.isConfirmed) {
                const data = {
                    'vr_sq': '<?= $data['vr_sq'] ?>',
                    'degress': degress,
                };

                $.ajax({
                    url: '/m705/m705a/rotateImage',
                    contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
                    method: 'POST',
                    data: data,
                    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 saveCorp() {
        const vr_sq = '<?= $data['vr_sq'] ?>';
        const atcl_no = '<?= $data['atcl_no'] ?>';

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

                $.ajax({
                    url: '/m705/m705a/saveCorp',
                    contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
                    method: 'POST',
                    data: data,
                    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 nextRegi() {
        swal.fire({
            text: "다음 등기부등본 이미지를 불러오시겠습니까?",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "예",
            cancelButtonText: "아니오",
            closeOnConfirm: false,
            closeOnCancel: true,
            confirmButtonColor: "#3085d6",
            cancelButtonColor: "#d33",
        }).then((result) => {
            if (result.isConfirmed) {
                const data = {
                    'vr_sq': '<?= $data['vr_sq'] ?>'
                };

                $.ajax({
                    url: '/m705/m705a/getNextInfo',
                    contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
                    method: 'POST',
                    data: data,
                    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') {

                            if (result.res != null) {
                                location.replace("<?= site_url('m705/m705a/detail') ?>/" + result.res);
                            } else {
                                Swal.fire({
                                    title: "파일이 존재하지 않습니다.",
                                    icon: "error"
                                });
                            }

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

    // 등기부등본 확인정보 저장
    function saveRegi() {
        var frm = document.rcptFrm;
        var atcl_vrtc_type = frm.atcl_vrtc_type.value;
        var chk_hscp_no = frm.chk_hscp_no.value;
        var trade_type = "<?= $data['trade_type_cd'] ?>";
        var vrfc_type = "<?= $data['vrfc_type_cd'] ?>";

        var chkBox = $('input:checkbox[name=img_chk_chk]').is(':checked');	//등기소, 리얼탑 열람, 리얼탑 기열람, 열람

        var cert_register = "<?= $data['cert_register'] ?>";	//등기부등본 url이 있을경우
        var filePdf = '<?= $file_pdf ?>';

        if (vrfc_type == "M") {
            // 검증방식이 모바일이면 파일체크는 하지않고 열람인지 등기소, 리얼탑 열람, 리얼탑 기열람인지만 체크함
            if (chkBox == false) {
                Swal.fire({
                    title: "등기부등본 확인 상태를 선택해주세요.",
                    icon: "warning"
                });
                return false;
            }
        } else {
            if (chk_hscp_no == "" && trade_type == "A1") {
                // 비공동매물이고 거래방식이 매매일 경우에 파일 체크를 하지 않고 열람인지 등기소, 리얼탑 열람, 리얼탑 기열람인지만 체크함.
                if (chkBox == false) {
                    Swal.fire({
                        title: "등기부등본 확인 상태를 선택해주세요.",
                        icon: "warning"
                    });
                    return false;
                }
            } else {
                if (cert_register == "") {	//등기부등본url이 없을경우
                    // 파일이 없으며 등기부등본 이미지 파일없음이 아니면 파일을 선택하도록 함.
                    if (frm.regi_file.value == "" && reg_file_yn == false) {
                        if (frm.img_chk_chk.checked == false) {
                            Swal.fire({
                                title: "파일을 선택해주세요.",
                                icon: "warning"
                            });
                            return false;
                        }
                    } else {
                        if (chkBox == false) {
                            Swal.fire({
                                title: "등기부등본 확인 상태를 선택해주세요.",
                                icon: "warning"
                            });
                            return false;
                        }
                    }
                } else {
                    if (chkBox == false) {
                        Swal.fire({
                            title: "등기부등본 확인 상태를 선택해주세요.",
                            icon: "warning"
                        });
                        return false;
                    }
                }
            }
        }

        var type = "<?= $data['vrfc_type_sub'] ?>";
        if ((type == 'D2') && (filePdf == 'pdf' || filePdf == 'PDF')) {	//홍보v2고, pdf로 업로드됐을때
            var chk = $("#img_chk_chk4").prop("checked");
            if (chk == false) {
                Swal.fire({
                    title: "소유자명 확인이 필요합니다.",
                    icon: "warning"
                });
                click = true;
                return false;
            }
        }

        var radio_val = $('input:radio[name=owner_verifiable]').is(':checked');
        if (type == 'D2' && radio_val == false) {	//홍보확인서v2고 실소유주 확인 선택안되었을때
            Swal.fire({
                title: "실소유주 확인 결과를 선택해주세요.",
                icon: "warning"
            });
            click = true;
            return false;
        }

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

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

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

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

        //	불일치가 하나라도 있으면
        if ((type == 'M1' || type == 'O1') && (frm.reg_conf_yn_2.value == "20000" || frm.reg_conf_yn_3.value == "20000")) {
            if (!$("input:checkbox[name='cert_uncnfrm_status[]']").is(":checked")) {
                Swal.fire({
                    title: "등기부등본 미확인여부 상세를 체크해주세요.",
                    icon: "warning"
                });
                frm.cert_uncnfrm_status.focus();
                click = true;
                return false;
            }

            //	다중체크된거 가져오기			
            var arr_uncnfrm_status = [];
            $('input:checkbox[name="cert_uncnfrm_status[]"]:checked').each(function () {
                arr_uncnfrm_status.push($(this).val());
            });

            var uncnfrm_status_str = arr_uncnfrm_status.join('|');
            console.log('====')
            console.log(uncnfrm_status_str)
            console.log('====')

            $('#arr_uncnfrm_status').val(uncnfrm_status_str);
        }


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

                $.ajax({
                    url: '/m705/m705a/saveRegi',
                    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() ?>