diff --git a/app/Controllers/Admin/AdminController.php b/app/Controllers/Admin/AdminController.php
index 1cc2cfc..4f7c400 100644
--- a/app/Controllers/Admin/AdminController.php
+++ b/app/Controllers/Admin/AdminController.php
@@ -32,25 +32,12 @@ abstract class AdminController extends CommonController
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));
+ $formFields = $this->service->getFormService()->getFormFields($action);
+ $formFilters = $this->service->getFormService()->getFormFilters($action);
+ $this->addViewDatas('formFields', $formFields);
+ $this->addViewDatas('formFilters', $formFilters);
+ $this->addViewDatas('formRules', $this->service->getFormService()->getFormRules($action, array_keys($formFields)));
+ $this->addViewDatas('formOptions', $this->service->getFormService()->getFormOptions($action, $formFilters));
}
protected function create_form_process(array $formDatas = []): array
{
@@ -128,6 +115,31 @@ abstract class AdminController extends CommonController
return redirect()->back()->withInput()->with('message', $e->getMessage());
}
}
+ protected function view_process($uid): CommonEntity
+ {
+ if (!$uid) {
+ throw new \Exception("계정 번호가 정의 되지 않았습니다.");
+ }
+ $entity = $this->service->getEntity($uid);
+ if (!$entity instanceof CommonEntity) {
+ throw new \Exception("{$uid}에 해당하는 계정을 찾을수 없습니다.");
+ }
+ return $entity;
+ }
+ final public function view($uid): string
+ {
+ $action = __FUNCTION__;
+ try {
+ //초기화
+ $this->action_init_process($action);
+ $entity = $this->view_process($uid);
+ $this->addViewDatas('entity', $entity);
+ } catch (\Exception $e) {
+ log_message('error', $e->getMessage());
+ session()->setFlashdata('message', $e->getMessage());
+ }
+ return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas());
+ }
//리스트관련
//조건절 처리
protected function index_condition_process(string $action): void
@@ -137,7 +149,7 @@ abstract class AdminController extends CommonController
foreach ($this->service->getFormService()->getFormFilters($action) as $field) {
$value = $this->request->getVar($field) ?? null;
if ($value) {
- $this->service->index_condition_filterField($field, $value);
+ $this->service->setFilter($field, $value);
$index_filters[$field] = $value;
}
}
@@ -145,37 +157,37 @@ abstract class AdminController extends CommonController
//검색어조건절 처리
$index_word = $this->request->getVar('index_word');
if ($index_word !== null && $index_word !== '') {
- $this->service->index_condition_filterWord($index_word);
+ $this->service->setSearchWord($index_word);
}
$this->addViewDatas('index_word', $index_word);
//날자검색
$index_start = $this->request->getVar('index_start');
$index_end = $this->request->getVar('index_end');
if ($index_start !== null && $index_start !== '' && $index_end !== null && $index_end !== '') {
- $this->service->index_condition_filterDate($index_start, $index_end);
+ $this->service->setDateFilter($index_start, $index_end);
}
$this->addViewDatas('index_start', $index_start);
$this->addViewDatas('index_end', $index_end);
}
//Index Option출력용
- protected function index_pagenation_options_process(int $index_totalcount, int $index_perpage): array
+ protected function pagenation_options_process(int $index_totalcount, int $perpage): array
{
- $index_page_options = ["" => "줄수선택"];
- for ($i = $index_perpage; $i <= $index_totalcount; $i += $index_perpage) {
- $index_page_options[$i] = $i;
+ $page_options = ["" => "줄수선택"];
+ for ($i = $perpage; $i <= $index_totalcount; $i += $perpage) {
+ $page_options[$i] = $i;
}
- $index_page_options[$index_totalcount] = $index_totalcount;
- return $index_page_options;
+ $page_options[$index_totalcount] = $index_totalcount;
+ return $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
+ protected function 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);
+ // $page = $pager->getCurrentPage($pager_group);
$this->addViewDatas('index_totalpage', $pager->getPageCount($pager_group));
return $pager->links($pager_group, $template);
}
@@ -196,33 +208,33 @@ abstract class AdminController extends CommonController
$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);
+ $page = (int) $this->request->getVar('page') ?: 1;
+ $perpage = (int) $this->request->getVar('perpage') ?: intval(DEFAULTS['INDEX_PERPAGE']);
+ $this->addViewDatas('page', $page);
+ $this->addViewDatas('perpage', $perpage);
//index_totalcount
//조건절 처리 index_totalcount용
$this->index_condition_process($action);
- $index_totalcount = $this->service->getindex_totalcount();
+ $index_totalcount = $this->service->getTotalCount();
$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));
+ $this->addViewDatas('index_pagination', $this->pagenation_process($index_totalcount, $page, $perpage));
+ $this->addViewDatas('index_pagination_options', $this->pagenation_options_process($index_totalcount, $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);
+ $this->service->setLimit($perpage);
+ $this->service->setOffset(($page - 1) * $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());
+ $this->addViewDatas('index_batchjobFields', $this->service->getFormService()->getBatchjobFields($action));
+ $this->addViewDatas('index_batchjobButtions', $this->service->getFormService()->getBatchjobButtons($action));
} catch (\Exception $e) {
session()->setFlashdata('message', $e->getMessage());
}
diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php
index deb1998..3dd75e7 100644
--- a/app/Controllers/Admin/UserController.php
+++ b/app/Controllers/Admin/UserController.php
@@ -38,6 +38,10 @@ class UserController extends AdminController
$redirect_url = $this->getAuthContext()->popPreviousUrl() ?? implode(DIRECTORY_SEPARATOR, $this->getActionPaths());
return redirect()->to($redirect_url)->with('message', "{$entity->getTitle()} 계정 생성이 완료되었습니다.");
}
+ protected function modify_form_process($uid): UserEntity
+ {
+ return parent::modify_form_process($uid);
+ }
protected function modify_process($uid): RedirectResponse
{
if (!$uid) {
@@ -53,4 +57,9 @@ class UserController extends AdminController
$redirect_url = $this->getAuthContext()->popPreviousUrl() ?? implode(DIRECTORY_SEPARATOR, $this->getActionPaths());
return redirect()->to($redirect_url)->with('message', "{$entity->getTitle()} 계정 수정이 완료되었습니다.");
}
+
+ protected function view_process($uid): UserEntity
+ {
+ return parent::view_process($uid);
+ }
}
diff --git a/app/Forms/CommonForm.php b/app/Forms/CommonForm.php
index a264343..414cd4c 100644
--- a/app/Forms/CommonForm.php
+++ b/app/Forms/CommonForm.php
@@ -9,7 +9,6 @@ abstract class CommonForm
{
private array $_attributes = [];
protected function __construct() {}
- abstract public function getFormFields(string $action, ?array $fields = null): array;
final public function setAttributes(array $attributes): void
{
$this->_attributes = $attributes;
@@ -36,33 +35,26 @@ abstract class CommonForm
return $options;
}
//필수함수
- public function getFormFilters(string $action, ?array $fields = null): array
+ public function getFormFields(string $action, array $fields = []): array
{
- return $fields ?? [];
+ $temps = [];
+ foreach ($fields as $field) {
+ $temps[$field] = lang("{$this->getAttribute('class_path')}.label.{$field}");
+ }
+ return $temps;
}
- public function getViewFields(string $action = 'view', ?array $fields = null): array
+ public function getFormFilters(string $action, array $fields = []): array
{
- return $fields ?? $this->getFormFields($action);
+ return $fields;
}
- public function getViewFilters(string $action = 'view', ?array $fields = null): array
+ public function getBatchjobFields(string $action, array $fields = []): array
{
- return $fields ?? $this->getFormFilters($action);
+ return $fields;
}
- public function getIndexFields(string $action = 'index', ?array $fields = null): array
+ public function getBatchjobButtons(string $action, array $buttions = []): array
{
- return $fields ?? $this->getFormFields($action);
- }
- public function getIndexFilters(string $action = 'index', ?array $fields = null): array
- {
- return $fields ?? $this->getFormFilters($action);
- }
- public function getBatchjobFields(string $action = 'index', ?array $fields = null): array
- {
- return $fields ?? $this->getIndexFilters($action);
- }
- public function getBatchjobButtons(string $action = 'index', ?array $buttions = null): array
- {
- return $buttions ?? [
+ return [
+ ...$buttions,
'batchjob' => '일괄 처리',
'batchjob_delete' => '일괄 삭제',
];
@@ -106,21 +98,23 @@ abstract class CommonForm
{
switch ($field) {
case 'user_uid':
- $userService = service('UserService');
- $option = $userService->getEntities();
- break;
case 'clientinfo_uid':
- $clientService = service('ClientService');
- $option = $clientService->getEntities();
+ $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
+ foreach (service('UserService')->getEntities() as $entity) {
+ $tempOptions[$entity->getPK()] = $entity->getTitle();
+ }
+ $options[$field]['options'] = $tempOptions;
+ $options[$field]['extras'] = ['class' => 'select-field'];
break;
default:
- $option = lang($this->getAttribute('class_path') . "." . strtoupper($field));
+ $tempOptions = [
+ '' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택",
+ ...lang($this->getAttribute('class_path') . "." . strtoupper($field))
+ ];
+ $options[$field]['options'] = $tempOptions;
+ $options[$field]['extras'] = [];
break;
}
- if (!is_array($option)) {
- throw new \Exception(static::class . DIRECTORY_SEPARATOR . __FUNCTION__ . "에서 {$field}의 options 값들이 배열이 아닙니다.\n" . var_export($option, true));
- }
- $options[$field] = $option;
return $options;
}
}
diff --git a/app/Forms/UserForm.php b/app/Forms/UserForm.php
index 3e8df0d..e3d63b9 100644
--- a/app/Forms/UserForm.php
+++ b/app/Forms/UserForm.php
@@ -11,53 +11,69 @@ class UserForm extends CommonForm
parent::__construct();
}
- public function getFormFields(string $action, ?array $fields = null): array
+ public function getFormFields(string $action, array $fields = []): array
{
- $fields = $fields ?? [
- 'id',
- 'passwd',
- 'confirmpassword',
- 'name',
- 'email',
- 'mobile',
- 'role',
- ];
- if (in_array($action, ['modify_form', 'modify'])) {
- $fields = $fields ?? [
- 'passwd',
- 'confirmpassword',
- 'name',
- 'email',
- 'mobile',
- 'role',
- 'status',
- ];
+ switch ($action) {
+ case 'create':
+ case 'create_form':
+ $fields = [
+ ...$fields,
+ 'id',
+ 'passwd',
+ 'confirmpassword',
+ 'name',
+ 'email',
+ 'mobile',
+ 'role',
+ ];
+ break;
+ case 'modify':
+ case 'modify_form':
+ $fields = [
+ ...$fields,
+ 'id',
+ 'passwd',
+ 'confirmpassword',
+ 'name',
+ 'email',
+ 'mobile',
+ 'role',
+ 'status',
+ ];
+ break;
+ case 'view':
+ $fields = [
+ ...$fields,
+ 'id',
+ 'name',
+ 'email',
+ 'mobile',
+ 'role',
+ 'status',
+ ];
+ break;
+ default:
+ $fields = [
+ ...$fields,
+ 'id',
+ 'name',
+ 'email',
+ 'mobile',
+ 'role',
+ 'status'
+ ];
+ break;
}
- return $fields;
+ return parent::getFormFields($action, $fields);
}
- public function getFormFilters(string $action, ?array $fields = null): array
+ public function getFormFilters(string $action, array $fields = []): array
{
- return $fields ?? [
- 'role',
- 'status',
- ];
+ return parent::getFormFilters($action, [...$fields, 'role', 'status']);
}
- public function getIndexFields(string $action = 'index', ?array $fields = null): array
+ public function getBatchjobFields(string $action, array $fields = []): array
{
- return $fields ?? [
- 'id',
- 'name',
- 'email',
- 'mobile',
- 'role',
- 'status',
- ];
+ return parent::getBatchjobFields($action, [...$fields, 'status']);
}
- public function getBatchjobFields(string $action = 'index', ?array $fields = null): array
- {
- return $fields ?? ['status'];
- }
-
public function getFormRule(string $action, string $field, array $rules = []): array
{
switch ($field) {
@@ -67,14 +83,14 @@ class UserForm extends CommonForm
$rules[$field] = $rule;
break;
case "passwd":
- $rules[$field] = in_array($action, ["create", "create_form"]) ? "required|trim|string" : "permit_empty|trim|string";
+ $rules[$field] = in_array($action, ["create", "create_form"]) ? "required" : "permit_empty" . "|trim|string";
break;
case "confirmpassword":
- $rules[$field] = in_array($action, ["create", "create_form"]) ? "required|trim|string|matches[passwd]" : "permit_empty|trim|string|matches[passwd]";
+ $rules[$field] = in_array($action, ["create", "create_form"]) ? "required" : "permit_empty" . "|trim|string|matches[passwd]";
break;
case "email":
$rule = "required|trim|valid_email";
- $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "";
+ $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "" . "|trim|valid_email";
$rules[$field] = $rule;
break;
case "role":
diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php
index 7d675ab..ae9df40 100644
--- a/app/Helpers/CommonHelper.php
+++ b/app/Helpers/CommonHelper.php
@@ -22,59 +22,57 @@ class CommonHelper
}
return $this->_attributes[$key];
}
- 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['formOptions'])) {
- return ""; // 필터 옵션이 없으면 빈 문자열 반환
- }
- $extra = "";
- foreach ($extras as $extra_tag => $extra_value) {
- $extra .= sprintf(" %s=\"%s\"", $extra_tag, $extra_value);
- }
- // $formOptions는 필터 옵션 배열로, key는 필터 엔티티의 PK, value는 필터 엔티티 객체
- $html = sprintf("", $field, $extra);
- $html .= "" . lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택" . " ";
- $html .= $this->form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes, $isAll);
- $html .= ' ';
- return $html;
- }
- //필수함수
- protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = [], bool $isAll = false): string
- {
- $html = "";
- switch ($field) {
- default:
- 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() != DEFAULTS['STATUS'] && !$isAll) {
- continue;
- }
- foreach ($attributes as $attribute_name => $attribute_value) {
- $attribute .= sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value);
- }
- $label = $option_value->getCustomTitle();
- } else {
- $label = $option_value;
- }
- $html .= sprintf("%s ", $option_key, $isSelected, $isDisabled, $attribute, $label);
- }
- break;
- }
- return $html;
- }
+ // 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['formOptions'])) {
+ // return ""; // 필터 옵션이 없으면 빈 문자열 반환
+ // }
+ // $extra = "";
+ // foreach ($extras as $extra_tag => $extra_value) {
+ // $extra .= sprintf(" %s=\"%s\"", $extra_tag, $extra_value);
+ // }
+ // // $formOptions는 필터 옵션 배열로, key는 필터 엔티티의 PK, value는 필터 엔티티 객체
+ // $html = sprintf("", $field, $extra);
+ // $html .= "" . lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택" . " ";
+ // $html .= $this->form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes, $isAll);
+ // $html .= ' ';
+ // return $html;
+ // }
+ // //필수함수
+ // protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = [], bool $isAll = false): string
+ // {
+ // $html = "";
+ // switch ($field) {
+ // default:
+ // foreach ($viewDatas['formOptions'][$field]['options'] 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() != DEFAULTS['STATUS'] && !$isAll) {
+ // continue;
+ // }
+ // foreach ($attributes as $attribute_name => $attribute_value) {
+ // $attribute .= sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value);
+ // }
+ // $label = $option_value->getCustomTitle();
+ // } else {
+ // $label = $option_value;
+ // }
+ // $html .= sprintf("%s ", $option_key, $isSelected, $isDisabled, $attribute, $label);
+ // }
+ // break;
+ // }
+ // return $html;
+ // }
public function getFieldLabel(string $field, string $label, array $viewDatas, array $extras = []): string
{
switch ($field) {
default:
- dd($viewDatas['formRules']);
- // required가 있으면 class 추가
$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]);
+ $label = form_label($label, $field, ['class' => 'form-label-sm', ...$extras]);
break;
}
return $label;
@@ -99,25 +97,6 @@ class CommonHelper
...$extras
]);
break;
- case 'role':
- 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['action'], ['create_form', 'modify_form'])) {
- $forms = [];
- 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를 써야함
- $forms[] = form_checkbox("{$field}[]", $key, in_array($key, $values), $extras) . $label;
- }
- }
- $form = implode(" ", $forms);
- } else {
- $form = form_dropdown($field, $value, $viewDatas, $extras);
- }
- break;
case 'issue_at':
case 'expired_at':
case 'billing_at':
@@ -142,10 +121,8 @@ class CommonHelper
break;
default:
if (in_array($field, $viewDatas['formFilters'])) {
- if (str_contains($field, "_uid")) {
- $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
- }
- $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
+ $form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $viewDatas['formOptions'][$field]['extras']);
+ // $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
} else {
$form = form_input($field, $value ?? "", [
"class" => "form-control",
@@ -161,14 +138,14 @@ class CommonHelper
{
switch ($field) {
case 'clientinfo_uid':
- if (array_key_exists($value, $viewDatas['formOptions'][$field])) {
- $value = "" . $viewDatas['formOptions'][$field][$value]->getTitle() . " ";
+ if (array_key_exists($value, $viewDatas['formOptions'][$field]['options'])) {
+ $value = "{$viewDatas['formOptions'][$field]['options'][$value]} ";
}
break;
case 'role':
$roles = [];
foreach ($value as $key) {
- $roles[] = $viewDatas['formOptions'][$field][$key] ?? "";
+ $roles[] = $viewDatas['formOptions'][$field]['options'][$key] ?? "";
}
$value = implode(" , ", $roles);
break;
@@ -192,11 +169,7 @@ class CommonHelper
break;
default:
if (in_array($field, $viewDatas['formFilters'])) {
- if (str_contains($field, "_uid")) {
- $value = array_key_exists($value, $viewDatas['formOptions'][$field]) && $viewDatas['formOptions'][$field][$value] ? $viewDatas['formOptions'][$field][$value]->getTitle() : "";
- } else {
- $value = array_key_exists($value, $viewDatas['formOptions'][$field]) ? $viewDatas['formOptions'][$field][$value] : "";
- }
+ $value = $viewDatas['formOptions'][$field]['options'][$value] ?? "";
}
break;
}
@@ -205,19 +178,18 @@ class CommonHelper
}
return $value;
}
- public function getListFilter(string $field, mixed $value, array $viewDatas, array $extras = []): string
+ public function getListFilter(string $field, mixed $value, array $viewDatas, $extras = []): string
{
switch ($field) {
default:
+ $filter = "";
if (in_array($field, $viewDatas['formFilters'])) {
- if (str_contains($field, "_uid")) {
- $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
- }
- $attributes = [];
- $isAll = true;
- $filter = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes, $isAll);
- } else {
- $filter = array_key_exists($value, $viewDatas['formOptions'][$field]) ? $viewDatas['formOptions'][$field][$value] : "";
+ $filter = form_dropdown(
+ $field,
+ $viewDatas['formOptions'][$field]['options'],
+ $value,
+ [...$extras, ...$viewDatas['formOptions'][$field]['extras']]
+ );
}
break;
}
@@ -227,8 +199,6 @@ 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"];
}
@@ -237,7 +207,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('index_perpage', $viewDatas['index_pagination_options'], $viewDatas['index_perpage'], ['onChange' => 'this.form.submit()']);
+ form_dropdown('perpage', $viewDatas['index_pagination_options'], $viewDatas['perpage'], ['onChange' => 'this.form.submit()']);
break;
}
return $label;
diff --git a/app/Helpers/UserHelper.php b/app/Helpers/UserHelper.php
index 6699be4..841b21c 100644
--- a/app/Helpers/UserHelper.php
+++ b/app/Helpers/UserHelper.php
@@ -18,19 +18,15 @@ class UserHelper extends CommonHelper
$form = form_password($field, "", [...$extras]);
break;
case 'role':
- //$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['formOptions']['role'] as $key => $label) {
+ //Form페이지에서는 맨앞에것 제외하기 위함
+ $firstOption = array_shift($viewDatas['formOptions'][$field]['options']);
+ foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label) {
$checked = in_array(strtolower(trim($key)), $currentRoles);
$form .= '';
- // form_checkbox에 들어가는 값($key)은 원본 값을 유지(저장용).
$form .= form_checkbox('role[]', $key, $checked, array_merge(['id' => "role_{$key}"], $extras));
$form .= " {$label}";
$form .= ' ';
diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php
index 76fac49..7deafd7 100644
--- a/app/Services/CommonService.php
+++ b/app/Services/CommonService.php
@@ -5,6 +5,7 @@ namespace App\Services;
use App\Entities\CommonEntity;
use App\Models\CommonModel;
use CodeIgniter\Validation\Exceptions\ValidationException;
+use PhpParser\Node\Scalar\MagicConst\Dir;
use RuntimeException;
abstract class CommonService
@@ -48,7 +49,11 @@ abstract class CommonService
final public function getEntities(mixed $where = null, array $columns = ['*']): array
{
try {
- return $this->getEntities_process($where, $columns);
+ $entities = $this->getEntities_process($where, $columns);
+ echo "
test
";
+ echo "test
";
+ echo static::class . DIRECTORY_SEPARATOR . __FUNCTION__ . " Query:" . $this->model->getLastQuery();
+ return $entities;
} catch (\Exception $e) {
$message = sprintf(
"\n------%s SQL오류----- \n%s\n%s\n------------------------------\n",
@@ -165,21 +170,21 @@ abstract class CommonService
return $this->delete_process($uid);
}
//Index용
- final public function getindex_totalcount(): int
+ final public function getTotalCount(): int
{
- return $this->model->countAllResults(false);
+ return $this->model->countAllResults();
}
//Limit처리
- final public function setLimit(int $per_page): void
+ final public function setLimit(int $perpage): void
{
- $this->model->limit($per_page);
+ $this->model->limit($perpage);
}
//Offset처리
final public function setOffset(int $offset): void
{
$this->model->offset($offset);
}
- public function index_condition_filterField(string $field, mixed $filter_value): void
+ public function setFilter(string $field, mixed $filter_value): void
{
switch ($field) {
default:
@@ -188,12 +193,12 @@ abstract class CommonService
}
}
//검색어조건절처리
- public function index_condition_filterWord(string $word): void
+ public function setSearchWord(string $word): void
{
$this->model->orLike($this->model->getTable() . "." . $this->model->getTitleField(), $word, 'both');
}
//날자검색
- public function index_condition_filterDate(string $start, string $end): void
+ public function setDateFilter(string $start, string $end): void
{
$this->model->where(sprintf("%s.created_at >= '%s 00:00:00'", $this->model->getTable(), $start));
$this->model->where(sprintf("%s.created_at <= '%s 23:59:59'", $this->model->getTable(), $end));
diff --git a/app/Services/UserService.php b/app/Services/UserService.php
index 3a80d61..0d245e8 100644
--- a/app/Services/UserService.php
+++ b/app/Services/UserService.php
@@ -8,7 +8,6 @@ use App\Entities\UserEntity;
use App\Forms\UserForm;
use App\Helpers\UserHelper;
use App\Models\UserModel;
-use CodeIgniter\Validation\Exceptions\ValidationException;
use RuntimeException;
class UserService extends CommonService
@@ -83,7 +82,7 @@ class UserService extends CommonService
}
//List 검색용
//FormFilter 조건절 처리
- public function index_condition_filterField(string $field, mixed $filter_value): void
+ public function setFilter(string $field, mixed $filter_value): void
{
switch ($field) {
case 'role':
@@ -92,16 +91,16 @@ class UserService extends CommonService
$this->model->where($where, null, false);
break;
default:
- parent::index_condition_filterField($field, $filter_value);
+ parent::setFilter($field, $filter_value);
break;
}
}
//검색어조건절처리
- public function index_condition_filterWord(string $word): void
+ public function setSearchWord(string $word): void
{
$this->model->orLike($this->model->getTable() . '.id', $word, 'both');
$this->model->orLike($this->model->getTable() . "." . $this->model->getTitleField(), $word, 'both');
$this->model->orLike($this->model->getTable() . '.email', $word, 'both');
- parent::index_condition_filterWord($word);
+ parent::setSearchWord($word);
}
}
diff --git a/app/Views/admin/create_form.php b/app/Views/admin/create_form.php
deleted file mode 100644
index 5849a70..0000000
--- a/app/Views/admin/create_form.php
+++ /dev/null
@@ -1,24 +0,0 @@
-= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
-= $this->section('content') ?>
-getHelper()->alertTrait($error) ?>
-
-
= $this->include("templates/{$viewDatas['layout']}/form_content_top"); ?>
- = form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
-
-
= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?>
-
-= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/download.php b/app/Views/admin/download.php
deleted file mode 100644
index b94a70f..0000000
--- a/app/Views/admin/download.php
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
- = lang("{$viewDatas['class_path']}.label.{$field}") ?>
-
-
-
-
-
-
-
-
-
- = $viewDatas['service']->getHelper()->getFieldView($field, $entity->$field, $viewDatas) ?>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/Views/admin/index.php b/app/Views/admin/index.php
deleted file mode 100644
index 6a8fc39..0000000
--- a/app/Views/admin/index.php
+++ /dev/null
@@ -1,70 +0,0 @@
-= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
-= $this->section('content') ?>
-getHelper()->alertTrait($error) ?>
-= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/top'); ?>
-
-
-
-
-
- = $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu'); ?>
-
-
-
-
-
-
-
-
- = form_open(current_url(), ["method" => "get"]) ?>
-
-
-
- 조건:
-
- = $viewDatas['service']->getHelper()->getListFilter($field, $viewDatas['index_filters'][$field] ?? old($field), $viewDatas) ?>
-
-
- = $this->include("templates/{$viewDatas['layout']}/index_content_top"); ?>
-
-
- = form_close() ?>
- = form_open(current_url(), ['id' => 'batchjob_form', 'method' => "post"]) ?>
-
-
-
- 번호
-
- = $viewDatas['service']->getHelper()->getListLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?>
-
- 작업
-
-
-
-
-
- getStatus() === DEFAULTS['STATUS'] ? "" : 'class="table-danger"' ?>>
-
- = $viewDatas['service']->getHelper()->getListButton('modify', $num, $viewDatas) ?>
-
- = $viewDatas['service']->getHelper()->getFieldView($field, $entity->$field, $viewDatas) ?>
-
-
- = $viewDatas['service']->getHelper()->getListButton('view', '', $viewDatas) ?>
- = $viewDatas['service']->getHelper()->getListButton('delete', '', $viewDatas) ?>
-
-
-
-
-
-
- = $this->include("templates/{$viewDatas['layout']}/index_content_bottom"); ?>
- = form_close() ?>
-
-
-
-
-
-
-= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/bottom'); ?>
-= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/modify_form.php b/app/Views/admin/modify_form.php
deleted file mode 100644
index cba6eb0..0000000
--- a/app/Views/admin/modify_form.php
+++ /dev/null
@@ -1,24 +0,0 @@
-= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
-= $this->section('content') ?>
-getHelper()->alertTrait($error) ?>
-
-
= $this->include("templates/{$viewDatas['layout']}/form_content_top"); ?>
- = form_open(current_url(), ['id' => 'action_form', ...$viewDatas['forms']['attributes']], $viewDatas['forms']['hiddens']) ?>
-
-
= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?>
-
-= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/popup/create_form.php b/app/Views/admin/popup/create_form.php
deleted file mode 100644
index 5849a70..0000000
--- a/app/Views/admin/popup/create_form.php
+++ /dev/null
@@ -1,24 +0,0 @@
-= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
-= $this->section('content') ?>
-getHelper()->alertTrait($error) ?>
-
-
= $this->include("templates/{$viewDatas['layout']}/form_content_top"); ?>
- = form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
-
-
= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?>
-
-= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/popup/index.php b/app/Views/admin/popup/index.php
deleted file mode 100644
index 370da75..0000000
--- a/app/Views/admin/popup/index.php
+++ /dev/null
@@ -1,55 +0,0 @@
-= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
-= $this->section('content') ?>
-getHelper()->alertTrait($error) ?>
-
-
-
-
- = form_open(current_url(), ["method" => "get"]) ?>
-
-
-
- 조건:
-
- = $viewDatas['service']->getHelper()->getListFilter($field, $viewDatas['index_filters'][$field] ?? old($field), $viewDatas) ?>
-
-
-
-
- = form_close() ?>
- = form_open(current_url(), ['id' => 'batchjob_form', 'method' => "post"]) ?>
-
-
-
- 번호
-
- = $viewDatas['service']->getHelper()->getListLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?>
-
- 작업
-
-
-
-
-
-
- getStatus() === DEFAULTS['STATUS'] ? "" : 'class="table-danger"' ?>>
-
- = $viewDatas['service']->getHelper()->getListButton('modify', $num, $viewDatas) ?>
-
- = $viewDatas['service']->getHelper()->getFieldView($field, $entity->$field, $viewDatas) ?>
-
-
- = $viewDatas['service']->getHelper()->getListButton('view', '', $viewDatas) ?>
- = $viewDatas['service']->getHelper()->getListButton('delete', '', $viewDatas) ?>
-
-
-
-
-
-
- = $this->include("templates/{$viewDatas['layout']}/index_content_bottom"); ?>
- = form_close() ?>
-
-
-
-= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/popup/modify_form.php b/app/Views/admin/popup/modify_form.php
deleted file mode 100644
index a78c67c..0000000
--- a/app/Views/admin/popup/modify_form.php
+++ /dev/null
@@ -1,24 +0,0 @@
-= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
-= $this->section('content') ?>
-getHelper()->alertTrait($error) ?>
-
-
= $this->include("templates/{$viewDatas['layout']}/form_content_top"); ?>
- = form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
-
-
= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?>
-
-= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/popup/view.php b/app/Views/admin/popup/view.php
deleted file mode 100644
index 2e4eac1..0000000
--- a/app/Views/admin/popup/view.php
+++ /dev/null
@@ -1,17 +0,0 @@
-= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
-= $this->section('content') ?>
-getHelper()->alertTrait($error) ?>
-
-= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/user/create_form.php b/app/Views/admin/user/create_form.php
index 65e5109..5ae7388 100644
--- a/app/Views/admin/user/create_form.php
+++ b/app/Views/admin/user/create_form.php
@@ -3,22 +3,20 @@
= $this->include("templates/{$viewDatas['layout']}/form_content_top"); ?>
= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
-
-
= session('message') ?>
+
+ $label): ?>
+
+ = $viewDatas['helper']->getFieldLabel($field, $label, $viewDatas) ?>
+
+ = $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas['formDatas'][$field] ?? null), $viewDatas) ?>
+ = validation_show_error($field); ?>
+
+
+
+
+
= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?>
+ = form_close(); ?>
+
= nl2br(session('message')) ?>
= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?>
= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/user/download.php b/app/Views/admin/user/download.php
index b94a70f..c835c18 100644
--- a/app/Views/admin/user/download.php
+++ b/app/Views/admin/user/download.php
@@ -1,9 +1,7 @@
-
- = lang("{$viewDatas['class_path']}.label.{$field}") ?>
-
+ $label): ?>= $label ?>
diff --git a/app/Views/admin/user/index.php b/app/Views/admin/user/index.php
index 931e936..3096cf3 100644
--- a/app/Views/admin/user/index.php
+++ b/app/Views/admin/user/index.php
@@ -1,11 +1,10 @@
= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
+= session('message') ? $viewDatas['helper']->alertTrait(session('message')) : "" ?>
= $this->section('content') ?>
-
= $this->include("{$layouts['path']}/top"); ?>
@@ -21,7 +20,9 @@ $template = "templates" . DIRECTORY_SEPARATOR . "{$viewDatas['layout']}";
번호
- = $viewDatas['helper']->getListLabel($field, lang("{$viewDatas['classPath']}.label.{$field}"), $viewDatas) ?>
+ $label): ?>
+ = $viewDatas['helper']->getListLabel($field, $label, $viewDatas) ?>
+
작업
@@ -32,11 +33,11 @@ $template = "templates" . DIRECTORY_SEPARATOR . "{$viewDatas['layout']}";
$viewDatas['entity'] = $entity;
$isDefaultStatus = $entity->getStatus() === DEFAULTS['STATUS'];
$rowClass = $isDefaultStatus ? "" : 'class="table-danger"';
- $num = $viewDatas['index_totalcount'] - (($viewDatas['index_page'] - 1) * $viewDatas['index_perpage'] + $cnt);
+ $num = $viewDatas['index_totalcount'] - (($viewDatas['page'] - 1) * $viewDatas['perpage'] + $cnt);
?>
>
= $viewDatas['helper']->getListButton('modify', $num, $viewDatas) ?>
- = $viewDatas['helper']->getFieldView($field, $entity->$field, $viewDatas) ?>
+ $label): ?>= $viewDatas['helper']->getFieldView($field, $entity->$field, $viewDatas) ?>
= $viewDatas['helper']->getListButton('view', '', $viewDatas) ?>
= $viewDatas['helper']->getListButton('delete', '', $viewDatas) ?>
diff --git a/app/Views/admin/user/modify_form.php b/app/Views/admin/user/modify_form.php
index 570ff72..b70a549 100644
--- a/app/Views/admin/user/modify_form.php
+++ b/app/Views/admin/user/modify_form.php
@@ -3,22 +3,20 @@
= $this->include("templates/{$viewDatas['layout']}/form_content_top"); ?>
= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
-
-
= session('message') ?>
+
+ $label): ?>
+
+ = $viewDatas['helper']->getFieldLabel($field, $label, $viewDatas) ?>
+
+ = $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas['entity']->$field ?? null), $viewDatas) ?>
+ = validation_show_error($field); ?>
+
+
+
+
+
= form_submit('', '수정', array("class" => "btn btn-outline btn-primary")); ?>
+ = form_close(); ?>
+
= nl2br(session('message')) ?>
= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?>
= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/user/view.php b/app/Views/admin/user/view.php
index cf72e61..db4650e 100644
--- a/app/Views/admin/user/view.php
+++ b/app/Views/admin/user/view.php
@@ -1,18 +1,16 @@
= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
= $this->section('content') ?>
-getHelper()->alertTrait($error) ?>
-
-
-
= session('message') ?>
+
= $this->include("templates/{$viewDatas['layout']}/form_content_top"); ?>
+
+ $label): ?>
+
+ = $viewDatas['helper']->getFieldLabel($field, $label, $viewDatas) ?>
+ = $viewDatas['helper']->getFieldView($field, old($field) ?? ($viewDatas['entity']->$field ?? null), $viewDatas) ?>
+
+
+
+
= nl2br(session('message')) ?>
+
= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?>
= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/admin/view.php b/app/Views/admin/view.php
deleted file mode 100644
index 2e4eac1..0000000
--- a/app/Views/admin/view.php
+++ /dev/null
@@ -1,17 +0,0 @@
-= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
-= $this->section('content') ?>
-getHelper()->alertTrait($error) ?>
-
-= $this->endSection() ?>
\ No newline at end of file
diff --git a/app/Views/layouts/admin/left_menu/base.php b/app/Views/layouts/admin/left_menu/base.php
index b974811..999d8f7 100644
--- a/app/Views/layouts/admin/left_menu/base.php
+++ b/app/Views/layouts/admin/left_menu/base.php
@@ -1,4 +1,6 @@
+
\ No newline at end of file
diff --git a/app/Views/templates/admin/index_content_bottom.php b/app/Views/templates/admin/index_content_bottom.php
index d610ada..6ff4636 100644
--- a/app/Views/templates/admin/index_content_bottom.php
+++ b/app/Views/templates/admin/index_content_bottom.php
@@ -2,10 +2,10 @@
= $viewDatas['helper']->getListButton('create', '', $viewDatas) ?>
= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL
-
+
= $viewDatas['helper']->getListFilter($field, null, $viewDatas, ['data-batchjob' => 'true']) ?>
- $label): ?>
+ $label): ?>
= $viewDatas['helper']->getListButton($action, $label, $viewDatas) ?>
@@ -17,7 +17,7 @@
function submitBatchJob() {
var validate = false;
//batchjob용 선택사항 검증
-
+
var element = document.querySelector('[name="= $field ?>"][data-batchjob="true"]');
if (element && element.value !== "") {
validate = true;
diff --git a/app/Views/templates/admin/index_content_top.php b/app/Views/templates/admin/index_content_top.php
index a5d5a11..910657e 100644
--- a/app/Views/templates/admin/index_content_top.php
+++ b/app/Views/templates/admin/index_content_top.php
@@ -5,7 +5,7 @@
= anchor(current_url() . '/download/excel', ICONS['EXCEL'], ["target" => "_self", "class" => "excel"]) ?>
- Page:= $viewDatas['index_page'] ?? 1 ?>/= $viewDatas['index_totalpage'] ?>
- = form_dropdown('index_perpage', $viewDatas['index_pagination_options'], $viewDatas['index_perpage'], ['onChange' => 'this.form.submit()']) ?>
+ Page:= $viewDatas['page'] ?? 1 ?>/= $viewDatas['index_totalpage'] ?>
+ = form_dropdown('perpage', $viewDatas['index_pagination_options'], $viewDatas['perpage'], ['onChange' => 'this.form.submit()']) ?>
/ 총:= $viewDatas['index_totalcount'] ?>
\ No newline at end of file