From e0672d325ca78540a6244865d42611491f90c19b Mon Sep 17 00:00:00 2001 From: yangsh Date: Mon, 29 Dec 2025 13:50:46 +0900 Subject: [PATCH] =?UTF-8?q?=EC=95=84=ED=8C=8C=ED=8A=B8=20=ED=8F=89?= =?UTF-8?q?=EB=A9=B4=EB=8F=84=20=EC=83=81=EC=84=B8=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Config/Routes.php | 5 + app/Controllers/Article/Ground.php | 141 ++++ app/Libraries/MyUpload.php | 20 + app/Models/article/GroundModel.php | 262 +++++++- app/Views/layouts/sidebar.php | 15 + app/Views/pages/article/detail2.php | 977 +++++++++++++++++++++++++++- app/Views/pages/article/lists2.php | 48 +- 7 files changed, 1432 insertions(+), 36 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index e47dbc7..2c672c8 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -106,6 +106,11 @@ $routes->group('article', ['namespace' => 'App\Controllers\Article'], function ( $routes->post('apt/ground/uploadFile', 'Ground::uploadFile'); $routes->get('apt/ground/print', 'Ground::print'); + $routes->post('apt/ground/saveMemo', 'Ground::saveMemo'); + $routes->post('apt/ground/saveKeeper', 'Ground::saveKeeper'); + $routes->post('apt/ground/statusChange', 'Ground::statusChange'); + $routes->post('apt/ground/saveNote', 'Ground::saveNote'); + }); diff --git a/app/Controllers/Article/Ground.php b/app/Controllers/Article/Ground.php index 79a820e..beafaae 100644 --- a/app/Controllers/Article/Ground.php +++ b/app/Controllers/Article/Ground.php @@ -217,15 +217,156 @@ class Ground extends BaseController throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound(); } + $bonbu = $this->model->getBonbuList(); + $team = $this->model->getTeamList(); + $user = $this->model->getUserList(); + // 상세정보 $apt = $this->model->getDetail($rcpt_no, $hscp_no); + // 동일단지 + $rdata = $this->model->getDetailLists($rcpt_no, $hscp_no); + + // 변경이력 + $history = $this->model->getHistory($rcpt_no); return view("pages/article/detail2", [ + 'bonbu' => $bonbu, + 'team' => $team, + 'user' => $user, 'apt' => $apt, + 'rdata' => $rdata, + 'history' => $history, ]); } + // 메모저장 + public function saveMemo() + { + try { + + $data = [ + 'rcpt_no' => $this->request->getPost('rcpt_no'), + 'memo' => $this->request->getPost('memo'), + ]; + + // UPDATE apt_ground + $this->model->saveMemo($data); + + return $this->response->setJSON([ + 'code' => '0', + 'msg' => 'success' + ]); + + } catch (\Exception $e) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => $e->getMessage(), + ]); + } + } + + // 담당자 변경 + public function saveKeeper() + { + try { + + + $data = [ + 'rcpt_no' => $this->request->getPost('rcpt_no'), + 'bonbu' => $this->request->getPost('bonbu'), + 'team' => $this->request->getPost('team'), + 'user' => $this->request->getPost('user'), + ]; + + + // UPDATE apt_ground + $this->model->saveKeeper($data); + + + return $this->response->setJSON([ + 'code' => '0', + 'msg' => 'success' + ]); + + } catch (\Exception $e) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => $e->getMessage(), + ]); + } + } + + // 단지상태변경 + public function statusChange() + { + $lib = new MyUpload(); + + try { + + $type = $this->request->getPost('type'); + $rcpt_no = $this->request->getPost('rcpt_no'); + + + if ($type === "phoX") { + $apt = $this->model->getDetail($rcpt_no, ""); + + if (!empty($apt['pho_no'])) { + $path = $apt['file_path'] . "" . $apt['filenm_up']; + + $lib->deleteFile($path); + } + + + } + + // UPDATE apt_ground + $this->model->statusChange($rcpt_no, $type); + + + return $this->response->setJSON([ + 'code' => '0', + 'msg' => 'success' + ]); + + } catch (\Exception $e) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => $e->getMessage(), + ]); + } + } + + // 단지 특이사항 저장 + public function saveNote() + { + try { + + $rcpt_no = $this->request->getPost('rcpt_no'); + + + $data = [ + 'rcpt_no' => $rcpt_no, + 'note' => $this->request->getPost('note'), + ]; + + + // UPDATE apt_ground + $this->model->saveNote($data); + + + return $this->response->setJSON([ + 'code' => '0', + 'msg' => 'success' + ]); + + } catch (\Exception $e) { + return $this->response->setJSON([ + 'code' => '9', + 'msg' => $e->getMessage(), + ]); + } + } // 파일업로드(평면도) diff --git a/app/Libraries/MyUpload.php b/app/Libraries/MyUpload.php index 5615b93..00e566d 100644 --- a/app/Libraries/MyUpload.php +++ b/app/Libraries/MyUpload.php @@ -110,6 +110,26 @@ class MyUpload return $this->s3_data; } + /** + * + */ + public function deleteFile($key) + { + $s3Client = $this->makeS3Client(); + + try { + + $s3Client->deleteObject([ + 'Bucket' => NCLOUD_S3_BUCKET, + 'Key' => ltrim($key, '/'), + ]); + + return true; + } catch (\Throwable $e) { + return false; + } + } + /** * S3(NCLOUD) 파일 업로드 * 추가일 2025.12.24 diff --git a/app/Models/article/GroundModel.php b/app/Models/article/GroundModel.php index cd51011..cd57b5a 100644 --- a/app/Models/article/GroundModel.php +++ b/app/Models/article/GroundModel.php @@ -637,7 +637,7 @@ class GroundModel extends Model ,a.charger, a.dept_sq ,(SELECT pdept_sq FROM departments WHERE dept_sq = a.dept_sq) bonbu ,a.send_end_tm, a.supply_no_tm ,d.pho_cate2, d.pho_explain, d.pho_up_nu - ,gp.filenm_up, gp.file_path, gp.insert_tm + ,gp.pho_no ,gp.filenm_up, gp.file_path, gp.thumb_nm, gp.cloud_upload_yn, gp.insert_tm FROM apt_ground a LEFT JOIN apt_category d ON a.rcpt_no = d.rcpt_no @@ -645,19 +645,246 @@ class GroundModel extends Model FROM apt_ground_photo p WHERE p.rcpt_no = a.rcpt_no ORDER BY p.pho_no DESC - LIMIT 1) + LIMIT 1) AND gp.use_yn = 'Y' - WHERE a.rcpt_no = {$rcpt_no} AND a.hscp_no = {$hscp_no} "; + WHERE a.rcpt_no = {$rcpt_no} "; + + if (!empty($hscp_no)) { + $sql .= "AND a.hscp_no = {$hscp_no} "; + } + $query = $this->db->query($sql, [$rcpt_no]); return $query->getRowArray(); } + // 동일단지 + public function getDetailLists($rcpt_no, $hscp_no) + { + $sql = "SELECT + a.rcpt_no, a.hscp_no, a.part_no, a.addr, a.addr2, a.rcpt_hscp_nm, a.move_ym, a.households_cnt, a.dong_cnt, a.pyeong_cnt, a.apt_cate_nm, a.region_cd, a.rcpt_x, a.rcpt_y + ,a.vdo_up_tm, DATE_FORMAT(a.vdo_up_tm, '%Y-%m-%d') as rdate_dt_vdo ,DATE_FORMAT(a.vdo_up_tm, '%H:%i:%s') as rdate_tm_vdo + ,a.check_tm, DATE_FORMAT(a.check_tm, '%Y-%m-%d') as rdate_dt_chk ,DATE_FORMAT(a.check_tm, '%H:%i:%s') as rdate_tm_chk + ,a.memo, a.note, a.video_target, a.vdo_up_ynx, a.not_vdo_reson, a.apt_step, a.check_yn, a.resend_yn, a.write_complete_yn, a.all_no_pho + ,a.write_complete_tm, DATE_FORMAT(a.write_complete_tm, '%Y-%m-%d') as rdate_dt_cmpl ,DATE_FORMAT(a.write_complete_tm, '%H:%i:%s') as rdate_tm_cmpl + ,a.charger, a.dept_sq ,(SELECT pdept_sq FROM departments WHERE dept_sq = a.dept_sq) bonbu, b.usr_nm, i.dept_nm + ,a.send_end_tm, a.supply_no_tm + ,d.pho_cate2, d.pho_explain, d.pho_up_nu + ,gp.pho_no, gp.filenm ,gp.filenm_up, gp.file_path, gp.thumb_nm, gp.cloud_upload_yn, gp.insert_tm + FROM + apt_ground a + LEFT JOIN apt_category d ON a.rcpt_no = d.rcpt_no + LEFT JOIN apt_ground_photo gp ON gp.pho_no = (SELECT p.pho_no + FROM apt_ground_photo p + WHERE p.rcpt_no = a.rcpt_no + ORDER BY p.pho_no DESC + LIMIT 1) AND gp.use_yn = 'Y' + LEFT JOIN users b ON a.charger = b.usr_id + LEFT JOIN departments i ON a.dept_sq = i.dept_sq + WHERE a.rcpt_no = {$rcpt_no} AND a.hscp_no != {$hscp_no} "; + + + $query = $this->db->query($sql); + + return $query->getResultArray(); + } + + // 정보변경이력 + public function getHistory($rcpt_no) + { + $sql = " SELECT seq," . + " rcpt_no, " . + " apt_step, get_code_name('APT_GROUND_STEP',apt_step) AS apt_step_nm, " . + " changed_type, get_code_name('APT_GROUND_CHANGED_TYPE',changed_type) AS changed_type_nm, " . + " changed_detail, get_code_name('APT_GROUND_CHANGED_DETAIL',changed_detail) AS changed_detail_nm, " . + " charged_id, " . + " changed_tm, DATE_FORMAT(changed_tm, '%Y-%m-%d') as rdate_dt, DATE_FORMAT(changed_tm, '%H:%i:%s') as rdate_tm" . + " FROM apt_ground_history" . + " WHERE rcpt_no = ?" . + " ORDER BY changed_tm DESC"; + + + + $query = $this->db->query($sql, [$rcpt_no]); + + return $query->getResultArray(); + } + + // 메모저장 + public function saveMemo($data) + { + $sql = "UPDATE apt_ground SET + memo = '{$data['memo']}' + WHERE rcpt_no = {$data['rcpt_no']} + "; + + if ($this->db->query($sql) === false) { + return [ + 'success' => false, + 'msg' => '저장실패', + ]; + } + + + $row = $this->getDetail($data['rcpt_no'], ""); + $this->saveHistory($data['rcpt_no'], $row['apt_step'], 'C', 'A1', session('usr_id')); + + return [ + 'success' => true, + ]; + + } + + // 담당자 변경 + public function saveKeeper($data) + { + $sql = "UPDATE apt_ground SET + dept_sq = {$data['team']}, charger = '{$data['user']}' + WHERE rcpt_no = {$data['rcpt_no']} + "; + + if ($this->db->query($sql) === false) { + return [ + 'success' => false, + 'msg' => '저장실패', + ]; + } + + $row = $this->getDetail($data['rcpt_no'], ""); + $this->saveHistory($data['rcpt_no'], $row['apt_step'], 'C', 'A1', session('usr_id')); + + return [ + 'success' => true, + ]; + } + + // 단지상태변경 + public function statusChange($rcpt_no, $type) + { + $this->db->transStart(); + $data = [ + $rcpt_no + ]; + + + if ($type === "phoX") { + $detail = 'C1'; + + + $sql = "UPDATE apt_ground" . + " SET gpho_up_yn = 'N'" . + " ,apt_step = 'S01'" . + " WHERE rcpt_no = ?"; + + + if ($this->db->query($sql, $data) === false) { + return [ + 'success' => false, + 'msg' => '저장실패', + ]; + } + + $sql = "delete from apt_ground_photo" . + " WHERE rcpt_no = ?"; + + $this->db->query($sql, $data); + + + } else if ($type === "phoY") { + $detail = 'C3'; + + $sql = "UPDATE apt_ground" . + " SET gpho_up_yn = 'Y'" . + " ,apt_step = 'S03'" . + " WHERE rcpt_no = ?"; + + if ($this->db->query($sql, $data) === false) { + return [ + 'success' => false, + 'msg' => '저장실패', + ]; + } + + $sql = "UPDATE apt_ground_photo" . + " SET insert_tm = NOW()" . + " WHERE rcpt_no = ?"; + + $this->db->query($sql, $data); + + } else if ($type === "sendE") { + $detail = 'C4'; + + $sql = "UPDATE apt_ground" . + " SET send_end_tm = NOW()" . + " ,supply_no_tm = NULL" . + " ,apt_step = 'S04'" . + " WHERE rcpt_no = ?"; + + if ($this->db->query($sql, $data) === false) { + return [ + 'success' => false, + 'msg' => '저장실패', + ]; + } + + } else if ($type === "suppN") { + $detail = 'C2'; + + $sql = "UPDATE apt_ground" . + " SET all_no_pho = 'Y'" . + " ,apt_step = 'S02'" . + " ,supply_no_tm = NOW()" . + " ,send_end_tm = NULL" . + " WHERE rcpt_no = ?"; + + if ($this->db->query($sql, $data) === false) { + return [ + 'success' => false, + 'msg' => '저장실패', + ]; + } + } + + $row = $this->getDetail($rcpt_no, ""); + $this->saveHistory($rcpt_no, $row['apt_step'], 'E', $detail, session('usr_id')); + + $this->db->transComplete(); + + return [ + 'success' => true, + ]; + + } + + // 단지 특이사항 저장 + public function saveNote($data) + { + $sql = "UPDATE apt_ground SET + note = '{$data['note']}' + WHERE rcpt_no = {$data['rcpt_no']} + "; + + if ($this->db->query($sql) === false) { + return [ + 'success' => false, + 'msg' => '저장실패', + ]; + } + + $row = $this->getDetail($data['rcpt_no'], ""); + $this->saveHistory($data['rcpt_no'], $row['apt_step'], 'C', 'D1', session('usr_id')); + + return [ + 'success' => true, + ]; + } // 평면도 정보 저장 public function saveImg($data) { + $this->db->transStart(); + $sql = "INSERT INTO apt_ground_photo (rcpt_no, filenm, filenm_up, file_ext, insert_tm, file_path, thumb_path, thumb_nm, use_yn, cloud_upload_yn) VALUES @@ -673,9 +900,38 @@ class GroundModel extends Model ]; } + + $sql = "UPDATE apt_ground SET + gpho_up_yn = 'Y', apt_step = 'S03' + WHERE rcpt_no = {$data['rcpt_no']} + "; + + $this->db->query($sql); + + $this->db->transComplete(); + return [ 'success' => true, ]; } + + // 이력 저장 + public function saveHistory($rcpt_no, $apt_step, $changed_type, $changed_detail, $charged_id) + { + $sql = "INSERT INTO apt_ground_history" . + " (rcpt_no, apt_step, changed_type, changed_detail, charged_id, changed_tm)" . + " VALUES (?, ?, ?, ?, ?, NOW())"; + $data = [ + $rcpt_no, + $apt_step, + $changed_type, + $changed_detail, + $charged_id + ]; + + + $res = $this->db->query($sql, $data); + } + } \ No newline at end of file diff --git a/app/Views/layouts/sidebar.php b/app/Views/layouts/sidebar.php index 9534dca..a9b6632 100644 --- a/app/Views/layouts/sidebar.php +++ b/app/Views/layouts/sidebar.php @@ -93,6 +93,21 @@ section('content') ?>