diff --git a/app/Config/Database.php b/app/Config/Database.php
index 41c2417..779eb73 100644
--- a/app/Config/Database.php
+++ b/app/Config/Database.php
@@ -26,10 +26,10 @@ class Database extends Config
*/
public array $default = [
'DSN' => '',
- 'hostname' => '192.168.10.246',
- 'username' => '',
- 'password' => '',
- 'database' => '',
+ 'hostname' => '192.168.10.243',
+ 'username' => 'confirms',
+ 'password' => 'zjsvjatm',
+ 'database' => 'db_confirms',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 5b9c28d..6ba30c2 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -16,6 +16,10 @@ $routes->get('/logout', 'Login::out');
$routes->get('/', 'Home\Home::dashboard');
$routes->get('/home', 'Home\Home::dashboard');
+$routes->get('/home/viewStatData', to: 'Home\Home::viewStatData'); // 실적조회
+$routes->get('/home/getHomeFaxCount', to: 'Home\Home::getHomeFaxCount'); // 팩스조회
+
+
/**
* 게시판 (board) 그룹
@@ -39,6 +43,101 @@ $routes->group('board', ['namespace' => 'App\Controllers\Board'], function ($rou
});
+/**
+ * 실적관리 (results) 그룹
+ */
+$routes->group('results', ['namespace' => 'App\Controllers\Results'], function ($routes) {
+ /** 화면 */
+ $routes->match(['get', 'post'], 'summary/stats_s01', 'Summary::lists'); // 현장확인요약실적
+ $routes->match(['get', 'post'], 'dept/stats_d01', 'Dept::lists'); // 현장확인요약실적
+ $routes->match(['get', 'post'], 'person/stats_p01', 'Person::lists'); // 현장확인개인별실적
+ $routes->match(['get', 'post'], 'assign/stats_a01', 'Assign::lists'); // 현장확인인원별배정현황
+ $routes->match(['get', 'post'], 'm409/m409a/stats', 'M409::stats'); // 확인매물일별실적
+
+
+ /** API - 현장확인조직별실적 */
+ $routes->get('dept/excel', 'Sms::excel');
+
+ /** API - 현장확인개인별실적 */
+ $routes->get('person/getUserList', 'Person::getUserList');
+ $routes->get('person/excel', 'Person::excel');
+
+ /** API - 현장확인인원별배정현황 */
+ $routes->get('assign/getUserList', 'Assign::getUserList');
+ $routes->get('assign/excel', 'Assign::excel');
+
+ /** API - 확인매물일별실적 */
+});
+
+$routes->group('', ['namespace' => 'App\Controllers\Results'], static function ($routes) {
+
+ // 확인매물일별실적
+ $routes->group('m409', static function ($routes) {
+ $routes->match(['get', 'post'], 'm409a/stats', 'M409::stats');
+
+ // API
+ $routes->get('m409a/getResultList', 'M409::getResultList');
+ $routes->get('m409a/excel', 'M409::excel');
+ });
+
+ // 확인매물개인별실적
+ $routes->group('m410', static function ($routes) {
+ $routes->match(['get', 'post'], 'm410a/stats', 'M410::stats');
+
+ // API
+ $routes->get('m410a/getResultList', 'M410::getResultList');
+ $routes->get('m410a/excel', 'M410::excel');
+ });
+
+ // 확인매물매체사실적
+ $routes->group('m411', static function ($routes) {
+ $routes->match(['get', 'post'], 'm411a/stats', 'M411::stats');
+
+ // API
+ $routes->get('m411a/getResultList', 'M411::getResultList');
+ $routes->get('m411a/excel', 'M411::excel');
+ });
+
+ // 확인매물일자별실적
+ $routes->group('m412', static function ($routes) {
+ $routes->match(['get', 'post'], 'm412a/stats', 'M412::stats');
+
+ // API
+ $routes->get('m412a/getResultList', 'M412::getResultList');
+ $routes->get('m412a/excel', 'M412::excel');
+ $routes->post('m412a/saveSendType', 'M412::saveSendType');
+ });
+
+ // 검증소요시간
+ $routes->group('m415', static function ($routes) {
+ $routes->match(['get', 'post'], 'm415a/stats', 'M415::stats');
+
+ // API
+ $routes->get('m415a/getResultList', 'M415::getResultList');
+ $routes->get('m415a/excel', 'M415::excel');
+ });
+
+ // 개인별이동거리
+ $routes->group('m416', static function ($routes) {
+ $routes->match(['get', 'post'], 'm416a/stats', 'M416::stats');
+
+ // API
+ $routes->get('m416a/getResultList', 'M416::getResultList');
+ $routes->get('m416a/excel', 'M416::excel');
+ });
+
+ // 신규매물실적관리
+ $routes->group('m417', static function ($routes) {
+ $routes->match(['get', 'post'], 'm417a/stats', 'M417::stats');
+
+ // API
+ $routes->get('m417a/getResultList', 'M417::getResultList');
+ $routes->get('m417a/excel', 'M417::excel');
+ });
+
+});
+
+
/**
* 시스템관리 (manage) 그룹
*/
diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php
index 0d1302d..f3863b9 100644
--- a/app/Controllers/BaseController.php
+++ b/app/Controllers/BaseController.php
@@ -7,10 +7,12 @@ use CodeIgniter\Controller;
abstract class BaseController extends Controller
{
+ protected $helpers = ['array', 'function'];
protected $session;
protected $data = [];
+
public function initController($request, $response, $logger)
{
parent::initController($request, $response, $logger);
diff --git a/app/Controllers/home/Home.php b/app/Controllers/home/Home.php
index 39f98ee..971238b 100644
--- a/app/Controllers/home/Home.php
+++ b/app/Controllers/home/Home.php
@@ -39,4 +39,25 @@ class Home extends BaseController
]);
}
+ // 실적조회
+ public function viewStatData()
+ {
+ $params = [
+ 's_date' => $this->request->getGet('s_date'),
+ 'usr_sq' => session('usr_sq'),
+ ];
+
+ $data = $this->homeModel->viewStatData($params);
+
+ return $this->response->setJSON($data);
+ }
+
+ // 팩스건수 조회
+ public function getHomeFaxCount()
+ {
+
+ $data = $this->homeModel->getHomeFaxCount();
+
+ return $this->response->setJSON($data);
+ }
}
diff --git a/app/Controllers/results/Assign.php b/app/Controllers/results/Assign.php
new file mode 100644
index 0000000..73ddda4
--- /dev/null
+++ b/app/Controllers/results/Assign.php
@@ -0,0 +1,82 @@
+assignModel = new AssignModel();
+ }
+
+ public function lists(): string
+ {
+ $bonbu = $this->assignModel->getBonbuList();
+ $team = $this->assignModel->getTeamList();
+ $sido = $this->assignModel->getAreaList();
+
+
+ return view("pages/results/assign/stats_a01", [
+ 'bonbu' => $bonbu,
+ 'team' => $team,
+ 'sido' => $sido,
+ ]);
+ }
+
+ public function getUserList()
+ {
+ $start = (int) $this->request->getGet('start') ?: 0;
+ $end = (int) $this->request->getGet('length') ?: 10;
+
+ $data = [
+ 'bonbu' => $this->request->getGet('bonbu'),
+ 'team' => $this->request->getGet('team'),
+ 'schDateGb' => $this->request->getGet('schDateGb'),
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'srchType' => $this->request->getGet('srchType'),
+ 'srchTxt' => $this->request->getGet('srchTxt'),
+ ];
+
+ $totalCount = $this->assignModel->getTotalCount($data);
+
+
+ $datas = $this->assignModel->getUserList($start, $end, $data);
+
+ return $this->response->setJSON(body: [
+ 'recordsTotal' => $totalCount,
+ 'recordsFiltered' => $totalCount,
+ 'data' => $datas,
+ ]);
+ }
+
+ // 엑셀 다운로드
+ public function excel()
+ {
+ try {
+
+ $data = [
+ 'bonbu' => $this->request->getGet('bonbu'),
+ 'team' => $this->request->getGet('team'),
+ 'schDateGb' => $this->request->getGet('schDateGb'),
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'srchType' => $this->request->getGet('srchType'),
+ 'srchTxt' => $this->request->getGet('srchTxt'),
+ ];
+
+ $datas = $this->assignModel->getExcelUserList($data);
+
+ return $this->response->setJSON(body: [
+ 'data' => $datas,
+ ]);
+
+ } catch (\Exception $e) {
+ $e->getPrevious()->getTraceAsString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/results/Dept.php b/app/Controllers/results/Dept.php
new file mode 100644
index 0000000..d643b98
--- /dev/null
+++ b/app/Controllers/results/Dept.php
@@ -0,0 +1,98 @@
+deptModel = new DeptModel();
+ }
+
+ public function index()
+ {
+
+
+ }
+
+
+ public function lists(): string
+ {
+
+
+ $this->schDateGb = $this->request->getPost('schDateGb') ?? '1';
+
+ $this->sdate = $this->request->getPost('sdate');
+ if (empty($this->sdate)) {
+ $this->sdate = date('Y-m-01'); // 이번달 1일
+ }
+
+ $this->edate = $this->request->getPost('edate');
+ if (empty($this->edate)) {
+ $this->edate = date('Y-m-t'); // 이번달 말일
+ }
+
+ $this->bonbu = $this->request->getPost('bonbu');
+ if (empty($this->bonbu)) {
+ $this->bonbu = '';
+ }
+
+ $this->dept_sq = $this->request->getPost('dept_sq');
+ if (empty($this->dept_sq)) {
+ $this->dept_sq = '';
+ }
+
+ $data = [
+ 'schDateGb' => $this->schDateGb,
+ 'sdate' => $this->sdate,
+ 'edate' => $this->edate,
+ 'bonbu' => $this->bonbu,
+ 'dept_sq' => $this->dept_sq,
+ ];
+
+ $bonbu = $this->deptModel->getBonbuList();
+ $team = $this->deptModel->getTeamList();
+
+ $res = $this->deptModel->st_d01($data);
+
+ return view("pages/results/dept/stats_d01", [
+ 'pBonbu' => $this->bonbu,
+ 'pDeptSq' => $this->dept_sq,
+ 'schDateGb' => $this->schDateGb,
+ 'sdate' => $this->sdate,
+ 'edate' => $this->edate,
+ 'bonbu' => $bonbu,
+ 'team' => $team,
+ 'st_list' => $res,
+ ]);
+ }
+
+ // 엑셀 다운로드
+ public function excel()
+ {
+ $data = [
+ 'schDateGb' => $this->request->getGet('schDateGb'),
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'bonbu' => $this->request->getGet('bonbu'),
+ 'dept_sq' => $this->request->getGet('dept_sq'),
+ ];
+
+
+ $res = $this->deptModel->getExcelList($data);
+
+ return $this->response->setJSON(body: [
+ 'data' => $res,
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/results/M409.php b/app/Controllers/results/M409.php
new file mode 100644
index 0000000..9826844
--- /dev/null
+++ b/app/Controllers/results/M409.php
@@ -0,0 +1,75 @@
+model = new M409Model();
+ }
+
+ public function stats(): string
+ {
+ $codes = $this->model->getCodeList(['VRFCREQ_WAY', 'CP_ID']);
+
+ $CODE_VRFCREQ_WAY = convertArrayToHashTable($codes['VRFCREQ_WAY'], 'cd', 'cd_nm', []);
+ $CODE_CP_ID = convertArrayToHashTable($codes['CP_ID'], 'cd', 'cd_nm', []);
+
+ return view("pages/results/m409/stats", [
+ 'code_vrfcreq_way' => $CODE_VRFCREQ_WAY,
+ 'code_cp_id' => $CODE_CP_ID,
+ ]);
+ }
+
+ public function getResultList()
+ {
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'vrfcreq_way' => $this->request->getGet('vrfcreq_way'),
+ 'cp_id' => $this->request->getGet('cp_id'),
+ ];
+
+ $totalCount = $this->model->getTotalCount($data);
+
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'recordsTotal' => $totalCount,
+ 'recordsFiltered' => $totalCount,
+ 'data' => $datas,
+ ]);
+
+ }
+
+
+ // 엑셀 다운로드
+ public function excel()
+ {
+ try {
+
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'vrfcreq_way' => $this->request->getGet('vrfcreq_way'),
+ 'cp_id' => $this->request->getGet('cp_id'),
+ ];
+
+ $datas = $this->model->getExcelList($data);
+
+ return $this->response->setJSON(body: [
+ 'data' => $datas,
+ ]);
+
+ } catch (\Exception $e) {
+ $e->getPrevious()->getTraceAsString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/results/M410.php b/app/Controllers/results/M410.php
new file mode 100644
index 0000000..6ae28ae
--- /dev/null
+++ b/app/Controllers/results/M410.php
@@ -0,0 +1,74 @@
+model = new M410Model();
+ }
+
+ public function stats(): string
+ {
+ $codes = $this->model->getCodeList(['VRFCREQ_WAY', 'CP_ID']);
+
+ $CODE_VRFCREQ_WAY = convertArrayToHashTable($codes['VRFCREQ_WAY'], 'cd', 'cd_nm', []);
+ $CODE_CP_ID = convertArrayToHashTable($codes['CP_ID'], 'cd', 'cd_nm', []);
+ $department = $this->model->getDepart();
+
+ return view("pages/results/m410/stats", [
+ 'code_vrfcreq_way' => $CODE_VRFCREQ_WAY,
+ 'code_cp_id' => $CODE_CP_ID,
+ 'department' => $department,
+ ]);
+ }
+
+ public function getResultList()
+ {
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'dept_sq' => $this->request->getGet('dept_sq'),
+ 'vrfcreq_way' => $this->request->getGet('vrfcreq_way'),
+ ];
+
+ $totalCount = $this->model->getTotalCount($data);
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'recordsTotal' => $totalCount,
+ 'recordsFiltered' => $totalCount,
+ 'data' => $datas,
+ ]);
+
+ }
+
+ // 엑셀 다운로드
+ public function excel()
+ {
+ try {
+
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'dept_sq' => $this->request->getGet('dept_sq'),
+ 'vrfcreq_way' => $this->request->getGet('vrfcreq_way'),
+ ];
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'data' => $datas,
+ ]);
+
+ } catch (\Exception $e) {
+ $e->getPrevious()->getTraceAsString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/results/M411.php b/app/Controllers/results/M411.php
new file mode 100644
index 0000000..db27276
--- /dev/null
+++ b/app/Controllers/results/M411.php
@@ -0,0 +1,62 @@
+model = new M411Model();
+ }
+
+ public function stats(): string
+ {
+ return view("pages/results/m411/stats", [
+ ]);
+ }
+
+ public function getResultList()
+ {
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ ];
+
+ $totalCount = $this->model->getTotalCount($data);
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'recordsTotal' => $totalCount,
+ 'recordsFiltered' => $totalCount,
+ 'data' => $datas,
+ ]);
+
+ }
+
+
+ // 엑셀 다운로드
+ public function excel()
+ {
+ try {
+
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ ];
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'data' => $datas,
+ ]);
+
+ } catch (\Exception $e) {
+ $e->getPrevious()->getTraceAsString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/results/M412.php b/app/Controllers/results/M412.php
new file mode 100644
index 0000000..c79af1f
--- /dev/null
+++ b/app/Controllers/results/M412.php
@@ -0,0 +1,233 @@
+model = new M412Model();
+ $this->smsModel = new SmsModel();
+ }
+
+
+ public function stats(): string
+ {
+ $sendH = $this->model->get_send_yn('H');
+ $sendD = $this->model->get_send_yn('D');
+ $sendT = $this->model->get_send_yn('T');
+ $sendN = $this->model->get_send_yn('N');
+ $sendJ = $this->model->get_send_yn('J');
+ $sendO = $this->model->get_send_yn('O');
+
+ return view("pages/results/m412/stats", [
+ 'sendH' => $sendH,
+ 'sendD' => $sendD,
+ 'sendT' => $sendT,
+ 'sendN' => $sendN,
+ 'sendJ' => $sendJ,
+ 'sendO' => $sendO,
+ ]);
+ }
+
+ public function getResultList()
+ {
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ ];
+
+ $totalCount = $this->model->getTotalCount($data);
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'recordsTotal' => $totalCount,
+ 'recordsFiltered' => $totalCount,
+ 'data' => $datas,
+ ]);
+ }
+
+ // 타입별 전송 on/off 저장
+ public function saveSendType()
+ {
+ try {
+
+ $usr_nm = session('usr_nm');
+ $client_ip = getRealClientIp();
+
+ $data = [
+ 'type' => $this->request->getPost('type'),
+ 'yn' => $this->request->getPost('yn'),
+ 'usr_sq' => session('usr_sq'),
+ ];
+
+ // INSERT v2_stop_api_chg_stat
+ $this->model->saveSendType($data);
+
+ $send_sms_member = [
+ ["name" => '김인', "tel" => '010-4010-8318'],
+ ["name" => "이민호", "tel" => '010-6743-3112'],
+ ["name" => "이권희", "tel" => '010-4706-3638'],
+ ];
+
+
+ $send_h_yn = $this->model->get_send_yn('H');//가장 마지막의 홍보확인서 전송여부
+ $send_t_yn = $this->model->get_send_yn('T'); //가장 마지막의 전화확인 전송여부
+ $send_d_yn = $this->model->get_send_yn('D');//가장 마지막의 등기부등본 전송여부
+ $send_n_yn = $this->model->get_send_yn('N'); //가장 마지막의 전화확인 전송여부
+ $send_j_yn = $this->model->get_send_yn('J');//가장 마지막의 전화확인 전송여부
+ $send_o_yn = $this->model->get_send_yn('O'); //가장 마지막의 모바일확인 V2 전송여부
+
+
+ foreach ($send_sms_member as $member):
+
+ $dest_phone = $member['tel'];
+ $dest_name = $member['name'];
+ $send_phone = '1600-5749';
+ $send_name = 'SYSTEM';
+ $subject = '매물 전송 확인 -' . date("Y-m-d H:i:s");
+
+ $msg_body = '[' . date("Y-m-d H:i:s") . ']' . $usr_nm . "(" . $client_ip . ")" . '매물 전송 확인' . PHP_EOL
+ . '홍보확인서:' . $send_h_yn . PHP_EOL
+ . '전화확인:' . $send_t_yn . PHP_EOL
+ . '등기부등본:' . $send_d_yn . PHP_EOL
+ . '신홍보확인서:' . $send_n_yn . PHP_EOL
+ . '공동중개매물:' . $send_j_yn . PHP_EOL
+ . '모바일확인 V2:' . $send_o_yn;
+
+
+ $msg_length = strlen(iconv('UTF-8', 'EUCKR', $msg_body));
+ $msg_type = 0;
+ if ($msg_length > 80 && $msg_type == 0) {
+ $msg_type = 5;
+ }
+
+ $memo = $msg_body;
+
+ // 문자 발송
+ // $this->smsModel->sendSms($dest_phone, $dest_name, $send_phone, $send_name, $subject, $msg_body, $msg_type, $memo);
+
+ endforeach;
+
+
+
+
+ return $this->response->setJSON([
+ 'code' => '0',
+ 'msg' => 'success'
+ ]);
+
+ } catch (\Exception $e) {
+ return $this->response->setJSON([
+ 'code' => '9',
+ 'msg' => $e->getMessage(),
+ ]);
+ }
+ }
+
+ // 전화확인완료 처리
+ public function saveSendComplete()
+ {
+ try {
+ $data = [
+ 'sdate' => $this->request->getPost('sdate'),
+ 'edate' => $this->request->getPost('edate'),
+ 'stat_cd' => 35,
+ ];
+
+ $lists = $this->model->getLists($data);
+
+ if (empty($lists)) {
+ return $this->response->setJSON([
+ 'status' => 'error',
+ 'msg' => '데이터 누락'
+ ]);
+ } else {
+ foreach ($lists as $row):
+ $usr_sq = session('usr_sq');
+ $stat_cd = 60;
+ $vr_sq = $row['vr_sq'];
+ $fax_sq = $row['fax_sq'];
+ $toDay = date('Y-m-d H:i:s');
+ $atcl_no = $row['atcl_no'];
+ $vrfc_type = $row['vrfc_type'];
+ $cpid = $row['cpid'];
+
+ // INSERT INTO v2_chg_stat
+ $result_query8 = $this->model->chgStat($vr_sq, '60', $usr_sq, $toDay);
+
+ // UPDATE v2_vrfc_req
+ $chgVrfc60 = $this->model->chgStatVrfc($vr_sq, '60'); //v2_vrfc_req INSERT
+
+ // UPDATE fax_imgs
+ $statFaxUp60 = $this->model->chgStatFax($vr_sq, '60'); //fax_imgs
+
+ //★검증완료일때
+ //0.불일치 이력이 있는지 확인
+ $cnt = $this->model->getFaxFailTimeForHistory($vr_sq);
+ if (empty($cnt)) {
+ //1.서류전화 들어온시간
+ $insert_tm = $this->model->getSaveTimeForHistory($vr_sq);
+ //2.서류/전화 확인일자
+ $tel_doc_conf_dt = $this->model->getConfTimeForHistory($vr_sq);
+ //3.검증시간
+ $finishTime = $this->model->get_60_ForHistory($vr_sq);
+ //4.해당 정보를 테이블에 넣는다
+ $this->model->insert_v2_time_required_Conf_Done($atcl_no, $cpid, $vrfc_type, $insert_tm['recv_time'], $tel_doc_conf_dt['insert_tm'], $finishTime['insert_tm']);
+ }
+
+ // 홍보확인서완료 등기부등본확인 안함 저장
+ $this->model->set_v2_st_daily(NULL, $cpid, 'D0205', '1', 'add');
+
+ endforeach;
+
+ echo json_encode(['error' => ['code' => '0', 'message' => $cnt . '건 - 처리되었습니다.']]);
+
+ }
+
+
+ return $this->response->setJSON([
+ 'code' => '0',
+ 'msg' => 'success'
+ ]);
+
+ } catch (\Exception $e) {
+ return $this->response->setJSON([
+ 'code' => '9',
+ 'msg' => $e->getMessage(),
+ ]);
+ }
+
+ }
+
+
+ // 엑셀 다운로드
+ public function excel()
+ {
+ try {
+
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ ];
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'data' => $datas,
+ ]);
+
+ } catch (\Exception $e) {
+ $e->getPrevious()->getTraceAsString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/results/M415.php b/app/Controllers/results/M415.php
new file mode 100644
index 0000000..fa151d3
--- /dev/null
+++ b/app/Controllers/results/M415.php
@@ -0,0 +1,60 @@
+model = new M415Model();
+ }
+
+ public function stats(): string
+ {
+ return view("pages/results/m415/stats", [
+ ]);
+ }
+
+
+ public function getResultList()
+ {
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ ];
+
+ $totalCount = $this->model->getTotalCount($data);
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'recordsTotal' => $totalCount,
+ 'recordsFiltered' => $totalCount,
+ 'data' => $datas,
+ ]);
+ }
+
+ // 엑셀 다운로드
+ public function excel()
+ {
+ try {
+
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ ];
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'data' => $datas,
+ ]);
+
+ } catch (\Exception $e) {
+ $e->getPrevious()->getTraceAsString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/results/M416.php b/app/Controllers/results/M416.php
new file mode 100644
index 0000000..1ba9ce3
--- /dev/null
+++ b/app/Controllers/results/M416.php
@@ -0,0 +1,76 @@
+model = new M416Model();
+ }
+
+ public function stats(): string
+ {
+
+ $bonbu = $this->model->getBonbuList();
+ $team = $this->model->getTeamList();
+ $sido = $this->model->getAreaList();
+
+ return view("pages/results/m416/stats", [
+ 'bonbu' => $bonbu,
+ 'team' => $team,
+ 'sido' => $sido,
+ ]);
+ }
+
+
+ public function getResultList()
+ {
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'bonbu' => $this->request->getGet('bonbu'),
+ 'dept_sq' => $this->request->getGet('dept_sq'),
+ 'srchType' => $this->request->getGet('srchType'),
+ 'srchTxt' => $this->request->getGet('srchTxt'),
+ ];
+
+ $totalCount = $this->model->getTotalCount($data);
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'recordsTotal' => $totalCount,
+ 'recordsFiltered' => $totalCount,
+ 'data' => $datas,
+ ]);
+ }
+
+ // 엑셀 다운로드
+ public function excel()
+ {
+ try {
+
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'bonbu' => $this->request->getGet('bonbu'),
+ 'dept_sq' => $this->request->getGet('dept_sq'),
+ 'srchType' => $this->request->getGet('srchType'),
+ 'srchTxt' => $this->request->getGet('srchTxt'),
+ ];
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'data' => $datas,
+ ]);
+
+ } catch (\Exception $e) {
+ $e->getPrevious()->getTraceAsString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/results/M417.php b/app/Controllers/results/M417.php
new file mode 100644
index 0000000..1c79567
--- /dev/null
+++ b/app/Controllers/results/M417.php
@@ -0,0 +1,69 @@
+model = new M417Model();
+ }
+
+ public function stats(): string
+ {
+ $department = $this->model->getDepart();
+
+ return view("pages/results/m417/stats", [
+ 'department' => $department,
+ ]);
+ }
+
+
+ public function getResultList()
+ {
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'dept_sq' => $this->request->getGet(index: 'dept_sq'),
+ ];
+
+ $totalCount = $this->model->getTotalCount($data);
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'recordsTotal' => $totalCount,
+ 'recordsFiltered' => $totalCount,
+ 'data' => $datas,
+ ]);
+
+ }
+
+
+ // 엑셀 다운로드
+ public function excel()
+ {
+ try {
+
+ $data = [
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'dept_sq' => $this->request->getGet(index: 'dept_sq'),
+ ];
+
+ $datas = $this->model->getResultList($data);
+
+ return $this->response->setJSON(body: [
+ 'data' => $datas,
+ ]);
+
+ } catch (\Exception $e) {
+ $e->getPrevious()->getTraceAsString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/results/Person.php b/app/Controllers/results/Person.php
new file mode 100644
index 0000000..bc0d4b1
--- /dev/null
+++ b/app/Controllers/results/Person.php
@@ -0,0 +1,87 @@
+personModel = new PersonModel();
+ }
+
+ public function index()
+ {
+ }
+
+ public function lists(): string
+ {
+ $bonbu = $this->personModel->getBonbuList();
+ $team = $this->personModel->getTeamList();
+ $sido = $this->personModel->getAreaList();
+
+ return view("pages/results/person/stats_p01", [
+ 'bonbu' => $bonbu,
+ 'team' => $team,
+ 'sido' => $sido,
+ ]);
+ }
+
+ public function getUserList()
+ {
+ $start = (int) $this->request->getGet('start') ?: 0;
+ $end = (int) $this->request->getGet('length') ?: 10;
+
+ $data = [
+ 'bonbu' => $this->request->getGet('bonbu'),
+ 'team' => $this->request->getGet('team'),
+ 'schDateGb' => $this->request->getGet('schDateGb'),
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'srchType' => $this->request->getGet('srchType'),
+ 'srchTxt' => $this->request->getGet('srchTxt'),
+ ];
+
+ $totalCount = $this->personModel->getTotalCount($data);
+
+
+ $datas = $this->personModel->getUserList($start, $end, $data);
+
+ return $this->response->setJSON(body: [
+ 'recordsTotal' => $totalCount,
+ 'recordsFiltered' => $totalCount,
+ 'data' => $datas,
+ ]);
+ }
+
+ // 엑셀 다운로드
+ public function excel()
+ {
+ try {
+
+ $data = [
+ 'bonbu' => $this->request->getGet('bonbu'),
+ 'team' => $this->request->getGet('team'),
+ 'schDateGb' => $this->request->getGet('schDateGb'),
+ 'sdate' => $this->request->getGet('sdate'),
+ 'edate' => $this->request->getGet('edate'),
+ 'srchType' => $this->request->getGet('srchType'),
+ 'srchTxt' => $this->request->getGet('srchTxt'),
+ ];
+
+ $datas = $this->personModel->getExcelUserList($data);
+
+ return $this->response->setJSON(body: [
+ 'data' => $datas,
+ ]);
+
+ } catch (\Exception $e) {
+ $e->getPrevious()->getTraceAsString();
+ }
+
+
+
+ }
+}
\ No newline at end of file
diff --git a/app/Controllers/results/Summary.php b/app/Controllers/results/Summary.php
new file mode 100644
index 0000000..c25708b
--- /dev/null
+++ b/app/Controllers/results/Summary.php
@@ -0,0 +1,99 @@
+summaryModel = new SummaryModel();
+ }
+
+ public function index()
+ {
+ $this->schDateGb = $this->request->getPost('schDateGb') ?? '1';
+ $this->sdate = $this->request->getPost('sdate') ?? date('Y-m-d', strtotime('first day of this month'));
+ $this->edate = $this->request->getPost('edate') ?? date('Y-m-d', strtotime('last day of this month'));
+ }
+
+
+ public function lists(): string
+ {
+
+ $this->schDateGb = $this->request->getPost('schDateGb') ?? '1';
+
+ $this->sdate = $this->request->getPost('sdate');
+ if (empty($this->sdate)) {
+ $this->sdate = date('Y-m-01'); // 이번달 1일
+ }
+
+ $this->edate = $this->request->getPost('edate');
+ if (empty($this->edate)) {
+ $this->edate = date('Y-m-t'); // 이번달 말일
+ }
+
+ $data = [
+ 'schDateGb' => $this->schDateGb,
+ 'sdate' => $this->sdate,
+ 'edate' => $this->edate
+ ];
+
+ $res = $this->summaryModel->st_s01($data);
+ $res2 = $this->summaryModel->st_s01_2($data);
+ $totalAmount = 0;
+
+ if (!empty($res)) {
+ foreach ($res as $row) {
+ foreach ($row as $key => $value) {
+ if (empty($value))
+ $value = 0;
+
+ switch ($key) {
+ case 'next_visit_cnt':
+ $res['cost'][$key] = 8000;
+ $res['amt'][$key] = $res['cost'][$key] * intval($value);
+ $totalAmount += $res['amt'][$key];
+ break;
+
+ case 'next_shoot_cnt':
+ $res['cost'][$key] = 10000;
+ $res['amt'][$key] = $res['cost'][$key] * intval($value);
+ $totalAmount += $res['amt'][$key];
+ break;
+
+ case 'delay_confirm_cnt':
+ case 'fail_confirm_cnt':
+ case 'confirm_cnt':
+ $res['cost'][$key] = 13000;
+ $res['amt'][$key] = $res['cost'][$key] * intval($value);
+ $totalAmount += $res['amt'][$key];
+ break;
+
+ default:
+ $res['cost'][$key] = 0;
+ $res['amt'][$key] = $res['cost'][$key] * intval($value);
+ $totalAmount += $res['amt'][$key];
+ break;
+ }
+ }
+ }
+ }
+
+ return view("pages/results/summary/stats_s01", [
+ 'schDateGb' => $this->schDateGb,
+ 'sdate' => $this->sdate,
+ 'edate' => $this->edate,
+ 'st_list' => $res,
+ 'st_agent' => $res2,
+ 'totalAmount' => $totalAmount,
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/app/Helpers/function_helper.php b/app/Helpers/function_helper.php
new file mode 100644
index 0000000..724a8d7
--- /dev/null
+++ b/app/Helpers/function_helper.php
@@ -0,0 +1,239 @@
+call_kiso_api->hscpMarketPriceInfo($hscp_no, $ptp_no);
+
+ if (isset($hscpMarketPriceInfo['error'])) { //결과값 확인
+ if ($hscpMarketPriceInfo['error']['code'] == 'VC027') {
+ $return = array();
+ } else {
+ $return = $hscpMarketPriceInfo['error'];
+ }
+ } else {
+ $limitH = 0;
+ $limitL = 0;
+ // 상한가, 하한가 체크 ( 상한가 * 2, 하한가 * 0.7) 이내의 범위에 가격이 있어야 함.
+ if ($trade_type == 'A1') {
+ // 매매
+ if (isset($hscpMarketPriceInfo['result']['deal_uplmt_prc'])) {
+ $limitH = $hscpMarketPriceInfo['result']['deal_uplmt_prc'];
+ }
+ if (isset($hscpMarketPriceInfo['result']['deal_lwlmt_prc'])) {
+ $limitL = $hscpMarketPriceInfo['result']['deal_lwlmt_prc'];
+ }
+ } elseif ($trade_type == 'B1') {
+ // 전세
+ if (isset($hscpMarketPriceInfo['result']['lease_uplmt_prc'])) {
+ $limitH = $hscpMarketPriceInfo['result']['lease_uplmt_prc'];
+ }
+ if (isset($hscpMarketPriceInfo['result']['lease_lwlmt_prc'])) {
+ $limitL = $hscpMarketPriceInfo['result']['lease_lwlmt_prc'];
+ }
+ }
+
+ if (!empty($limitH)) {
+ $limitH = $limitH * 2;
+
+ if ($limitH < $atcl_amt) {
+ $return = array('code' => 'ERC_02', 'message' => '최근 시세 하한가 70% ~ 상한가 200% 혹은 네이버 분양 서비스 내 평균 분양가격 하한가 60%(시세가 없는 분양권)를 벗어나는 가격입니다.');
+ }
+ }
+
+ if (!empty($limitL)) {
+ $limitL = $limitL * 0.7;
+
+ if ($limitL > $atcl_amt) {
+ $return = array('code' => 'ERC_03', 'message' => '최근 시세 하한가 70% ~ 상한가 200% 혹은 네이버 분양 서비스 내 평균 분양가격 하한가 60%(시세가 없는 분양권)를 벗어나는 가격입니다.');
+ }
+ }
+
+ }
+ }
+ return $return;
+ }
+}
+
+/**
+ * 공동중개 매물 stat_cd 이름 변경
+ */
+function getCdChangeNm($stat_cd)
+{
+ switch ($stat_cd) {
+ case "30":
+ return "공동중개 확인중";
+ break;
+ }
+}
+
+/**
+ * 클라이언트 아이피 체크
+ */
+function getRealClientIp()
+{
+ $ipaddress = '';
+
+ // HTTP_CLIENT_IP 확인 (일부 프록시에서 사용)
+ if (isset($_SERVER['HTTP_CLIENT_IP'])) {
+ $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
+ }
+ // HTTP_X_FORWARDED_FOR 확인 (프록시/로드 밸런서에서 가장 흔하게 사용)
+ else if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+ $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
+ // HTTP_X_FORWARDED_FOR는 쉼표로 구분된 여러 IP를 포함할 수 있음
+ // 보통 첫 번째 IP가 실제 클라이언트 IP
+ if (strpos($ipaddress, ',') !== false) {
+ $ips = explode(',', $ipaddress);
+ $ipaddress = trim($ips[0]);
+ }
+ }
+ // 다른 X-Forwarded 헤더들 확인 (덜 흔하지만 확인 필요)
+ else if (isset($_SERVER['HTTP_X_FORWARDED'])) {
+ $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
+ } else if (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
+ $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
+ } else if (isset($_SERVER['HTTP_FORWARDED'])) {
+ $ipaddress = $_SERVER['HTTP_FORWARDED'];
+ }
+ // X-Real-IP 확인 (Nginx와 같은 리버스 프록시에서 주로 사용)
+ else if (isset($_SERVER['X-Real-IP'])) {
+ $ipaddress = $_SERVER['X-Real-IP'];
+ }
+ // REMOTE_ADDR 확인 (가장 직접적인 연결에서 신뢰할 수 있음)
+ else if (isset($_SERVER['REMOTE_ADDR'])) {
+ $ipaddress = $_SERVER['REMOTE_ADDR'];
+ } else {
+ $ipaddress = '알수없음';
+ }
+
+ return $ipaddress;
+}
+
+function specailCharChange($str)
+{
+
+ if (!$str)
+ return '';
+
+ $str = str_replace(">", "〉", $str);
+ $str = str_replace("<", "〈", $str);
+
+ return $str;
+}
+/**
+ * csv 용
+ * @param mixed $str
+ * @return array|string
+ */
+function csvDataReplace($str)
+{
+ $str = str_replace("\r\n", "", $str);
+ $str = str_replace(",", " ", $str);
+ return $str;
+}
+
+if (!function_exists('str_contains')) {
+ function str_contains($haystack, $needle)
+ {
+ return '' === $needle || false !== strpos($haystack, $needle);
+ }
+}
+
+
+/**
+ * Checks if a file exists at a given URL by attempting to retrieve its HTTP headers.
+ * This function is specifically designed to work with NCLOUD Object Storage URLs.
+ * It includes a timeout to prevent indefinite blocking due to unresponsive external resources.
+ *
+ * @param string $url The relative URL of the file within NCLOUD Object Storage.
+ * @return bool True if the file exists (HTTP 2xx status), false otherwise or on error/timeout.
+ */
+function url_fileExist($url)
+{
+ // 134: 입력 URL이 비어있는지 확인. 비어있으면 즉시 false 반환.
+ if (empty($url)) {
+ return false;
+ }
+
+ // 135: NCLOUD_OBJECT_STORAGE_URL 상수를 사용하여 완전한 URL을 구성.
+ // 이 상수는 NCLOUD Object Storage의 기본 URL (예: 'https://kr.object.ncloudstorage.com/')을 포함해야 합니다.
+ $fullUrl = NCLOUD_OBJECT_STORAGE_URL . $url;
+
+ // 136: (빈 라인)
+
+ // 137: get_headers() 호출에 타임아웃을 적용하기 위한 스트림 컨텍스트 생성.
+ // 'http' 옵션에 'timeout'을 설정하여 PHP가 응답을 기다리는 최대 시간을 지정합니다.
+ // 'method'를 'HEAD'로 설정하여 파일 내용을 다운로드하지 않고 헤더만 요청하므로 효율적입니다.
+ // 'ssl' 옵션은 HTTPS 연결 시 SSL/TLS 인증서 검증 오류를 방지합니다.
+ // 운영 환경에서는 'verify_peer'와 'verify_peer_name'을 'true'로 설정하여 보안을 강화하는 것을 권장하며,
+ // 적절한 CA 인증서 번들 경로를 'cafile' 또는 'capath'로 지정해야 합니다.
+ $context = stream_context_create(array(
+ 'http' => array(
+ 'timeout' => 5, // 응답을 5초 동안 기다림 (이 값은 네트워크 환경과 외부 서비스 응답 시간에 따라 조정 가능)
+ 'method' => 'HEAD' // HEAD 요청은 파일 존재 여부 확인에 충분하며 대역폭을 절약합니다.
+ ),
+ 'ssl' => array(
+ 'verify_peer' => false, // 경고: 프로덕션 환경에서는 'true'로 설정하고 CA 인증서를 구성하여 보안을 강화해야 합니다.
+ 'verify_peer_name' => false, // 경고: 프로덕션 환경에서는 'true'로 설정하고 CA 인증서를 구성하여 보안을 강화해야 합니다.
+ )
+ ));
+
+ // get_headers() 함수를 호출하여 HTTP 헤더를 가져옵니다.
+ // @ suppression operator를 사용하여 네트워크 오류 등으로 인한 PHP 경고를 억제합니다.
+ // $context를 세 번째 인자로 전달하여 위에서 정의한 타임아웃 및 기타 옵션을 적용합니다.
+ $array = @get_headers($fullUrl, 0, $context);
+
+ // 헤더를 가져오지 못했거나 (예: 타임아웃, 네트워크 오류) false가 반환된 경우 처리.
+ // 이 경우 파일이 존재하지 않거나 접근할 수 없는 것으로 간주합니다.
+ if ($array === false) {
+ // 이 곳에 오류 로깅 또는 추가적인 오류 처리 로직을 추가할 수 있습니다.
+ // 예: error_log("Failed to get headers for URL: " . $fullUrl . " at " . __FILE__ . ":" . __LINE__);
+ return false;
+ }
+
+ // HTTP 응답의 첫 번째 줄(상태 코드)에서 숫자로 된 상태 코드를 추출합니다.
+ // 정규식을 사용하여 "HTTP/1.1 200 OK"와 같은 문자열에서 "200" 부분을 추출합니다.
+ if (preg_match('/^HTTP\/\d\.\d\s(\d{3})/', $array[0], $matches)) {
+ $statusCode = (int) $matches[1];
+ // HTTP 상태 코드가 2xx (성공) 범위인지 확인합니다.
+ // 200 OK, 201 Created, 202 Accepted 등 성공적인 응답을 모두 포함합니다.
+ return ($statusCode >= 200 && $statusCode < 300);
+ }
+
+ // 만약 위 preg_match가 실패하거나, 응답 형식이 예상과 다르면,
+ // 원래 로직대로 "200 OK" 문자열 포함 여부로 한 번 더 확인합니다.
+ // 이는 후방 호환성을 위한 것이며, 위의 상태 코드 확인 로직이 더 견고합니다.
+ return str_contains($array[0], "200 OK");
+}
+
+function realFilePath($url)
+{
+ if (empty($url))
+ return;
+
+ if (url_fileExist($url)) {
+ $return_url = NCLOUD_OBJECT_STORAGE_URL . $url;
+ } else {
+ $return_url = $url;
+ }
+
+ return $return_url;
+}
+
+function han($s)
+{
+ return reset(json_decode('{"s":"' . $s . '"}'));
+}
+// function to_han ($str) { return preg_replace('/(\\\u[a-f0-9]+)+/e','han("$0")',$str); }
+
diff --git a/app/Models/Home/HomeModel.php b/app/Models/Home/HomeModel.php
index a579043..d435816 100644
--- a/app/Models/Home/HomeModel.php
+++ b/app/Models/Home/HomeModel.php
@@ -148,4 +148,51 @@ class HomeModel extends Model
return $rows;
}
+ // 실적 조회
+ public function viewStatData($param)
+ {
+ $sql = "select a1.*
+ from(
+ SELECT
+ CASE a.insert_user WHEN 0 THEN 1 ELSE a.insert_user END insert_user,
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '38' THEN a.vr_sq ELSE NULL END ) phone_cnt ,
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND (a.stat_cd = '35' or a.stat_cd = '39') THEN a.vr_sq ELSE NULL END ) paper_cnt ,
+ COUNT( CASE WHEN (a.stat_cd = '77') THEN a.vr_sq ELSE NULL END ) + COUNT( DISTINCT CASE WHEN b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) AS reg_open_cnt,
+ COUNT( CASE WHEN (a.stat_cd = '85') THEN a.vr_sq ELSE NULL END ) + COUNT( DISTINCT CASE WHEN b.stat_cd = '60' AND a.stat_cd = '80' THEN a.vr_sq ELSE NULL END ) AS reg_tempOpen_cnt,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '86' or a.stat_cd = '88' THEN a.vr_sq ELSE NULL END ) AS real_top_R,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '87' or a.stat_cd = '89' THEN a.vr_sq ELSE NULL END ) AS real_top_G,
+ IFNULL((select count(distinct f1.vr_sq)
+ from v2_files f1
+ INNER JOIN v2_vrfc_req b ON b.vr_sq = f1.vr_sq and b.vrfc_type = 'M'
+ where f1.insert_tm between concat(DATE_FORMAT({$param['s_date']}, '%Y-%m-%d'),' 00:00:00') AND concat(DATE_FORMAT({$param['s_date']}, '%Y-%m-%d'),' 23:59:59')
+ and f1.file_type = '2'
+ and f1.use_yn = 'Y'
+ AND f1.insert_user = a.insert_user) ,0) AS mobile_cnt
+ FROM v2_chg_stat_stats a
+ INNER JOIN v2_vrfc_req b ON b.vr_sq = a.vr_sq
+ INNER JOIN v2_article_info c ON c.vr_sq = a.vr_sq
+ WHERE 1=1
+ and a.insert_user = {$param['usr_sq']}
+ and a.insert_tm between concat(DATE_FORMAT({$param['s_date']}, '%Y-%m-%d'),' 00:00:00') AND concat(DATE_FORMAT({$param['s_date']}, '%Y-%m-%d'),' 23:59:59')
+ ) a1 ";
+
+ $query = $this->db->query($sql);
+
+ return $query->getRowArray();
+ }
+
+ // 팩스 건수 조회
+ public function getHomeFaxCount()
+ {
+ $sql = "SELECT
+ date_format(now(), '%H') as base_time
+ ,(SELECT count(*) FROM uds_tiff where save_time >= concat(date_format(now(), '%Y-%m-%d %H'), ':00:00')) as enfax_count
+ ,(SELECT COUNT(*) FROM FC_RECV_TRAN where TR_RECVTIME >= concat(date_format(now(), '%Y%m%d%H'), '0000')) as lgfax_count ";
+
+ $query = $this->db->query($sql);
+
+
+ return $query->getRowArray();
+
+ }
}
\ No newline at end of file
diff --git a/app/Models/common/SmsModel.php b/app/Models/common/SmsModel.php
new file mode 100644
index 0000000..45343fa
--- /dev/null
+++ b/app/Models/common/SmsModel.php
@@ -0,0 +1,52 @@
+db->query($sql);
+ $row = $query->getRowArray();
+
+ $cmid = $row['cmid'] ?? null;
+ $currDate = $row['currDttm'] ?? Time::now()->toDateTimeString(); // fallback
+
+ // 2) 메시지 길이(EUC-KR) 체크
+ $msg_length = strlen(iconv('UTF-8', 'EUC-KR//IGNORE', $msg_body));
+ if ($msg_length > 80 && (int) $msg_type === 0) {
+ $msg_type = 5; // LMS
+ }
+
+ // 3) etc2 분기
+ $etc2 = ($memo === '로그인 인증') ? 'S13' : 'S12';
+
+ // 4) insert 데이터
+ $data = [
+ // 'cmid' => $cmid, // 필요하면 활성화
+ 'dest_phone' => $dest_phone,
+ 'dest_name' => $dest_name,
+ 'send_phone' => $send_phone,
+ 'send_name' => $send_name,
+ 'subject' => $subject,
+ 'msg_body' => $msg_body,
+ 'msg_type' => $msg_type,
+ 'request_time' => $currDate,
+ 'send_time' => $currDate,
+ 'etc2' => $etc2,
+ 'etc3' => $memo,
+ ];
+
+ // 5) Query Builder insert
+ $builder = $this->db->table('ums_data');
+ $res = $builder->insert($data);
+
+ // 6) 실행 쿼리 로그 (CI4)
+ log_message('debug', '161616 ' . $this->db->getLastQuery());
+ }
+}
\ No newline at end of file
diff --git a/app/Models/results/AssignModel.php b/app/Models/results/AssignModel.php
new file mode 100644
index 0000000..e5ef125
--- /dev/null
+++ b/app/Models/results/AssignModel.php
@@ -0,0 +1,312 @@
+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 getAreaList($sido = '', $gugun = '')
+ {
+
+ if (!empty($gugun)) {
+ $gugun = substr($gugun, '0', '5');
+
+ $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,5),'00000')" .
+ " WHERE a.region_cd LIKE concat(?, '%')" .
+ " AND a.region_cd NOT LIKE '%00000'" .
+ " AND a.region_cd LIKE '%00'" .
+ " AND a.use_yn = 'Y'" .
+ " ORDER BY a.region_nm ASC";
+
+ $query = $this->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 getTotalCount($data)
+ {
+ $sql = "SELECT
+ COUNT(*) AS cnt
+ FROM result a
+ INNER JOIN users b ON b.usr_sq = a.usr_sq
+ INNER JOIN receipt d ON d.rcpt_sq = a.rcpt_sq
+ INNER JOIN departments c ON c.dept_sq = a.dept_sq
+
+ WHERE 1=1 ";
+
+ if (!empty($data['bonbu'])) {
+ $sql .= "AND c.pdept_sq = {$data['bonbu']} ";
+ }
+
+ if (!empty($data['team'])) {
+ $sql .= "AND c.dept_sq = {$data['team']} ";
+ }
+
+ if (!empty($data['schDateGb'])) {
+ if ($data['schDateGb'] === "1") {
+
+ if (!empty($data['sdate'])) {
+ $sql .= "AND a.rsrv_date >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND a.rsrv_date <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+
+ } else if ($data['schDateGb'] === "2") {
+ if (!empty($data['sdate'])) {
+ $sql .= "AND d.rcpt_tm >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND d.rcpt_tm <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+ }
+ }
+
+ if (!empty($data['srchTxt'])) {
+ if ($data['srchType'] === "1") {
+ $sql .= "AND usr_id like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else if ($data['srchType'] === "2") {
+ $sql .= "AND usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else {
+ $sql .= "AND (
+ usr_id like CONCAT('%', '{$data['srchTxt']}', '%' )
+ OR usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' )
+ ) ";
+ }
+ }
+
+ $query = $this->db->query($sql);
+
+ return $query->getRow()->cnt;
+ }
+
+ public function getUserList($start, $end, $data)
+ {
+ $sql = "SELECT
+ b.usr_nm, b.usr_id, b.usr_sq, c.dept_sq, c.pdept_sq, c.depth
+ , SUM(CASE WHEN a.rsrv_tm_hour IN ('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24') THEN 1 ELSE 0 END) TODAY
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour = '09' THEN 1 ELSE 0 END) AM09
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour = '10' THEN 1 ELSE 0 END) AM10
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour = '11' THEN 1 ELSE 0 END) AM11
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour = '12' THEN 1 ELSE 0 END) AM12
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour IN ('00','01','02','03','04','05','06','07','08') THEN 1 ELSE 0 END) AMETC
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('01', '13') THEN 1 ELSE 0 END) PM01
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('02', '14') THEN 1 ELSE 0 END) PM02
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('03', '15') THEN 1 ELSE 0 END) PM03
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('04', '16') THEN 1 ELSE 0 END) PM04
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('05', '17') THEN 1 ELSE 0 END) PM05
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('06', '18') THEN 1 ELSE 0 END) PM06
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('07', '19') THEN 1 ELSE 0 END) PM07
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('00','08','09','10','11','12','20','21','22','23','24') THEN 1 ELSE 0 END) PMETC
+ FROM result a
+ INNER JOIN users b ON b.usr_sq = a.usr_sq
+ INNER JOIN receipt d ON d.rcpt_sq = a.rcpt_sq
+ INNER JOIN departments c ON c.dept_sq = a.dept_sq
+
+ WHERE 1=1 ";
+
+ if (!empty($data['bonbu'])) {
+ $sql .= "AND c.pdept_sq = {$data['bonbu']} ";
+ }
+
+ if (!empty($data['team'])) {
+ $sql .= "AND c.dept_sq = {$data['team']} ";
+ }
+
+ if (!empty($data['schDateGb'])) {
+ if ($data['schDateGb'] === "1") {
+
+ if (!empty($data['sdate'])) {
+ $sql .= "AND a.rsrv_date >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND a.rsrv_date <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+
+ } else if ($data['schDateGb'] === "2") {
+ if (!empty($data['sdate'])) {
+ $sql .= "AND d.rcpt_tm >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND d.rcpt_tm <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+ }
+ }
+
+ if (!empty($data['srchTxt'])) {
+ if ($data['srchType'] === "1") {
+ $sql .= "AND usr_id like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else if ($data['srchType'] === "2") {
+ $sql .= "AND usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else {
+ $sql .= "AND (
+ usr_id like CONCAT('%', '{$data['srchTxt']}', '%' )
+ OR usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' )
+ ) ";
+ }
+ }
+
+ $sql .= "GROUP BY b.usr_id, b.usr_nm ";
+
+ $sql .= "LIMIT {$start}, {$end}";
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+
+ // 엑셀 다운로드
+ public function getExcelUserList($data)
+ {
+ $sql = "SELECT
+ b.usr_id
+ , b.usr_nm
+ , SUM(CASE WHEN a.rsrv_tm_hour IN ('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24') THEN 1 ELSE 0 END) TODAY
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour = '09' THEN 1 ELSE 0 END) AM09
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour = '10' THEN 1 ELSE 0 END) AM10
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour = '11' THEN 1 ELSE 0 END) AM11
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour = '12' THEN 1 ELSE 0 END) AM12
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour IN ('00','01','02','03','04','05','06','07','08') THEN 1 ELSE 0 END) AMETC
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('01', '13') THEN 1 ELSE 0 END) PM01
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('02', '14') THEN 1 ELSE 0 END) PM02
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('03', '15') THEN 1 ELSE 0 END) PM03
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('04', '16') THEN 1 ELSE 0 END) PM04
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('05', '17') THEN 1 ELSE 0 END) PM05
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('06', '18') THEN 1 ELSE 0 END) PM06
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('07', '19') THEN 1 ELSE 0 END) PM07
+ , SUM(CASE WHEN a.rsrv_tm_ap = 'PM' AND a.rsrv_tm_hour IN ('00','08','09','10','11','12','20','21','22','23','24') THEN 1 ELSE 0 END) PMETC
+ FROM result a
+ INNER JOIN users b ON b.usr_sq = a.usr_sq
+ INNER JOIN receipt d ON d.rcpt_sq = a.rcpt_sq
+ INNER JOIN departments c ON c.dept_sq = a.dept_sq
+
+ WHERE 1=1 ";
+
+ if (!empty($data['bonbu'])) {
+ $sql .= "AND c.pdept_sq = {$data['bonbu']} ";
+ }
+
+ if (!empty($data['team'])) {
+ $sql .= "AND c.dept_sq = {$data['team']} ";
+ }
+
+ if (!empty($data['schDateGb'])) {
+ if ($data['schDateGb'] === "1") {
+
+ if (!empty($data['sdate'])) {
+ $sql .= "AND a.rsrv_date >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND a.rsrv_date <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+
+ } else if ($data['schDateGb'] === "2") {
+ if (!empty($data['sdate'])) {
+ $sql .= "AND d.rcpt_tm >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND d.rcpt_tm <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+ }
+ }
+
+ if (!empty($data['srchTxt'])) {
+ if ($data['srchType'] === "1") {
+ $sql .= "AND usr_id like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else if ($data['srchType'] === "2") {
+ $sql .= "AND usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else {
+ $sql .= "AND (
+ usr_id like CONCAT('%', '{$data['srchTxt']}', '%' )
+ OR usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' )
+ ) ";
+ }
+ }
+
+ $sql .= "GROUP BY b.usr_id, b.usr_nm ";
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+
+}
\ No newline at end of file
diff --git a/app/Models/results/DeptModel.php b/app/Models/results/DeptModel.php
new file mode 100644
index 0000000..a3d4ef3
--- /dev/null
+++ b/app/Models/results/DeptModel.php
@@ -0,0 +1,128 @@
+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 st_d01($data)
+ {
+ $sql_where2 = '';
+ if ($data['schDateGb'] == '2') {
+ $sql_where = " AND c.insert_tm between DATE('{$data['sdate']} 00:00:00') and DATE('{$data['edate']} 23:59:59')";
+ } else {
+ $sql_where = " AND c.rsrv_date between DATE('{$data['sdate']} 00:00:00') and DATE('{$data['edate']} 23:59:59') ";
+ }
+
+ $sql = "SELECT
+ a.dept_sq, CONCAT(SPACE(4*(a.depth-1)), a.dept_nm) dept_nm, a.depth, a.pdept_sq
+ , (SELECT COUNT(*) FROM region_codes d WHERE CONCAT(',',GROUP_CONCAT(DISTINCT b.dept_sq), ',') LIKE CONCAT('%,',d.dept_sq,',%') AND d.region_cd NOT LIKE '%00000') AS region_cnt
+ , COUNT(DISTINCT e.rcpt_sq) rcpt_cnt
+ , COUNT(DISTINCT CASE WHEN c.cancel_dt IS NOT NULL THEN CASE WHEN c.result_cd2 IN ('9010','9020') THEN c.rcpt_sq END END) resv_cancel_cnt
+ , COUNT(DISTINCT CASE WHEN c.assign_save_dt IS NOT NULL THEN c.rcpt_sq END) resv_assign_cnt
+ , COUNT(DISTINCT CASE WHEN c.cancel_dt IS NOT NULL THEN CASE WHEN c.result_cd2 = '9030' THEN c.rcpt_sq END END) prev_visit_cnt
+ , COUNT(DISTINCT CASE WHEN c.cancel_dt IS NOT NULL THEN CASE WHEN c.result_cd2 = '9040' THEN c.rcpt_sq END END) next_visit_cnt
+ , COUNT(DISTINCT CASE WHEN c.cancel_dt IS NOT NULL THEN CASE WHEN c.result_cd2 = '9045' THEN c.rcpt_sq END END) next_shoot_cnt
+ , COUNT(DISTINCT CASE WHEN c.photo_save_dt IS NOT NULL THEN c.rcpt_sq END) shoot_cnt
+ , COUNT(DISTINCT CASE WHEN c.result_cd1 = '70' THEN c.rcpt_sq END) delay_confirm_cnt
+ , COUNT(DISTINCT CASE WHEN c.result_cd2 = '9050' THEN c.rcpt_sq END) fail_confirm_cnt
+ , COUNT(DISTINCT CASE WHEN c.result_cd1 = '60' THEN c.rcpt_sq END) confirm_cnt
+ FROM departments a
+ LEFT JOIN departments b ON b.lft BETWEEN a.lft AND a.rgt
+ LEFT JOIN result c ON c.dept_sq = b.dept_sq {$sql_where}
+ LEFT JOIN receipt e ON e.rcpt_sq = c.rcpt_sq
+ WHERE a.pdept_sq != 0 AND a.use_yn = 'Y' ";
+
+ if (!empty($data['bonbu'])) {
+ $sql .= "AND b.pdept_sq = {$data['bonbu']} ";
+
+ if (!empty($data['dept_sq'])) {
+ $sql .= "AND a.dept_sq = {$data['dept_sq']} ";
+ }
+ }
+
+ $sql .= "GROUP BY a.dept_sq ORDER BY a.lft";
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+
+
+ public function getExcelList($data)
+ {
+ $sql_where2 = '';
+ if ($data['schDateGb'] == '2') {
+ $sql_where = " AND c.insert_tm between DATE('{$data['sdate']} 00:00:00') and DATE('{$data['edate']} 23:59:59')";
+ } else {
+ $sql_where = " AND c.rsrv_date between DATE('{$data['sdate']} 00:00:00') and DATE('{$data['edate']} 23:59:59') ";
+ }
+
+ $sql = "SELECT
+ CONCAT(SPACE(4*(a.depth-1)), a.dept_nm) AS '조직명'
+ , (SELECT COUNT(*) FROM region_codes d WHERE CONCAT(',',GROUP_CONCAT(DISTINCT b.dept_sq), ',') LIKE CONCAT('%,',d.dept_sq,',%') AND d.region_cd NOT LIKE '%00000') AS '관할지역'
+ , COUNT(DISTINCT e.rcpt_sq) '접수'
+ , COUNT(DISTINCT CASE WHEN c.cancel_dt IS NOT NULL THEN CASE WHEN c.result_cd2 IN ('9010','9020') THEN c.rcpt_sq END END) AS '예약취소'
+ , COUNT(DISTINCT CASE WHEN c.assign_save_dt IS NOT NULL THEN c.rcpt_sq END) AS '예약확인'
+ , COUNT(DISTINCT CASE WHEN c.cancel_dt IS NOT NULL THEN CASE WHEN c.result_cd2 = '9030' THEN c.rcpt_sq END END) AS '방문전취소'
+ , COUNT(DISTINCT CASE WHEN c.cancel_dt IS NOT NULL THEN CASE WHEN c.result_cd2 = '9040' THEN c.rcpt_sq END END) AS '방문후취소'
+ , COUNT(DISTINCT CASE WHEN c.cancel_dt IS NOT NULL THEN CASE WHEN c.result_cd2 = '9045' THEN c.rcpt_sq END END) AS '촬영후취소'
+ , COUNT(DISTINCT CASE WHEN c.photo_save_dt IS NOT NULL THEN c.rcpt_sq END) AS '촬영'
+ , COUNT(DISTINCT CASE WHEN c.result_cd1 = '70' THEN c.rcpt_sq END) AS '검수지연'
+ , COUNT(DISTINCT CASE WHEN c.result_cd2 = '9050' THEN c.rcpt_sq END) AS '검수실패'
+ , COUNT(DISTINCT CASE WHEN c.result_cd1 = '60' THEN c.rcpt_sq END) AS '검수완료'
+ FROM departments a
+ LEFT JOIN departments b ON b.lft BETWEEN a.lft AND a.rgt
+ LEFT JOIN result c ON c.dept_sq = b.dept_sq {$sql_where}
+ LEFT JOIN receipt e ON e.rcpt_sq = c.rcpt_sq
+ WHERE a.pdept_sq != 0 AND a.use_yn = 'Y' ";
+
+ if (!empty($data['bonbu'])) {
+ $sql .= "AND b.pdept_sq = {$data['bonbu']} ";
+
+ if (!empty($data['dept_sq'])) {
+ $sql .= "AND a.dept_sq = {$data['dept_sq']} ";
+ }
+ }
+
+ $sql .= "GROUP BY a.dept_sq ORDER BY a.lft";
+
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/Models/results/M409Model.php b/app/Models/results/M409Model.php
new file mode 100644
index 0000000..f512339
--- /dev/null
+++ b/app/Models/results/M409Model.php
@@ -0,0 +1,173 @@
+db->table('codes')
+ ->select('category, cd, cd_nm, use_yn')
+ ->whereIn('category', $data)
+ ->where('use_yn', 'Y')
+ ->orderBy('category', 'ASC')
+ ->orderBy('view_odr', 'ASC');
+
+ // if ($useYn !== null && $useYn !== '') {
+ // $builder->where('use_yn', $useYn);
+ // }
+
+ $rows = $builder->get()->getResultArray();
+
+ $codes = [];
+ foreach ($rows as $row) {
+ $codes[$row['category']][] = [
+ 'cd' => $row['cd'],
+ 'cd_nm' => $row['cd_nm'],
+ ];
+ }
+
+ return $codes;
+ }
+ public function getTotalCount($data)
+ {
+ $sql = "SELECT COUNT(*) AS cnt
+ FROM (
+ SELECT DATE_FORMAT(b.insert_tm, '%Y-%m-%d') AS ref_date
+ FROM v2_vrfc_req a
+ INNER JOIN v2_chg_stat b
+ ON b.vr_sq = a.vr_sq
+ AND b.insert_tm >= '{$data['sdate']} 00:00:00'
+ AND b.insert_tm <= '{$data['edate']} 23:59:59'
+ LEFT JOIN v2_confirm c
+ ON c.vr_sq = a.vr_sq AND c.vrfc_type = a.vrfc_type
+ LEFT JOIN v2_check_list d1
+ ON d1.vr_sq = a.vr_sq AND d1.vrfc_type = a.vrfc_type AND d1.type = CONCAT(d1.vrfc_type,'11')
+ LEFT JOIN v2_check_list d2
+ ON d2.vr_sq = a.vr_sq AND d2.vrfc_type = a.vrfc_type AND d2.type = CONCAT(d2.vrfc_type,'12')
+ LEFT JOIN v2_check_list d3
+ ON d3.vr_sq = a.vr_sq AND d3.vrfc_type = a.vrfc_type AND d3.type = CONCAT(d3.vrfc_type,'13')
+ LEFT JOIN v2_check_list d4
+ ON d4.vr_sq = a.vr_sq AND d4.vrfc_type = a.vrfc_type AND d4.type = CONCAT(d4.vrfc_type,'14')
+ LEFT JOIN v2_check_list e1
+ ON e1.vr_sq = a.vr_sq AND e1.vrfc_type = a.vrfc_type AND e1.type = '21'
+ LEFT JOIN v2_check_list e2
+ ON e2.vr_sq = a.vr_sq AND e2.vrfc_type = a.vrfc_type AND e2.type = '22'
+ WHERE 1=1 ";
+
+ if (!empty($data['vrfcreq_way'])) {
+ $sql .= "AND a.vrfc_type = '{$data['vrfcreq_way']}' ";
+ }
+
+ if (!empty($data['cp_id'])) {
+ $sql .= "AND a.cp_id = '{$data['cp_id']}' ";
+ }
+
+ $sql .= "GROUP BY DATE_FORMAT(b.insert_tm, '%Y-%m-%d')
+ ) AS t ";
+
+
+ $query = $this->db->query($sql);
+
+ return $query->getRow()->cnt;
+ }
+
+ public function getResultList($data)
+ {
+ $sql = "SELECT
+ DATE_FORMAT(b.insert_tm, '%Y-%m-%d') ref_date
+ , COUNT( DISTINCT CASE b.stat_cd WHEN '10' THEN a.vr_sq ELSE NULL END ) rcpt_cnt
+ , COUNT( DISTINCT CASE a.stat_cd WHEN '10' THEN a.vr_sq ELSE NULL END ) notassign_cnt
+ , COUNT( DISTINCT CASE a.stat_cd WHEN '10' THEN NULL ELSE a.vr_sq END ) assign_cnt
+ , COUNT( DISTINCT CASE WHEN a.vrfc_type = 'D' AND b.stat_cd = '35' THEN a.vr_sq ELSE NULL END) paper_cnt
+ , COUNT( DISTINCT CASE WHEN a.vrfc_type = 'T' AND b.stat_cd = '35' THEN a.vr_sq ELSE NULL END) phone_cnt
+ , COUNT( DISTINCT CASE b.stat_cd WHEN '19' THEN a.vr_sq ELSE NULL END) cancel_cnt
+ , COUNT( DISTINCT CASE ifnull(d1.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) priv_cnt
+ , COUNT( DISTINCT CASE ifnull(d2.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) info_cnt
+ , COUNT( DISTINCT CASE ifnull(d3.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) price_cnt
+ , COUNT( DISTINCT CASE ifnull(d4.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) owner_cnt
+ , COUNT( DISTINCT CASE b.stat_cd WHEN '39' THEN a.vr_sq ELSE NULL END) fail_cnt
+ , COUNT( DISTINCT CASE WHEN a.try_cnt > 0 THEN a.vr_sq ELSE NULL END) retry_cnt
+ , COUNT( DISTINCT CASE ifnull(e1.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) reg_info_cnt
+ , COUNT( DISTINCT CASE ifnull(e2.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) reg_owner_cnt
+ , COUNT( DISTINCT CASE b.stat_cd WHEN '60' THEN a.vr_sq ELSE NULL END) complete_cnt
+ , COUNT( DISTINCT CASE WHEN a.rgbk_confirm = '1' AND b.stat_cd = '60' THEN a.vr_sq ELSE NULL END) rgbk_cnt
+ FROM v2_vrfc_req a
+ INNER JOIN v2_chg_stat b ON b.vr_sq = a.vr_sq AND b.insert_tm BETWEEN CONCAT('{$data['sdate']} 00:00:00') AND CONCAT('{$data['edate']} 23:59:59')
+ LEFT JOIN v2_confirm c ON c.vr_sq = a.vr_sq AND c.vrfc_type = a.vrfc_type
+ LEFT JOIN v2_check_list d1 ON d1.vr_sq = a.vr_sq AND d1.vrfc_type = a.vrfc_type AND d1.type=CONCAT(d1.vrfc_type,'11')
+ LEFT JOIN v2_check_list d2 ON d2.vr_sq = a.vr_sq AND d2.vrfc_type = a.vrfc_type AND d2.type=CONCAT(d2.vrfc_type,'12')
+ LEFT JOIN v2_check_list d3 ON d3.vr_sq = a.vr_sq AND d3.vrfc_type = a.vrfc_type AND d3.type=CONCAT(d3.vrfc_type,'13')
+ LEFT JOIN v2_check_list d4 ON d4.vr_sq = a.vr_sq AND d4.vrfc_type = a.vrfc_type AND d4.type=CONCAT(d4.vrfc_type,'14')
+ LEFT JOIN v2_check_list e1 ON e1.vr_sq = a.vr_sq AND e1.vrfc_type = a.vrfc_type AND e1.type='21'
+ LEFT JOIN v2_check_list e2 ON e2.vr_sq = a.vr_sq AND e2.vrfc_type = a.vrfc_type AND e2.type='22'
+ WHERE 1=1 ";
+
+ if (!empty($data['vrfcreq_way'])) {
+ $sql .= "AND a.vrfc_type = '{$data['vrfcreq_way']}' ";
+ }
+
+ if (!empty($data['cp_id'])) {
+ $sql .= "AND a.cp_id = '{$data['cp_id']}' ";
+ }
+
+ $sql .= "GROUP BY DATE_FORMAT(b.insert_tm, '%Y-%m-%d') ";
+
+ // $sql .= "LIMIT {$start}, {$end} ";
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+
+ // 엑셀 다운로드
+ public function getExcelList($data)
+ {
+ $sql = "SELECT
+ DATE_FORMAT(b.insert_tm, '%Y-%m-%d') ref_date
+ , COUNT( DISTINCT CASE b.stat_cd WHEN '10' THEN a.vr_sq ELSE NULL END ) rcpt_cnt
+ , COUNT( DISTINCT CASE a.stat_cd WHEN '10' THEN a.vr_sq ELSE NULL END ) notassign_cnt
+ , COUNT( DISTINCT CASE a.stat_cd WHEN '10' THEN NULL ELSE a.vr_sq END ) assign_cnt
+ , COUNT( DISTINCT CASE WHEN a.vrfc_type = 'D' AND b.stat_cd = '35' THEN a.vr_sq ELSE NULL END) paper_cnt
+ , COUNT( DISTINCT CASE WHEN a.vrfc_type = 'T' AND b.stat_cd = '35' THEN a.vr_sq ELSE NULL END) phone_cnt
+ , COUNT( DISTINCT CASE b.stat_cd WHEN '19' THEN a.vr_sq ELSE NULL END) cancel_cnt
+ , COUNT( DISTINCT CASE ifnull(d1.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) priv_cnt
+ , COUNT( DISTINCT CASE ifnull(d2.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) info_cnt
+ , COUNT( DISTINCT CASE ifnull(d3.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) price_cnt
+ , COUNT( DISTINCT CASE ifnull(d4.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) owner_cnt
+ , COUNT( DISTINCT CASE b.stat_cd WHEN '39' THEN a.vr_sq ELSE NULL END) fail_cnt
+ , COUNT( DISTINCT CASE WHEN a.try_cnt > 0 THEN a.vr_sq ELSE NULL END) retry_cnt
+ , COUNT( DISTINCT CASE ifnull(e1.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) reg_info_cnt
+ , COUNT( DISTINCT CASE ifnull(e2.code, '10000') WHEN '10000' THEN NULL ELSE a.vr_sq END) reg_owner_cnt
+ , COUNT( DISTINCT CASE b.stat_cd WHEN '60' THEN a.vr_sq ELSE NULL END) complete_cnt
+ , COUNT( DISTINCT CASE WHEN a.rgbk_confirm = '1' AND b.stat_cd = '60' THEN a.vr_sq ELSE NULL END) rgbk_cnt
+ FROM v2_vrfc_req a
+ INNER JOIN v2_chg_stat b ON b.vr_sq = a.vr_sq AND b.insert_tm BETWEEN CONCAT('{$data['sdate']} 00:00:00') AND CONCAT('{$data['edate']} 23:59:59')
+ LEFT JOIN v2_confirm c ON c.vr_sq = a.vr_sq AND c.vrfc_type = a.vrfc_type
+ LEFT JOIN v2_check_list d1 ON d1.vr_sq = a.vr_sq AND d1.vrfc_type = a.vrfc_type AND d1.type=CONCAT(d1.vrfc_type,'11')
+ LEFT JOIN v2_check_list d2 ON d2.vr_sq = a.vr_sq AND d2.vrfc_type = a.vrfc_type AND d2.type=CONCAT(d2.vrfc_type,'12')
+ LEFT JOIN v2_check_list d3 ON d3.vr_sq = a.vr_sq AND d3.vrfc_type = a.vrfc_type AND d3.type=CONCAT(d3.vrfc_type,'13')
+ LEFT JOIN v2_check_list d4 ON d4.vr_sq = a.vr_sq AND d4.vrfc_type = a.vrfc_type AND d4.type=CONCAT(d4.vrfc_type,'14')
+ LEFT JOIN v2_check_list e1 ON e1.vr_sq = a.vr_sq AND e1.vrfc_type = a.vrfc_type AND e1.type='21'
+ LEFT JOIN v2_check_list e2 ON e2.vr_sq = a.vr_sq AND e2.vrfc_type = a.vrfc_type AND e2.type='22'
+ WHERE 1=1 ";
+
+ if (!empty($data['vrfcreq_way'])) {
+ $sql .= "AND a.vrfc_type = '{$data['vrfcreq_way']}' ";
+ }
+
+ if (!empty($data['cp_id'])) {
+ $sql .= "AND a.cp_id = '{$data['cp_id']}' ";
+ }
+
+ $sql .= "GROUP BY DATE_FORMAT(b.insert_tm, '%Y-%m-%d') ";
+
+ // $sql .= "LIMIT {$start}, {$end} ";
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+}
\ No newline at end of file
diff --git a/app/Models/results/M410Model.php b/app/Models/results/M410Model.php
new file mode 100644
index 0000000..f382030
--- /dev/null
+++ b/app/Models/results/M410Model.php
@@ -0,0 +1,191 @@
+db->table('codes')
+ ->select('category, cd, cd_nm, use_yn')
+ ->whereIn('category', $data)
+ ->where('use_yn', 'Y')
+ ->orderBy('category', 'ASC')
+ ->orderBy('view_odr', 'ASC');
+
+ // if ($useYn !== null && $useYn !== '') {
+ // $builder->where('use_yn', $useYn);
+ // }
+
+ $rows = $builder->get()->getResultArray();
+
+ $codes = [];
+ foreach ($rows as $row) {
+ $codes[$row['category']][] = [
+ 'cd' => $row['cd'],
+ 'cd_nm' => $row['cd_nm'],
+ ];
+ }
+
+ return $codes;
+ }
+
+ public function getDepart()
+ {
+ $sql = "SELECT * from departments " .
+ "WHERE pdept_sq = 3 " .
+ "ORDER BY dept_nm";
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+
+ public function getTotalCount($data)
+ {
+ $sql = "SELECT COUNT(*) AS cnt FROM ( ";
+ $sql .= "SELECT
+ a.usr_sq, a.usr_id, a.usr_nm, IFNULL(c.mobile_upload, 0)mobile_upload , b.*
+ FROM users AS a
+ LEFT JOIN (
+ SELECT CASE a.insert_user WHEN 0 THEN 1 ELSE a.insert_user END insert_user,
+ COUNT(*) total_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '10' THEN a.vr_sq ELSE NULL END ) receipt_cnt
+ , COUNT( DISTINCT CASE WHEN b.stat_cd = '10' THEN a.vr_sq ELSE NULL END ) notassign_cnt
+ , COUNT( DISTINCT CASE WHEN b.stat_cd = '10' THEN NULL ELSE a.vr_sq END ) assign_cnt
+ , COUNT( DISTINCT CASE WHEN b.stat_cd = '19' THEN a.vr_sq ELSE NULL END ) cancel_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '30' THEN a.vr_sq ELSE NULL END ) phone_checking_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '30' THEN a.vr_sq ELSE NULL END ) paper_checking_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '35' THEN a.vr_sq ELSE NULL END ) phone_complete_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '35' THEN a.vr_sq ELSE NULL END ) paper_complete_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '38' THEN a.vr_sq ELSE NULL END ) phone_all_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '39' THEN a.vr_sq ELSE NULL END ) phone_fail_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '39' THEN a.vr_sq ELSE NULL END ) paper_fail_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '40' THEN a.vr_sq ELSE NULL END ) reg_checking_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '45' THEN a.vr_sq ELSE NULL END ) reg_complete_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '70' THEN a.vr_sq ELSE NULL END ) reg_none
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '86' THEN a.vr_sq ELSE NULL END ) real_top_RS
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '88' THEN a.vr_sq ELSE NULL END ) real_top_RF
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '87' THEN a.vr_sq ELSE NULL END ) real_top_GS
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '89' THEN a.vr_sq ELSE NULL END ) real_top_GF
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '49' THEN a.vr_sq ELSE NULL END ) reg_fail_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '60' THEN a.vr_sq ELSE NULL END ) complete_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '69' THEN a.vr_sq ELSE NULL END ) fail_cnt
+ , COUNT( CASE WHEN (a.stat_cd = '85') THEN a.vr_sq ELSE NULL END ) reg_fail_tempOpen
+ , COUNT( CASE WHEN (a.stat_cd = '77') THEN a.vr_sq ELSE NULL END ) reg_fail_Open
+ , COUNT( DISTINCT CASE WHEN b.stat_cd = '60' AND a.stat_cd = '80' THEN a.vr_sq ELSE NULL END ) same_reg_tempOpen
+ , COUNT( DISTINCT CASE WHEN b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) same_reg_open
+ , COUNT( distinct c.vr_sq ) AS final_fail_cnt
+ FROM v2_chg_stat_stats a
+ INNER JOIN v2_vrfc_req b ON b.vr_sq = a.vr_sq ";
+
+ if (!empty($data['vrfcreq_way'])) {
+ $sql .= "AND b.vrfc_type = '{$data['vrfcreq_way']}' ";
+ } else {
+ $sql .= "AND b.vrfc_type <> 'N' ";
+ }
+
+
+ $sql .= " LEFT OUTER JOIN v2_article_fail c ON c.vr_sq = a.vr_sq
+
+ WHERE 1=1
+
+ AND a.insert_tm BETWEEN concat('{$data['sdate']} 00:00:00') AND concat('{$data['edate']} 23:59:59')
+
+ GROUP BY CASE a.insert_user WHEN 0 THEN 1 ELSE a.insert_user END
+ ) AS b on b.insert_user = a.usr_sq
+
+ LEFT JOIN (
+ select f1.insert_user, count(distinct f1.vr_sq) mobile_upload
+ from v2_files f1
+ INNER JOIN v2_vrfc_req b ON b.vr_sq = f1.vr_sq and b.vrfc_type = 'M'
+ where f1.insert_tm between concat('2025-12-16 00:00:00') AND concat('2025-12-16 23:59:59')
+ and f1.file_type = '2'
+ and f1.use_yn = 'Y' group by f1.insert_user
+ ) AS c on c.insert_user = a.usr_sq
+ WHERE (b.insert_user is not null or c.insert_user is not null) ";
+
+ if (!empty($data['dept_sq'])) {
+ $sql .= "AND a.dept_sq = {$data['dept_sq']} ";
+ }
+
+ $sql .= ") AS t ";
+
+ $query = $this->db->query($sql);
+
+ return $query->getRow()->cnt;
+ }
+
+ public function getResultList($data)
+ {
+ $sql = "SELECT
+ a.usr_sq, a.usr_id, a.usr_nm, IFNULL(c.mobile_upload, 0) mobile_upload, b.*
+ FROM users AS a
+ LEFT JOIN (
+ SELECT CASE a.insert_user WHEN 0 THEN 1 ELSE a.insert_user END insert_user,
+ COUNT(*) total_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '10' THEN a.vr_sq ELSE NULL END ) receipt_cnt
+ , COUNT( DISTINCT CASE WHEN b.stat_cd = '10' THEN a.vr_sq ELSE NULL END ) notassign_cnt
+ , COUNT( DISTINCT CASE WHEN b.stat_cd = '10' THEN NULL ELSE a.vr_sq END ) assign_cnt
+ , COUNT( DISTINCT CASE WHEN b.stat_cd = '19' THEN a.vr_sq ELSE NULL END ) cancel_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '30' THEN a.vr_sq ELSE NULL END ) phone_checking_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '30' THEN a.vr_sq ELSE NULL END ) paper_checking_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '35' THEN a.vr_sq ELSE NULL END ) phone_complete_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '35' THEN a.vr_sq ELSE NULL END ) paper_complete_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '38' THEN a.vr_sq ELSE NULL END ) phone_all_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '39' THEN a.vr_sq ELSE NULL END ) phone_fail_cnt
+ , COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '39' THEN a.vr_sq ELSE NULL END ) paper_fail_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '40' THEN a.vr_sq ELSE NULL END ) reg_checking_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '45' THEN a.vr_sq ELSE NULL END ) reg_complete_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '70' THEN a.vr_sq ELSE NULL END ) reg_none
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '86' THEN a.vr_sq ELSE NULL END ) real_top_RS
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '88' THEN a.vr_sq ELSE NULL END ) real_top_RF
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '87' THEN a.vr_sq ELSE NULL END ) real_top_GS
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '89' THEN a.vr_sq ELSE NULL END ) real_top_GF
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '49' THEN a.vr_sq ELSE NULL END ) reg_fail_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '60' THEN a.vr_sq ELSE NULL END ) complete_cnt
+ , COUNT( DISTINCT CASE WHEN a.stat_cd = '69' THEN a.vr_sq ELSE NULL END ) fail_cnt
+ , COUNT( CASE WHEN (a.stat_cd = '85') THEN a.vr_sq ELSE NULL END ) reg_fail_tempOpen
+ , COUNT( CASE WHEN (a.stat_cd = '77') THEN a.vr_sq ELSE NULL END ) reg_fail_Open
+ , COUNT( DISTINCT CASE WHEN b.stat_cd = '60' AND a.stat_cd = '80' THEN a.vr_sq ELSE NULL END ) same_reg_tempOpen
+ , COUNT( DISTINCT CASE WHEN b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) same_reg_open
+ , COUNT( distinct c.vr_sq ) AS final_fail_cnt
+ FROM v2_chg_stat_stats a
+ INNER JOIN v2_vrfc_req b ON b.vr_sq = a.vr_sq ";
+
+ if (!empty($data['vrfcreq_way'])) {
+ $sql .= "AND b.vrfc_type = '{$data['vrfcreq_way']}' ";
+ } else {
+ $sql .= "AND b.vrfc_type <> 'N' ";
+ }
+
+
+ $sql .= " LEFT OUTER JOIN v2_article_fail c ON c.vr_sq = a.vr_sq
+
+ WHERE 1=1
+
+ AND a.insert_tm BETWEEN concat('{$data['sdate']} 00:00:00') AND concat('{$data['edate']} 23:59:59')
+
+ GROUP BY CASE a.insert_user WHEN 0 THEN 1 ELSE a.insert_user END
+ ) AS b on b.insert_user = a.usr_sq
+
+ LEFT JOIN (
+ select f1.insert_user, count(distinct f1.vr_sq) mobile_upload
+ from v2_files f1
+ INNER JOIN v2_vrfc_req b ON b.vr_sq = f1.vr_sq and b.vrfc_type = 'M'
+ where f1.insert_tm between concat('2025-12-16 00:00:00') AND concat('2025-12-16 23:59:59')
+ and f1.file_type = '2'
+ and f1.use_yn = 'Y' group by f1.insert_user
+ ) AS c on c.insert_user = a.usr_sq
+ WHERE (b.insert_user is not null or c.insert_user is not null) ";
+
+ if (!empty($data['dept_sq'])) {
+ $sql .= "AND a.dept_sq = {$data['dept_sq']} ";
+ }
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+}
\ No newline at end of file
diff --git a/app/Models/results/M411Model.php b/app/Models/results/M411Model.php
new file mode 100644
index 0000000..43e0c68
--- /dev/null
+++ b/app/Models/results/M411Model.php
@@ -0,0 +1,182 @@
+db->query($sql);
+
+ return $query->getRow()->cnt;
+ }
+
+ public function getResultList($data)
+ {
+ $sql = "SELECT
+ cpid,
+ SUM(t_cnt) t_cnt,
+ SUM(hong1_cnt) hong1_cnt,
+ SUM(hong2_cnt) hong2_cnt,
+ SUM(m_cnt) m_cnt,
+ SUM(v2_cnt) v2_cnt,
+ sum(total) total,
+
+ SUM(a) t_o,
+ SUM(b) t_x,
+ SUM(c) t_n,
+ SUM(d) t_e,
+
+ SUM(e) d_o,
+ SUM(f) d_x,
+
+ (SUM(a)+SUM(e)) dt_o,
+ (SUM(b)+SUM(f)) dt_x,
+
+ SUM(e)+SUM(f) d_tot,
+ SUM(a)+SUM(b)+SUM(c)+SUM(d) t_tot,
+
+ SUM(g) dt_tot,
+
+ SUM(h) r_o,
+ SUM(i) r_x,
+ SUM(h) r_e,
+ SUM(k) done,
+ SUM(l) r_tot,
+
+ SUM(m) s_1,
+ round((SUM(m) / total),2) s_2
+ FROM (
+ SELECT a.cpid,
+ COUNT(*) total
+ ,SUM(CASE vrfc_type_sub WHEN 'D1' THEN 1 ELSE 0 END) hong1_cnt
+ ,SUM(CASE vrfc_type_sub WHEN 'D2' THEN 1 ELSE 0 END) hong2_cnt
+ ,SUM(CASE vrfc_type_sub WHEN 'M1' THEN 1 ELSE 0 END) m_cnt
+ ,SUM(CASE vrfc_type_sub WHEN 'O1' THEN 1 ELSE 0 END) v2_cnt
+ ,SUM(CASE vrfc_type_sub WHEN 'T1' THEN 1 ELSE 0 END) t_cnt
+ , 0 a,0 b,0 c,0 d,0 e,0 f,0 g,0 h,0 i,0 j,0 k, 0 l, 0 m
+ FROM v2_article_info a
+ INNER JOIN v2_vrfc_req b ON a.vr_sq = b.vr_sq
+ WHERE b.insert_tm BETWEEN CONCAT('{$data['sdate']} 00:00:00') AND CONCAT('{$data['edate']} 23:59:59')
+ GROUP BY a.cpid
+
+ UNION ALL
+
+ SELECT cpid
+ ,0 ,0 ,0 ,0 ,0 ,0
+ ,t_o,t_x,t_n,t_e
+ ,d_o,d_x
+ ,(t_o+t_x+t_n+t_e+d_o+d_x) AS dt_tot
+ ,r_o,r_x,r_e
+ ,(d_d+d_t) AS done
+ ,(r_o+r_x+r_e) AS r_tot
+ ,(r_o+r_e+d_d+d_t) AS s_1
+ FROM (
+ SELECT cpid,
+ SUM(CASE gbn_cd WHEN 'T0201' THEN cnt ELSE 0 END) t_o,
+ SUM(CASE gbn_cd WHEN 'T0202' THEN cnt ELSE 0 END) t_x,
+ SUM(CASE gbn_cd WHEN 'T0203' THEN cnt ELSE 0 END) t_n,
+ SUM(CASE gbn_cd WHEN 'T0204' THEN cnt ELSE 0 END) t_e,
+ SUM(CASE gbn_cd WHEN 'D0201' THEN cnt ELSE 0 END) d_o,
+ SUM(CASE gbn_cd WHEN 'D0202' THEN cnt ELSE 0 END) d_x,
+ SUM(CASE gbn_cd WHEN 'R0101' THEN cnt ELSE 0 END) r_o,
+ SUM(CASE gbn_cd WHEN 'R0102' THEN cnt ELSE 0 END) r_x,
+ SUM(CASE gbn_cd WHEN 'R0103' THEN cnt ELSE 0 END) r_e,
+ SUM(CASE gbn_cd WHEN 'D0205' THEN cnt ELSE 0 END) d_d,
+ SUM(CASE gbn_cd WHEN 'T0206' THEN cnt ELSE 0 END) d_t
+ FROM v2_st_daily
+ WHERE st_date BETWEEN CONCAT('{$data['sdate']} 00:00:00') AND CONCAT('{$data['edate']} 23:59:59')
+ GROUP BY cpid
+ )A
+ ) table1
+ GROUP BY cpid ";
+
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+}
\ No newline at end of file
diff --git a/app/Models/results/M412Model.php b/app/Models/results/M412Model.php
new file mode 100644
index 0000000..67a531f
--- /dev/null
+++ b/app/Models/results/M412Model.php
@@ -0,0 +1,473 @@
+db->query($sql, [$data]);
+ $row = $query->getRow();
+
+ return $row ? $row->stop_yn : 'N';
+ }
+ public function getTotalCount($data)
+ {
+ $sql = "SELECT COUNT(*) AS cnt FROM (
+ SELECT * FROM v2_st_daily a
+ WHERE a.st_date BETWEEN DATE('{$data['sdate']}') AND DATE('{$data['edate']}')
+ GROUP BY a.st_date, a.cpid
+ ) AS t ";
+
+ $query = $this->db->query($sql);
+
+ return $query->getRow()->cnt;
+ }
+
+ public function getResultList($data)
+ {
+ $sql = "SELECT
+ st_date,
+ cpid,
+ T0101, T0102, T0103,
+ T0201, T0202, T0203, T0204,
+ (T0201 + T0202 + T0203 + T0204) AS T0205,
+ T0301, T0302,
+ (T0101 + T0102 + T0103 - (T0201 + T0202 + T0203 + T0204)) AS T0303,
+ D0101, D0102, D0103,
+ D0201, D0202, D0203,
+ (D0201 + D0202 + D0203) AS D0204,
+ D0301, D0302,
+ (D0101 + D0102 + D0103 - (D0201 + D0202 + D0203)) AS D0303,
+ R0101, R0102, R0103,
+ (R0101 + R0102 + R0103) AS R0104,
+ R0105,
+ (T0101 + T0102 + T0103 + D0101 + D0102 + D0103) AS Z0101,
+ (T0201 + T0202 + T0203 + T0204 + D0201 + D0202 + D0203) AS Z0102,
+ (T0206 + D0205 + R0101 + R0103) AS Z0103,
+ (T0101 + T0102 + T0103 + D0101 + D0102 + D0103 - T0206 - D0205 - R0101 - R0103) AS Z0104,
+ A0101
+ FROM (
+ SELECT
+ a.st_date,
+ a.cpid,
+ SUM(CASE a.gbn_cd WHEN 'T0101' THEN COALESCE(a.cnt,0) ELSE 0 END) AS T0101,
+ SUM(CASE a.gbn_cd WHEN 'T0102' THEN COALESCE(a.cnt,0) ELSE 0 END) AS T0102,
+ SUM(CASE a.gbn_cd WHEN 'T0103' THEN COALESCE(a.cnt,0) ELSE 0 END) AS T0103,
+ SUM(CASE a.gbn_cd WHEN 'T0201' THEN COALESCE(a.cnt,0) ELSE 0 END) AS T0201,
+ SUM(CASE a.gbn_cd WHEN 'T0202' THEN COALESCE(a.cnt,0) ELSE 0 END) AS T0202,
+ SUM(CASE a.gbn_cd WHEN 'T0203' THEN COALESCE(a.cnt,0) ELSE 0 END) AS T0203,
+ SUM(CASE a.gbn_cd WHEN 'T0204' THEN COALESCE(a.cnt,0) ELSE 0 END) AS T0204,
+ SUM(CASE a.gbn_cd WHEN 'T0206' THEN COALESCE(a.cnt,0) ELSE 0 END) AS T0206,
+ SUM(CASE a.gbn_cd WHEN 'T0301' THEN COALESCE(a.cnt,0) ELSE 0 END) AS T0301,
+ SUM(CASE a.gbn_cd WHEN 'T0302' THEN COALESCE(a.cnt,0) ELSE 0 END) AS T0302,
+ SUM(CASE a.gbn_cd WHEN 'D0101' THEN COALESCE(a.cnt,0) ELSE 0 END) AS D0101,
+ SUM(CASE a.gbn_cd WHEN 'D0102' THEN COALESCE(a.cnt,0) ELSE 0 END) AS D0102,
+ SUM(CASE a.gbn_cd WHEN 'D0103' THEN COALESCE(a.cnt,0) ELSE 0 END) AS D0103,
+ SUM(CASE a.gbn_cd WHEN 'D0201' THEN COALESCE(a.cnt,0) ELSE 0 END) AS D0201,
+ SUM(CASE a.gbn_cd WHEN 'D0202' THEN COALESCE(a.cnt,0) ELSE 0 END) AS D0202,
+ SUM(CASE a.gbn_cd WHEN 'D0203' THEN COALESCE(a.cnt,0) ELSE 0 END) AS D0203,
+ SUM(CASE a.gbn_cd WHEN 'D0205' THEN COALESCE(a.cnt,0) ELSE 0 END) AS D0205,
+ SUM(CASE a.gbn_cd WHEN 'D0301' THEN COALESCE(a.cnt,0) ELSE 0 END) AS D0301,
+ SUM(CASE a.gbn_cd WHEN 'D0302' THEN COALESCE(a.cnt,0) ELSE 0 END) AS D0302,
+ SUM(CASE a.gbn_cd WHEN 'R0101' THEN COALESCE(a.cnt,0) ELSE 0 END) AS R0101,
+ SUM(CASE a.gbn_cd WHEN 'R0102' THEN COALESCE(a.cnt,0) ELSE 0 END) AS R0102,
+ SUM(CASE a.gbn_cd WHEN 'R0103' THEN COALESCE(a.cnt,0) ELSE 0 END) AS R0103,
+ SUM(CASE a.gbn_cd WHEN 'R0105' THEN COALESCE(a.cnt,0) ELSE 0 END) AS R0105,
+ SUM(CASE a.gbn_cd WHEN 'A0101' THEN COALESCE(a.cnt,0) ELSE 0 END) AS A0101
+ FROM v2_st_daily a
+ WHERE a.st_date BETWEEN DATE('{$data['sdate']}') AND DATE('{$data['edate']}')
+ GROUP BY a.st_date, a.cpid
+ ) AS V_T ";
+
+ $query = $this->db->query($sql);
+
+
+ return $query->getResultArray();
+ }
+
+ // 전송 타입 저장
+ public function saveSendType($data)
+ {
+ $sql = "INSERT INTO v2_stop_api_chg_stat(`type`, insert_date, stop_yn, usr_sq) ";
+ $sql .= "VALUES (?, NOW(), ?, ?) ";
+
+ $this->db->query($sql, [
+ $data['type'],
+ $data['yn'],
+ $data['usr_sq'],
+ ]);
+
+
+ if ($this->db->transStatus() === false) {
+ return [
+ 'success' => false,
+ 'msg' => '저장실패',
+ ];
+ }
+
+ // 성공
+ return [
+ 'success' => true,
+ ];
+ }
+
+
+ public function getLists($data)
+ {
+ $sql = "SELECT
+ a.vr_sq,
+ j.usr_nm as reg_charger,
+ a.atcl_no,
+ a.cpid,
+ a.cp_atcl_id,
+ a.rlet_type_cd,
+ a.address1,
+ a.sise,
+ a.rdate,
+ a.seller_tel_no,
+ a.seller_nm,
+ a.realtor_nm,
+ a.realtor_tel_no,
+ a.rlet_type_cd,
+ a.charger,
+ b.insert_tm,
+ b.stat_cd,
+ c.bild_nm,
+ b.vrfc_type,
+ c.rm_no,
+ c.`floor`,
+ c.address_code,
+ c.address2,
+ m.address2a,
+ m.address2b,
+ c.address3,
+ c.trade_type,
+ c.deal_amt,
+ c.wrrnt_amt,
+ c.lease_amt,
+ c.isale_amt,
+ c.prem_amt,
+ c.sply_spc,
+ c.excls_spc,
+ c.tot_spc,
+ c.grnd_spc,
+ c.bldg_spc,
+ c.hscp_no,
+ c.ptp_no,
+ d.insert_tm as update_res_tm,
+ greatest(ifnull(d45.insert_tm, ''), ifnull(d49.insert_tm, '')) as rgbk_check_tm,
+ e.insert_tm as result_tm,
+ f.region_nm,
+ g.cd_nm as pre_stat,
+ h.cd_nm as vrfc_type,
+ i.usr_nm,
+ d2.insert_tm as stat_39_tm,
+ a.vrfc_type_sub,
+ a.reference_file_url_yn,
+ k.`comment` AS reg_conf_yn_info_2,
+ l.`comment` AS reg_conf_yn_info_3,
+ m.corp_own
+ FROM
+ v2_article_info a
+ JOIN v2_vrfc_req b ON a.vr_sq = b.vr_sq
+ JOIN v2_modify_info c ON a.vr_sq = c.vr_sq
+ LEFT JOIN v2_article_info_etc m ON a.vr_sq = m.vr_sq
+ LEFT JOIN region_codes f ON a.address_code = f.region_cd
+ LEFT JOIN v2_chg_stat d ON a.vr_sq = d.vr_sq AND d.stat_cd = '35'
+ LEFT JOIN v2_chg_stat d45 ON d45.vr_sq = a.vr_sq AND d45.stat_cd = '45'
+ LEFT JOIN v2_chg_stat d49 ON d49.vr_sq = a.vr_sq AND d49.stat_cd = '49'
+ LEFT JOIN v2_chg_stat e ON a.vr_sq = e.vr_sq AND e.stat_cd = '60'
+ LEFT JOIN codes g ON b.stat_cd = g.cd AND g.category = 'STEP_VERIFICATION'
+ LEFT JOIN codes h ON b.vrfc_type = h.cd AND h.category = 'VRFCREQ_WAY'
+ LEFT JOIN users i ON a.charger = i.usr_id
+ LEFT JOIN users j ON a.reg_charger = j.usr_id
+ LEFT JOIN v2_check_list k ON a.vr_sq = k.vr_sq AND k.`type` = '21'
+ LEFT JOIN v2_check_list l ON a.vr_sq = l.vr_sq AND l.type = '22'
+ LEFT JOIN v2_chg_stat d2 ON d2.vr_sq = a.vr_sq AND d2.stat_cd = '39'
+
+ WHERE
+ 1=1 ";
+
+ if (!empty($data['stat_cd'])) {
+ $sql .= "AND b.stat_cd = {$data['stat_cd']} ";
+ }
+
+ if (!empty($data['sdate'])) {
+ $sql .= "AND b.insert_tm >= '{$data['sdate']} 00:00:00' ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND b.insert_tm <= '{$data['edate']} 00:00:00' ";
+ }
+
+
+ $sql .= "ORDER BY b.vr_sq desc , b.insert_tm desc ";
+
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+
+ public function chgStat($vr_sq, $stat_cd, $usr_sq, $insert_tm)
+ {
+ $sql = "INSERT INTO v2_chg_stat (vr_sq, stat_cd, insert_user, insert_tm) ";
+ $sql .= "VALUES (?, ?, ?, ?) ";
+ $sql .= "ON DUPLICATE KEY UPDATE ";
+ $sql .= "UPDATE vr_sq=VALUES(vr_sq), stat_cd=VALUES(stat_cd), insert_user=VALUES(insert_user), insert_tm=VALUES(insert_tm) ";
+
+ $this->db->query($sql, [$vr_sq, $stat_cd, $usr_sq, $insert_tm]);
+
+ if ($this->db->transStatus() === false) {
+ return [
+ 'success' => false,
+ 'msg' => 'v2_chg_stat 저장실패',
+ ];
+ }
+
+ // 성공
+ return [
+ 'success' => true,
+ ];
+ }
+
+ public function chgStatVrfc($vr_sq, $stat_cd)
+ {
+ $sql = "UPDATE v2_vrfc_req SET ";
+ $sql .= "stat_cd = ? ";
+ $sql .= "WHERE vr_sq = ? ";
+
+ $this->db->query($sql, [$stat_cd, $vr_sq]);
+
+ if ($this->db->transStatus() === false) {
+ return [
+ 'success' => false,
+ 'msg' => 'v2_vrfc_req 저장실패',
+ ];
+ }
+
+ // 성공
+ return [
+ 'success' => true,
+ ];
+ }
+
+ public function chgStatFax($vr_sq, $stat_cd)
+ {
+ $sql = "UPDATE fax_imgs SET ";
+ $sql .= "stat_cd = ? ";
+ $sql .= "WHERE vr_sq = ? ";
+
+ $this->db->query($sql, [$stat_cd, $vr_sq]);
+
+ if ($this->db->transStatus() === false) {
+ return [
+ 'success' => false,
+ 'msg' => 'fax_imgs 저장실패',
+ ];
+ }
+
+ // 성공
+ return [
+ 'success' => true,
+ ];
+ }
+
+ // 서류/전화 불일치 시간
+ public function getFaxFailTimeForHistory($vr_sq)
+ {
+ $sql = "select insert_tm from v2_chg_history" .
+ " where vr_sq = ?" .
+ " and stat_cd = '39'" .
+ " and chg_type= 'C9'" .
+ " order by seq desc" .
+ " limit 1 ";
+
+ $query = $this->db->query($sql, [$vr_sq]);
+
+ return $query->getRowArray();
+ }
+
+ // 서류/전화 인입시간
+ public function getSaveTimeForHistory($vr_sq)
+ {
+ $sql = "select insert_tm from v2_chg_history" .
+ " where vr_sq = ?" .
+ " and stat_cd = '30'" .
+ " and chg_type= 'C9'" .
+ " order by seq desc" .
+ " limit 1 ";
+
+ $query = $this->db->query($sql, [$vr_sq]);
+
+ return $query->getRowArray();
+ }
+
+ // 서류/전화 확인완료 시간 = 등기부등본 확인중 시간
+ public function getConfTimeForHistory($vr_sq)
+ {
+ $sql = "select insert_tm from v2_chg_history" .
+ " where vr_sq = ?" .
+ " and stat_cd = '35'" .
+ " and chg_type= 'C9'" .
+ " order by seq desc" .
+ " limit 1 ";
+
+ $query = $this->db->query($sql, [$vr_sq]);
+
+ return $query->getRowArray();
+ }
+
+ // 검증완료 시간
+ public function get_60_ForHistory($vr_sq)
+ {
+ $sql = "select insert_tm from v2_chg_history" .
+ " where vr_sq = ?" .
+ " and stat_cd = '60'" .
+ " and chg_type= 'C9'" .
+ " order by seq desc" .
+ " limit 1 ";
+
+ $query = $this->db->query($sql, [$vr_sq]);
+
+ return $query->getRowArray();
+ }
+
+
+ public function insert_v2_time_required_Conf_Done($atcl_no, $cpid, $vrfc_type, $insert_tm, $tel_doc_conf_dt, $finishTime)
+ {
+ if (substr($insert_tm, 0, 10) == substr($tel_doc_conf_dt, 0, 10)) {
+ switch ($vrfc_type) {
+ case 'D':
+ if (('12:00:00' < substr($insert_tm, -8)) && (substr($insert_tm, -8) < '13:00:00')) {//접수시간이 12~13시 사이면 13시로 해준다
+ if (substr($tel_doc_conf_dt, -8) > '13:00:00') { //검증완료가 13시 '이후'에 끝나면 접수시간을 13시로 변경해준다
+ $insert_tm = date("Y-m-d", time()) . " 13:00:00";
+ }
+ } else if (
+ (substr($insert_tm, -8) > '17:30:00' || substr($insert_tm, -8) < '08:59:59') && //접수와 확인완료시간이 모두 17:30:00 ~ 09:00:00 사이가 아니면
+ (substr($tel_doc_conf_dt, -8) < '17:30:00' || substr($tel_doc_conf_dt, -8) < '08:59:59')
+ ) {
+ $insert_tm = date("Y-m-d", time()) . " 09:00:00";
+ }
+ ;
+ break;
+
+ case 'T':
+ if (('13:00:00' < substr($insert_tm, -8)) && (substr($insert_tm, -8) < '14:00:00')) {//접수시간이 13~14시 사이면 14시로 해준다
+ if (substr($tel_doc_conf_dt, -8) > '14:00:00') { //검증완료가 14시 '이후'에 끝나면 접수시간을 14시로 변경해준다
+ $insert_tm = date("Y-m-d", time()) . " 14:00:00";
+ }
+ } else if (
+ (substr($insert_tm, -8) > '17:30:00' || substr($insert_tm, -8) < '08:59:59') &&
+ (substr($tel_doc_conf_dt, -8) < '17:30:00' || substr($tel_doc_conf_dt, -8) < '08:59:59')
+ ) { //접수와 확인완료시간이 모두 17:30:00 ~ 09:00:00 사이면
+ $insert_tm = date("Y-m-d", time()) . " 09:30:00";
+ }
+ ;
+ break;
+ }
+ } else {
+ if ($vrfc_type == 'D') { //홍보
+ if (substr($insert_tm, -8) > '17:30:00' || substr($insert_tm, -8) < '08:59:59') {
+ $insert_tm = date("Y-m-d", time()) . " 09:00:00";
+ }
+ } else { //전화
+ if (substr($insert_tm, -8) > '17:30:00' || substr($insert_tm, -8) < '08:59:59') {
+ $insert_tm = date("Y-m-d", time()) . " 09:30:00";
+ }
+ }
+ }
+ $stan_date = substr($insert_tm, 0, 10);
+
+
+ $sql = "INSERT INTO v2_time_required(stan_date, atcl_no, cpid, vrfc_type, insert_tm, tel_doc_conf_dt,conf_required_tm,tot_required_tm)" .
+ " VALUES(?, ?, ?, ?, ?, ?, TIMEDIFF(?,?), TIMEDIFF(?,?)) " .
+ " ON DUPLICATE KEY UPDATE insert_tm = VALUES(insert_tm), tel_doc_conf_dt=VALUES(tel_doc_conf_dt),conf_required_tm = VALUES(conf_required_tm),tot_required_tm = VALUES(tot_required_tm) ";
+
+ $this->db->query($sql, [
+ $stan_date,
+ $atcl_no,
+ $cpid,
+ $vrfc_type,
+ $insert_tm,
+ $tel_doc_conf_dt,
+ $tel_doc_conf_dt,
+ $insert_tm,
+ $tel_doc_conf_dt,
+ $insert_tm,
+ ]);
+
+ if ($this->db->transStatus() === false) {
+ return [
+ 'success' => false,
+ 'msg' => 'v2_time_required 저장실패',
+ ];
+ }
+
+ // 성공
+ return [
+ 'success' => true,
+ ];
+ }
+
+ /**
+ * 일자별 통계데이터에 값 집어 넣기...
+ * 반환값 없음.
+ * @param date $sd_date 날짜 값이 없을경우 현재날짜로 입력됨.
+ * @param string $cpid CPID
+ * @param string $gbn_cd 코드값 (category='STATISTICS_DAILY3')
+ * @param int $cnt 더할 숫자..
+ * @param string $cnt_type 숫자를 더할것인지.. 아니변 변경할것인지.
+ */
+ public function set_v2_st_daily($st_date, $cpid, $gbn_cd, $cnt, $cnt_type = 'add')
+ {
+ if (empty($cnt))
+ $cnt = '0';
+
+ $sql_dup = "";
+ switch (strtolower($cnt_type)) {
+ case 'add':
+ $sql_dup = "on duplicate key update cnt = cnt + " . $cnt;
+ break;
+
+ case 'change':
+ $sql_dup = "on duplicate key update cnt = values(cnt)";
+ break;
+ }
+ if (empty($st_date)) {
+ $sql = "insert into v2_st_daily (st_date, cpid, gbn_cd, cnt) values (now(), ?, ?, ?)" . $sql_dup;
+ $data =
+ [
+ $cpid,
+ $gbn_cd,
+ $cnt
+ ]
+ ;
+ } else {
+ $sql = "insert into v2_st_daily (st_date, cpid, gbn_cd, cnt) values (?, ?, ?, ?)" . $sql_dup;
+ $data = [
+ $st_date,
+ $cpid,
+ $gbn_cd,
+ $cnt
+ ];
+ }
+
+ $this->db->query($sql, $data);
+
+ $return['error_number'] = $this->db->_error_number();
+ $return['error_message'] = $this->db->_error_message();
+
+ return $return;
+ }
+}
\ No newline at end of file
diff --git a/app/Models/results/M415Model.php b/app/Models/results/M415Model.php
new file mode 100644
index 0000000..2c9b481
--- /dev/null
+++ b/app/Models/results/M415Model.php
@@ -0,0 +1,158 @@
+db->query($sql);
+
+ return $query->getRow()->cnt;
+ }
+
+ public function getResultList($data)
+ {
+ $sql = "SELECT
+ stan_date,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'M' THEN doc ELSE NULL END)),1,8) m_doc,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'M' THEN cert ELSE NULL END)),1,8) m_cert,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'M' THEN tot ELSE NULL END)),1,8) m_tot,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'T' THEN doc ELSE NULL END)),1,8) t_doc,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'T' THEN cert ELSE NULL END)),1,8) t_cert,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'T' THEN tot ELSE NULL END)),1,8) t_tot,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'D' THEN doc ELSE NULL END)),1,8) d_doc,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'D' THEN cert ELSE NULL END)),1,8) d_cert,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'D' THEN tot ELSE NULL END)),1,8) d_tot,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'N' THEN doc ELSE NULL END)),1,8) n_doc,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'N' THEN cert ELSE NULL END)),1,8) n_cert,
+ SUBSTR(SEC_TO_TIME(AVG(CASE vrfc_type WHEN 'N' THEN tot ELSE NULL END)),1,8) n_tot
+ FROM (
+ SELECT
+ stan_date,
+ 'M' vrfc_type,
+ AVG((TIME_TO_SEC(conf_required_tm))) AS doc,
+ AVG((TIME_TO_SEC(cert_required_tm))) AS cert,
+ AVG((TIME_TO_SEC(tot_required_tm))) AS tot
+ FROM v2_time_required
+ WHERE stan_date BETWEEN '{$data['sdate']}' AND '{$data['edate']}'
+ AND vrfc_type IN ('M','O')
+ AND tot_required_tm IS NOT NULL
+ GROUP BY stan_date
+
+ UNION ALL
+
+ SELECT
+ stan_date,
+ 'T' vrfc_type,
+ AVG((TIME_TO_SEC(conf_required_tm))) AS doc,
+ AVG((TIME_TO_SEC(cert_required_tm))) AS cert,
+ AVG((TIME_TO_SEC(tot_required_tm))) AS tot
+ FROM v2_time_required
+ WHERE stan_date BETWEEN '{$data['sdate']}' AND '{$data['edate']}'
+ AND vrfc_type = 'T'
+ AND tot_required_tm IS NOT NULL
+ GROUP BY stan_date
+
+ UNION ALL
+
+ SELECT
+ stan_date,
+ 'D' vrfc_type,
+ AVG((TIME_TO_SEC(conf_required_tm))) AS doc,
+ AVG((TIME_TO_SEC(cert_required_tm))) AS cert,
+ AVG((TIME_TO_SEC(tot_required_tm))) AS tot
+ FROM v2_time_required
+ WHERE stan_date BETWEEN '{$data['sdate']}' AND '{$data['edate']}'
+ AND vrfc_type = 'D'
+ AND tot_required_tm IS NOT NULL
+ GROUP BY stan_date
+
+ UNION ALL
+
+ SELECT
+ stan_date,
+ 'N' vrfc_type,
+ AVG((TIME_TO_SEC(conf_required_tm))) AS doc,
+ AVG((TIME_TO_SEC(cert_required_tm))) AS cert,
+ AVG((TIME_TO_SEC(tot_required_tm))) AS tot
+ FROM v2_time_required
+ WHERE stan_date BETWEEN '{$data['sdate']}' AND '{$data['edate']}'
+ AND vrfc_type = 'N'
+ AND tot_required_tm IS NOT NULL
+ GROUP BY stan_date
+
+
+ ) summary
+ GROUP BY stan_date ";
+
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+}
\ No newline at end of file
diff --git a/app/Models/results/M416Model.php b/app/Models/results/M416Model.php
new file mode 100644
index 0000000..da62dd4
--- /dev/null
+++ b/app/Models/results/M416Model.php
@@ -0,0 +1,190 @@
+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 getAreaList($sido = '', $gugun = '')
+ {
+
+ if (!empty($gugun)) {
+ $gugun = substr($gugun, '0', '5');
+
+ $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,5),'00000')" .
+ " WHERE a.region_cd LIKE concat(?, '%')" .
+ " AND a.region_cd NOT LIKE '%00000'" .
+ " AND a.region_cd LIKE '%00'" .
+ " AND a.use_yn = 'Y'" .
+ " ORDER BY a.region_nm ASC";
+
+ $query = $this->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 getTotalCount($data)
+ {
+ $sql = "SELECT COUNT(*) AS cnt FROM (
+ SELECT
+ a.usr_id
+ FROM indi_distance_daily a
+ INNER JOIN users b ON a.usr_id = b.usr_id INNER JOIN departments c ON b.dept_sq = c.dept_sq
+ WHERE a.`date` BETWEEN '{$data['sdate']}' AND '{$data['edate']}' ";
+
+ if (!empty($data['bonbu'])) {
+ $sql .= "AND c.pdept_sq = {$data['bonbu']} ";
+ }
+
+ if (!empty($data['dept_sq'])) {
+ $sql .= "AND b.dept_sq = {$data['bonbu']} ";
+ }
+
+ if (!empty($data['srchTxt'])) {
+ if ($data['srchType'] == "1") {
+ $sql .= "AND a.usr_id LIKE CONCAT('%', '{$data['srchTxt']}', '%') ";
+ } else if ($data['srchType'] == "1") {
+ $sql .= "AND a.usr_nm LIKE CONCAT('%', '{$data['srchTxt']}', '%') ";
+ } else {
+ $sql .= "AND (
+ a.usr_id LIKE CONCAT('%', '{$data['srchTxt']}', '%')
+ OR a.usr_nm LIKE CONCAT('%', '{$data['srchTxt']}', '%')
+ ) ";
+ }
+ }
+
+
+ $sql .= "GROUP BY a.usr_id, a.usr_nm ) AS t";
+
+ $query = $this->db->query($sql);
+
+ return $query->getRow()->cnt;
+ }
+
+
+ public function getResultList($data)
+ {
+ $lastDay = (int) date('t', strtotime($data['edate']));
+
+ $sql = "SELECT
+ a.usr_id, a.usr_nm
+ , SUM(a.shoot_cnt) shoot_cnt ";
+
+ if ($lastDay > 0) {
+ for ($i = 1; $i <= $lastDay; $i++) {
+ $day2 = sprintf('%02d', $i);
+ $sql .= ", SUM(CASE WHEN DAY(a.date) = {$i} THEN distance ELSE 0 END) AS d{$day2}";
+ }
+ }
+
+ $sql .= ", ROUND(SUM(a.distance),1) tot_distance ";
+
+ $sql .= "
+ FROM indi_distance_daily a
+ INNER JOIN users b ON a.usr_id = b.usr_id INNER JOIN departments c ON b.dept_sq = c.dept_sq
+ WHERE
+ a.`date` BETWEEN '{$data['sdate']}' AND '{$data['edate']}' ";
+
+ if (!empty($data['bonbu'])) {
+ $sql .= "AND c.pdept_sq = {$data['bonbu']} ";
+ }
+
+ if (!empty($data['dept_sq'])) {
+ $sql .= "AND b.dept_sq = {$data['bonbu']} ";
+ }
+
+ if (!empty($data['srchTxt'])) {
+ if ($data['srchType'] == "1") {
+ $sql .= "AND a.usr_id LIKE CONCAT('%', '{$data['srchTxt']}', '%') ";
+ } else if ($data['srchType'] == "1") {
+ $sql .= "AND a.usr_nm LIKE CONCAT('%', '{$data['srchTxt']}', '%') ";
+ } else {
+ $sql .= "AND (
+ a.usr_id LIKE CONCAT('%', '{$data['srchTxt']}', '%')
+ OR a.usr_nm LIKE CONCAT('%', '{$data['srchTxt']}', '%')
+ ) ";
+ }
+ }
+
+ $sql .= "GROUP BY a.usr_id, a.usr_nm ";
+
+
+ $query = $this->db->query($sql);
+
+
+ return $query->getResultArray();
+ }
+}
\ No newline at end of file
diff --git a/app/Models/results/M417Model.php b/app/Models/results/M417Model.php
new file mode 100644
index 0000000..017e2bf
--- /dev/null
+++ b/app/Models/results/M417Model.php
@@ -0,0 +1,189 @@
+db->query($sql);
+
+ return $query->getResultArray();
+ }
+
+ public function getTotalCount($data)
+ {
+ $sql = "SELECT
+ COUNT(*) AS cnt
+ FROM
+ users a
+ left join (
+ SELECT
+ CASE
+ a.insert_user WHEN 0 THEN 1
+ ELSE a.insert_user
+ END insert_user,
+ COUNT(*) total_cnt ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '10' THEN a.vr_sq ELSE NULL END ) receipt_cnt ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '10' THEN a.vr_sq ELSE NULL END ) notassign_cnt ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '10' THEN NULL ELSE a.vr_sq END ) assign_cnt ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '19' THEN a.vr_sq ELSE NULL END ) cancel_cnt ,
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '30' THEN a.vr_sq ELSE NULL END ) phone_checking_cnt ,
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '30' THEN a.vr_sq ELSE NULL END ) paper_checking_cnt ,
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '35' THEN a.vr_sq ELSE NULL END ) phone_complete_cnt , -- 전화확인 완료
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '35' THEN a.vr_sq ELSE NULL END ) paper_complete_cnt ,
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '38' THEN a.vr_sq ELSE NULL END ) phone_all_cnt , -- 전화확인 전체
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '39' THEN a.vr_sq ELSE NULL END ) phone_fail_cnt , -- 전화확인 실패
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '39' THEN a.vr_sq ELSE NULL END ) paper_fail_cnt ,
+ COUNT( DISTINCT case when (b.certRegister IS NOT NULL AND b.stat_cd = '60' AND a.stat_cd = '76') then a.vr_sq ELSE NULL END ) cert_same_reg_open ,
+ COUNT( DISTINCT case when (b.certRegister IS NOT NULL AND a.stat_cd = '77') then a.vr_sq ELSE NULL END ) cert_reg_fail_open,
+ COUNT( DISTINCT case when (b.referenceFileUrl IS NOT NULL AND b.stat_cd = '60' AND a.stat_cd = '76') then a.vr_sq ELSE NULL END ) reference_same_reg_open ,
+ COUNT( DISTINCT case when (b.referenceFileUrl IS NOT NULL AND a.stat_cd = '77') then a.vr_sq ELSE NULL END ) reference_reg_fail_open ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '40' THEN a.vr_sq ELSE NULL END ) reg_checking_cnt ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '45' THEN a.vr_sq ELSE NULL END ) reg_complete_cnt ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '70' THEN a.vr_sq ELSE NULL END ) reg_none , -- 등기부 등본 없음
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '86' THEN a.vr_sq ELSE NULL END ) real_top_RS ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '88' THEN a.vr_sq ELSE NULL END ) real_top_RF ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '87' THEN a.vr_sq ELSE NULL END ) real_top_GS ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '89' THEN a.vr_sq ELSE NULL END ) real_top_GF ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '49' THEN a.vr_sq ELSE NULL END ) reg_fail_cnt ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '60' THEN a.vr_sq ELSE NULL END ) complete_cnt ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '60' THEN a.vr_sq ELSE NULL END ) complete_cnt1,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '69' THEN a.vr_sq ELSE NULL END ) fail_cnt ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '69' THEN a.vr_sq ELSE NULL END ) fail_cnt1 ,
+ COUNT( CASE WHEN (a.stat_cd = '85') THEN a.vr_sq ELSE NULL END ) reg_fail_tempOpen ,
+ COUNT( CASE WHEN (a.stat_cd = '77') THEN a.vr_sq ELSE NULL END ) reg_fail_Open ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '60' AND a.stat_cd = '80' THEN a.vr_sq ELSE NULL END ) same_reg_tempOpen ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) same_reg_open,
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '0' and a.stat_cd = '77' THEN a.vr_sq ELSE NULL END ) as referin_s0, -- 첨부파일 불일치 개인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '1' and a.stat_cd = '77' THEN a.vr_sq ELSE NULL END ) as referin_s1, -- 첨부파일 불일치 위임장
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '2' and a.stat_cd = '77' THEN a.vr_sq ELSE NULL END ) as referin_s2, -- 첨부파일 불일치 법인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '3' and a.stat_cd = '77' THEN a.vr_sq ELSE NULL END ) as referin_s3, -- 첨부파일 불일치 외국인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '0' and b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_n0, -- 첨부파일 일치 개인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '1' and b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_n1, -- 첨부파일 일치 위임장
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '2' and b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_n2, -- 첨부파일 일치 법인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '3' and b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_n3, -- 첨부파일 일치 외국인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '0' and a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_nn0,
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '1' and a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_nn1,
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '2' and a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_nn2,
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '3' and a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_nn3
+ FROM
+ v2_chg_stat_stats a
+ INNER JOIN v2_vrfc_req b ON b.vr_sq = a.vr_sq and b.vrfc_type = 'N'
+ LEFT JOIN v2_article_info_etc c1 on a.vr_sq = c1.vr_sq
+
+ WHERE 1 = 1 and a.insert_tm between CONCAT('{$data['sdate']}' , ':00') AND CONCAT('{$data['edate']}' , ':59') GROUP BY CASE a.insert_user WHEN 0 THEN 1 ELSE a.insert_user END ) b on b.insert_user = a.usr_sq
+ LEFT JOIN (
+ select
+ f1.insert_user,
+ count(distinct f1.vr_sq) mobile_upload
+ from v2_files f1
+ INNER JOIN v2_vrfc_req b ON b.vr_sq = f1.vr_sq and b.vrfc_type = 'N'
+ where
+ f1.insert_tm BETWEEN CONCAT('{$data['sdate']}' , ':00') AND CONCAT('{$data['edate']}' , ':59')
+ and f1.file_type = '2' and f1.use_yn = 'Y' group by f1.insert_user
+ ) c on c.insert_user = a.usr_sq
+ WHERE (b.insert_user is not null or c.insert_user is not null) ";
+
+ if (!empty($data['dept_sq'])) {
+ $sql .= "AND a.dept_sq = {$data['dept_sq']} ";
+ }
+
+ $query = $this->db->query($sql);
+
+ return $query->getRow()->cnt;
+ }
+
+ public function getResultList($data)
+ {
+ $sql = "SELECT
+ a.usr_sq,
+ a.usr_id,
+ a.usr_nm,
+ IFNULL(c.mobile_upload, 0)mobile_upload ,
+ b.*
+ FROM
+ users a
+ left join (
+ SELECT
+ CASE
+ a.insert_user WHEN 0 THEN 1
+ ELSE a.insert_user
+ END insert_user,
+ COUNT(*) total_cnt ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '10' THEN a.vr_sq ELSE NULL END ) receipt_cnt ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '10' THEN a.vr_sq ELSE NULL END ) notassign_cnt ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '10' THEN NULL ELSE a.vr_sq END ) assign_cnt ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '19' THEN a.vr_sq ELSE NULL END ) cancel_cnt ,
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '30' THEN a.vr_sq ELSE NULL END ) phone_checking_cnt ,
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '30' THEN a.vr_sq ELSE NULL END ) paper_checking_cnt ,
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '35' THEN a.vr_sq ELSE NULL END ) phone_complete_cnt , -- 전화확인 완료
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '35' THEN a.vr_sq ELSE NULL END ) paper_complete_cnt ,
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '38' THEN a.vr_sq ELSE NULL END ) phone_all_cnt , -- 전화확인 전체
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'T' AND a.stat_cd = '39' THEN a.vr_sq ELSE NULL END ) phone_fail_cnt , -- 전화확인 실패
+ COUNT( DISTINCT CASE WHEN b.vrfc_type = 'D' AND a.stat_cd = '39' THEN a.vr_sq ELSE NULL END ) paper_fail_cnt ,
+ COUNT( DISTINCT case when (b.certRegister IS NOT NULL AND b.stat_cd = '60' AND a.stat_cd = '76') then a.vr_sq ELSE NULL END ) cert_same_reg_open ,
+ COUNT( DISTINCT case when (b.certRegister IS NOT NULL AND a.stat_cd = '77') then a.vr_sq ELSE NULL END ) cert_reg_fail_open,
+ COUNT( DISTINCT case when (b.referenceFileUrl IS NOT NULL AND b.stat_cd = '60' AND a.stat_cd = '76') then a.vr_sq ELSE NULL END ) reference_same_reg_open ,
+ COUNT( DISTINCT case when (b.referenceFileUrl IS NOT NULL AND a.stat_cd = '77') then a.vr_sq ELSE NULL END ) reference_reg_fail_open ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '40' THEN a.vr_sq ELSE NULL END ) reg_checking_cnt ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '45' THEN a.vr_sq ELSE NULL END ) reg_complete_cnt ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '70' THEN a.vr_sq ELSE NULL END ) reg_none , -- 등기부 등본 없음
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '86' THEN a.vr_sq ELSE NULL END ) real_top_RS ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '88' THEN a.vr_sq ELSE NULL END ) real_top_RF ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '87' THEN a.vr_sq ELSE NULL END ) real_top_GS ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '89' THEN a.vr_sq ELSE NULL END ) real_top_GF ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '49' THEN a.vr_sq ELSE NULL END ) reg_fail_cnt ,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '60' THEN a.vr_sq ELSE NULL END ) complete_cnt ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '60' THEN a.vr_sq ELSE NULL END ) complete_cnt1,
+ COUNT( DISTINCT CASE WHEN a.stat_cd = '69' THEN a.vr_sq ELSE NULL END ) fail_cnt ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '69' THEN a.vr_sq ELSE NULL END ) fail_cnt1 ,
+ COUNT( CASE WHEN (a.stat_cd = '85') THEN a.vr_sq ELSE NULL END ) reg_fail_tempOpen ,
+ COUNT( CASE WHEN (a.stat_cd = '77') THEN a.vr_sq ELSE NULL END ) reg_fail_Open ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '60' AND a.stat_cd = '80' THEN a.vr_sq ELSE NULL END ) same_reg_tempOpen ,
+ COUNT( DISTINCT CASE WHEN b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) same_reg_open,
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '0' and a.stat_cd = '77' THEN a.vr_sq ELSE NULL END ) as referin_s0, -- 첨부파일 불일치 개인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '1' and a.stat_cd = '77' THEN a.vr_sq ELSE NULL END ) as referin_s1, -- 첨부파일 불일치 위임장
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '2' and a.stat_cd = '77' THEN a.vr_sq ELSE NULL END ) as referin_s2, -- 첨부파일 불일치 법인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '3' and a.stat_cd = '77' THEN a.vr_sq ELSE NULL END ) as referin_s3, -- 첨부파일 불일치 외국인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '0' and b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_n0, -- 첨부파일 일치 개인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '1' and b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_n1, -- 첨부파일 일치 위임장
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '2' and b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_n2, -- 첨부파일 일치 법인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '3' and b.stat_cd = '60' AND a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_n3, -- 첨부파일 일치 외국인
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '0' and a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_nn0,
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '1' and a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_nn1,
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '2' and a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_nn2,
+ COUNT( DISTINCT CASE WHEN ( ( if ( b.referenceFileUrl = '[]' , NULL , b.referenceFileUrl) ) IS NOT NULL ) and c1.ownerTypeCode = '3' and a.stat_cd = '76' THEN a.vr_sq ELSE NULL END ) as referin_nn3
+ FROM
+ v2_chg_stat_stats a
+ INNER JOIN v2_vrfc_req b ON b.vr_sq = a.vr_sq and b.vrfc_type = 'N'
+ LEFT JOIN v2_article_info_etc c1 on a.vr_sq = c1.vr_sq
+
+ WHERE 1 = 1 and a.insert_tm between CONCAT('{$data['sdate']}' , ':00') AND CONCAT('{$data['edate']}' , ':59') GROUP BY CASE a.insert_user WHEN 0 THEN 1 ELSE a.insert_user END ) b on b.insert_user = a.usr_sq
+ LEFT JOIN (
+ select
+ f1.insert_user,
+ count(distinct f1.vr_sq) mobile_upload
+ from v2_files f1
+ INNER JOIN v2_vrfc_req b ON b.vr_sq = f1.vr_sq and b.vrfc_type = 'N'
+ where
+ f1.insert_tm BETWEEN CONCAT('{$data['sdate']}' , ':00') AND CONCAT('{$data['edate']}' , ':59')
+ and f1.file_type = '2' and f1.use_yn = 'Y' group by f1.insert_user
+ ) c on c.insert_user = a.usr_sq
+ WHERE (b.insert_user is not null or c.insert_user is not null) ";
+
+ if (!empty($data['dept_sq'])) {
+ $sql .= "AND a.dept_sq = {$data['dept_sq']} ";
+ }
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+
+}
\ No newline at end of file
diff --git a/app/Models/results/PersonModel.php b/app/Models/results/PersonModel.php
new file mode 100644
index 0000000..d1de173
--- /dev/null
+++ b/app/Models/results/PersonModel.php
@@ -0,0 +1,304 @@
+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 getAreaList($sido = '', $gugun = '')
+ {
+
+ if (!empty($gugun)) {
+ $gugun = substr($gugun, '0', '5');
+
+ $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,5),'00000')" .
+ " WHERE a.region_cd LIKE concat(?, '%')" .
+ " AND a.region_cd NOT LIKE '%00000'" .
+ " AND a.region_cd LIKE '%00'" .
+ " AND a.use_yn = 'Y'" .
+ " ORDER BY a.region_nm ASC";
+
+ $query = $this->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 getTotalCount($data)
+ {
+ $sql = "SELECT
+ COUNT(*) AS cnt
+ FROM result a
+ INNER JOIN users b ON b.usr_sq = a.usr_sq
+ INNER JOIN departments c ON c.dept_sq = a.dept_sq
+ INNER JOIN receipt d ON d.rcpt_sq = a.rcpt_sq
+ WHERE 1=1 ";
+
+ if (!empty($data['bonbu'])) {
+ $sql .= "AND c.pdept_sq = {$data['bonbu']} ";
+ }
+
+ if (!empty($data['team'])) {
+ $sql .= "AND c.dept_sq = {$data['team']} ";
+ }
+
+ if (!empty($data['schDateGb'])) {
+ if ($data['schDateGb'] === "1") {
+
+ if (!empty($data['sdate'])) {
+ $sql .= "AND a.rsrv_date >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND a.rsrv_date <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+
+ } else if ($data['schDateGb'] === "2") {
+ if (!empty($data['sdate'])) {
+ $sql .= "AND d.rcpt_tm >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND d.rcpt_tm <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+ }
+ }
+
+ if (!empty($data['srchTxt'])) {
+ if ($data['srchType'] === "1") {
+ $sql .= "AND usr_id like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else if ($data['srchType'] === "2") {
+ $sql .= "AND usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else {
+ $sql .= "AND (
+ usr_id like CONCAT('%', '{$data['srchTxt']}', '%' )
+ OR usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' )
+ ) ";
+ }
+ }
+
+ $query = $this->db->query($sql);
+
+ return $query->getRow()->cnt;
+ }
+
+ public function getUserList($start, $end, $data)
+ {
+ $sql = "SELECT
+ b.usr_nm, b.usr_id, b.usr_sq, c.dept_sq, c.pdept_sq, c.depth
+ , count(distinct a.rcpt_sq) rcpt_cnt
+ , COUNT(DISTINCT CASE WHEN a.cancel_dt IS NOT NULL THEN CASE WHEN a.result_cd2 IN ('9010','9020') THEN a.rcpt_sq END END) resv_cancel_cnt
+ , COUNT(DISTINCT CASE WHEN a.assign_save_dt IS NOT NULL THEN a.rcpt_sq END) resv_assign_cnt
+ , COUNT(DISTINCT CASE WHEN a.cancel_dt IS NOT NULL THEN CASE WHEN a.result_cd2 = '9030' THEN a.rcpt_sq END END) prev_visit_cnt
+ , COUNT(DISTINCT CASE WHEN a.cancel_dt IS NOT NULL THEN CASE WHEN a.result_cd2 = '9040' THEN a.rcpt_sq END END) next_visit_cnt
+ , COUNT(DISTINCT CASE WHEN a.cancel_dt IS NOT NULL THEN CASE WHEN a.result_cd2 = '9045' THEN a.rcpt_sq END END) next_shoot_cnt
+ , COUNT(DISTINCT CASE WHEN a.photo_save_dt IS NOT NULL THEN a.rcpt_sq END) shoot_cnt
+ , COUNT(DISTINCT CASE WHEN a.result_cd1 = '70' THEN a.rcpt_sq END) delay_confirm_cnt
+ , COUNT(DISTINCT CASE WHEN a.result_cd2 = '9050' THEN a.rcpt_sq END) fail_confirm_cnt
+ , COUNT(DISTINCT CASE WHEN a.result_cd1 = '60' THEN a.rcpt_sq END) confirm_cnt
+ FROM result a
+ INNER JOIN users b ON b.usr_sq = a.usr_sq
+ INNER JOIN departments c ON c.dept_sq = a.dept_sq
+ INNER JOIN receipt d ON d.rcpt_sq = a.rcpt_sq
+ WHERE 1=1 ";
+
+ if (!empty($data['bonbu'])) {
+ $sql .= "AND c.pdept_sq = {$data['bonbu']} ";
+ }
+
+ if (!empty($data['team'])) {
+ $sql .= "AND c.dept_sq = {$data['team']} ";
+ }
+
+ if (!empty($data['schDateGb'])) {
+ if ($data['schDateGb'] === "1") {
+
+ if (!empty($data['sdate'])) {
+ $sql .= "AND a.rsrv_date >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND a.rsrv_date <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+
+ } else if ($data['schDateGb'] === "2") {
+ if (!empty($data['sdate'])) {
+ $sql .= "AND d.rcpt_tm >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND d.rcpt_tm <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+ }
+ }
+
+ if (!empty($data['srchTxt'])) {
+ if ($data['srchType'] === "1") {
+ $sql .= "AND usr_id like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else if ($data['srchType'] === "2") {
+ $sql .= "AND usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else {
+ $sql .= "AND (
+ usr_id like CONCAT('%', '{$data['srchTxt']}', '%' )
+ OR usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' )
+ ) ";
+ }
+ }
+
+
+ $sql .= "GROUP BY b.usr_id, b.usr_nm ";
+
+ $sql .= "LIMIT {$start}, {$end}";
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+
+ // 엑셀 다운로드
+ public function getExcelUserList($data)
+ {
+ $sql = "SELECT
+ b.usr_id AS '아이디'
+ , b.usr_nm AS '이름'
+ , count(distinct a.rcpt_sq) AS '접수'
+ , COUNT(DISTINCT CASE WHEN a.cancel_dt IS NOT NULL THEN CASE WHEN a.result_cd2 IN ('9010','9020') THEN a.rcpt_sq END END) AS '예약취소'
+ , COUNT(DISTINCT CASE WHEN a.assign_save_dt IS NOT NULL THEN a.rcpt_sq END) AS '예약확인'
+ , COUNT(DISTINCT CASE WHEN a.cancel_dt IS NOT NULL THEN CASE WHEN a.result_cd2 = '9030' THEN a.rcpt_sq END END) AS '방문전취소'
+ , COUNT(DISTINCT CASE WHEN a.cancel_dt IS NOT NULL THEN CASE WHEN a.result_cd2 = '9040' THEN a.rcpt_sq END END) AS '방문후취소'
+ , COUNT(DISTINCT CASE WHEN a.cancel_dt IS NOT NULL THEN CASE WHEN a.result_cd2 = '9045' THEN a.rcpt_sq END END) AS '촬영후취소'
+ , COUNT(DISTINCT CASE WHEN a.photo_save_dt IS NOT NULL THEN a.rcpt_sq END) AS '촬영'
+ , COUNT(DISTINCT CASE WHEN a.result_cd1 = '70' THEN a.rcpt_sq END) AS '검수지연'
+ , COUNT(DISTINCT CASE WHEN a.result_cd2 = '9050' THEN a.rcpt_sq END) AS '검수실패'
+ , COUNT(DISTINCT CASE WHEN a.result_cd1 = '60' THEN a.rcpt_sq END) AS '검수완료'
+ FROM result a
+ INNER JOIN users b ON b.usr_sq = a.usr_sq
+ INNER JOIN departments c ON c.dept_sq = a.dept_sq
+ INNER JOIN receipt d ON d.rcpt_sq = a.rcpt_sq
+ WHERE 1=1 ";
+
+ if (!empty($data['bonbu'])) {
+ $sql .= "AND c.pdept_sq = {$data['bonbu']} ";
+ }
+
+ if (!empty($data['team'])) {
+ $sql .= "AND c.dept_sq = {$data['team']} ";
+ }
+
+ if (!empty($data['schDateGb'])) {
+ if ($data['schDateGb'] === "1") {
+
+ if (!empty($data['sdate'])) {
+ $sql .= "AND a.rsrv_date >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND a.rsrv_date <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+
+ } else if ($data['schDateGb'] === "2") {
+ if (!empty($data['sdate'])) {
+ $sql .= "AND d.rcpt_tm >= CONCAT('{$data['sdate']} 00:00:00') ";
+ }
+
+ if (!empty($data['edate'])) {
+ $sql .= "AND d.rcpt_tm <= CONCAT('{$data['edate']} 23:59:59') ";
+ }
+ }
+ }
+
+ if (!empty($data['srchTxt'])) {
+ if ($data['srchType'] === "1") {
+ $sql .= "AND usr_id like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else if ($data['srchType'] === "2") {
+ $sql .= "AND usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
+ } else {
+ $sql .= "AND (
+ usr_id like CONCAT('%', '{$data['srchTxt']}', '%' )
+ OR usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' )
+ ) ";
+ }
+ }
+
+
+ $sql .= "GROUP BY b.usr_id, b.usr_nm ";
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+}
\ No newline at end of file
diff --git a/app/Models/results/SummaryModel.php b/app/Models/results/SummaryModel.php
new file mode 100644
index 0000000..71456cd
--- /dev/null
+++ b/app/Models/results/SummaryModel.php
@@ -0,0 +1,57 @@
+db->query($sql);
+
+ return $query->getResultArray();
+ }
+
+ public function st_s01_2($data)
+ {
+ $sql = "SELECT
+ a.agent_id, a.agent_nm, count(a.agent_id) rcpt_count, sum(case when b.photo_save_dt is null then 0 else 1 end) shoot_count
+ FROM
+ receipt AS a
+ INNER JOIN result AS b ON b.rcpt_sq = a.rcpt_sq
+ WHERE
+ a.rcpt_tm >= DATE('{$data['sdate']} 00:00:00')
+ AND a.rcpt_tm <= DATE('{$data['edate']} 23:59:59')
+ GROUP BY a.agent_id, a.agent_nm
+ HAVING count(a.agent_id) > 80
+
+ ORDER BY rcpt_count DESC ";
+
+
+ $query = $this->db->query($sql);
+
+ return $query->getResultArray();
+ }
+}
\ No newline at end of file
diff --git a/app/Views/layouts/header.php b/app/Views/layouts/header.php
index c7f4b3d..278f9d9 100644
--- a/app/Views/layouts/header.php
+++ b/app/Views/layouts/header.php
@@ -51,6 +51,7 @@
+
\ No newline at end of file
diff --git a/app/Views/layouts/main.php b/app/Views/layouts/main.php
index ca05963..bbc6986 100644
--- a/app/Views/layouts/main.php
+++ b/app/Views/layouts/main.php
@@ -27,6 +27,123 @@
= $this->renderSection('modals') ?>
+
+