From ef9f4d1ea99c121790f20bd447b43b17168f455c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Sun, 9 Nov 2025 00:10:01 +0900 Subject: [PATCH] trafficmonitor init...2 --- app/Config/Constants.php | 13 +- app/Controllers/Admin/AdminController.php | 175 ++++++++++-------- app/Controllers/Admin/Home.php | 80 +------- app/Controllers/Admin/TrafficController.php | 2 +- app/Controllers/Admin/UserController.php | 3 - app/Controllers/CommonController.php | 17 +- app/DTOs/CertificationDTO.php | 37 ---- app/DTOs/CommonDTO.php | 13 ++ app/DTOs/UserDTO.php | 9 + app/Forms/CommonForm.php | 8 +- app/Helpers/CommonHelper.php | 40 ++-- app/Helpers/HomeHelper.php | 2 +- app/Helpers/UserHelper.php | 8 +- .../MySocket/GoogleSocket/GoogleSocket.php | 2 +- app/Services/Auth/AuthService.php | 1 + app/Services/CommonService.php | 3 +- app/Services/TrafficService.php | 2 +- app/Views/admin/create_form.php | 10 +- app/Views/admin/download.php | 4 +- app/Views/admin/index.php | 30 +-- app/Views/admin/modify_form.php | 8 +- app/Views/admin/popup/create_form.php | 10 +- app/Views/admin/popup/index.php | 20 +- app/Views/admin/popup/modify_form.php | 8 +- app/Views/admin/popup/view.php | 6 +- app/Views/admin/user/create_form.php | 12 +- app/Views/admin/user/download.php | 4 +- app/Views/admin/user/index.php | 43 ++--- app/Views/admin/user/modify_form.php | 12 +- app/Views/admin/user/view.php | 6 +- app/Views/admin/view.php | 6 +- app/Views/admin/welcome/index.php | 20 +- app/Views/layouts/admin.php | 12 +- app/Views/layouts/admin/left_menu.php | 10 +- app/Views/layouts/admin/left_menu/base.php | 1 + app/Views/layouts/admin/left_menu/board.php | 14 -- .../layouts/admin/left_menu/customer.php | 17 -- .../layouts/admin/left_menu/equipment.php | 14 -- app/Views/layouts/admin/left_menu/part.php | 29 --- app/Views/layouts/admin/top.php | 126 ++----------- app/Views/layouts/empty.php | 12 +- app/Views/layouts/front.php | 12 +- .../templates/admin/form_content_top.php | 4 +- .../templates/admin/index_content_bottom.php | 14 +- .../templates/admin/index_content_filter.php | 8 +- .../templates/admin/index_content_top.php | 8 +- app/Views/templates/admin/index_footer.php | 2 +- app/Views/templates/admin/index_header.php | 47 +---- app/Views/templates/common/modal_iframe.php | 2 +- 49 files changed, 328 insertions(+), 618 deletions(-) delete mode 100644 app/DTOs/CertificationDTO.php delete mode 100644 app/Views/layouts/admin/left_menu/board.php delete mode 100644 app/Views/layouts/admin/left_menu/customer.php delete mode 100644 app/Views/layouts/admin/left_menu/equipment.php delete mode 100644 app/Views/layouts/admin/left_menu/part.php diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 4a5a932..7d5ca57 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -78,11 +78,6 @@ defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code -//Default값 정의 -define('DEFAULTS', [ - 'DELIMITER_FILE' => "||", - 'DELIMITER_ROLE' => "," -]); define('MESSAGES', [ 'CREATED' => '생성되었습니다.', 'UPDATED' => '수정되였습니다.', @@ -397,3 +392,11 @@ define("ROLE", [ ], 'CLIENT' => [], ]); + +//Default값 정의 +define('DEFAULTS', [ + 'DELIMITER_FILE' => "||", + 'DELIMITER_ROLE' => ",", + 'INDEX_PERPAGE' => 20, + 'STATUS' => STATUS['AVAILABLE'] +]); diff --git a/app/Controllers/Admin/AdminController.php b/app/Controllers/Admin/AdminController.php index 1120a0a..1cc2cfc 100644 --- a/app/Controllers/Admin/AdminController.php +++ b/app/Controllers/Admin/AdminController.php @@ -25,9 +25,33 @@ abstract class AdminController extends CommonController } final protected function getLayout(): string { - return self::PATH; + return 'admin'; + } + protected function action_init_process(string $action): void + { + parent::action_init_process($action); + $this->addViewDatas('layout', $this->getLayout()); + $this->addViewDatas('helper', $this->service->getHelper($action, $this->getViewDatas())); + switch ($action) { + case 'create_form': + case 'create': + case 'modify_form': + case 'modify': + case 'view': + $formFields = $this->service->getFormService()->getFormFields($action); + $this->addViewDatas('formFields', $formFields); + break; + default: + $formField = $this->service->getFormService()->getIndexFields($action); + $this->addViewDatas('indexFields', $formField); + break; + } + $this->addViewDatas('formFilters', $this->service->getFormService()->getFormFilters($action)); + $this->addViewDatas('formRules', $this->service->getFormService()->getFormRules($action, $formFields)); + $this->addViewDatas('formOptions', $this->service->getFormService()->getFormOptions($action, $formFields)); + $this->addViewDatas('batchjobFields', $this->service->getFormService()->getBatchjobFields($action)); + $this->addViewDatas('batchjobButtons', $this->service->getFormService()->getBatchjobButtons($action)); } - protected function create_form_process(array $formDatas = []): array { return $formDatas; @@ -106,11 +130,11 @@ abstract class AdminController extends CommonController } //리스트관련 //조건절 처리 - protected function index_condition_process(): void + protected function index_condition_process(string $action): void { //Filter조건절 처리 $index_filters = []; - foreach ($this->service->getFormFilters() as $field) { + foreach ($this->service->getFormService()->getFormFilters($action) as $field) { $value = $this->request->getVar($field) ?? null; if ($value) { $this->service->index_condition_filterField($field, $value); @@ -133,76 +157,77 @@ abstract class AdminController extends CommonController $this->addViewDatas('index_start', $index_start); $this->addViewDatas('index_end', $index_end); } - // //PageNation 처리 - // protected function index_pagenation_process($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); - // // 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', 추가 - // $pager = service("pager"); - // $pager->makeLinks($this->page, $this->per_page, $this->total_count, $template, $segment, $pager_group); - // $this->page = $pager->getCurrentPage($pager_group); - // $this->total_page = $pager->getPageCount($pager_group); - // return $pager->links($pager_group, $template); - // } + //Index Option출력용 + protected function index_pagenation_options_process(int $index_totalcount, int $index_perpage): array + { + $index_page_options = ["" => "줄수선택"]; + for ($i = $index_perpage; $i <= $index_totalcount; $i += $index_perpage) { + $index_page_options[$i] = $i; + } + $index_page_options[$index_totalcount] = $index_totalcount; + return $index_page_options; + } + //PageNation 처리 + protected function index_pagenation_process(int $index_totalcount, int $page, int $perpage, $pager_group = 'default', int $segment = 0, $template = 'bootstrap_full'): mixed + { + // 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', 추가 + $pager = service("pager"); + $pager->makeLinks($page, $perpage, $index_totalcount, $template, $segment, $pager_group); + // $index_page = $pager->getCurrentPage($pager_group); + $this->addViewDatas('index_totalpage', $pager->getPageCount($pager_group)); + return $pager->links($pager_group, $template); + } // //Page출력 처리 - // protected function index_pageOptions_process(): array - // { - // $page_options = ["" => "줄수선택"]; - // for ($i = $this->per_page; $i <= $this->total_count; $i += $this->per_page) { - // $page_options[$i] = $i; - // } - // $page_options[$this->total_count] = $this->total_count; - // return $page_options; - // } - // //Entities처리 - // protected function index_process(array $entities = []): array - // { - // foreach ($this->service->getEntities() as $entity) { - // $entities[] = $entity; - // } - // return $entities; - // } - // public function index(): RedirectResponse|string - // { - // try { - // $this->service->setAction(__FUNCTION__); - // $this->service->setFormFields(); - // //전달값정의 - // $this->service->setFormDatas($this->request->getGet()); - // $this->service->setFormFilters(); - // $this->service->setFormRules(); - // $this->service->setFormOptions(); - // //일괄작업용 Fields정의 - // $this->service->setControlDatas('batchjob_fields', $this->service->getBatchjobFields()); - // //일괄작업용 버튼정의 - // $this->service->setControlDatas('batchjob_buttions', $this->service->getBatchjobButtons()); - // helper(['form']); - // //Return Url정의 - // $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : "")); - // //조건절 처리 - // $this->index_condition_process(); - // //TotalCount (SoftDelete적용이 되려면 countAllResults를 사용해야함) - // $this->total_count = $this->service->getTotalCount(); - // //Pagination 처리 - // $this->pagination = $this->index_pagenation_process(); - // //줄수 처리용 - // $this->page_options = $this->index_pageOptions_process(); - // //조건절 처리 - // //OrcerBy , Limit 처리 - // $this->order_field = $this->request->getVar('order_field'); - // $this->order_value = $this->request->getVar('order_value'); - // $this->service->setOrderBy($this->order_field, $this->order_value); - // $this->service->setLimit($this->per_page); - // $this->service->setOffset(($this->page - 1) * $this->per_page); - // $this->index_condition_process(); - // $this->entities = $this->index_process(); - // return $this->getResultSuccess(); - // } catch (\Exception $e) { - // return $this->getResultFail($e->getMessage()); - // } - // } + //Entities처리 + protected function index_process(array $entities = []): array + { + foreach ($this->service->getEntities() as $entity) { + $entities[] = $entity; + } + return $entities; + } + public function index(): string + { + $action = __FUNCTION__; + try { + //초기화 + $this->action_init_process($action); + $this->addViewDatas('uri', $this->request->getUri()); + //Page, Per_page필요부분 + $index_page = (int) $this->request->getVar('index_page') ?: 1; + $index_perpage = (int) $this->request->getVar('index_perpage') ?: intval(DEFAULTS['INDEX_PERPAGE']); + $this->addViewDatas('index_page', $index_page); + $this->addViewDatas('index_perpage', $index_perpage); + //index_totalcount + //조건절 처리 index_totalcount용 + $this->index_condition_process($action); + $index_totalcount = $this->service->getindex_totalcount(); + $this->addViewDatas('index_totalcount', $index_totalcount); + $this->addViewDatas('index_pagination', $this->index_pagenation_process($index_totalcount, $index_page, $index_perpage)); + $this->addViewDatas('index_pagination_options', $this->index_pagenation_options_process($index_totalcount, $index_perpage)); + //OrcerBy , Limit 처리 + $order_field = $this->request->getVar('order_field'); + $order_value = $this->request->getVar('order_value'); + $this->service->setOrderBy($order_field, $order_value); + $this->addViewDatas('order_field', $order_field); + $this->addViewDatas('order_value', $order_value); + $this->service->setLimit($index_page); + $this->service->setOffset(($index_page - 1) * $index_perpage); + //List + //조건절 처리 List용 + $this->index_condition_process($action); + $this->addViewDatas('entities', $this->index_process()); + helper(['form']); + $this->addViewDatas('formDatas', $this->request->getGet()); + $this->addViewDatas('index_batchjobFields', $this->service->getFormService()->getBatchjobFields()); + $this->addViewDatas('index_batchjobButtions', $this->service->getFormService()->getBatchjobButtons()); + } catch (\Exception $e) { + session()->setFlashdata('message', $e->getMessage()); + } + //현재 URL을 세션에 저장 + $this->getAuthContext()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : "")); + return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas()); + } } diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php index 095c127..7e38e75 100644 --- a/app/Controllers/Admin/Home.php +++ b/app/Controllers/Admin/Home.php @@ -2,88 +2,24 @@ namespace App\Controllers\Admin; -use App\Services\BoardService; -use App\Services\Customer\ServiceService; -use CodeIgniter\HTTP\RedirectResponse; -use CodeIgniter\HTTP\RequestInterface; -use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use CodeIgniter\HTTP\ResponseInterface; +use CodeIgniter\HTTP\RequestInterface; +use App\Controllers\CommonController; -class Home extends AdminController +class Home extends CommonController { - private $_service = null; - private ?BoardService $_boardService = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); - $this->content_title = lang("{$this->getService()->getClassPath()}.title"); - $this->class_path .= $this->getService()->getClassPath(); - $this->uri_path .= strtolower($this->getService()->getClassPath('/')) . '/'; - $this->view_path .= 'welcome' . DIRECTORY_SEPARATOR; } - - final public function getService(): ServiceService + final protected function getLayout(): string { - if (!$this->_service) { - $this->_service = new ServiceService(); - } - return $this->_service; + return 'empty'; } - final public function getBoardService(): BoardService - { - if (!$this->_boardService) { - $this->_boardService = new BoardService(); - } - return $this->_boardService; - } - protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string - { - switch ($this->getService()->getAction()) { - case 'index': - $this->service = $this->getService(); - $this->control = $this->getService()->getControlDatas(); - $this->getService()->getHelper()->setViewDatas($this->getViewDatas()); - $actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate; - if ($actionTemplate) { - $view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getService()->getAction(); - } else { - $view_file = $this->view_path . $this->getService()->getAction(); - } - $result = view($view_file, ['viewDatas' => $this->getViewDatas()]); - break; - default: - $result = parent::getResultSuccess($message, $actionTemplate); - } - return $result; - } - - //Index,FieldForm관련 - public function index(): RedirectResponse|string + public function index(): string { - $this->getService()->setAction(__FUNCTION__); - //기본전달값정의 - $this->getService()->setFormDatas($this->request->getGet()); - $this->getService()->setFormFields(); - $this->getService()->setFormFilters(); - $this->getService()->setFormRules(); - $this->getService()->setFormOptions(); - //요청업무 - $this->boardRequestTaskCount = $this->getBoardService()->getRequestTaskCount($this->getMyAuth()->getUIDByAuthInfo()); - //Total 서버 현황 - //interval을 기준으로 최근 신규 서비스정보 가져오기 - $this->interval = intval($this->request->getVar('interval') ?? SERVICE['NEW_INTERVAL']); - $this->newServiceEntities = $this->getService()->getNewServiceEntities($this->interval); - $this->newServiceCount = count($this->newServiceEntities); - //서비스별 미납 Count - $unPaidTotalCount = $unPaidTotalAmount = 0; - foreach (array_values($this->getService()->getPaymentService()->getUnPaids('serviceinfo_uid')) as $unPaid) { - $unPaidTotalCount += $unPaid['cnt']; - $unPaidTotalAmount += $unPaid['amount']; - } - $this->unPaidTotalCount = $unPaidTotalCount; - $this->unPaidTotalAmount = $unPaidTotalAmount; - helper(['form']); - return $this->getResultSuccess(); + return "준비중..."; } } diff --git a/app/Controllers/Admin/TrafficController.php b/app/Controllers/Admin/TrafficController.php index 37c59bf..4699477 100644 --- a/app/Controllers/Admin/TrafficController.php +++ b/app/Controllers/Admin/TrafficController.php @@ -36,7 +36,7 @@ class TrafficController extends CommonController $formDatas['type'] = 'normal'; $formDatas['billing_at'] = date("Y-m-d"); $formDatas['start_at'] = date("Y-m-d"); - $formDatas['status'] = TrafficEntity::DEFAULT_STATUS; + $formDatas['status'] = DEFAULTS['STATUS']; //viewData처리 $this->action = __FUNCTION__; $this->formFields = $this->service->getFormFields(); diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index d45421a..deb1998 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -6,11 +6,8 @@ use App\DTOs\UserDTO; use App\Entities\UserEntity; use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; - use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\Validation\Validation; use Psr\Log\LoggerInterface; -use App\Services\UserService; class UserController extends AdminController { diff --git a/app/Controllers/CommonController.php b/app/Controllers/CommonController.php index efeb721..8d839e7 100644 --- a/app/Controllers/CommonController.php +++ b/app/Controllers/CommonController.php @@ -16,11 +16,9 @@ abstract class CommonController extends BaseController private array $_action_paths = []; private array $_viewDatas = []; protected $service = null; - protected $myCertification = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); - $this->myCertification = CertificationDTO::byAuthContext($this->getAuthContext()); } final protected function getAuthContext(): AuthContext { @@ -46,10 +44,6 @@ abstract class CommonController extends BaseController return $this->_viewDatas[$key] ?? null; } //공통 필수기능 - protected function getLayout(): string - { - return 'empty'; - } protected function doValidation(string $action): array { $dynamicRules = []; @@ -77,13 +71,8 @@ abstract class CommonController extends BaseController protected function action_init_process(string $action): void { $this->addViewDatas('action', $action); - $this->addViewDatas('myCertification', $this->myCertification); - $this->addViewDatas('layout', $this->getLayout()); - $this->addViewDatas('helper', $this->service->getHelper($action, $this->getViewDatas())); - $this->addViewDatas('formFields', $this->service->getFormService()->getFormFields($action)); - $this->addViewDatas('formFilters', $this->service->getFormService()->getFormFilters($action)); - $this->addViewDatas('formRules', $this->service->getFormService()->getFormRules($action)); - $this->addViewDatas('formOptions', $this->service->getFormService()->getFormOptions($action)); + $this->addViewDatas('authContext', $this->getAuthContext()); + $this->addViewDatas('classPath', $this->service->getClassPaths(false)); } protected function action_render_process(array $view_paths, string $view_file, array $viewDatas): string { @@ -100,7 +89,7 @@ abstract class CommonController extends BaseController $view_file ]); $view_datas = [ - 'control' => $viewDatas, + ...$viewDatas, 'forms' => ['attributes' => ['method' => "post",], 'hiddens' => []], ]; helper(['form', __FUNCTION__]); diff --git a/app/DTOs/CertificationDTO.php b/app/DTOs/CertificationDTO.php deleted file mode 100644 index 01795c7..0000000 --- a/app/DTOs/CertificationDTO.php +++ /dev/null @@ -1,37 +0,0 @@ - $value) { - if (property_exists($this, $key)) { - $this->{$key} = $value; - } - } - } - //인증 정보 - public static function byAuthContext(AuthContext $authContext): self - { - return new self( - [ - 'isLogin' => $authContext->isLoggedIn(), - 'uid' => $authContext->getUID(), - 'name' => $authContext->getName(), - 'role' => $authContext->getRole(), //배열(array|null)을 반환합니다. - ] - ); - } -} diff --git a/app/DTOs/CommonDTO.php b/app/DTOs/CommonDTO.php index ca4c90e..9d4eeca 100644 --- a/app/DTOs/CommonDTO.php +++ b/app/DTOs/CommonDTO.php @@ -5,4 +5,17 @@ namespace App\DTOs; abstract class CommonDTO { public function __construct() {} + + public function __get(string $name) + { + // 1. 속성이 클래스에 실제로 존재하는지 확인 + if (property_exists($this, $name)) { + // 2. 속성이 존재하면 값을 반환 (PHP 7.4 이상의 타입 속성 덕분에 null 병합 연산자 사용 불필요) + return $this->{$name}; + } + // 3. 속성이 존재하지 않으면 오류 발생 (일반적인 Entity/DTO 접근 방식) + throw new \BadMethodCallException( + "Undefined property or method: " . static::class . "::{$name}" + ); + } } diff --git a/app/DTOs/UserDTO.php b/app/DTOs/UserDTO.php index fcdf344..3471668 100644 --- a/app/DTOs/UserDTO.php +++ b/app/DTOs/UserDTO.php @@ -28,6 +28,15 @@ class UserDTO extends CommonDTO } } } + public function __get(string $name) + { + // 'role' 속성을 요청했을 때만 특별히 처리 + if ($name === 'role' && is_string($this->role)) { + return explode(DEFAULTS["DELIMITER_ROLE"], $this->role); + } + return parent::__get($name); + } + public function toArray(): array { return [ diff --git a/app/Forms/CommonForm.php b/app/Forms/CommonForm.php index 818c808..a264343 100644 --- a/app/Forms/CommonForm.php +++ b/app/Forms/CommonForm.php @@ -21,16 +21,16 @@ abstract class CommonForm } return $this->_attributes[$key]; } - final public function getFormRules(string $action, array $rules = [], ?array $fields = null): array + final public function getFormRules(string $action, array $fields, array $rules = []): array { - foreach ($fields ?? $this->getFormFields($action) as $field) { + foreach ($fields as $field) { $rules = $this->getFormRule($action, $field, $rules); } return $rules; } - final public function getFormOptions(string $action, array $options = [], ?array $fields = null): array + final public function getFormOptions(string $action, array $fields, array $options = []): array { - foreach ($fields ?? $this->getFormFilters($action) as $field) { + foreach ($fields as $field) { $options = $this->getFormOption($action, $field, $options); } return $options; diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php index 7bdaee4..7d675ab 100644 --- a/app/Helpers/CommonHelper.php +++ b/app/Helpers/CommonHelper.php @@ -25,7 +25,7 @@ class CommonHelper final public function form_dropdown_common(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = [], bool $isAll = false): string { // 필터 옵션이 없으면 빈 배열로 초기화 - if (!array_key_exists($field, $viewDatas['control']['formOptions'])) { + if (!array_key_exists($field, $viewDatas['formOptions'])) { return ""; // 필터 옵션이 없으면 빈 문자열 반환 } $extra = ""; @@ -45,13 +45,13 @@ class CommonHelper $html = ""; switch ($field) { default: - foreach ($viewDatas['control']['formOptions'][$field] as $option_key => $option_value) { + foreach ($viewDatas['formOptions'][$field] as $option_key => $option_value) { $isSelected = $option_key == $value ? ' selected' : ''; $isDisabled = ""; $attribute = ""; $label = ""; if ($option_value instanceof CommonEntity) { - if ($option_key != $value && $option_value->getStatus() != $option_value::DEFAULT_STATUS && !$isAll) { + if ($option_key != $value && $option_value->getStatus() != DEFAULTS['STATUS'] && !$isAll) { continue; } foreach ($attributes as $attribute_name => $attribute_value) { @@ -71,8 +71,9 @@ class CommonHelper { switch ($field) { default: + dd($viewDatas['formRules']); // required가 있으면 class 추가 - $extras = (strpos($viewDatas['control']['formRules'][$field], 'required') !== false) ? ["class" => "text-danger", "required" => "", ...$extras] : $extras; + $extras = (strpos($viewDatas['formRules'][$field], 'required') !== false) ? ["class" => "text-danger", "required" => "", ...$extras] : $extras; $label = $label ?: form_label(lang("{$this->getAttribute('class_path')}.label.{$field}"), $field, ['class' => 'form-label-sm', ...$extras]); break; } @@ -99,13 +100,13 @@ class CommonHelper ]); break; case 'role': - if (!is_array($viewDatas['control']['formOptions'][$field])) { + if (!is_array($viewDatas['formOptions'][$field])) { throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다."); } // create, modify, create_form, modify_form일때 checkbox로 표시 - if (in_array($viewDatas['control']['action'], ['create_form', 'modify_form'])) { + if (in_array($viewDatas['action'], ['create_form', 'modify_form'])) { $forms = []; - foreach ($viewDatas['control']['formOptions'][$field] as $key => $label) { + foreach ($viewDatas['formOptions'][$field] as $key => $label) { if ($key !== '') { // 빈값은 제외 $values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value); //form_check에는 "class" => "form-control" 쓰면 않되거나 form-check를 써야함 @@ -140,7 +141,7 @@ class CommonHelper ]); break; default: - if (in_array($field, $viewDatas['control']['formFilters'])) { + if (in_array($field, $viewDatas['formFilters'])) { if (str_contains($field, "_uid")) { $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; } @@ -160,14 +161,14 @@ class CommonHelper { switch ($field) { case 'clientinfo_uid': - if (array_key_exists($value, $viewDatas['control']['formOptions'][$field])) { - $value = "" . $viewDatas['control']['formOptions'][$field][$value]->getTitle() . ""; + if (array_key_exists($value, $viewDatas['formOptions'][$field])) { + $value = "" . $viewDatas['formOptions'][$field][$value]->getTitle() . ""; } break; case 'role': $roles = []; - foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) { - $roles[] = $viewDatas['control']['formOptions'][$field][$key] ?? ""; + foreach ($value as $key) { + $roles[] = $viewDatas['formOptions'][$field][$key] ?? ""; } $value = implode(" , ", $roles); break; @@ -175,7 +176,7 @@ class CommonHelper case 'content': case 'detail': case 'history': - if (in_array($viewDatas['control']['action'], ['view', 'index'])) { + if (in_array($viewDatas['action'], ['view', 'index'])) { $value = html_entity_decode($value, ENT_QUOTES, 'UTF-8'); } break; @@ -190,11 +191,11 @@ class CommonHelper $value = $value ? date("Y-m-d", strtotime($value)) : ""; break; default: - if (in_array($field, $viewDatas['control']['formFilters'])) { + if (in_array($field, $viewDatas['formFilters'])) { if (str_contains($field, "_uid")) { - $value = array_key_exists($value, $viewDatas['control']['formOptions'][$field]) && $viewDatas['control']['formOptions'][$field][$value] ? $viewDatas['control']['formOptions'][$field][$value]->getTitle() : ""; + $value = array_key_exists($value, $viewDatas['formOptions'][$field]) && $viewDatas['formOptions'][$field][$value] ? $viewDatas['formOptions'][$field][$value]->getTitle() : ""; } else { - $value = array_key_exists($value, $viewDatas['control']['formOptions'][$field]) ? $viewDatas['control']['formOptions'][$field][$value] : ""; + $value = array_key_exists($value, $viewDatas['formOptions'][$field]) ? $viewDatas['formOptions'][$field][$value] : ""; } } break; @@ -208,7 +209,7 @@ class CommonHelper { switch ($field) { default: - if (in_array($field, $viewDatas['control']['formFilters'])) { + if (in_array($field, $viewDatas['formFilters'])) { if (str_contains($field, "_uid")) { $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; } @@ -216,7 +217,7 @@ class CommonHelper $isAll = true; $filter = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes, $isAll); } else { - $filter = array_key_exists($value, $viewDatas['control']['formOptions'][$field]) ? $viewDatas['control']['formOptions'][$field][$value] : ""; + $filter = array_key_exists($value, $viewDatas['formOptions'][$field]) ? $viewDatas['formOptions'][$field][$value] : ""; } break; } @@ -226,6 +227,7 @@ class CommonHelper { switch ($field) { default: + // dd($viewDatas); $label = $this->getFieldLabel($field, $label, $viewDatas, $extras); if (isset($viewDatas['order_field']) && $viewDatas['order_field'] == $field) { $label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"]; @@ -235,7 +237,7 @@ class CommonHelper $query .= "order_field={$field}&order_value="; $query .= isset($viewDatas['order_value']) && $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC"; $label = anchor(current_url() . "?" . $query, $label); - form_dropdown('per_page', $viewDatas['page_options'], $viewDatas['per_page'], ['onChange' => 'this.form.submit()']); + form_dropdown('index_perpage', $viewDatas['index_pagination_options'], $viewDatas['index_perpage'], ['onChange' => 'this.form.submit()']); break; } return $label; diff --git a/app/Helpers/HomeHelper.php b/app/Helpers/HomeHelper.php index f49b943..18e5f74 100644 --- a/app/Helpers/HomeHelper.php +++ b/app/Helpers/HomeHelper.php @@ -16,7 +16,7 @@ class HomeHelper extends CommonHelper { switch ($field) { case 'type': - $value = $viewDatas['control']['formOptions'][$field][$value]; + $value = $viewDatas['formOptions'][$field][$value]; break; case 'amount': $value = number_format($value) . "원"; diff --git a/app/Helpers/UserHelper.php b/app/Helpers/UserHelper.php index 90a8482..6699be4 100644 --- a/app/Helpers/UserHelper.php +++ b/app/Helpers/UserHelper.php @@ -18,16 +18,16 @@ class UserHelper extends CommonHelper $form = form_password($field, "", [...$extras]); break; case 'role': - //$viewDatas['control']['entity']->$field에서 getRole()로 캐스팅이 되지 않아서 대체함 - if (($viewDatas['control']['entity'] ?? null) instanceof UserEntity) { - $value = $viewDatas['control']['entity']->getRole(); + //$viewDatas['entity']->$field에서 getRole()로 캐스팅이 되지 않아서 대체함 + if (($viewDatas['entity'] ?? null) instanceof UserEntity) { + $value = $viewDatas['entity']->getRole(); } $currentRoles = is_array($value) ? array_map('strtolower', array_map('trim', $value)) : []; $form = ''; //체크박스를 순회하며 생성 - foreach ($viewDatas['control']['formOptions']['role'] as $key => $label) { + foreach ($viewDatas['formOptions']['role'] as $key => $label) { $checked = in_array(strtolower(trim($key)), $currentRoles); $form .= '