diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 7735ff8..7498a57 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -95,7 +95,6 @@ define('EVENT_PRIORITY_HIGH', 10); //Default값 정의 define('DEFAULTS', [ - 'ROLE' => "guest", 'EMPTY' => "", 'DELIMITER_FILE' => "||", 'DELIMITER_ROLE' => ",", diff --git a/app/Controllers/Admin/Customer/ClientController.php b/app/Controllers/Admin/Customer/ClientController.php index 9aa4dce..9693ba5 100644 --- a/app/Controllers/Admin/Customer/ClientController.php +++ b/app/Controllers/Admin/Customer/ClientController.php @@ -2,16 +2,17 @@ namespace App\Controllers\Admin\Customer; -use CodeIgniter\HTTP\RedirectResponse; -use CodeIgniter\HTTP\RequestInterface; +use App\Entities\Customer\AccountEntity; +use App\Entities\Customer\ClientEntity; +use App\Entities\Customer\CouponEntity; +use App\Helpers\Customer\ClientHelper; +use App\Services\Customer\ClientService; +use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\Validation\Validation; use Psr\Log\LoggerInterface; -use App\Helpers\Customer\ClientHelper; -use App\Services\Customer\ClientService; - class ClientController extends CustomerController { public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) @@ -36,6 +37,10 @@ class ClientController extends CustomerController } return $this->_helper; } + public function getFields(): array + { + return ['name', 'email', 'phone', 'role']; + } //Index,FieldForm관련 protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation { @@ -50,5 +55,57 @@ class ClientController extends CustomerController } return $validation; } + + protected function create_process(): ClientEntity + { + //데이터 검증 + $this->formDatas = $this->doValidate($this->action, $this->fields); + $entity = $this->getService()->create($this->formDatas); + + //Account정보 + $temps = []; + $temps['clientinfo_uid'] = $entity->getPK(); + $temps['title'] = "첫가입"; + $temps['alias'] = $entity->getTitle(); + $temps['amount'] = $this->formDatas['account_balance'] ?? 0; + $temps['status'] = lang("{$this->getAccountService()->getClassPath()}.DEFAULTS.status"); + $this->getAccountService()->create($temps, new AccountEntity()); + + //Coupon정보 + $temps = []; + $temps['clientinfo_uid'] = $entity->getPK(); + $temps['title'] = "첫가입"; + $temps['amount'] = $this->formDatas['coupon_balance'] ?? 0; + $temps['status'] = lang("{$this->getCouponService()->getClassPath()}.DEFAULTS.status"); + $this->getCouponService()->create($temps, new CouponEntity()); + + //Point정보 + $temps = []; + $temps['clientinfo_uid'] = $entity->getPK(); + $temps['title'] = "첫가입"; + $temps['amount'] = $this->formDatas['point_balance'] ?? 0; + $temps['status'] = lang("{$this->getPointService()->getClassPath()}.DEFAULTS.status"); + $this->getPointService()->create($temps, new CouponEntity()); + + return $entity; + } //Index,FieldForm관련. + + //View관련 + protected function view_process($uid): mixed + { + $fields = [ + 'fields' => [$this->getService()->getModel()::TITLE, 'email', 'phone', 'role', 'account_balance', 'coupon_balance', 'point_balance', 'status'], + ]; + $this->init('view', $fields); + return parent::view_process($uid); + } + protected function index_process(): array + { + $fields = [ + 'fields' => [$this->getService()->getModel()::TITLE, 'email', 'phone', 'role', 'account_balance', 'coupon_balance', 'point_balance', 'status'], + ]; + $this->init('index', $fields); + return parent::index_process(); + } } diff --git a/app/Controllers/Admin/Customer/CouponController.php b/app/Controllers/Admin/Customer/CouponController.php index 821785e..b9928ae 100644 --- a/app/Controllers/Admin/Customer/CouponController.php +++ b/app/Controllers/Admin/Customer/CouponController.php @@ -2,7 +2,6 @@ namespace App\Controllers\Admin\Customer; -use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; @@ -35,4 +34,6 @@ class CouponController extends CustomerController return $this->_helper; } //Index,FieldForm관련. + + } diff --git a/app/Controllers/Admin/Customer/CustomerController.php b/app/Controllers/Admin/Customer/CustomerController.php index fbe7ec0..68806e0 100644 --- a/app/Controllers/Admin/Customer/CustomerController.php +++ b/app/Controllers/Admin/Customer/CustomerController.php @@ -6,7 +6,11 @@ use App\Controllers\Admin\AdminController; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; + +use App\Services\Customer\AccountService; use App\Services\Customer\ClientService; +use App\Services\Customer\CouponService; +use App\Services\Customer\PointService; abstract class CustomerController extends AdminController { @@ -24,6 +28,27 @@ abstract class CustomerController extends AdminController } return $this->_clientService; } + final public function getAccountService(): AccountService + { + if (!$this->_accountService) { + $this->_accountService = new AccountService($this->request); + } + return $this->_accountService; + } + final public function getCouponService(): CouponService + { + if (!$this->_couponService) { + $this->_couponService = new CouponService($this->request); + } + return $this->_couponService; + } + final public function getPointService(): PointService + { + if (!$this->_pointService) { + $this->_pointService = new PointService($this->request); + } + return $this->_pointService; + } //Index,FieldForm관련 protected function getFormFieldOption(string $field, array $options = []): array { @@ -39,5 +64,4 @@ abstract class CustomerController extends AdminController } return $options; } - //Index,FieldForm관련 } diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index 166bcdb..6373e51 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -54,6 +54,11 @@ class UserController extends AdminController } //Index,FieldForm관련. + public function getFields(): array + { + return ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role']; + } + protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string { switch ($action) { diff --git a/app/Controllers/CommonController.php b/app/Controllers/CommonController.php index 93edf19..439ec22 100644 --- a/app/Controllers/CommonController.php +++ b/app/Controllers/CommonController.php @@ -141,8 +141,6 @@ abstract class CommonController extends BaseController if (!$validation) { $validation = service('validation'); } - // var_dump($this->field_rules); - // exit; foreach ($fields as $field) { $validation = $this->setValidation($validation, $action, $field, $this->field_rules[$field] ?? null); } @@ -205,11 +203,11 @@ abstract class CommonController extends BaseController helper(['form']); $this->entity = $this->create_process(); $this->getService()->getModel()->transCommit(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["SUCCESS"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]); return $this->getResultPageByActon($this->action); } catch (\Exception $e) { $this->getService()->getModel()->transRollback(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]); return redirect()->back()->withInput()->with('error', $e->getMessage()); } } @@ -247,11 +245,11 @@ abstract class CommonController extends BaseController helper(['form']); $this->entity = $this->modify_process($uid); $this->getService()->getModel()->transCommit(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["SUCCESS"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]); return $this->getResultPageByActon($this->action); } catch (\Exception $e) { $this->getService()->getModel()->transRollback(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]); return redirect()->back()->withInput()->with('error', $e->getMessage()); } } @@ -273,11 +271,11 @@ abstract class CommonController extends BaseController $this->fields = [$field]; $this->entity = $this->toggle_process($uid); $this->getService()->getModel()->transCommit(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["SUCCESS"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]); return $this->getResultPageByActon($this->action); } catch (\Exception $e) { $this->getService()->getModel()->transRollback(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]); return redirect()->back()->withInput()->with('error', $e->getMessage()); } } @@ -321,11 +319,11 @@ abstract class CommonController extends BaseController } $this->entities = $this->batchjob_process($entities); $this->getService()->getModel()->transCommit(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["SUCCESS"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]); return $this->getResultPageByActon($this->action); } catch (\Exception $e) { $this->getService()->getModel()->transRollback(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]); return redirect()->back()->withInput()->with('error', $e->getMessage()); } } @@ -348,11 +346,11 @@ abstract class CommonController extends BaseController $entity = $this->getService()->getEntity($uid); $this->entity = $this->delete_process($entity); $this->getService()->getModel()->transCommit(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["SUCCESS"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]); return $this->getResultPageByActon($this->action); } catch (\Exception $e) { $this->getService()->getModel()->transRollback(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]); return redirect()->back()->withInput()->with('error', $e->getMessage()); } } @@ -392,11 +390,11 @@ abstract class CommonController extends BaseController throw new \Exception($message); } $this->getService()->getModel()->transCommit(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["SUCCESS"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]); return $this->getResultPageByActon($this->action); } catch (\Exception $e) { $this->getService()->getModel()->transRollback(); - $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); + $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]); return redirect()->back()->withInput()->with('error', $e->getMessage()); } } @@ -426,27 +424,36 @@ abstract class CommonController extends BaseController //리스트 //List 조건절 처리 - protected function setConditionForList(array $filter_fields): void + final protected function setConditionForList(array $filter_fields): void { //조건절 처리 foreach ($filter_fields as $field) { - $this->$field = $this->request->getVar($field) ?? DEFAULTS['EMPTY']; - if ($this->$field !== DEFAULTS['EMPTY']) { - $this->getService()->getModel()->setList_FieldFilter($field, $this->$field); + $this->$field = $this->request->getVar($field); + echo "
"; + echo "1{$field}:{$this->$field}"; + echo "
"; + if (!is_null($this->$field)) { + echo "2{$field}:{$this->$field}"; + $this->getService()->getModel()->where($this->getService()->getModel()->getTable() . '.' . $field, $this->$field); } } //검색어 처리 - $this->word = $this->request->getVar('word') ?? DEFAULTS['EMPTY']; - if ($this->word !== DEFAULTS['EMPTY']) { + $this->word = $this->request->getVar('word'); + if (!is_null($this->word)) { $this->getService()->getModel()->setList_WordFilter($this->word); } //검색일 처리 - $this->start = $this->request->getVar('start') ?? DEFAULTS['EMPTY']; - $this->end = $this->request->getVar('end') ?? DEFAULTS['EMPTY']; - $this->getService()->getModel()->setList_DateFilter($this->start, $this->end); + $this->start = $this->request->getVar('start'); + $this->end = $this->request->getVar('end'); + if ($this->start) { + $this->getService()->getModel()->where($this->getService()->getModel()->getTable() . ".created_at >= '{$this->start} 00:00:00'"); + } + if ($this->end) { + $this->getService()->getModel()->where($this->getService()->getModel()->getTable() . ".created_at <= '{$this->start} 23:59:59'"); + } } //PageNation 처리 - protected function getPageOptionsByPaginationForList(): array + final protected function getPageOptionsByPaginationForList(): array { $page_options = ["" => "줄수선택"]; for ($i = $this->per_page; $i <= $this->total_count; $i += $this->per_page) { @@ -455,7 +462,7 @@ abstract class CommonController extends BaseController $page_options[$this->total_count] = $this->total_count; return $page_options; } - protected function getPaginationForList($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full') + final protected function getPaginationForList($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full') { //Page, Per_page필요부분 $this->page = (int) $this->request->getVar('page') ?: 1; @@ -498,7 +505,7 @@ abstract class CommonController extends BaseController $this->init(__FUNCTION__); $this->entities = $this->index_process(); // 현재 URL을 스택에 저장 - $this->_myAuth->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : "")); + $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : "")); helper(['form']); return $this->getResultPageByActon($this->action); } catch (\Exception $e) { diff --git a/app/Helpers/AuthHelper.php b/app/Helpers/AuthHelper.php index dca1b01..846ff27 100644 --- a/app/Helpers/AuthHelper.php +++ b/app/Helpers/AuthHelper.php @@ -18,7 +18,7 @@ class AuthHelper extends CommonHelper if (in_array($viewDatas['action'], ['create', 'modify'])) { $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; } - $value = $value ?: DEFAULTS['EMPTY']; + $value = $value ?? DEFAULTS['EMPTY']; switch ($field) { case 'id': case 'passwd': diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php index 9e60161..9a2df28 100644 --- a/app/Helpers/CommonHelper.php +++ b/app/Helpers/CommonHelper.php @@ -184,7 +184,7 @@ class CommonHelper if (in_array($viewDatas['action'], ['create', 'modify'])) { $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; } - $value = $value ?: DEFAULTS['EMPTY']; + $value = $value ?? DEFAULTS['EMPTY']; switch ($field) { case 'email': $form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]); @@ -206,31 +206,32 @@ class CommonHelper } $form = implode(" ", $forms); } else { - $formOptions = array_merge( - ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'], - $viewDatas['field_options'][$field] - ); + $formOptions = ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택']; + foreach ($viewDatas['field_options'][$field] as $key => $label) { + $formOptions[$key] = $label; + } $form = form_dropdown($field, $formOptions, $value, $extras); } break; - case 'status': - if (!is_array($viewDatas['field_options'][$field])) { - echo var_dump($viewDatas['field_options']); - exit; - } - $formOptions = array_merge( - ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'], - $viewDatas['field_options'][$field] - ); - $form = form_dropdown($field, $formOptions, $value, $extras); - break; case 'updated_at': case 'created_at': $extra_class = isset($extras['class']) ? $extras['class'] . ' calender' : 'calender'; $form = form_input($field, $value, ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]); break; default: - $form = form_input($field, $value, ["autocomplete" => $field, ...$extras]); + if (in_array($field, $viewDatas['filter_fields'])) { + if (!is_array($viewDatas['field_options'][$field])) { + echo var_dump($viewDatas['field_options']); + exit; + } + $formOptions = ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택']; + foreach ($viewDatas['field_options'][$field] as $key => $label) { + $formOptions[$key] = $label; + } + $form = form_dropdown($field, $formOptions, $value, $extras); + } else { + $form = form_input($field, $value, ["autocomplete" => $field, ...$extras]); + } break; } return $form; @@ -238,7 +239,7 @@ class CommonHelper public function getFieldView(string $field, array $viewDatas, array $extras = []): string { - $value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; + $value = $viewDatas['entity']->$field ?? DEFAULTS['EMPTY']; switch ($field) { case $this->getTitleField(): $value = form_label( @@ -295,12 +296,10 @@ class CommonHelper } return $value; } - public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'use'): string { return $entity->isMatched($field, $value) ? "" : 'class="table-danger"'; } - public function getListLabel(string $field, array $viewDatas, array $extras = []): string { switch ($field) { diff --git a/app/Helpers/Customer/AccountHelper.php b/app/Helpers/Customer/AccountHelper.php index aa5d47f..d32fa61 100644 --- a/app/Helpers/Customer/AccountHelper.php +++ b/app/Helpers/Customer/AccountHelper.php @@ -13,4 +13,8 @@ class AccountHelper extends CustomerHelper parent::__construct($request); $this->setTitleField(AccountModel::TITLE); } + public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'in'): string + { + return $entity->isMatched($field, $value) ? "" : 'class="table-danger"'; + } } diff --git a/app/Helpers/Customer/ClientHelper.php b/app/Helpers/Customer/ClientHelper.php index eb8946c..bb9cff9 100644 --- a/app/Helpers/Customer/ClientHelper.php +++ b/app/Helpers/Customer/ClientHelper.php @@ -13,60 +13,14 @@ class ClientHelper extends CustomerHelper parent::__construct($request); $this->setTitleField(ClientModel::TITLE); } - public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string - { - if (in_array($viewDatas['action'], ['create', 'modify'])) { - $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; - } - $value = $value ?: DEFAULTS['EMPTY']; - switch ($field) { - case 'email': - $form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]); - break; - case 'phone': - $form = form_input($field, $value, ["placeholder" => "예)010-0010-0010", ...$extras]); - break; - case 'role': - if (!is_array($viewDatas['field_options'][$field])) { - echo var_dump($viewDatas['field_options']); - exit; - } - if (in_array($viewDatas['action'], ['create_form', 'modify_form'])) { - $forms = []; - foreach ($viewDatas['field_options'][$field] as $key => $label) { - $values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value); - $forms[] = form_checkbox("{$field}[]", $key, in_array($key, $values)) . $label; - } - $form = implode(" ", $forms); - } else { - $formOptions = array_merge( - ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'], - $viewDatas['field_options'][$field] - ); - $form = form_dropdown($field, $formOptions, $value, $extras); - } - break; - default: - $form = parent::getFieldForm($field, $value, $viewDatas, $extras); - break; - } - return $form; - } // public function getFieldView(string $field, array $viewDatas, array $extras = []): string { - $value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; + $value = $viewDatas['entity']->$field ?? DEFAULTS['EMPTY']; switch ($field) { - case 'role': - $roles = []; - foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) { - $roles[] = $viewDatas['field_options'][$field][$key]; - } - $value = implode(" , ", $roles); - break; case 'account_balance': case 'coupon_balance': case 'point_balance': - $value = number_format($value); + $value = number_format(intval($value)); break; default: $value = parent::getFieldView($field, $viewDatas, $extras); diff --git a/app/Helpers/Customer/CouponHelper.php b/app/Helpers/Customer/CouponHelper.php index ec87cd0..aa845f4 100644 --- a/app/Helpers/Customer/CouponHelper.php +++ b/app/Helpers/Customer/CouponHelper.php @@ -13,4 +13,8 @@ class CouponHelper extends CustomerHelper parent::__construct($request); $this->setTitleField(CouponModel::TITLE); } + public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'in'): string + { + return $entity->isMatched($field, $value) ? "" : 'class="table-danger"'; + } } diff --git a/app/Helpers/Customer/CustomerHelper.php b/app/Helpers/Customer/CustomerHelper.php index ea8aa04..91a6a4e 100644 --- a/app/Helpers/Customer/CustomerHelper.php +++ b/app/Helpers/Customer/CustomerHelper.php @@ -11,32 +11,4 @@ class CustomerHelper extends CommonHelper { parent::__construct($request); } - public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string - { - if (in_array($viewDatas['action'], ['create', 'modify'])) { - $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; - } - $value = $value ?: DEFAULTS['EMPTY']; - switch ($field) { - case "clientinfo_uid": - if (!is_array($viewDatas['field_options'][$field])) { - echo var_dump($viewDatas['field_options']); - exit; - } - $formOptions = array_merge( - ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'], - $viewDatas['field_options'][$field] - ); - $form = form_dropdown($field, $formOptions, $value, $extras); - break; - default: - $form = parent::getFieldForm($field, $value, $viewDatas, $extras); - break; - } - return $form; - } // - public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'in'): string - { - return $entity->isMatched($field, $value) ? "" : 'class="table-danger"'; - } } diff --git a/app/Helpers/Customer/PointHelper.php b/app/Helpers/Customer/PointHelper.php index e297f66..f851907 100644 --- a/app/Helpers/Customer/PointHelper.php +++ b/app/Helpers/Customer/PointHelper.php @@ -13,4 +13,8 @@ class PointHelper extends CustomerHelper parent::__construct($request); $this->setTitleField(field: PointModel::TITLE); } + public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'in'): string + { + return $entity->isMatched($field, $value) ? "" : 'class="table-danger"'; + } } diff --git a/app/Helpers/Device/DeviceHelper.php b/app/Helpers/Device/DeviceHelper.php index 8d59398..06f200e 100644 --- a/app/Helpers/Device/DeviceHelper.php +++ b/app/Helpers/Device/DeviceHelper.php @@ -16,7 +16,7 @@ class DeviceHelper extends CommonHelper if (in_array($viewDatas['action'], ['create', 'modify'])) { $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; } - $value = $value ?: DEFAULTS['EMPTY']; + $value = $value ?? DEFAULTS['EMPTY']; switch ($field) { case "serverinfo_uid": if (!is_array($viewDatas['field_options'][$field])) { diff --git a/app/Helpers/MyLogHelper.php b/app/Helpers/MyLogHelper.php index a615c34..9763be3 100644 --- a/app/Helpers/MyLogHelper.php +++ b/app/Helpers/MyLogHelper.php @@ -16,7 +16,7 @@ class MyLogHelper extends CommonHelper public function getFieldView(string $field, array $viewDatas, array $extras = []): string { - $value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; + $value = $viewDatas['entity']->$field ?? DEFAULTS['EMPTY']; switch ($field) { case 'content': $value = nl2br($value); diff --git a/app/Helpers/UserHelper.php b/app/Helpers/UserHelper.php index d2e4318..dc02803 100644 --- a/app/Helpers/UserHelper.php +++ b/app/Helpers/UserHelper.php @@ -18,7 +18,7 @@ class UserHelper extends CommonHelper if (in_array($viewDatas['action'], ['create', 'modify'])) { $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; } - $value = $value ?: DEFAULTS['EMPTY']; + $value = $value ?? DEFAULTS['EMPTY']; switch ($field) { case 'passwd': case 'confirmpassword': diff --git a/app/Language/en/Customer/Account.php b/app/Language/en/Customer/Account.php index 2c131cc..42d3c45 100644 --- a/app/Language/en/Customer/Account.php +++ b/app/Language/en/Customer/Account.php @@ -10,6 +10,9 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일", ], + 'DEFAULTS' => [ + 'status' => "in" + ], "STATUS" => [ "in" => "입금", "out" => "출금", diff --git a/app/Language/en/Customer/Client.php b/app/Language/en/Customer/Client.php index 8ce5c1f..fac3caf 100644 --- a/app/Language/en/Customer/Client.php +++ b/app/Language/en/Customer/Client.php @@ -13,6 +13,10 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일", ], + 'DEFAULTS' => [ + 'role' => "user", + 'status' => "use" + ], "ROLE" => [ "user" => "일반회원", "vip" => "VIP회원", diff --git a/app/Language/en/Customer/Coupon.php b/app/Language/en/Customer/Coupon.php index 1c020c6..c06d042 100644 --- a/app/Language/en/Customer/Coupon.php +++ b/app/Language/en/Customer/Coupon.php @@ -9,6 +9,9 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일", ], + 'DEFAULTS' => [ + 'status' => "in" + ], "STATUS" => [ "in" => "추가", "out" => "사용", diff --git a/app/Language/en/Customer/Point.php b/app/Language/en/Customer/Point.php index 94e4039..378d1fb 100644 --- a/app/Language/en/Customer/Point.php +++ b/app/Language/en/Customer/Point.php @@ -9,6 +9,9 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일", ], + 'DEFAULTS' => [ + 'status' => "in" + ], "STATUS" => [ "in" => "입금", "out" => "출금", diff --git a/app/Language/en/MyLog.php b/app/Language/en/MyLog.php index 245e99c..af6165b 100644 --- a/app/Language/en/MyLog.php +++ b/app/Language/en/MyLog.php @@ -12,6 +12,9 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일", ], + 'DEFAULTS' => [ + 'status' => "use" + ], "STATUS" => [ "use" => "완료", "fail" => "실패", diff --git a/app/Language/en/User.php b/app/Language/en/User.php index 19d78ce..b6faecd 100644 --- a/app/Language/en/User.php +++ b/app/Language/en/User.php @@ -14,6 +14,10 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일", ], + 'DEFAULTS' => [ + 'role' => "manager", + 'status' => "use" + ], "ROLE" => [ "manager" => "관리자", "cloudflare" => "Cloudflare관리자", diff --git a/app/Libraries/MySocket/GoogleSocket/GoogleSocket.php b/app/Libraries/MySocket/GoogleSocket/GoogleSocket.php index 4aca207..2f5c755 100644 --- a/app/Libraries/MySocket/GoogleSocket/GoogleSocket.php +++ b/app/Libraries/MySocket/GoogleSocket/GoogleSocket.php @@ -71,7 +71,7 @@ abstract class GoogleSocket extends MySocket } } //상태가 use(승인완료)가 아니라면 - if ($entity->getStatus() !== DEFAULTS['STATUS']) { + if ($entity->getStatus() !== 'use') { throw new PageNotFoundException("{$entity->getSite()}의{$entity->getEmail()}:{$entity->getTitle()}님은 {$entity->status}입니다 "); } return $entity; diff --git a/app/Models/CommonModel.php b/app/Models/CommonModel.php index ed10103..d309ece 100644 --- a/app/Models/CommonModel.php +++ b/app/Models/CommonModel.php @@ -52,7 +52,6 @@ abstract class CommonModel extends Model } abstract public function getFilterFields(): array; abstract public function getBatchJobFields(): array; - abstract public function setList_WordFilter(string $word): void; final public function getTable(): string { return constant("static::TABLE"); @@ -211,18 +210,9 @@ abstract class CommonModel extends Model return $this->save_process($entity); } - //List관련 - final public function setList_FieldFilter(string $field, int|string $value): void + //List 검색용 + public function setList_WordFilter(string $word): void { - $this->where($this->getTable() . '.' . $field, $value); - } - final public function setList_DateFilter(string $start, string $end, $field = "created_at"): void - { - if ($start !== DEFAULTS['EMPTY']) { - $this->where($this->getTable() . ".{$field} >= '{$start} 00:00:00'"); - } - if ($end !== DEFAULTS['EMPTY']) { - $this->where($this->getTable() . ".{$field} <= '{$end} 23:59:59'"); - } + $this->orLike($this->getTable() . "." . $this->getTitleField(), $word, 'both'); } } diff --git a/app/Models/Customer/AccountModel.php b/app/Models/Customer/AccountModel.php index fd56065..ae86274 100644 --- a/app/Models/Customer/AccountModel.php +++ b/app/Models/Customer/AccountModel.php @@ -39,7 +39,7 @@ class AccountModel extends CustomerModel switch ($field) { case "clientinfo_uid": case "amount": - $rule = "required|number"; + $rule = "required|numeric"; break; case "title": case "alias": @@ -54,11 +54,10 @@ class AccountModel extends CustomerModel } return $rule; } - //List 검색용 public function setList_WordFilter(string $word): void { - $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); $this->orLike(self::TABLE . '.alias', $word, 'both'); + parent::setList_WordFilter($word); } } diff --git a/app/Models/Customer/ClientModel.php b/app/Models/Customer/ClientModel.php index 49f939a..4b33cfc 100644 --- a/app/Models/Customer/ClientModel.php +++ b/app/Models/Customer/ClientModel.php @@ -67,7 +67,7 @@ class ClientModel extends CustomerModel //List 검색용 public function setList_WordFilter(string $word): void { - $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); $this->orLike(self::TABLE . '.email', $word, 'both'); + parent::setList_WordFilter($word); } } diff --git a/app/Models/Customer/CouponModel.php b/app/Models/Customer/CouponModel.php index acae44b..287c829 100644 --- a/app/Models/Customer/CouponModel.php +++ b/app/Models/Customer/CouponModel.php @@ -38,7 +38,7 @@ class CouponModel extends CustomerModel switch ($field) { case "clientinfo_uid": case "amount": - $rule = "required|number"; + $rule = "required|numeric"; break; case "title": $rule = "required|trim|string"; @@ -52,11 +52,4 @@ class CouponModel extends CustomerModel } return $rule; } - - //List 검색용 - public function setList_WordFilter(string $word): void - { - $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); - $this->orLike(self::TABLE . '.alias', $word, 'both'); - } } diff --git a/app/Models/Customer/PointModel.php b/app/Models/Customer/PointModel.php index 075dff5..69e620c 100644 --- a/app/Models/Customer/PointModel.php +++ b/app/Models/Customer/PointModel.php @@ -38,7 +38,7 @@ class PointModel extends CustomerModel switch ($field) { case "clientinfo_uid": case "amount": - $rule = "required|number"; + $rule = "required|numeric"; break; case "title": $rule = "required|trim|string"; @@ -52,11 +52,4 @@ class PointModel extends CustomerModel } return $rule; } - - //List 검색용 - public function setList_WordFilter(string $word): void - { - $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); - $this->orLike(self::TABLE . '.alias', $word, 'both'); - } } diff --git a/app/Models/Device/IpModel.php b/app/Models/Device/IpModel.php index fbf70d2..271cc7a 100644 --- a/app/Models/Device/IpModel.php +++ b/app/Models/Device/IpModel.php @@ -38,7 +38,7 @@ class IpModel extends DeviceModel switch ($field) { case "clientinfo_uid": case "amount": - $rule = "required|number"; + $rule = "required|numeric"; break; case "title": $rule = "required|trim|string"; @@ -52,11 +52,4 @@ class IpModel extends DeviceModel } return $rule; } - - //List 검색용 - public function setList_WordFilter(string $word): void - { - $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); - $this->orLike(self::TABLE . '.alias', $word, 'both'); - } } diff --git a/app/Models/Device/LineModel.php b/app/Models/Device/LineModel.php index acdd366..6b379c8 100644 --- a/app/Models/Device/LineModel.php +++ b/app/Models/Device/LineModel.php @@ -38,7 +38,7 @@ class LineModel extends DeviceModel switch ($field) { case "clientinfo_uid": case "amount": - $rule = "required|number"; + $rule = "required|numeric"; break; case "title": $rule = "required|trim|string"; @@ -52,11 +52,4 @@ class LineModel extends DeviceModel } return $rule; } - - //List 검색용 - public function setList_WordFilter(string $word): void - { - $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); - $this->orLike(self::TABLE . '.alias', $word, 'both'); - } } diff --git a/app/Models/Device/NetworkModel.php b/app/Models/Device/NetworkModel.php index ce0f9b8..db92f91 100644 --- a/app/Models/Device/NetworkModel.php +++ b/app/Models/Device/NetworkModel.php @@ -38,7 +38,7 @@ class NetworkModel extends DeviceModel switch ($field) { case "clientinfo_uid": case "amount": - $rule = "required|number"; + $rule = "required|numeric"; break; case "title": $rule = "required|trim|string"; @@ -52,11 +52,4 @@ class NetworkModel extends DeviceModel } return $rule; } - - //List 검색용 - public function setList_WordFilter(string $word): void - { - $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); - $this->orLike(self::TABLE . '.alias', $word, 'both'); - } } diff --git a/app/Models/Device/PartModel.php b/app/Models/Device/PartModel.php index c8f1c15..f3908d7 100644 --- a/app/Models/Device/PartModel.php +++ b/app/Models/Device/PartModel.php @@ -38,7 +38,7 @@ class PartModel extends DeviceModel switch ($field) { case "clientinfo_uid": case "amount": - $rule = "required|number"; + $rule = "required|numeric"; break; case "title": $rule = "required|trim|string"; @@ -52,11 +52,4 @@ class PartModel extends DeviceModel } return $rule; } - - //List 검색용 - public function setList_WordFilter(string $word): void - { - $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); - $this->orLike(self::TABLE . '.alias', $word, 'both'); - } } diff --git a/app/Models/Device/RackModel.php b/app/Models/Device/RackModel.php index 0479425..47e8d3f 100644 --- a/app/Models/Device/RackModel.php +++ b/app/Models/Device/RackModel.php @@ -38,7 +38,7 @@ class RackModel extends DeviceModel switch ($field) { case "clientinfo_uid": case "amount": - $rule = "required|number"; + $rule = "required|numeric"; break; case "title": $rule = "required|trim|string"; @@ -52,11 +52,4 @@ class RackModel extends DeviceModel } return $rule; } - - //List 검색용 - public function setList_WordFilter(string $word): void - { - $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); - $this->orLike(self::TABLE . '.alias', $word, 'both'); - } } diff --git a/app/Models/Device/ServerModel.php b/app/Models/Device/ServerModel.php index 452a346..6438264 100644 --- a/app/Models/Device/ServerModel.php +++ b/app/Models/Device/ServerModel.php @@ -38,7 +38,7 @@ class ServerModel extends DeviceModel switch ($field) { case "clientinfo_uid": case "amount": - $rule = "required|number"; + $rule = "required|numeric"; break; case "title": $rule = "required|trim|string"; @@ -52,11 +52,4 @@ class ServerModel extends DeviceModel } return $rule; } - - //List 검색용 - public function setList_WordFilter(string $word): void - { - $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); - $this->orLike(self::TABLE . '.alias', $word, 'both'); - } } diff --git a/app/Models/Device/SoftwareModel.php b/app/Models/Device/SoftwareModel.php index ae50981..26483f3 100644 --- a/app/Models/Device/SoftwareModel.php +++ b/app/Models/Device/SoftwareModel.php @@ -38,7 +38,7 @@ class SoftwareModel extends DeviceModel switch ($field) { case "clientinfo_uid": case "amount": - $rule = "required|number"; + $rule = "required|numeric"; break; case "title": $rule = "required|trim|string"; @@ -52,11 +52,4 @@ class SoftwareModel extends DeviceModel } return $rule; } - - //List 검색용 - public function setList_WordFilter(string $word): void - { - $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); - $this->orLike(self::TABLE . '.alias', $word, 'both'); - } } diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php index 378e3f5..8b22868 100644 --- a/app/Services/CommonService.php +++ b/app/Services/CommonService.php @@ -72,6 +72,9 @@ abstract class CommonService foreach ($this->getModel()->select(implode(',', $columns))->findAll() as $entity) { $entitys[$entity->getPK()] = $entity; } + if (env('app.debug.index')) { + echo $this->getModel()->getLastQuery(); + } return $entitys; } // //FieldForm관련용 diff --git a/app/Services/Customer/ClientService.php b/app/Services/Customer/ClientService.php index faae700..6ea8f27 100644 --- a/app/Services/Customer/ClientService.php +++ b/app/Services/Customer/ClientService.php @@ -2,9 +2,10 @@ namespace App\Services\Customer; +use CodeIgniter\HTTP\IncomingRequest; + use App\Entities\Customer\ClientEntity; use App\Models\Customer\ClientModel; -use CodeIgniter\HTTP\IncomingRequest; class ClientService extends CustomerService { @@ -26,7 +27,7 @@ class ClientService extends CustomerService { return new ClientEntity(); } - public function create(array $formDatas, mixed $entity = null): ClientEntity + public function create(array $formDatas, mixed $entity = new ClientEntity()): ClientEntity { $formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']); return parent::create($formDatas, $entity ?? new ClientEntity()); diff --git a/app/Services/Customer/CustomerService.php b/app/Services/Customer/CustomerService.php index 4e204bf..3edbdfb 100644 --- a/app/Services/Customer/CustomerService.php +++ b/app/Services/Customer/CustomerService.php @@ -5,15 +5,11 @@ namespace App\Services\Customer; use App\Services\CommonService; use CodeIgniter\HTTP\IncomingRequest; -use App\Services\Customer\AccountService; -use App\Services\Customer\CouponService; -use App\Services\Customer\PointService; +use App\Services\Customer\ClientService; abstract class CustomerService extends CommonService { - private ?AccountService $_accountService = null; - private ?CouponService $_couponService = null; - private ?PointService $_pointService = null; + private ?ClientService $_clientService = null; public function __construct(?IncomingRequest $request = null) { parent::__construct($request); @@ -23,25 +19,11 @@ abstract class CustomerService extends CommonService return "Customer"; } - final public function getAccountService(): AccountService + final public function getClientService(): ClientService { - if (!$this->_accountService) { - $this->_accountService = new AccountService($this->getRequest()); + if (!$this->_clientService) { + $this->_clientService = new ClientService($this->request); } - return $this->_accountService; - } - final public function getCouponService(): CouponService - { - if (!$this->_couponService) { - $this->_couponService = new CouponService($this->getRequest()); - } - return $this->_couponService; - } - final public function getPointService(): PointService - { - if (!$this->_pointService) { - $this->_pointService = new PointService($this->getRequest()); - } - return $this->_pointService; + return $this->_clientService; } } diff --git a/app/Services/UserService.php b/app/Services/UserService.php index e1b4406..4f31a4a 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -25,10 +25,6 @@ class UserService extends CommonService { return new UserEntity(); } - public function getFields(): array - { - return ['id', 'passwd', 'confirmpassword', $this->getModel()::TITLE, 'email', 'mobile', 'role']; - } public function create(array $formDatas, mixed $entity = null): UserEntity { $formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']); diff --git a/app/Views/admin/create_form.php b/app/Views/admin/create_form.php index 5af7c31..0dfe5ab 100644 --- a/app/Views/admin/create_form.php +++ b/app/Views/admin/create_form.php @@ -18,7 +18,7 @@
"btn btn-outline btn-primary")); ?>
- has('error')): ?>
+ has('error')): ?>
endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/modify_form.php b/app/Views/admin/modify_form.php index 50b79e6..8e278dc 100644 --- a/app/Views/admin/modify_form.php +++ b/app/Views/admin/modify_form.php @@ -18,7 +18,7 @@
"btn btn-outline btn-primary"]) ?>
- has('error')): ?>
+ has('error')): ?>
endSection() ?> \ No newline at end of file diff --git a/app/Views/auth/login_form.php b/app/Views/auth/login_form.php index c93b806..0f1b2cf 100644 --- a/app/Views/auth/login_form.php +++ b/app/Views/auth/login_form.php @@ -18,7 +18,7 @@
- has('error')): ?>
+ has('error')): ?>
\ No newline at end of file