diff --git a/app/Controllers/Admin/Customer/ClientController.php b/app/Controllers/Admin/Customer/ClientController.php index a158cb8..31590bc 100644 --- a/app/Controllers/Admin/Customer/ClientController.php +++ b/app/Controllers/Admin/Customer/ClientController.php @@ -50,4 +50,19 @@ class ClientController extends CustomerController return $validation; } //Index,FieldForm관련. + protected function setFilterConditionForList(): void + { + foreach ($this->getFilterFields() as $field) { + $this->$field = $this->request->getVar($field); + if ($this->$field !== null && $this->$field !== '') { + if ($field === 'role') { + $where = "FIND_IN_SET(" . $this->getService()->getModel()->escape($this->$field) . ", {$this->getService()->getModel()->getTable()}.{$field}) > 0"; + //FIND_IN_SET()은 MySQL 함수이므로 CodeIgniter가 이를 일반 컬럼명으로 착각하고 escape하게 되면 오류가 발생합니다. 따라서 ->where($sql, null, false)로 명시하여 escape를 꺼줘야 정상 작동 + $this->getService()->getModel()->where($where, null, false); + } else { + $this->getService()->getModel()->where("{$this->getService()->getModel()->getTable()}.{$field}", $this->$field); + } + } + } + } } diff --git a/app/Controllers/Admin/Customer/ServiceController.php b/app/Controllers/Admin/Customer/ServiceController.php index 530f349..b943708 100644 --- a/app/Controllers/Admin/Customer/ServiceController.php +++ b/app/Controllers/Admin/Customer/ServiceController.php @@ -97,6 +97,18 @@ class ServiceController extends CustomerController } return $result; } + + protected function setWordConditionForList(): void + { + $this->word = $this->request->getVar('word'); + if ($this->word !== null && $this->word !== '') { + if ($this->getHelper()->isIPAddress($this->word, 'ipv4')) { + $this->getService()->setSearchIp($this->word); + } else { + $this->getService()->getModel()->setList_WordFilter($this->word); + } + } + } //Index,FieldForm관련 protected function index_process(): array { diff --git a/app/Controllers/Admin/Customer/ServiceItemController.php b/app/Controllers/Admin/Customer/ServiceItemController.php index 10f774f..fa90dee 100644 --- a/app/Controllers/Admin/Customer/ServiceItemController.php +++ b/app/Controllers/Admin/Customer/ServiceItemController.php @@ -48,6 +48,12 @@ class ServiceItemController extends CustomerController } return $this->_serviceService; } + protected function initAction(string $action): void + { + //$item_type(CPU,RAM,STORAGE등)에 따라 선언된 getFormFieldOption용 사용됨 (initAction보다 먼저 호출해야 됨) + $this->initServiceItemOptions(); + parent::initAction($action); + } protected function getFormFieldOption(string $field, array $options = []): array { switch ($field) { diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index d87442b..193eedf 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -54,4 +54,19 @@ class UserController extends AdminController return $validation; } //Index,FieldForm관련. + protected function setFilterConditionForList(): void + { + foreach ($this->getFilterFields() as $field) { + $this->$field = $this->request->getVar($field); + if ($this->$field !== null && $this->$field !== '') { + if ($field === 'role') { + $where = "FIND_IN_SET(" . $this->getService()->getModel()->escape($this->$field) . ", {$this->getService()->getModel()->getTable()}.{$field}) > 0"; + //FIND_IN_SET()은 MySQL 함수이므로 CodeIgniter가 이를 일반 컬럼명으로 착각하고 escape하게 되면 오류가 발생합니다. 따라서 ->where($sql, null, false)로 명시하여 escape를 꺼줘야 정상 작동 + $this->getService()->getModel()->where($where, null, false); + } else { + $this->getService()->getModel()->where("{$this->getService()->getModel()->getTable()}.{$field}", $this->$field); + } + } + } + } } diff --git a/app/Controllers/CommonController.php b/app/Controllers/CommonController.php index aff548e..eca9eb2 100644 --- a/app/Controllers/CommonController.php +++ b/app/Controllers/CommonController.php @@ -575,28 +575,27 @@ abstract class CommonController extends BaseController } //리스트 - //List 조건절 처리 - final protected function setConditionForList(): void + //Filter 조건절 처리 + protected function setFilterConditionForList(): void { - //조건절 처리 foreach ($this->getFilterFields() as $field) { $this->$field = $this->request->getVar($field); if ($this->$field !== null && $this->$field !== '') { - if ($field === 'role') { - $where = "FIND_IN_SET(" . $this->getService()->getModel()->escape($this->$field) . ", {$this->getService()->getModel()->getTable()}.{$field}) > 0"; - //FIND_IN_SET()은 MySQL 함수이므로 CodeIgniter가 이를 일반 컬럼명으로 착각하고 escape하게 되면 오류가 발생합니다. 따라서 ->where($sql, null, false)로 명시하여 escape를 꺼줘야 정상 작동 - $this->getService()->getModel()->where($where, null, false); - } else { - $this->getService()->getModel()->where("{$this->getService()->getModel()->getTable()}.{$field}", $this->$field); - } + $this->getService()->getModel()->where("{$this->getService()->getModel()->getTable()}.{$field}", $this->$field); } } - //검색어 처리 + } + //검색어 조건절 처리 + protected function setWordConditionForList(): void + { $this->word = $this->request->getVar('word'); if ($this->word !== null && $this->word !== '') { $this->getService()->getModel()->setList_WordFilter($this->word); } - //검색일 처리 + } + //검색일 조건절 처리 + protected function setDateConditionForList(): void + { $this->start = $this->request->getVar('start'); if ($this->start !== null && $this->start !== '') { $this->getService()->getModel()->where(sprintf("%s.created_at >= '%s 00:00:00'", $this->getService()->getModel()->getTable(), $this->start)); @@ -606,9 +605,9 @@ abstract class CommonController extends BaseController $this->getService()->getModel()->where(sprintf("%s.created_at <= '%s 23:59:59'", $this->getService()->getModel()->getTable(), $this->end)); } } + //OrderBy 처리 protected function setOrderByForList() { - //OrderBy 처리 $this->order_field = $this->request->getVar('order_field'); $this->order_value = $this->request->getVar('order_value'); if ($this->order_field !== null && $this->order_field !== '') { @@ -617,8 +616,15 @@ abstract class CommonController extends BaseController $this->getService()->getModel()->orderBy(sprintf("%s.%s %s", $this->getService()->getModel()->getTable(), $this->getService()->getModel()->getPKField(), "DESC")); } } + //조건절 처리 + protected function setConditionForList(): void + { + $this->setFilterConditionForList(); + $this->setWordConditionForList(); + $this->setDateConditionForList(); + } //PageNation 처리 - final protected function getPageOptionsByPaginationForList(): array + protected function getPageOptiosForList(): array { $page_options = ["" => "줄수선택"]; for ($i = $this->per_page; $i <= $this->total_count; $i += $this->per_page) { @@ -627,13 +633,11 @@ abstract class CommonController extends BaseController $page_options[$this->total_count] = $this->total_count; return $page_options; } - final protected function getPaginationForList($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full') + protected function getPaginationForList($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full') { //Page, Per_page필요부분 $this->page = (int) $this->request->getVar('page') ?: 1; $this->per_page = (int) $this->request->getVar('per_page') ?: intval(DEFAULT_LIST_PERPAGE ?? 20); - //줄수 처리용 - $this->page_options = $this->getPageOptionsByPaginationForList(); // 1.Views/Pagers/에 bootstrap_full.php,bootstrap_simple.php 생성 // 2.app/Config/Pager.php/$templates에 'bootstrap_full => 'Pagers\bootstrap_full', // 'bootstrap_simple' => 'Pagers\bootstrap_simple', 추가 @@ -652,6 +656,8 @@ abstract class CommonController extends BaseController $this->total_count = intval($this->getService()->getModel()->selectCount('*', 'cnt')->get()->getRow()->cnt); //Pagination 처리 $this->pagination = $this->getPaginationForList(); + //줄수 처리용 + $this->page_options = $this->getPageOptiosForList(); //조건절 , OrcerBy , Limit 처리 $this->setConditionForList(); $this->setOrderByForList(); diff --git a/app/Helpers/Customer/ServiceHelper.php b/app/Helpers/Customer/ServiceHelper.php index a79d844..b33e079 100644 --- a/app/Helpers/Customer/ServiceHelper.php +++ b/app/Helpers/Customer/ServiceHelper.php @@ -58,7 +58,10 @@ class ServiceHelper extends CustomerHelper $form_temps = ["