diff --git a/app/Config/Filters.php b/app/Config/Filters.php index cca04dc..1bc4d68 100644 --- a/app/Config/Filters.php +++ b/app/Config/Filters.php @@ -85,6 +85,7 @@ class Filters extends BaseFilters 'index.php/login/*', // /index.php/login/* 'register', // 회원가입 등 'register/*', + '/listfax/listfax/getLists', 'kiso/*', // 필요하면 API는 예외 ], ], diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 55f9145..5fb6734 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -18,6 +18,7 @@ $routes->get('/home', 'Home\Home::dashboard'); $routes->get('/home/viewStatData', 'Home\Home::viewStatData'); // 실적조회 $routes->get('/home/getHomeFaxCount', 'Home\Home::getHomeFaxCount'); // 팩스조회 +$routes->get('/listfax/listfax/getLists', 'Listfax\ListFax::getLists'); // 팩스수신확인 /** * 공통 API diff --git a/app/Controllers/Listfax/ListFax.php b/app/Controllers/Listfax/ListFax.php index dc66b37..467e8a1 100644 --- a/app/Controllers/Listfax/ListFax.php +++ b/app/Controllers/Listfax/ListFax.php @@ -9,6 +9,8 @@ use App\Models\listfax\ListFaxModel; class ListFax extends BaseController { + private $listfaxModel; + private $todo = ''; // 검색, 엑셀다운 구분 private $menuid = ''; // 레프트메뉴아이디 @@ -38,6 +40,10 @@ class ListFax extends BaseController private $pars = []; + public function __construct() + { + $this->listfaxModel = new ListFaxModel(); + } public function index() { @@ -133,8 +139,7 @@ class ListFax extends BaseController // CI3: $base_uri = '/listfax/listfax/lists'; $base_uri = '/listfax/listfax/lists'; - // CI3: $this->load->model('v2/listfax_model', 'listfax_model'); - $listfaxModel = new ListFaxModel(); + // CI3: $this->load->model('v2/listfax_model', 'listfax_model'); // CI3: $this->load->helper('array_helper'); helper(filenames: 'array'); // array_helper => array 로 이름 바꿨다면 이렇게 @@ -149,7 +154,7 @@ class ListFax extends BaseController 'total' => 0, ]; } else { - $resultData = $listfaxModel->getLists( + $resultData = $this->listfaxModel->getLists( $this->todo, $this->page, $this->pagesize, @@ -185,4 +190,26 @@ class ListFax extends BaseController return view('listfax/listfax/lists', $data); } + + public function getLists() + { + $start = (int) $this->request->getGet('start') ?: 0; + $end = (int) $this->request->getGet('length') ?: 10; + + + $data = [ + 'caller_no' => $this->request->getGet('caller_no'), + ]; + + $totalCount = $this->listfaxModel->getTotalCount($data); + + $datas = $this->listfaxModel->getResultList($start, $end, $data); + + return $this->response->setJSON(body: [ + 'recordsTotal' => $totalCount, + 'recordsFiltered' => $totalCount, + 'data' => $datas, + ]); + } + } \ No newline at end of file diff --git a/app/Models/listfax/ListFaxModel.php b/app/Models/listfax/ListFaxModel.php index 1746067..e4239ae 100644 --- a/app/Models/listfax/ListFaxModel.php +++ b/app/Models/listfax/ListFaxModel.php @@ -6,5 +6,48 @@ use CodeIgniter\Model; class ListFaxModel extends Model { + public function getTotalCount($data) + { + $sql = "SELECT + COUNT(*) AS cnt + FROM + fax_imgs a + WHERE + a.RECV_TIME >= CONCAT(DATE_FORMAT(DATE_ADD(NOW(), INTERVAL - 7 DAY), 'Y-m-d'), ' 00:00:00') + AND a.RECV_TIME <= CONCAT(DATE_FORMAT(NOW(), 'Y-m-d'), ' 23:59:59') + AND a.caller_no LIKE CONCAT('%', REPLACE('{$data['caller_no']}', '-', ''), '%') + + GROUP BY a.`MID` + "; + + + $query = $this->db->query($sql); + + $row = $query->getRow(); + return $row ? $row->cnt : 0; + } + + public function getResultList($start, $end, $data) + { + $sql = " + SELECT + a.fax_sq, a.mid, GROUP_CONCAT(a.file_name) AS file_name, a.file_path, a.CALLER_NO, a.CALLEE_NO, a.RECV_TIME, a.SAVE_TIME, COUNT(a.file_name) AS cnt + FROM + fax_imgs a + WHERE + a.RECV_TIME >= CONCAT(DATE_FORMAT(DATE_ADD(NOW(), INTERVAL - 7 DAY), 'Y-m-d'), ' 00:00:00') + AND a.RECV_TIME <= CONCAT(DATE_FORMAT(NOW(), 'Y-m-d'), ' 23:59:59') + AND a.caller_no LIKE CONCAT('%', REPLACE('{$data['caller_no']}', '-', ''), '%') + + GROUP BY a.`MID` + ORDER BY a.fax_sq DESC, a.RECV_TIME DESC + + LIMIT {$start}, {$end} + "; + + $query = $this->db->query($sql); + + return $query->getResultArray(); + } } \ No newline at end of file diff --git a/app/Views/pages/login.php b/app/Views/pages/login.php index cd8cfe3..b9334e0 100644 --- a/app/Views/pages/login.php +++ b/app/Views/pages/login.php @@ -41,6 +41,7 @@ + @@ -105,8 +106,7 @@ - + 팩스 수신 확인 @@ -132,12 +132,80 @@ + + +