<?php

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

$usr_level = session('usr_level');

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

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

<?= $this->section('content') ?>

<form name="rcptFrm" id="rcptFrm" method="post" action="" enctype="multipart/form-data" onsubmit="return false;">
    <input type="hidden" name="address_code" id="address_code" value="<?= $data['address_code'] ?>" />
    <input type="hidden" name="chTotal" id="chTotal" value="" />
    <input type="hidden" name="reg_chk_val" value="<?= $data['rgbk_confirm'] ?>" />
    <input type="hidden" name="rcpt_key" value="<?= $data['vr_sq'] ?>" />
    <input type="hidden" name="tel_file_yn" value="<?php if (!empty($tel)) if ($tel['file_name']) {
        echo "y";
    } ?>" />
    <div class="col-md-12 col-xl-12">
        <div class="col-lg-12">
            <div class="main-card mb-3 card">
                <div class="card-header bg-white border-bottom shadow-sm">
                    <div class="d-flex flex-wrap align-items-center gap-3">
                        <div class="flex-grow-1">
                            <h4 class="mb-0 fw-bold text-dark">전화확인매물 상세 내용</h4>
                        </div>
                        <div class="d-flex flex-wrap gap-3">
                            <div><span class="tit">매물ID:</span> <span class="num"><?= $data['atcl_no'] ?></span></div>
                            <div><span class="tit">CP ID:</span> <span class="num"><?= $data['cpid'] ?></span></div>
                            <div><span class="tit">현재 상태:</span> <span class="num"><?= $data['pre_stat'] ?></span></div>
                        </div>
                    </div>
                </div>
                <div class="card-body">
                    <h5 class="card-title">공인 중개사 정보</h5>
                    <table class="table table-bordered table-sm tbl_basic2 apt-info-table">
                        <colgroup>
                            <col width="15%" />
                            <col width="35%" />
                            <col width="15%" />
                            <col width="35%" />
                        </colgroup>
                        <tr>
                            <th>중개사명</th>
                            <td>
                                <?= $data['realtor_nm'] ?>
                            </td>
                            <th>대표전화</th>
                            <td>
                                <?= $data['realtor_tel_no'] ?>
                            </td>
                        </tr>

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

            <!-- 매물정보 -->
            <div class="main-card mb-3 card">
                <div class="card-body p-2">
                    <h5 class="card-title">매물 정보</h5>
                    <table class="table table-bordered table-sm tbl_basic2 apt-info-table">
                        <colgroup>
                            <col style="width:120px">
                            <col style="width:320px">
                            <col style="width:120px">
                            <col style="width:320px">
                        </colgroup>

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

                                <th>전화/서류 완료일시</th>
                                <td>
                                    <select class="form-select" name="atcl_vrtc_way" id="atcl_vrtc_way"
                                        disabled="disabled">
                                        <option value="">-선택-</option>
                                        <?php foreach ($codes as $c) { ?>
                                            <?php if ($c['category'] === "VRFCREQ_WAY"): ?>
                                                <option value="<?= $c['cd'] ?>" <?php if ($data['vrfc_type_cd'] == $c['cd'])
                                                      echo "selected"; ?>>
                                                    <?= $c['cd_nm'] ?>
                                                </option>
                                            <?php endif; ?>
                                        <?php } ?>
                                    </select>
                                    <?= $data['update_res_tm'] ?>
                                </td>
                            </tr>
                            <tr>
                                <th>등기부등본 확인완료</th>
                                <td>
                                    <?= $data['result_tm'] ?>
                                </td>
                                <th>의뢰인(매도자)</th>
                                <td>
                                    <?php
                                    if ($data['stat_cd'] == '19' || $data['stat_cd'] == '60' || $data['stat_cd'] == '69') {
                                        echo ('***');
                                    } else {
                                        echo ($data['seller_nm']);
                                    }
                                    ?>
                                </td>
                            </tr>
                            <tr>
                                <th>매물구분</th>
                                <td>
                                    <?= $data['atcl_nm'] ?>
                                </td>
                                <th>거래구분</th>
                                <td>
                                    <div class="d-flex flex-wrap gap-3">
                                        <div class="form-check" id="buy_tra_area1" style="display: none;">
                                            <input class="form-check-input" type="radio" name="trade_type_cd"
                                                id="buy_tra_cd1" value="B1" <?= ($data['trade_type_cd'] === 'B1') ? 'checked' : '' ?> disabled>
                                            <label class="form-check-label" for="buy_tra_cd1">전세</label>
                                        </div>

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

                                        <div class="form-check" id="buy_tra_area3" style="display: none;">
                                            <input class="form-check-input" type="radio" name="trade_type_cd"
                                                id="buy_tra_cd3" value="A1" <?= ($data['trade_type_cd'] === 'A1') ? 'checked' : '' ?> disabled>
                                            <label class="form-check-label" for="buy_tra_cd3">매매</label>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <th rowspan="3">지역구분</th>
                                <td rowspan="3">
                                    <?= $data['region_nm'] ?>
                                </td>
                                <th>리 주소</th>
                                <td>
                                    <input type="text" class="form-control" name="atcl_addr1a" id="atcl_addr1a"
                                        value="<?= $data['address2a'] ?>" size="70" disabled /><br />
                                </td>
                            </tr>
                            <tr>
                                <th>상세주소</th>
                                <td class="d-flex gap-1">
                                    <?php if (empty($data['address2b'])) { ?>
                                        <input type="text" class="form-control" name="atcl_addr1" id="atcl_addr1"
                                            value="<?= $data['address2'] ?>" size="70" disabled /><br />
                                        <input type="hidden" class="form-control" name="atcl_addr1b" id="atcl_addr1b"
                                            value="<?= $data['address2b'] ?>" size="70" disabled />
                                    <?php } else { ?>
                                        <input type="hidden" class="form-control" name="atcl_addr1" id="atcl_addr1"
                                            value="<?= $data['address2'] ?>" size="70" disabled />
                                        <input type="text" class="form-control" name="atcl_addr1b" id="atcl_addr1b"
                                            value="<?= $data['address2b'] ?>" size="70" disabled /><br />
                                    <?php } ?>
                                    <input type="text" class="form-control" name="atcl_addr2" id="atcl_addr2"
                                        value="<?= $data['address3'] ?>" size="70" disabled />
                                </td>
                            </tr>
                            <tr>
                                <th>기타주소</th>
                                <td>
                                    <input type="text" class="form-control" name="atcl_addr3" id="atcl_addr3"
                                        value="<?= $data['address4'] ?>" size="70" disabled />
                                </td>
                            </tr>
                            <tr>
                                <th>단지명</th>
                                <td>
                                    <input type="hidden" name="atcl_hscp_nm" id="atcl_hscp_nm"
                                            value="<?= $data['hscp_nm'] ?>" />
                                        <select class="form-select" name="atcl_hscp_no" id="atcl_hscp_no" disabled>
                                            <option value="">-단지선택-</option>
                                            <?php
                                            foreach ($complexList['result'] as $complex): ?>
                                                <option value="<?= $complex['rletNo'] ?>"
                                                    <?= ($complex['rletNo'] === $data['hscp_no']) ? 'selected' : '' ?>>
                                                    <?= $complex['rletNm'] ?>
                                                <?php endforeach; ?>
                                        </select>
                                </td>
                                <th>가격</th>
                                <td>
                                    <!-- 기본 가격 (매매) -->
                                    <div id="div_trade_type_price" style="display: none;">
                                        <div class="d-flex align-items-center gap-2">
                                            <div class="input-group input-group-sm" style="max-width: 220px;">
                                                <input type="text" class="form-control text-end" name="atcl_amt1"
                                                    id="atcl_amt1" value="<?= $data['deal_amt'] ?>" disabled>
                                                <span class="input-group-text">만원</span>
                                            </div>

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

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

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

                                    <!-- 분양가 / 프리미엄 -->
                                    <div id="div_trade_type_price2" style="display: none;">
                                        <div class="d-flex flex-column gap-2">
                                            <div class="d-flex align-items-center gap-2">
                                                <div class="input-group input-group-sm" style="max-width: 220px;">
                                                    <input type="text" class="form-control text-end" name="atcl_amt4"
                                                        id="atcl_amt4" value="<?= $data['deal_amt'] ?>" disabled>
                                                    <span class="input-group-text">만원</span>
                                                </div>

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

                                            <div class="d-flex gap-2">
                                                <div style="flex: 1;">
                                                    <label class="form-label small mb-1 text-muted">분양가</label>
                                                    <div class="input-group input-group-sm">
                                                        <input type="text" class="form-control text-end"
                                                            name="isale_amt" id="isale_amt"
                                                            value="<?= str_replace(',', '', $data['isale_amt']) ?>"
                                                            disabled>
                                                        <span class="input-group-text">만원</span>
                                                    </div>
                                                </div>

                                                <div style="flex: 1;">
                                                    <label class="form-label small mb-1 text-muted">프리미엄</label>
                                                    <div class="input-group input-group-sm">
                                                        <input type="text" class="form-control text-end" name="prem_amt"
                                                            id="prem_amt"
                                                            value="<?= str_replace(',', '', $data['prem_amt']) ?>"
                                                            disabled>
                                                        <span class="input-group-text">만원</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <th>평형</th>
                                <td>
                                    <input type="hidden" name="atcl_ptp_nm" id="atcl_ptp_nm"
                                        value="<?= $data['ptp_nm'] ?>" />
                                    <?php if (!empty($ptpList['result'])): ?>
                                        <select class="form-select" name="atcl_ptp_no" id="atcl_ptp_no" disabled>
                                            <option value="">-평형-</option>
                                            <?php foreach ($ptpList['result'] as $ptp):
                                                $isSelected = ($ptp['ptpNo'] === $data['ptp_no']);
                                                ?>
                                                <option value="<?= $ptp['ptpNo'] ?>" <?= $isSelected ? 'selected' : '' ?>>
                                                    <?= $ptp['ptpNm'] ?>
                                                </option>
                                            <?php endforeach; ?>
                                        </select>
                                    <?php else: ?>
                                        <select class="form-select" name="atcl_ptp_no" id="atcl_ptp_no" disabled>
                                            <option value="">-평형-</option>
                                        </select>
                                    <?php endif; ?>
                                </td>

                                <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>
                                    <div class="d-flex align-items-center gap-1">
                                        <input type="text" class="form-control form-control-sm" style="max-width:80px;"
                                            name="atcl_floor" id="atcl_floor" value="<?= $data['floor'] ?>" disabled>
                                        <span class="text-muted">/</span>
                                        <input type="text" class="form-control form-control-sm" style="max-width:80px;"
                                            name="atcl_floor2" id="atcl_floor2" value="<?= $data['floor2'] ?>" disabled>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <th>가주소 여부</th>
                                <td colspan="3">
                                    <?php
                                    $vir_style = "";
                                    if ($data['vir_addr_yn'] == 'Y') {
                                        $vir_style = "style='color:#F21E1E;font-weight: bold;'";
                                    }
                                    ?>
                                    <span <?= $vir_style ?>>
                                        <?= $data['vir_addr_yn'] ?>
                                    </span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <?php if ((int) $data['stat_cd'] < 45 && (int) $data['stat_cd'] !== 39):
                    if ((int) $data['try_cnt'] < 2):
                        ?>
                        <div class="card-footer d-flex justify-content-end gap-1">
                            <button class="mb-2 btn-transition btn btn-outline-secondary" id="btnModify"
                                onclick="editInfo();">수정</button>
                            <button class="mb-2 btn btn-primary" id="btnGreenModifyInfo" onclick="modifyInfo();"
                                disabled>저장</button>
                        </div>
                        <?php
                    endif;
                endif; ?>
            </div>

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

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

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

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

            <!-- 전화확인정보 -->
            <div class="main-card mb-3 card">
                <div class="card-body p-2">
                    <h5 class="card-title">전화확인 정보
                        <?php if ($data['req_type'] == "U"): ?>
                            <span style="color:red"> [ 재접수 ] </span>
                        <?php endif; ?>
                    </h5>
                    <table class="table table-bordered table-sm tbl_basic2 apt-info-table">
                        <colgroup>
                            <col style="width:120px">
                            <col>
                            <col style="width:120px">
                            <col>
                        </colgroup>
                        <tr>
                            <th>의뢰인(매도자) 전화번호</th>
                            <?php
                            if ($data['stat_cd'] == '19' || $data['stat_cd'] == '60' || $data['stat_cd'] == '69') {
                                //2015.07.03 수정 >> 개인정보 보호법에 의해서 전화(서류)확인 중 상태에만 전화번호와 의뢰인 이름이 보이도록 수정
                                ?>
                                <td>
                                    *********
                                    <?php if ($data['chg_seller_tel'] == 'Y') { ?>
                                        &nbsp; &nbsp; <span id="chg_address" style="color:red;"> ※전화 번호 수정</span>
                                    <?php }
                                    // 2015.09.01 임대사업자 등록번호
                                    // 수정예정 : M507 페이지 개설 후 DB에서 데이터 호출
                                    /*	$chk_number = array('010-2400-3202', '010-2400-3202', '010-2400-3202', '010-3661-0050',						
                                        '010-2400-3202', '010-6836-0701', '010-4315-5777', '010-3390-5115',
                                        '010-8796-6354', '010-3623-8383', '010-7106-7520', '011-742-3396',
                                        '010-2929-1416', '010-2336-3277', '010-4278-8820', '010-3851-2016',
                                        '010-8552-4852', '010-4213-9809', '010-9075-8820', '010-6271-0241',
                                        '011-227-5940' , '010-4884-7861', '010-3719-9666', '010-3266-6990',
                                        '010-7145-9781', '010-3093-4009', '010-3954-0608', '010-3024-7132',
                                        '010-5829-2016', '010-6350-8383', '010-5769-7809', '010-2380-5778');*/
                                    $chk_array = array();
                                    for ($cnt = 0; $cnt < count($phone_list); $cnt++) {
                                        array_push($chk_array, $phone_list[$cnt]['phone_number']);
                                    }


                                    if (in_array($data['seller_tel_no'], $chk_array)) {
                                        ?>
                                        &nbsp; &nbsp; <span id="chg_address" style="color:blue;"> ※주택임대사업자</span>
                                    <?php } ?>
                                </td>
                            <?php } else {
                                ?>
                                <!-- 상태가 전화(서류)확인 중이 아니면 *로 표기 -->
                                <td>
                                    <button class="mb-2 btn btn-outline-secondary" onclick="BtnCall();">
                                        <i class="pe-7s-call"> </i>전화걸기
                                    </button>
                                    <button class="mb-2 btn btn-outline-secondary" onclick="BtnOut();">
                                        <i class="pe-7s-close"> </i>전화끊기
                                    </button>
                                    <?php
                                    if ($data['chg_seller_tel'] == 'Y') { ?>
                                        &nbsp; &nbsp; <span id="chg_address" style="color:red;"> ※전화 번호 수정</span>
                                        <?php
                                    }

                                    $chk_array = array();	//임대사업자 등록되어있는지 확인
                                    for ($cnt = 0; $cnt < count($phone_list); $cnt++) {
                                        array_push($chk_array, $phone_list[$cnt]['phone_number']);
                                    }
                                    if (($data['realtor_tel_no'] == $data['seller_tel_no']) && !in_array($data['seller_tel_no'], $chk_array)) {	//대표전화와,의뢰인연락처 같은경우 & 임대업자등록이 안되어있을때만 //2016.11.11 수정
                                        ?>
                                        &nbsp; &nbsp; <span style="color:red;">※ 중개업소 대표번호와 동일</span>
                                        <?php
                                    }

                                    // 2015.09.01 임대사업자 등록번호
                                    // 수정예정 : M507 페이지 개설 후 DB에서 데이터 호출
                                    /*	$chk_number = array('010-2400-3202', '010-2400-3202', '010-2400-3202', '010-3661-0050',						
                                        '010-2400-3202', '010-6836-0701', '010-4315-5777', '010-3390-5115',
                                        '010-8796-6354', '010-3623-8383', '010-7106-7520', '011-742-3396',
                                        '010-2929-1416', '010-2336-3277', '010-4278-8820', '010-3851-2016',
                                        '010-8552-4852', '010-4213-9809', '010-9075-8820', '010-6271-0241',
                                        '011-227-5940' , '010-4884-7861', '010-3719-9666', '010-3266-6990',
                                        '010-7145-9781', '010-3093-4009', '010-3954-0608', '010-3024-7132',
                                        '010-5829-2016', '010-6350-8383', '010-5769-7809', '010-2380-5778');*/

                                    if (in_array($data['seller_tel_no'], $chk_array)) {
                                        ?>
                                        &nbsp; &nbsp; <span id="chg_address" style="color:blue;"> ※주택임대사업자</span>
                                        <?php
                                    }
                                    ?>
                                </td>
                                <?php
                                //echo('<td>'.$data['seller_tel_no'].'</td>');
                            }
                            ?>
                            <th>개인정보 제공동의</th>
                            <td>
                                <select class="form-select" name="tel_agree" id="tel_agree">
                                    <option value="">-선택-</option>
                                    <?php foreach ($codes as $c): ?>
                                        <?php if ($c['category'] === "CONFIRM_RESULT_T11"): ?>
                                            <option value="<?= $c['cd'] ?>" <?php if ($c['cd'] === $data['tel_agree']) {
                                                  echo "selected";
                                              } ?>><?= $c['cd_nm'] ?></option>
                                        <?php endif; ?>
                                    <?php endforeach; ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>의뢰인(매도자) 이름</th>
                            <td>
                                <?php
                                if ($data['stat_cd'] == '19' || $data['stat_cd'] == '60' || $data['stat_cd'] == '69') {
                                    echo ('***');
                                } else {
                                    echo ($data['seller_nm']);
                                }
                                ?>
                            </td>
                            <th>확인담당자</th>
                            <td><?= $data['usr_nm'] ?></td>

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

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

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

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

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



                            </td>

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

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

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

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

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

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

                                    <div class="text-end">
                                        <button type="button" class="btn btn-sm btn-outline-light"
                                            onclick="saveMemo('<?= $data['vr_sq'] ?>');">
                                            저장
                                        </button>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>소유자명</th>
                            <td>
                                <?php
                                if ($data['stat_cd'] == '19' || $data['stat_cd'] == '60' || $data['stat_cd'] == '69') {
                                    echo ('***');
                                } else {
                                    ?>
                                    <?= $data['ownerNm'] ?>
                                    <?php
                                }
                                ?>
                            </td>
                            <th>중개업소 어뷰징 의심</th>
                            <td class="d-flex gap-2">
                                <select class="form-select" name="atcl_vrtc_way" id="atcl_vrtc_way" disabled="disabled">
                                    <option value="">-선택-</option>
                                    <?php foreach ($codes as $c) { ?>
                                        <?php if ($c['category'] === "TEL_FAIL_CAUSE"): ?>
                                            <option value="<?= $c['cd'] ?>" <?php if ($data['tel_fail_cause'] == $c['cd'])
                                                  echo "selected"; ?>>
                                                <?= $c['cd_nm'] ?>
                                            </option>
                                        <?php endif; ?>
                                    <?php } ?>
                                </select>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="card-footer d-flex justify-content-end gap-1">
                    <?php if ((int) $data['stat_cd'] != 35 && (int) $data['stat_cd'] != 39 && (int) $data['stat_cd'] < 40): ?>
                        <button class="mb-2 btn btn-outline-warning" onclick="contactFail();">통화실패</button>
                        <button class="mb-2 btn btn-outline-primary" onclick="saveTel();">저장</button>
    <button class="mb-2 btn btn-outline-light" onclick="btnSilverNextAssign_onclick();">다음</button>
                                        <?php else: ?>
    <button class="mb-2 btn btn-outline-light" onclick="btnSilverNextAssign_onclick();">다음</button>
