diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 9e3220c..471abd2 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -185,6 +185,7 @@ $routes->group('', ['namespace' => 'App\Controllers\V2'], static function ($rout */ $routes->get('m708a/getResultList', 'M708::getResultList'); $routes->get('m708a/excel', 'M708::excel'); + $routes->post('m708a/rotateImage', 'M708::rotateImage'); // 이미지 회전 $routes->get('m708a/getArticleInfo', 'M708::getArticleInfo'); // 매물검색 $routes->post('m708a/saveNotArticle', 'M708::saveNotArticle'); // 홍보확인서 아님 저장 $routes->post('m708a/saveDuplImgs', 'M708::saveDuplImgs'); // 중복으로 저장 @@ -197,6 +198,28 @@ $routes->group('', ['namespace' => 'App\Controllers\V2'], static function ($rout }); + /** + * 모바일 추가 서류 + */ + $routes->group('m709', static function ($routes) { + $routes->get('m709a/lists', 'M709::lists'); + $routes->get('m709a/detail/(:num)', 'M709::detail/$1'); + + /** + * 모바일 추가 서류 - API + */ + $routes->get('m709a/getResultList', 'M709::getResultList'); + $routes->get('m709a/excel', 'M709::excel'); + $routes->post('m709a/rotateImage', 'M709::rotateImage'); // 이미지 회전 + $routes->get('m709a/getArticleInfo', 'M709::getArticleInfo'); // 매물검색 + $routes->post('m709a/saveNotArticle', 'M709::saveNotArticle'); // 홍보확인서 아님 저장 + $routes->post('m709a/saveDuplImgs', 'M709::saveDuplImgs'); // 중복으로 저장 + $routes->post('m709a/saveAddress', 'M709::saveAddress'); // 정보 저장 + $routes->post('m709a/saveImageArticle', 'M709::saveImageArticle'); // 확인결과저장 + $routes->post('m709a/getNextFaxImgs', 'M709::getNextFaxImgs'); // 다음매물 + + }); + }); diff --git a/app/Controllers/V2/M709.php b/app/Controllers/V2/M709.php new file mode 100644 index 0000000..bfa2f1d --- /dev/null +++ b/app/Controllers/V2/M709.php @@ -0,0 +1,399 @@ +model = new M709Model(); + $this->codeModel = new CodeModel(); + } + + public function lists(): string + { + $codes = $this->codeModel->getCodeLists(['CP_ID', 'STEP_VERIFICATION', 'RECEIPT_STATUS3', 'ARTICLE_TYPE']); // 코드조회 + $sido = $this->model->getAreaList(); // 지역조회 + $bonbu = $this->model->getBonbuList(); + $team = $this->model->getTeamList(); + $user = $this->model->getUserList(); + + $this->data['sido'] = $sido; + $this->data['bonbu'] = $bonbu; + $this->data['team'] = $team; + $this->data['user'] = $user; + $this->data['codes'] = $codes; + + return view("pages/v2/m709/lists", $this->data); + } + + + public function getResultList() + { + $start = (int) $this->request->getGet('start') ?: 0; + $end = (int) $this->request->getGet('length') ?: 10; + + $data = [ + 'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호 + 'chk_atcl_no' => $this->request->getGet('chk_atcl_no'), // 매물번호입력 + 'caller_no' => $this->request->getGet('caller_no'), // 발신팩스번호 + 'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태 + 'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소 + 'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부 + 'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2 + 'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1 + 'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2 + 'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1 + 'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2 + 'srcSido' => $this->request->getGet('srcSido'), // 시도 + 'srcGugun' => $this->request->getGet('srcGugun'), // 시군구 + 'srcDong' => $this->request->getGet('srcDong'), // 읍면동 + 'bonbu' => $this->request->getGet('bonbu'), // 본부 + 'team' => $this->request->getGet('team'), // 팀 + 'damdang' => $this->request->getGet('damdang'), // 담당 + 'target_yn' => $this->request->getGet('target_yn'), // 홍보확인서여부 + 'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사 + 'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류 + 'rcpt_v2' => $this->request->getGet('rcpt_v2'), // 검증방식 + ]; + + $totalCount = $this->model->getTotalCount($data); + + $datas = $this->model->getResultList($start, $end, $data); + + return $this->response->setJSON(body: [ + 'recordsTotal' => $totalCount, + 'recordsFiltered' => $totalCount, + 'data' => $datas, + ]); + + } + + public function excel() + { + + try { + + $data = [ + 'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호 + 'chk_atcl_no' => $this->request->getGet('chk_atcl_no'), // 매물번호입력 + 'caller_no' => $this->request->getGet('caller_no'), // 발신팩스번호 + 'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태 + 'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소 + 'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부 + 'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2 + 'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1 + 'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2 + 'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1 + 'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2 + 'srcSido' => $this->request->getGet('srcSido'), // 시도 + 'srcGugun' => $this->request->getGet('srcGugun'), // 시군구 + 'srcDong' => $this->request->getGet('srcDong'), // 읍면동 + 'bonbu' => $this->request->getGet('bonbu'), // 본부 + 'team' => $this->request->getGet('team'), // 팀 + 'damdang' => $this->request->getGet('damdang'), // 담당 + 'target_yn' => $this->request->getGet('target_yn'), // 홍보확인서여부 + 'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사 + 'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류 + 'rcpt_v2' => $this->request->getGet('rcpt_v2'), // 검증방식 + ]; + + $datas = $this->model->getExcelList($data); + + return $this->response->setJSON(body: [ + 'data' => $datas, + ]); + } catch (\Exception $e) { + $e->getPrevious()->getTraceAsString(); + } + } + + + // 상세화면 + public function detail($id) + { + $id = (int) $id; + + if ($id <= 0) { + throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound(); + } + + $codes = $this->codeModel->getCodeLists(['CONFIRM_RESULT_D11', 'CONSULTANT_COMMENT']); // 코드조회 + + $data = $this->model->getDetail($id); + $memo = $this->model->getMemo($id); + + + + $article = null; + $confirm = null; + if (!empty($data)) { + switch ($data['work_type']) { + case "1": // 현장확인 매물 + $article = $this->model->getArticleInfo1($data['atcl_no']); + break; + case "2": // 일반확인 매물 + $article = $this->model->getArticleInfo2($data['atcl_no']); + break; + } + + $this->data['article'] = $article; + $this->data['confirm'] = $confirm; + } + + // dd($data); + // exit; + + $history = $this->model->getHistory($id); + + $this->data['codes'] = $codes; + $this->data['data'] = $data; + $this->data['memo'] = $memo; + $this->data['history'] = $history; + + return view("pages/v2/m709/detail", $this->data); + } + + + // 이미지회전 + public function rotateImage() + { + $common = new Common(); + + try { + + $vr_sq = $this->request->getPost('vr_sq'); + $degress = $this->request->getPost('degress'); + + if (empty($degrees) || !is_numeric($degrees)) { + $degrees = 90; + } + + $regist = $this->model->getRecordInfo($vr_sq, '2'); + $fullPath = $regist['file_path'] . $regist['file_name']; + $fullPath = $_SERVER['DOCUMENT_ROOT'] . $common->realpath_to_webpath($fullPath); + + $degrees = (float) $degrees; + + $im = new \Imagick($fullPath); + + // 배경색(회전 시 빈 공간 채우는 색). 투명 원하면 'transparent' + $im->setImageBackgroundColor(new \ImagickPixel('white')); + + // 회전 + $im->rotateImage($im->getImageBackgroundColor(), $degrees); + + // 포맷/압축 유지(옵션) + $im->setImageCompressionQuality(90); + + // 덮어쓰기 + $im->writeImage($fullPath); + + $im->clear(); + $im->destroy(); + + return $this->response->setJSON([ + 'code' => '0', + 'msg' => 'success', + ]); + + } catch (\Exception $e) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => $e->getMessage(), + ]); + } + } + + // 매물검색 + public function getArticleInfo() + { + try { + + $atcl_no = $this->request->getGet('atcl_no'); + + $row = $this->model->getArticleInfo($atcl_no); + + + if (empty($row)) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => '매물이 존재하지 않습니다.', + ]); + } + + return $this->response->setJSON([ + 'code' => '0', + 'msg' => 'success', + 'atcl_no' => $row['vr_sq'], + ]); + + } catch (\Exception $e) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => $e->getMessage(), + ]); + } + } + + // 홍보확인서 아님 저장 + public function saveNotArticle() + { + try { + + $fax_sq = $this->request->getPost('fax_sq'); + + $this->model->saveNotArticle($fax_sq); + + + return $this->response->setJSON([ + 'code' => '0', + 'msg' => 'success', + ]); + + } catch (\Exception $e) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => $e->getMessage(), + ]); + } + } + + // 중복으로 저장 + public function saveDuplImgs() + { + try { + + $fax_sq = $this->request->getPost('fax_sq'); + $atcl_no = $this->request->getPost('atcl_no'); + $vr_sq = $this->request->getPost('vr_sq'); + + $this->model->saveDuplImgs($fax_sq, $atcl_no, $vr_sq); + + + return $this->response->setJSON([ + 'code' => '0', + 'msg' => 'success', + ]); + + } catch (\Exception $e) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => $e->getMessage(), + ]); + } + } + + // 정보저장 + public function saveAddress() + { + try { + + $vr_sq = $this->request->getPost('vr_sq'); // 확인요청순번 + $atcl_no = $this->request->getPost('atcl_no'); // 매물번호 + $fax_sq = $this->request->getPost('fax_sq'); // fax 순번 + $address2 = $this->request->getPost('address2'); // 상세주소1 + $address3 = $this->request->getPost('address3'); // 상세주소2 + $trade_type = $this->request->getPost('trade_type'); // 거래구분 + $floor = $this->request->getPost('floor'); // 층 + $floor2 = $this->request->getPost('floor2'); // 총층 + + + $data = [ + 'vr_sq' => $vr_sq, + 'atcl_no' => $atcl_no, + 'fax_sq' => $fax_sq, + 'address2' => $address2, + 'address3' => $address3, + 'trade_type' => $trade_type, + 'floor' => $floor, + 'floor2' => $floor2, + ]; + + $this->model->saveAddress($data); + + return $this->response->setJSON([ + 'code' => '0', + 'msg' => 'success', + ]); + + } catch (\Exception $e) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => $e->getMessage(), + ]); + } + } + + + // 확인결과저장 + public function saveImageArticle() + { + try { + + $fax_sq = $this->request->getPost('fax_sq'); + $work_type = $this->request->getPost('work_type'); + $atcl_no = $this->request->getPost('atcl_no'); + $vr_sq = $this->request->getPost('vr_sq'); + $file_type = $this->request->getPost('file_type'); + + $data = [ + 'fax_sq' => $fax_sq, + 'work_type' => $work_type, + 'atcl_no' => $atcl_no, + 'vr_sq' => $vr_sq, + 'file_type' => $file_type, + ]; + + $this->model->saveImageArticle($data); + + return $this->response->setJSON([ + 'code' => '0', + 'msg' => 'success', + ]); + + } catch (\Exception $e) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => $e->getMessage(), + ]); + } + } + + + // 다음 매물정보 조회 + public function getNextFaxImgs() + { + try { + + $curr_fax_sq = $this->request->getPost('curr_fax_sq'); + + $data = $this->model->getNextFaxImgs($curr_fax_sq); + + if (empty($data)) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => 'FAX 이미지가 존재하지 않습니다.' + ]); + } else { + return $this->response->setJSON([ + 'code' => '0', + 'msg' => 'success', + 'data' => $data + ]); + } + + } catch (\Exception $e) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => $e->getMessage(), + ]); + } + } +} \ No newline at end of file diff --git a/app/Models/v2/M708Model.php b/app/Models/v2/M708Model.php index a153689..e073e1e 100644 --- a/app/Models/v2/M708Model.php +++ b/app/Models/v2/M708Model.php @@ -961,6 +961,8 @@ class M708Model extends Model $current_tm = date('Y-m-d H:i:s'); $article = $this->getArticleInfo2($atcl_no, $vr_sq); + $this->saveFaxImgs($fax_sq, '2', $vr_sq, $atcl_no, $article['cpid'], $article['realtor_nm'], $article['stat_cd'], $current_tm, $article['address_code'], $article['address2']); + return [ 'success' => true, ]; diff --git a/app/Models/v2/M709Model.php b/app/Models/v2/M709Model.php new file mode 100644 index 0000000..3ef43f0 --- /dev/null +++ b/app/Models/v2/M709Model.php @@ -0,0 +1,1122 @@ +db->query($sql, [$gugun]); + + } else if (!empty($sido)) { + $chk_sido = substr($sido, '0', '2'); + + if ($chk_sido === '36') { + $sido = substr($sido, '0', '4'); + $sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " . + "FROM region_codes a " . + "LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " . + "WHERE a.region_cd LIKE concat(?, '%') " . + "AND a.region_cd NOT LIKE '%000000' " . + "AND a.region_cd LIKE '%00' " . + "AND a.use_yn = 'Y' " . + "AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " . + "ORDER BY a.region_nm ASC"; + } else { + $sido = substr($sido, '0', '2'); + $sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" . + " FROM region_codes a" . + " LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" . + " WHERE a.region_cd LIKE concat(?, '%')" . + " AND a.region_cd NOT LIKE '%00000000'" . + " AND a.region_cd LIKE '%00000'" . + " AND a.use_yn = 'Y'" . + " AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" . + " ORDER BY a.region_nm ASC"; + } + + $query = $this->db->query($sql, [$sido]); + } else { + $sql = "SELECT a.region_cd, a.region_nm " . + "FROM region_codes a " . + "WHERE (a.region_cd LIKE '%00000000' " . + "AND a.use_yn = 'Y') " . + "OR region_cd = 3611000000;"; + + $query = $this->db->query($sql); + } + + + return $query->getResultArray(); + } + + // 소속본부조회 + public function getBonbuList() + { + $sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" . + " FROM departments" . + " WHERE depth = 1" . + " AND use_yn = 'Y'" . + " ORDER BY lft"; + + $query = $this->db->query($sql); + + + return $query->getResultArray(); + } + + // 소속팀 조회 + public function getTeamList() + { + $sql = "SELECT dept_sq, pdept_sq, dept_nm" . + " FROM departments" . + " WHERE depth = 2" . + " AND use_yn = 'Y'" . + " ORDER BY dept_nm"; + + $query = $this->db->query($sql); + + + return $query->getResultArray(); + } + + // 유저 조회 + public function getUserList() + { + $sql = "SELECT + a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq + FROM users a + WHERE + a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70') + AND a.use_yn = 'Y' + AND EXISTS ( + SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y' + WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y' + ) + ORDER BY a.usr_level DESC, a.usr_nm ASC "; + + $query = $this->db->query($sql); + + return $query->getResultArray(); + } + + // 사용자 부서 조회 + public function getDepartmentPath($usr_sq) + { + $sql = "SELECT + b.dept_sq AS dept2_sq, c.dept_sq AS dept1_sq + FROM users a + JOIN departments b ON b.dept_sq = a.dept_sq + JOIN departments c ON c.dept_sq = b.pdept_sq + WHERE a.usr_sq = ?"; + + $query = $this->db->query($sql, [$usr_sq]); + + return $query->getRowArray(); + } + + public function getTotalCount($data) + { + $sql = "SELECT + COUNT(*) AS cnt + FROM + fax_imgs_mobile tbl + JOIN fax_imgs a ON a.fax_sq = tbl.fax_sq + LEFT JOIN v2_vrfc_req f2 ON f2.vr_sq = tbl.vr_sq AND f2.vrfc_type = 'M' + LEFT JOIN region_codes c ON c.region_cd = a.address_code + LEFT JOIN users d ON d.usr_id = a.charger + LEFT JOIN users e ON e.usr_id = a.reg_charger + LEFT JOIN v2_chg_stat d2 ON d2.vr_sq = a.vr_sq AND d2.stat_cd = '39' + + WHERE + tbl.RECV_TIME >= DATE_ADD(CURDATE(), INTERVAL -2 MONTH) + AND a.work_type = '2' "; + + + // 매물번호 + if (!empty($data['atcl_no'])) { + $sql .= "AND a.atcl = '{$data['atcl_no']}' "; + + // 발신팩스번호 + } else if (!empty($data['caller_no'])) { + $sql .= "EXISTS (SELECT 'x' + FROM fax_imgs b + WHERE b.RECV_TIME >= DATE_ADD(CURDATE(), INTERVAL -3 MONTH) + AND b.RECV_TIME >= '" . $data['receipt_sdate'] . "' AND b.RECV_TIME <= '" . $data['receipt_edate'] . "' + AND b.caller_no LIKE CONCAT('%', '" . $data['caller_no'] . "', '%') + AND b.fax_sq = a.fax_sq + ) "; + } else { + // 현재상태 + if (!empty($data['stat_cd'])) { + $sql .= "AND b.stat_cd = '{$data['stat_cd']}' "; + } + + // 매물번호입력 + if ($data['chk_atcl_no'] == "Y") { + $sql .= "AND a.atcl_no != '' "; + } + + // 중개소 + if (!empty($data['realtor_nm'])) { + $sql .= "AND a.realtor_nm = '{$data['realtor_nm']}' "; + } + + // 접수기간 + if (!empty($data['receipt_sdate'])) { + $sql .= "AND tbl.RECV_TIME >= '{$data['receipt_sdate']} 00:00:00' "; + } + + if (!empty($data['receipt_edate'])) { + $sql .= "AND tbl.RECV_TIME <= '{$data['receipt_edate']} 23:59:59' "; + } + + // 처리기간 + if (!empty($data['complete_sdate'])) { + $sql .= "AND a.send_tm >= '{$data['complete_sdate']} 00:00:00' "; + } + + if (!empty($data['complete_edate'])) { + $sql .= "AND a.send_tm <= '{$data['complete_edate']} 23:59:59' "; + } + + if (!empty($data['srcSido'])) { + $sql .= "a.address_code LIKE " . substr($data['srcSido'], 0, 2) . "% "; + } + + if (!empty($data['srcGugun'])) { + $chk_gugun = substr($data['srcGugun'], 0, 2); + if ($chk_gugun == '36') { + $sql .= "AND a.address_code = '{$data['srcGugun']}' "; + } else { + $sql .= "AND a.address_code LIKE " . substr($data['srcGugun'], 0, 5) . "% "; + } + } + + if (!empty($data['srcDong'])) { + $sql .= "AND a.address_code = '{$data['srcDong']}' "; + } + + // 현재상태 + if (!empty($data['stat_cd'])) { + $sql .= "AND a.work_type = '1' "; + $sql .= "EXISTS(SELECT 1 FROM receipt z WHERE z.rcpt_sq = a.vr_sq AND z.rcpt_stat LIKE '{$data['stat_cd']}%') "; + } + + // 매물종류 + if (!empty($data['rlet_type_cd'])) { + $sql .= "AND f1.rcpt_product = '{$data['rlet_type_cd']}' "; + } + + // 담당자 + if (!empty($data['damdang'])) { + + switch ($data['charger_gbn']) { + case "1": + $sql .= "a.charger = '{$data['damdang']}' "; + break; + case "2": + $sql .= "a.reg_charger = '{$data['damdang']}' "; + break; + } + + } else { + // 배정여부 + if ($data['assign_yn'] !== "A") { + switch ($data['charger_gbn'] . $data['assign_yn']) { + case "1Y": // 전화/서류 담당자 + $sql .= "a.charger != '' "; + break; + case "1N": // 전화/서류 담당자 + $sql .= "a.charger = '' "; + break; + case "2Y": // 등기부등본 담당자 + $sql .= "a.reg_charger != '' "; + break; + case "2N": // 등기부등본 담당자 + $sql .= "a.reg_charger IS NULL "; + break; + } + } + } + + // 본부 + if (!empty($data['bonbu'])) { + if ($data['charger_gbn'] === "1") { + $sql .= "AND a.dept1_sq = '{$data['bonbu']}' "; + } else { + $sql .= "AND a.reg_dept1_sq = '{$data['bonbu']}' "; + } + } + + // 팀 + if (!empty($data['team'])) { + if ($data['charger_gbn'] === "1") { + $sql .= "AND a.dept2_sq = '{$data['team']}' "; + } else { + $sql .= "AND a.reg_dept2_sq = '{$data['team']}' "; + } + } + + // 홍보확인서여부 + if (!empty($data['target_yn'])) { + switch ($data['target_yn']) { + case "1": + $sql .= "AND (a.work_type = '1' and a.send_yn = 'Y') "; + break; + case "E": + $sql .= "AND a.work_type ='E' "; + break; + case "3": + $sql .= "AND (a.work_type = '1' and a.bunyang_yn = 'Y') "; + break; + case "A": + $sql .= "AND (a.work_type = '1' and a.send_yn = 'N') "; + break; + } + } + + // 매체사 + if (!empty($data['rcpt_cpid'])) { + $sql .= "AND a.cpid = '{$data['rcpt_cpid']}' "; + } + + // 검증방식 + if (!empty($data['rcpt_v2'])) { + $sql .= "AND f1.isSiteVRVerification = '{$data['rcpt_v2']}' "; + } + + } + + + $sql .= "ORDER BY a.fax_sq DESC , a.RECV_TIME DESC "; + + + $query = $this->db->query($sql); + + return $query->getRow()->cnt; + } + + public function getResultList($start, $end, $data) + { + $sql = "SELECT + a.fax_sq, a.mid, a.file_name, a.file_path, a.thumbnail, a.img_width, a.img_height, a.img_size, a.img_sq, a.remark, a.work_type + , case when a.atcl_no = '' and a.work_type = '2' then f2.atcl_no else a.atcl_no end as atcl_no + , a.cpid, a.realtor_nm, a.stat_cd, a.proc_tm, a.send_tm, a.send_yn, f2.vrfc_type + , a.address_code, a.address2, a.address3, a.charger, a.reg_charger, a.CALLER_NO, a.callee_no, a.tiff_file_name, a.tiff_save_path, a.tiff_file_size, a.RECV_TIME, a.save_time + , c.region_nm, d.usr_nm, e.usr_nm reg_charger_nm, d2.insert_tm as stat_39_tm, f2.stat_cd as stat_cd2 + FROM + fax_imgs_mobile tbl + JOIN fax_imgs a ON a.fax_sq = tbl.fax_sq + LEFT JOIN v2_vrfc_req f2 ON f2.vr_sq = tbl.vr_sq AND f2.vrfc_type = 'M' + LEFT JOIN region_codes c ON c.region_cd = a.address_code + LEFT JOIN users d ON d.usr_id = a.charger + LEFT JOIN users e ON e.usr_id = a.reg_charger + LEFT JOIN v2_chg_stat d2 ON d2.vr_sq = a.vr_sq AND d2.stat_cd = '39' + + WHERE + tbl.RECV_TIME >= DATE_ADD(CURDATE(), INTERVAL -2 MONTH) + AND a.work_type = '2' "; + + + // 매물번호 + if (!empty($data['atcl_no'])) { + $sql .= "AND a.atcl = '{$data['atcl_no']}' "; + + // 발신팩스번호 + } else if (!empty($data['caller_no'])) { + $sql .= "EXISTS (SELECT 'x' + FROM fax_imgs b + WHERE b.RECV_TIME >= DATE_ADD(CURDATE(), INTERVAL -3 MONTH) + AND b.RECV_TIME >= '" . $data['receipt_sdate'] . "' AND b.RECV_TIME <= '" . $data['receipt_edate'] . "' + AND b.caller_no LIKE CONCAT('%', '" . $data['caller_no'] . "', '%') + AND b.fax_sq = a.fax_sq + ) "; + } else { + // 현재상태 + if (!empty($data['stat_cd'])) { + $sql .= "AND b.stat_cd = '{$data['stat_cd']}' "; + } + + // 매물번호입력 + if ($data['chk_atcl_no'] == "Y") { + $sql .= "AND a.atcl_no != '' "; + } + + // 중개소 + if (!empty($data['realtor_nm'])) { + $sql .= "AND a.realtor_nm = '{$data['realtor_nm']}' "; + } + + // 접수기간 + if (!empty($data['receipt_sdate'])) { + $sql .= "AND tbl.RECV_TIME >= '{$data['receipt_sdate']} 00:00:00' "; + } + + if (!empty($data['receipt_edate'])) { + $sql .= "AND tbl.RECV_TIME <= '{$data['receipt_edate']} 23:59:59' "; + } + + // 처리기간 + if (!empty($data['complete_sdate'])) { + $sql .= "AND a.send_tm >= '{$data['complete_sdate']} 00:00:00' "; + } + + if (!empty($data['complete_edate'])) { + $sql .= "AND a.send_tm <= '{$data['complete_edate']} 23:59:59' "; + } + + if (!empty($data['srcSido'])) { + $sql .= "a.address_code LIKE " . substr($data['srcSido'], 0, 2) . "% "; + } + + if (!empty($data['srcGugun'])) { + $chk_gugun = substr($data['srcGugun'], 0, 2); + if ($chk_gugun == '36') { + $sql .= "AND a.address_code = '{$data['srcGugun']}' "; + } else { + $sql .= "AND a.address_code LIKE " . substr($data['srcGugun'], 0, 5) . "% "; + } + } + + if (!empty($data['srcDong'])) { + $sql .= "AND a.address_code = '{$data['srcDong']}' "; + } + + // 현재상태 + if (!empty($data['stat_cd'])) { + $sql .= "AND a.work_type = '1' "; + $sql .= "EXISTS(SELECT 1 FROM receipt z WHERE z.rcpt_sq = a.vr_sq AND z.rcpt_stat LIKE '{$data['stat_cd']}%') "; + } + + // 매물종류 + if (!empty($data['rlet_type_cd'])) { + $sql .= "AND f1.rcpt_product = '{$data['rlet_type_cd']}' "; + } + + // 담당자 + if (!empty($data['damdang'])) { + + switch ($data['charger_gbn']) { + case "1": + $sql .= "a.charger = '{$data['damdang']}' "; + break; + case "2": + $sql .= "a.reg_charger = '{$data['damdang']}' "; + break; + } + + } else { + // 배정여부 + if ($data['assign_yn'] !== "A") { + switch ($data['charger_gbn'] . $data['assign_yn']) { + case "1Y": // 전화/서류 담당자 + $sql .= "a.charger != '' "; + break; + case "1N": // 전화/서류 담당자 + $sql .= "a.charger = '' "; + break; + case "2Y": // 등기부등본 담당자 + $sql .= "a.reg_charger != '' "; + break; + case "2N": // 등기부등본 담당자 + $sql .= "a.reg_charger IS NULL "; + break; + } + } + } + + // 본부 + if (!empty($data['bonbu'])) { + if ($data['charger_gbn'] === "1") { + $sql .= "AND a.dept1_sq = '{$data['bonbu']}' "; + } else { + $sql .= "AND a.reg_dept1_sq = '{$data['bonbu']}' "; + } + } + + // 팀 + if (!empty($data['team'])) { + if ($data['charger_gbn'] === "1") { + $sql .= "AND a.dept2_sq = '{$data['team']}' "; + } else { + $sql .= "AND a.reg_dept2_sq = '{$data['team']}' "; + } + } + + // 홍보확인서여부 + if (!empty($data['target_yn'])) { + switch ($data['target_yn']) { + case "1": + $sql .= "AND (a.work_type = '1' and a.send_yn = 'Y') "; + break; + case "E": + $sql .= "AND a.work_type ='E' "; + break; + case "3": + $sql .= "AND (a.work_type = '1' and a.bunyang_yn = 'Y') "; + break; + case "A": + $sql .= "AND (a.work_type = '1' and a.send_yn = 'N') "; + break; + } + } + + // 매체사 + if (!empty($data['rcpt_cpid'])) { + $sql .= "AND a.cpid = '{$data['rcpt_cpid']}' "; + } + + // 검증방식 + if (!empty($data['rcpt_v2'])) { + $sql .= "AND f1.isSiteVRVerification = '{$data['rcpt_v2']}' "; + } + + } + + + $sql .= "ORDER BY a.fax_sq DESC , a.RECV_TIME DESC "; + + $sql .= "LIMIT {$start}, {$end} "; + + $query = $this->db->query($sql); + + return $query->getResultArray(); + } + + + // 엑셀다운로드 + public function getExcelList($data) + { + $sql = "SELECT + a.atcl_no AS '매물번호', + (SELECT cd_nm FROM codes WHERE cd = f2.stat_cd AND category = 'STEP_VERIFICATION') AS '현재상태', + CASE + WHEN a.work_type = '1' AND a.send_yn = 'Y' THEN '홍보확인서' + WHEN a.work_type = '3' THEN '분양권' + WHEN a.work_type = 'E' THEN '홍보확인서 아님' + WHEN a.work_type = '1' AND a.send_yn = 'N' THEN '미처리' + END AS '홍보확인서여부', + a.RECV_TIME AS '수신시간', + a.CALLER_NO AS '발신번호', + c.region_nm AS '주소', + IFNULL(a.address2, '') AS '상세주소', + a.cpid AS '매체사', + a.realtor_nm AS '중개소', + d.usr_nm AS '서류/전화 담당자', + IFNULL(a.proc_tm, d2.insert_tm) AS '서류/전화 확인시간', + e.usr_nm AS '등기부등본 담당자 + FROM + fax_imgs_mobile tbl + JOIN fax_imgs a ON a.fax_sq = tbl.fax_sq + LEFT JOIN v2_vrfc_req f2 ON f2.vr_sq = tbl.vr_sq AND f2.vrfc_type = 'M' + LEFT JOIN region_codes c ON c.region_cd = a.address_code + LEFT JOIN users d ON d.usr_id = a.charger + LEFT JOIN users e ON e.usr_id = a.reg_charger + LEFT JOIN v2_chg_stat d2 ON d2.vr_sq = a.vr_sq AND d2.stat_cd = '39' + + WHERE + tbl.RECV_TIME >= DATE_ADD(CURDATE(), INTERVAL -2 MONTH) + AND a.work_type = '2' "; + + + // 매물번호 + if (!empty($data['atcl_no'])) { + $sql .= "AND a.atcl = '{$data['atcl_no']}' "; + + // 발신팩스번호 + } else if (!empty($data['caller_no'])) { + $sql .= "EXISTS (SELECT 'x' + FROM fax_imgs b + WHERE b.RECV_TIME >= DATE_ADD(CURDATE(), INTERVAL -3 MONTH) + AND b.RECV_TIME >= '" . $data['receipt_sdate'] . "' AND b.RECV_TIME <= '" . $data['receipt_edate'] . "' + AND b.caller_no LIKE CONCAT('%', '" . $data['caller_no'] . "', '%') + AND b.fax_sq = a.fax_sq + ) "; + } else { + // 현재상태 + if (!empty($data['stat_cd'])) { + $sql .= "AND b.stat_cd = '{$data['stat_cd']}' "; + } + + // 매물번호입력 + if ($data['chk_atcl_no'] == "Y") { + $sql .= "AND a.atcl_no != '' "; + } + + // 중개소 + if (!empty($data['realtor_nm'])) { + $sql .= "AND a.realtor_nm = '{$data['realtor_nm']}' "; + } + + // 접수기간 + if (!empty($data['receipt_sdate'])) { + $sql .= "AND tbl.RECV_TIME >= '{$data['receipt_sdate']} 00:00:00' "; + } + + if (!empty($data['receipt_edate'])) { + $sql .= "AND tbl.RECV_TIME <= '{$data['receipt_edate']} 23:59:59' "; + } + + // 처리기간 + if (!empty($data['complete_sdate'])) { + $sql .= "AND a.send_tm >= '{$data['complete_sdate']} 00:00:00' "; + } + + if (!empty($data['complete_edate'])) { + $sql .= "AND a.send_tm <= '{$data['complete_edate']} 23:59:59' "; + } + + if (!empty($data['srcSido'])) { + $sql .= "a.address_code LIKE " . substr($data['srcSido'], 0, 2) . "% "; + } + + if (!empty($data['srcGugun'])) { + $chk_gugun = substr($data['srcGugun'], 0, 2); + if ($chk_gugun == '36') { + $sql .= "AND a.address_code = '{$data['srcGugun']}' "; + } else { + $sql .= "AND a.address_code LIKE " . substr($data['srcGugun'], 0, 5) . "% "; + } + } + + if (!empty($data['srcDong'])) { + $sql .= "AND a.address_code = '{$data['srcDong']}' "; + } + + // 현재상태 + if (!empty($data['stat_cd'])) { + $sql .= "AND a.work_type = '1' "; + $sql .= "EXISTS(SELECT 1 FROM receipt z WHERE z.rcpt_sq = a.vr_sq AND z.rcpt_stat LIKE '{$data['stat_cd']}%') "; + } + + // 매물종류 + if (!empty($data['rlet_type_cd'])) { + $sql .= "AND f1.rcpt_product = '{$data['rlet_type_cd']}' "; + } + + // 담당자 + if (!empty($data['damdang'])) { + + switch ($data['charger_gbn']) { + case "1": + $sql .= "a.charger = '{$data['damdang']}' "; + break; + case "2": + $sql .= "a.reg_charger = '{$data['damdang']}' "; + break; + } + + } else { + // 배정여부 + if ($data['assign_yn'] !== "A") { + switch ($data['charger_gbn'] . $data['assign_yn']) { + case "1Y": // 전화/서류 담당자 + $sql .= "a.charger != '' "; + break; + case "1N": // 전화/서류 담당자 + $sql .= "a.charger = '' "; + break; + case "2Y": // 등기부등본 담당자 + $sql .= "a.reg_charger != '' "; + break; + case "2N": // 등기부등본 담당자 + $sql .= "a.reg_charger IS NULL "; + break; + } + } + } + + // 본부 + if (!empty($data['bonbu'])) { + if ($data['charger_gbn'] === "1") { + $sql .= "AND a.dept1_sq = '{$data['bonbu']}' "; + } else { + $sql .= "AND a.reg_dept1_sq = '{$data['bonbu']}' "; + } + } + + // 팀 + if (!empty($data['team'])) { + if ($data['charger_gbn'] === "1") { + $sql .= "AND a.dept2_sq = '{$data['team']}' "; + } else { + $sql .= "AND a.reg_dept2_sq = '{$data['team']}' "; + } + } + + // 홍보확인서여부 + if (!empty($data['target_yn'])) { + switch ($data['target_yn']) { + case "1": + $sql .= "AND (a.work_type = '1' and a.send_yn = 'Y') "; + break; + case "E": + $sql .= "AND a.work_type ='E' "; + break; + case "3": + $sql .= "AND (a.work_type = '1' and a.bunyang_yn = 'Y') "; + break; + case "A": + $sql .= "AND (a.work_type = '1' and a.send_yn = 'N') "; + break; + } + } + + // 매체사 + if (!empty($data['rcpt_cpid'])) { + $sql .= "AND a.cpid = '{$data['rcpt_cpid']}' "; + } + + // 검증방식 + if (!empty($data['rcpt_v2'])) { + $sql .= "AND f1.isSiteVRVerification = '{$data['rcpt_v2']}' "; + } + + } + + + $sql .= "ORDER BY a.fax_sq DESC , a.RECV_TIME DESC "; + + $query = $this->db->query($sql); + + return $query->getResultArray(); + } + + + // 상세화면 + public function getDetail($fax_sq) + { + $this->db->transStart(); + + $sql = "SELECT + a.fax_sq, a.mid, a.file_name, a.file_path, a.thumbnail, a.img_width, a.img_height, a.img_size, a.img_sq, a.remark, + a.work_type, a.vr_sq, a.atcl_no, a.cpid, a.realtor_nm, a.stat_cd, a.proc_tm, a.send_tm, a.address_code, a.address2, + a.charger, a.caller_no + FROM + fax_imgs a + WHERE + fax_sq = ?"; + + $query = $this->db->query($sql, [$fax_sq]); + + $row = $query->getRowArray(); + + if ($row['stat_cd'] == "10") { + $usr_id = session('usr_id'); + $usr_sq = session('usr_sq'); + $row_dept = $this->getDepartmentPath($usr_sq); + $dept1_sq = ''; + $dept2_sq = ''; + if (!empty($row_dept)) { + $dept1_sq = $row_dept['dept1_sq']; + $dept2_sq = $row_dept['dept2_sq']; + } + + + $sql = "UPDATE fax_imgs SET stat_cd '20', charger = ?, dept1_sq = ?, dept2_sq = ? WHERE fax_sq = ?"; + + // $this->db->query($sql, [$usr_id, $dept1_sq, $dept2_sq, $fax_sq]); + } + + $this->db->transComplete(); + + return $row; + } + + // 메모조회 + public function getMemo($fax_sq) + { + $sql = "SELECT memo FROM v2_vrfc_req where vr_sq = ?"; + + $query = $this->db->query($sql, [$fax_sq]); + + return $query->getRowArray(); + } + + // 매물검색 + public function getArticleInfo($atcl_no) + { + $sql = "SELECT + a.fax_sq, a.mid, a.file_name, a.file_path, a.thumbnail, a.img_width, a.img_height, a.img_size, a.img_sq, a.remark, + a.work_type, a.vr_sq, a.atcl_no, a.cpid, a.realtor_nm, a.stat_cd, a.proc_tm, a.send_tm, a.address_code, a.address2, + a.address2a, a.address2b, a.charger, a.caller_no + FROM + fax_imgs a + WHERE + a.atcl_no = " . $atcl_no; + + $query = $this->db->query($sql); + + $row = $query->getRowArray(); + + return $row; + } + + // 현장확인매물 조회 + public function getArticleInfo1($atcl_no, $vr_sq = '') + { + $sql_where = ""; + if (!empty($vr_sq)) { + $sql_where = " and a.rcpt_sq = '" . $vr_sq . "'"; + } + + $sql = "select a.rcpt_sq vr_sq, a.rcpt_atclno atcl_no, a.rcpt_floor as floor, a.rcpt_floor2 as floor2, a.rcpt_cpid cpid, a.agent_nm realtor_nm, a.agent_head_tel agent_tel, a.agent_fax agent_fax, a.agent_contact_tel realtor_tel_no, a.rcpt_tm rdate, '' seller_nm, '' seller_tel_no, a.rcpt_product rlet_type_cd, a.rcpt_dong address_code, c.region_nm address1 , a.rcpt_dtl_addr address2, a.rcpt_li_addr address2a, a.rcpt_jibun_addr address2b, a.rcpt_etc_addr, a.rcpt_ho address3 , a.rcpt_ref_addr address4, a.rcpt_hscp_nm as hscp_nm, a.rcpt_ptp_nm as ptp_nm, a.trade_type" . + ", case substr(a.trade_type, 1, 1) when 'A' then SUBSTRING_INDEX(a.rcpt_product_info2, '/', 1) else 0 end deal_amt" . + ", case substr(a.trade_type, 1, 1) when 'B' then SUBSTRING_INDEX(a.rcpt_product_info2, '/', 1) else 0 end wrrnt_amt" . + ", case substr(a.trade_type, 1, 1) when 'B' then case when a.rcpt_product_info3 is null || a.rcpt_product_info3 = '' || a.rcpt_product_info3 = '0' then SUBSTRING_INDEX(a.rcpt_product_info2, '/', -1) else a.rcpt_product_info3 end else 0 end lease_amt" . + ", a.rcpt_product_info4 isale_amt, a.rcpt_product_info5 prem_amt, a.rcpt_product_nm rlet_type_nm, d.cd_nm trade_type_nm, b.dbUsageAgrYn, b.resYn ,'1' try_cnt, '10' stat_cd" . + ", b.request_msg" . + ", (SELECT cd_nm FROM codes WHERE category = 'RECEIPT_STATUS3' AND cd = a.rcpt_stat) AS current_stat" . + ", case when a.isSiteVRVerification = 'Y' then '현장v2' else '현장' end as typeOfProperty" . + ", a.rcpt_hscp_no as hscp_no " . + " from receipt a" . + " inner join result b on b.rcpt_sq = a.rcpt_sq" . + " left join region_codes c on c.region_cd = a.rcpt_dong" . + " left join codes d on d.category = 'TRADE_TYPE' AND d.cd = a.trade_type" . + " where a.rcpt_atclno = ? " . $sql_where . + "order by a.rcpt_sq desc, b.rsrv_sq desc"; + + $data = [ + $atcl_no + ]; + + $query = $this->db->query($sql, $data); + + return $query->getRowArray(); + } + + // 일반확인매물조회 + public function getArticleInfo2($atcl_no, $vr_sq = '') + { + $sql = "SELECT + a.memo, g.cd_nm as pre_stat, a.vr_sq, a.atcl_no, a.cpid, a.realtor_nm, a.realtor_tel_no, b.floor, b.floor2, b.rdate, b.seller_nm, b.seller_tel_no, b.rlet_type_cd, b.address_code, f.bild_nm as address1, f.address2, f.address3, f.hscp_nm, f.ptp_nm, b.trade_type, f.deal_amt, f.wrrnt_amt, f.lease_amt, f.isale_amt, f.prem_amt, c.cd_nm as rlet_type_nm, d.cd_nm as trade_type_nm, a.try_cnt, a.stat_cd, '' request_msg + , (SELECT cd_nm FROM codes WHERE category = 'STEP_VERIFICATION' AND cd = a.stat_cd) AS current_stat + FROM v2_vrfc_req a + INNER JOIN v2_article_info b on b.vr_sq = a.vr_sq and b.rdate >= date_add( now(), interval -3 month) + LEFT JOIN codes c on c.category = 'ARTICLE_TYPE' AND c.cd = b.rlet_type_cd + LEFT JOIN codes d on d.category = 'VRFCREQ_DEAL_TYPE' AND d.cd = b.trade_type + LEFT JOIN codes g on g.category = 'STEP_VERIFICATION' AND g.cd = a.stat_cd + LEFT JOIN region_codes e on e.region_cd = b.address_code + LEFT JOIN v2_modify_info f on f.vr_sq = a.vr_sq + WHERE 1=1 "; + + if (!empty($vr_sq)) { + $sql .= "AND a.vr_sq = ?"; + } else { + $sql .= "AND a.atcl_no = ?"; + } + + + $sql .= "ORDER BY a.vr_sq DESC + LIMIT 1"; + + $query = $this->db->query($sql, [$atcl_no]); + + return $query->getRowArray(); + } + + // 변경이력 조회 + public function getHistory($id) + { + $sql = "SELECT + a.seq, + a.rcpt_sq vr_sq, + a.rcpt_stat stat_cd, + a.changed_type chg_type, + a.changed_id insert_id, + a.changed_tm insert_tm, + a.remark memo, + b.cd_nm as stat_cd_nm, + c.cd_nm as chg_type + FROM + changed_history a + LEFT JOIN codes b ON a.rcpt_stat = b.cd AND b.category = 'RECEIPT_STATUS3' + LEFT JOIN codes c ON a.changed_type = c.cd AND c.category = 'CHANGED_TYPE' + WHERE + a.rcpt_sq = ? + ORDER BY a.seq DESC "; + + $query = $this->db->query($sql, [$id]); + + return $query->getResultArray(); + } + + // 홍보확인서 아님 저장 + public function saveNotArticle($fax_sq) + { + $usr_id = session('usr_id'); + $usr_sq = session('usr_sq'); + + $row_dept = $this->getDepartmentPath($usr_sq); + $dept1_sq = ''; + $dept2_sq = ''; + if (!empty($row_dept)) { + $dept1_sq = $row_dept['dept1_sq']; + $dept2_sq = $row_dept['dept2_sq']; + } + + $sql = "UPDATE fax_imgs SET + work_type = 'E', proc_tm = NOW(), stat_cd = '69', charger = ?, dept1_sq = ?, dept2_sq = ? WHERE fax_sq = ? + "; + + $data = [ + $usr_id, + $dept1_sq, + $dept2_sq, + $fax_sq + ]; + + if ($this->db->query($sql, $data) === false) { + return [ + 'success' => false, + 'msg' => '저장 실패', + ]; + } + + return [ + 'success' => true + ]; + } + + // 중복으로 저장 + public function saveDuplImgs($fax_sq, $atcl_no, $vr_sq) + { + $current_tm = date('Y-m-d H:i:s'); + $article = $this->getArticleInfo2($atcl_no, $vr_sq); + + $this->saveFaxImgs($fax_sq, '2', $vr_sq, $atcl_no, $article['cpid'], $article['realtor_nm'], $article['stat_cd'], $current_tm, $article['address_code'], $article['address2']); + + return [ + 'success' => true, + ]; + } + + // 정보저장 + public function saveAddress($data) + { + $rcpt_sq = $this->getRcptSq($data['atcl_no']); + + $data = [ + 'rcpt_dtl_addr' => $data['address2'], + 'rcpt_ho' => $data['address3'], + 'trade_type' => $data['trade_type'], + 'rcpt_floor' => $data['floor'], + 'rcpt_floor2' => $data['floor2'], + ]; + + $builder = $this->db->table('receipt')->where('rcpt_sq', $rcpt_sq['rcpt_sq']); + $ok = $builder->update($data); + + if ($ok === false) { + return [ + 'success' => false, + 'msg' => '저장 실패', + ]; + } + + return [ + 'success' => true, + ]; + + } + + public function getRcptSq($rcpt_atclno) + { + $sql = "select rcpt_sq from receipt + where rcpt_atclno = ?"; + $data = array($rcpt_atclno); + $query = $this->db->query($sql, $data); + $row = $query->getRowArray(); + + return $row; + } + + // 확인결과 저장 + public function saveImageArticle($data) + { + $this->db->transStart(); + + $usr_id = session('usr_id'); + $stat_cd = ""; + $current_tm = date('Y-m-d H:i:s'); + + $sql = "UPDATE v2_article_info SET charger = ? WHERE vr_sq = ?"; + + if ($this->db->query($sql, [$usr_id, $data['vr_sq']]) === false) { + return [ + 'success' => false, + 'msg' => '담당자 저장 실패', + ]; + } else { + + $fax = $this->getFaxImgs($data['fax_sq']); + + if (!empty($fax)) { + $arrImagePath = array( + '/home/confirms/test-admin.confirms.co.kr/upload/', + '/home/confirms/upload/', + '/home/www/admin.confirms.co.kr/upload/', + '/home/www/upload/', + '/image/confirms_upload/', + '/misc/image/confirms_upload/', + '/storage/web/admin.confirms.co.kr/src/upload/', + '/storage/web/admin.confirms.co.kr/upload/', + $_SERVER['DOCUMENT_ROOT'] . '/upload/', + ); + + $file_path = str_replace($arrImagePath, '/upload/', $fax['file_path']); + // 1. 등록여부 확인 + $sql = "SELECT count(*) file_cnt FROM v2_files" . + " WHERE vr_sq = ?" . + " AND file_type = ?" . + " AND file_path = ?" . + " AND file_name = ?" . + " AND use_yn = 'Y'"; + $data = [ + $data['vr_sq'], + $fax['file_type'], + $file_path, + $fax['file_name'] + ]; + $query = $this->db->query($sql, $data); + $row = $query->getRowArray(); + + if (!empty($row['file_cnt'])) { + // 2. 다른파일로 등록된 경우를 위해서 업데이트 + $sql = "UPDATE v2_files SET use_yn = 'N' WHERE vr_sq = ? AND file_type = ?"; + $this->db->query($sql, [$data['vr_sq'], $fax['file_type']]); + } + + // 3. 등록 + $sql = "INSERT INTO v2_files " . + " (vr_sq, use_yn, file_type, view_odr, file_path, file_name, file_ext, file_size, img_width, img_height, insert_user, insert_tm)" . + " VALUES" . + " (?, 'Y', ?, 1, ?, ?, ?, ?, ?, ?, ?, NOW())"; + + $data = [$data['vr_sq'], $fax['file_type'], $file_path, $fax['file_name'], $fax['file_ext'], $fax['file_size'], $fax['img_width'], $fax['img_height'], $usr_id]; + $this->db->query($sql, $data); + + $article = $this->getArticleInfo2('', $data['vr_sq']); + + //4.매물과 팩스를 이어준다 + $this->saveFaxImgs($data['fax_sq'], '2', $article['vr_sq'], $article['atcl_no'], $article['cpid'], $article['realtor_nm'], $stat_cd, $current_tm, $article['address_code'], $article['address2'], 'Y'); + } + + } + + + $this->db->transComplete(); + } + + // 다음매물조회 + public function getNextFaxImgs($fax_sq) + { + $this->db->transStart(); + + $h_y = $this->get_send_yn('H'); + $usr_id = session('usr_id'); + $usr_sq = session('usr_sq'); + $row_dept = $this->getDepartmentPath($usr_sq); + $dept1_sq = ''; + $dept2_sq = ''; + if (!empty($row_dept)) { + $dept1_sq = $row_dept['dept1_sq']; + $dept2_sq = $row_dept['dept2_sq']; + } + + + $sql = "SELECT a.fax_sq FROM fax_imgs a + WHERE + a.recv_time > DATE_ADD(NOW(), INTERVAL -7 DAY) AND a.stat_cd = '20' AND a.work_type = '1' AND a.chk_con = 'N' + AND a.fax_sq > ? + LIMIT 1 + FOR UPDATE SKIP LOCKED "; + + $query = $this->db->query($sql, [$fax_sq]); + $row = $query->getRowArray(); + + $sql = "UPDATE fax_imgs" . + " SET stat_cd = '20', charger='" . $usr_id . "', dept1_sq='" . $dept1_sq . "', dept2_sq='" . $dept2_sq . "', chk_con='Y'" . + " WHERE fax_sq = '" . $row['fax_sq'] . "'"; + $this->db->query($sql); + + $this->db->transComplete(); + + return $row; + } + + + public function getFaxImgs($fax_sq) + { + $sql = "SELECT + img_size, file_path, file_name, img_width, img_height + FROM + fax_imgs + WHERE fax_sq = ?"; + + $query = $this->db->query($sql, [$fax_sq]); + + return $query->getRowArray(); + } + + public function saveFaxImgs($fax_sq, $work_type, $vr_sq, $atcl_no, $cpid, $realtor_nm, $stat_cd, $proc_tm, $address_code, $address2, $send_yn) + { + $insert_id = session('usr_id'); + $usr_sq = session('usr_sq'); + + // 부서 정보 + $row_dept = $this->getDepartmentPath($usr_sq); + + $dept1_sq = $row_dept['dept1_sq'] ?? ''; + $dept2_sq = $row_dept['dept2_sq'] ?? ''; + + // 업데이트 데이터 + $dataFaxImgs = [ + 'work_type' => $work_type, + 'vr_sq' => $vr_sq, + 'atcl_no' => $atcl_no, + 'cpid' => $cpid, + 'realtor_nm' => $realtor_nm, + 'stat_cd' => $stat_cd, // 서류확인 완료 + 'proc_tm' => $proc_tm, + 'address_code' => $address_code, + 'address2' => $address2, + 'charger' => $insert_id, + 'dept1_sq' => $dept1_sq, + 'dept2_sq' => $dept2_sq, + 'send_yn' => $send_yn, + ]; + + // DB + $builder = $this->db->table('fax_imgs')->where('fax_sq', $fax_sq); + $ok = $builder->update($dataFaxImgs); + + if ($ok === false) { + return [ + 'success' => false, + 'msg' => 'fax_imgs 저장 실패', + ]; + } + + return [ + 'success' => true, + ]; + } + +} \ No newline at end of file diff --git a/app/Views/pages/v2/m709/detail.php b/app/Views/pages/v2/m709/detail.php new file mode 100644 index 0000000..de7a172 --- /dev/null +++ b/app/Views/pages/v2/m709/detail.php @@ -0,0 +1,1349 @@ + +extend('layouts/main') ?> +section('content') ?> + + + +
+
+
+
홍보확인서 상세 내용
+
+
+
+ +
+
+
+ + + + + +
+
+ +
+
+
+ + + 발신번호 : + + + + + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + +
+ + + + + + + fax + + + + + + +
+
+
+ 기본 정보 +
+ +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
매물번호 +
+ + + + +
+ + +
+
+
CP ID
현재 상태 +
+
+ +
+ + +
+
+ 공인중개사 정보 +
+
+ + + + + + + + + + + + + + + + + + + +
중개사명 +
대표전화/FAX + + + + + +
담당자전화 + +
+
+
+ + + +
+
+ 중개인 요청사항 +
+
+ + + + + + + + + + + +
중개인 요청사항 + +
+
+ + +
+
+
+ + + +
+
+ 매물 정보 +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
등록일시
의뢰인(매도자) +
매물구분 +
지역구분 +
단지명 + +
상세주소 + + + + + +
거래구분/가격 + / + + + + 만원 + + + + + + 만원 + + + + + + 만원 / + 만원 + +
+
+ + + / + + +
+
+
+
+ +
+
+ + + + +
+ +
+
+
+
+
+ + + +
+
+
정보변경 이력
+
+ + + + + + + + + + + + + + + + + + + +
진행상태변경내용처리자(ID)처리일시세부내용
+ + + + + + + + + +
+
+
+
+ +
+
+ + +section('modals') ?> + +endSection() ?> + + + +endSection() ?> \ No newline at end of file diff --git a/app/Views/pages/v2/m709/lists.php b/app/Views/pages/v2/m709/lists.php new file mode 100644 index 0000000..0f529d8 --- /dev/null +++ b/app/Views/pages/v2/m709/lists.php @@ -0,0 +1,774 @@ +extend('layouts/main') ?> + +section('content') ?> + + +

모바일 추가 서류

+ +
+
+
+
+ + + + + +
+ + 매물번호 또는 발신팩스번호를 입력하면 다른 조건은 무시됩니다. + +
+ + +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ +
+ + +
+
+
+
+ +
+ +
+ + ~ + +
+
+ + +
+ +
+ + ~ + +
+
+ + +
+ +
+ + + +
+
+
+
+ +
+ +
+ + + +
+
+ + +
+ +
+ +
+
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + +
+ + +
+
+ + +
+
+
+
+ +
+
+
+
+ +
+ +
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
매물번호현재상태홍보확인서
여부
수신기간발신번호주소상세주소매체사중개소서류/전화
담당자
서류/전화
확인시간
등기부등본
담당자
검증완료
일시
+
+
+
+ + + + + + + + +endSection() ?> \ No newline at end of file