<?php endif; ?>
                    
                </div>
            </div>


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


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

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

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

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

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

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

                </form>
            </div>
        </div>
    </div>
</div>
<?= $this->endSection() ?>

<script src="https://unpkg.com/dropzone@6.0.0-beta.1/dist/dropzone-min.js"></script>
<link href="https://unpkg.com/dropzone@6.0.0-beta.1/dist/dropzone.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">

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


    $(function () {

        if (but_ty == "A1") {
            $("#buy_tra_area3").show();
            $("#div_trade_type_price").show();
        } else {
            $("#buy_tra_area1").show();
            $("#buy_tra_area2").show();
            $("#div_trade_type_price_monthly").show();
        }

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

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

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

        /**
         *  파일 Dropzone
         * */
        const dz = new Dropzone("#myDropzone", {
            url: "/m704/m704a/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 editInfo() {
        var rletNo = '<?= $data['hscp_no'] ?>';
        //alert(rletNo);

        //ajax_code_complexList();
        //ajax_code_ptpList(rletNo);

        document.getElementById('atcl_vrtc_way').disabled = false;
        document.getElementById('atcl_addr1').disabled = false;
        document.getElementById('atcl_addr1a').disabled = false;
        document.getElementById('atcl_addr1b').disabled = false;
        document.getElementById('atcl_addr2').disabled = false;
        document.getElementById('atcl_addr3').disabled = false;

        document.getElementById('atcl_addr1').readonly = true;
        document.getElementById('atcl_addr1a').readonly = true;
        document.getElementById('atcl_addr1b').readonly = true;
        document.getElementById('atcl_addr2').readonly = true;
        document.getElementById('atcl_addr3').readonly = true;

        $("#atcl_addr1 , #atcl_addr1a , #atcl_addr1b , #atcl_addr2, #atcl_addr3").attr("readonly", true);

        document.getElementById('atcl_amt1').disabled = false;
        document.getElementById('atcl_amt2').disabled = false;
        document.getElementById('atcl_amt3').disabled = false;
        document.getElementById('atcl_amt4').disabled = false;
        document.getElementById('prem_amt').disabled = false;
        document.getElementById('isale_amt').disabled = false;
        //	document.getElementById('atcl_floor').disabled = false;
        //	document.getElementById('atcl_floor2').disabled = false;
        //	document.getElementById('atcl_hscp_no').disabled = false;
        //	document.getElementById('atcl_ptp_no').disabled = false;
        //	$('input[name=trade_type_cd]').attr("disabled",false);
        $('#btnSilverReadLatLng').removeAttr('disabled');
        $('#btnSilverModifyMap').removeAttr('disabled');
        $('#btnGreenModifyInfo').removeAttr('disabled');

    }


    // 매물정보 저장
    function modifyInfo() {
        var chkvrfc_hscp = '<?= $data['hscp_no'] ?>';
        var chkvrfc_ptp = '<?= $data['ptp_no'] ?>';
        var td_ty = '<?= $data['trade_type_cd'] ?>';
        var rlet_type_cd = '<?= $data['rlet_type_cd'] ?>';

        if (td_ty == "A1") {
            if (rlet_type_cd == "B01" || rlet_type_cd == "B02" || rlet_type_cd == "B03") {
                $('#atcl_amt1').val($.trim($('#atcl_amt4').val()));
            } else {
                $('#atcl_amt4').val($.trim($('#atcl_amt1').val()));
            }
        }

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

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

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

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


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

        } else {

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

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

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

            var atcl_addr2 = $.trim($('#atcl_addr2').val());
            if (atcl_addr2 == '') {
                Swal.fire({
                    title: '상세주소를 입력하세요.',
                    icon: 'warning'
                });
                $("#atcl_addr2").focus();
                return false;
            }

        }

        //가격
        if (td_ty == 'A1') {		//매매일때

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

        } else {					//전세나 월세일 때

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

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

        }

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


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

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

                            })

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


    function BtnCall() {
        var phone_num = "<?= $data['seller_tel_no'] ?>";
        var ch_phone_num = phone_num.replace(/-/gi, "");
        Btn_OpenDevice();
        TEIDLink.TEIDDialing(ch_phone_num);
    }

    function BtnOut() {
        TEIDLink.TEIDReset();
        Btn_CloseDevice();
    }

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

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

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

                            })

                            location.reload();
                        } else {
                            Swal.fire({
                                title: result.msg,
                                icon: "error"
                            })
                        }
                    }
                });
            }
        });
    }
    
    // 통화실패
    function contactFail() {
        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: '/m704/m704a/contactFail',
                    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') {

                            console.log(result.data)
                            const fax_sq = result.data.fax_sq;

                            location.replace("<?= site_url('m703/m703a/detail') ?>/" + fax_sq);

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

    // 전화확인정보 저장
    function saveTel() {
        var frm = document.rcptFrm;
	var peo_Agr_val = $("#tel_agree").val();
	var index_val = $("#tel_agree option:selected").val();	
	var address_chk1 = $('#address_chk1').is(":checked");
	var address_chk2 = $('#address_chk2').is(":checked");
	var price_chk1 = $('#price_chk1').is(":checked");
	var price_chk2 = $('#price_chk2').is(":checked");
	var client_chk1 = $('#client_chk1').is(":checked");
	var client_chk2 = $('#client_chk2').is(":checked");
	var fail_chk1 = $('#fail_chk1').is(":checked");
	var fail_chk2 = $('#fail_chk2').is(":checked");
	
    if(frm.tel_agree.value == "" && fail_chk1 == false && fail_chk2 == false){
        Swal.fire({
            title: "개인정보 제공동의 여부나 \n 전화확인 1차 실패를 선택해주세요",
            icon: "warning"
        });
        frm.tel_agree.focus();
        return false;
    }

    if(index_val == '10000' || peo_Agr_val == '10000'){
        if(address_chk1 == false && address_chk2 == false){
            Swal.fire({
                title: "매물주소 정보확인 결과를 선택해주세요",
                icon: "warning"
            });
            return false;
        }

        if(price_chk1 == false && price_chk2 == false){
            Swal.fire({
                title: "가격 거래구분 정보확인 결과를 선택해주세요",
                icon: "warning"
            });
            return false;
        }

        if(client_chk1 == false && client_chk2 == false){
            Swal.fire({
                title: "의뢰인 정보확인 결과를 선택해주세요",
                icon: "warning"
            });
            return false;
        }
    
        if(address_chk2 == true){
            if(frm.tel_conf_yn_info_2.value == ""){
                Swal.fire({
                    title: "매물주소 불일치에 대한 상세내용을 작성해주세요",
                    icon: "warning"
                });
                frm.tel_conf_yn_info_2.focus();
                return false;
            }
        }
    
        if(price_chk2 == true){
            if(frm.tel_conf_yn_info_3.value == ""){
                Swal.fire({
                    title: "가격 거래구분 불일치에 대한 상세내용을 작성해주세요",
                    icon: "warning"
                });
                frm.tel_conf_yn_info_3.focus();
                return false;
            }
        }
    
        if(client_chk2 == true){
            if(frm.tel_conf_yn_info_4.value == ""){
                Swal.fire({
                    title: "의뢰인정보 불일치에 대한 상세내용을 작성해주세요",
                    icon: "warning"
                });
                frm.tel_conf_yn_info_4.focus();
                return false;
            }
        }
        
        if(frm.chk_telv.checked == false){
            Swal.fire({
                title: "녹취파일 확인을 체크해주세요",
                icon: "warning"
            });
            frm.chk_telv.focus();
            return false;
        }
    }

    
}

    // 다음매물
    function btnSilverNextAssign_onclick() {
        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: '/m704/m704a/getNextTelInfo',
                    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') {

                            console.log(result.data)
                            const fax_sq = result.data.fax_sq;

                            location.replace("<?= site_url('m703/m703a/detail') ?>/" + fax_sq);

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

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