diff --git a/app/Controllers/Admin/Equipment/ServerController.php b/app/Controllers/Admin/Equipment/ServerController.php index 0193d74..f6f0feb 100644 --- a/app/Controllers/Admin/Equipment/ServerController.php +++ b/app/Controllers/Admin/Equipment/ServerController.php @@ -6,6 +6,7 @@ use App\Entities\Equipment\ServerEntity; use App\Helpers\Equipment\ServerHelper; use App\Services\Equipment\ServerService; +use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; @@ -38,6 +39,28 @@ class ServerController extends EquipmentController return $this->_helper; } //Index,FieldForm관련 + protected function getResultSuccess_process(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string + { + switch ($this->getAction()) { + case 'create_form': + case 'modify_form': + case 'index': + $this->control = $this->getControlDatas(); + $this->getHelper()->setViewDatas($this->getViewDatas()); + $actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'server'; + if ($actionTemplate) { + $view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getAction(); + } else { + $view_file = $this->view_path . $this->getAction(); + } + $result = view($view_file, ['viewDatas' => $this->getViewDatas()]); + break; + default: + $result = parent::getResultSuccess_process($message, $actionTemplate); + break; + } + return $result; + } //생성 protected function create_form_process(): void { diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php index 3ec5fa6..3783415 100644 --- a/app/Helpers/CommonHelper.php +++ b/app/Helpers/CommonHelper.php @@ -210,7 +210,7 @@ class CommonHelper } // header.php에서 getFieldForm_Helper사용 - protected function form_dropdown_custom(string $field, mixed $value, array $viewDatas, array $extras = []): string + public function form_dropdown_custom(string $field, mixed $value, array $viewDatas, array $extras = []): string { $extra = ""; foreach ($extras as $extra_tag => $extra_value) { diff --git a/app/Helpers/Equipment/ServerHelper.php b/app/Helpers/Equipment/ServerHelper.php index 0fee280..7d12b1d 100644 --- a/app/Helpers/Equipment/ServerHelper.php +++ b/app/Helpers/Equipment/ServerHelper.php @@ -11,39 +11,21 @@ class ServerHelper extends EquipmentHelper parent::__construct(); $this->setTitleField(field: ServerModel::TITLE); } - private function getServerPartForm(string $field, string $type, array $viewDatas, array $extras): string + private function getServerPartForm(string $field, mixed $value, array $viewDatas, array $extras, string $type): string { $serverpartEntity = null; if (array_key_exists('entity', $viewDatas)) { $serverpartEntity = $viewDatas['entity']->getServerPartEntity($type); } $form = ""; - if ($serverpartEntity !== null) { //수정시 사용할 uid + if ($serverpartEntity !== null) { //수정시 사용할 hidden uid $form = form_hidden("serverinfopartinfo_uid_{$type}", $serverpartEntity->getPK()); } //기존 입력화면에서 return 된것인지? - $partInfoUID = old($field); - if ($partInfoUID === null && $serverpartEntity !== null) { - $partInfoUID = $serverpartEntity->getPartInfoUID(); - } - $form .= $this->form_dropdown_custom($field, $partInfoUID, $viewDatas, $extras); - $cnt = old("{$field}_cnt"); - if ($cnt === null && $serverpartEntity !== null) { - $cnt = $serverpartEntity->getCnt(); - } else { - $cnt = 1; - } - $form .= " " . form_dropdown("{$field}_cnt", $viewDatas['serverinfopartinfo_cnt_range'], $cnt) . "개"; - //Disk인경우만 추가 정보용 - if (in_array($field, ['partinfo_uid_DISK'])) { - $extra = old("{$field}_extra"); - if ($extra === null && $serverpartEntity !== null) { - $extra = $serverpartEntity->getExtra(); - } else { - $extra = ""; - } - $form .= form_dropdown("{$field}_extra", $viewDatas['serverinfopartinfo_extra_options'], $extra); + if ($value === null && $serverpartEntity !== null) { + $value = $serverpartEntity->getPartInfoUID(); } + $form .= $this->form_dropdown_custom($field, $value, $viewDatas, $extras); return $form; } public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string @@ -55,22 +37,22 @@ class ServerHelper extends EquipmentHelper $form = form_input($field, $value ?? "", $extras); break; case 'partinfo_uid_CPU': - $form = $this->getServerPartForm($field, 'CPU', $viewDatas, $extras); + $form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'CPU'); break; case 'partinfo_uid_RAM': - $form = $this->getServerPartForm($field, 'RAM', $viewDatas, $extras); + $form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'RAM',); break; case 'partinfo_uid_DISK': - $form = $this->getServerPartForm($field, 'DISK', $viewDatas, $extras); + $form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'DISK'); break; case 'partinfo_uid_OS': - $form = $this->getServerPartForm($field, 'OS', $viewDatas, $extras); + $form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'OS'); break; case 'partinfo_uid_DB': - $form = $this->getServerPartForm($field, 'DB', $viewDatas, $extras); + $form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'DB'); break; case 'partinfo_uid_SOFTWARE': - $form = $this->getServerPartForm($field, 'SOFTWARE', $viewDatas, $extras); + $form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'SOFTWARE'); break; case 'ipinfo_uid': case 'csinfo_uid': diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index 97f03eb..1d890ab 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -22,16 +22,17 @@ class ServerService extends EquipmentService "code", "type", "title", - "partinfo_uid_CPU", - "partinfo_uid_RAM", - "partinfo_uid_DISK", - "partinfo_uid_OS", - "ipinfo_uid", "price", "amount", "manufactur_at", "format_at", "status", + "partinfo_uid_CPU", + "partinfo_uid_RAM", + "partinfo_uid_DISK", + "partinfo_uid_OS", + "ipinfo_uid", + "csinfo_uid", ], 'filters' => [ "clientinfo_uid", @@ -43,37 +44,11 @@ class ServerService extends EquipmentService "partinfo_uid_DISK", "partinfo_uid_OS", "ipinfo_uid", + "csinfo_uid", "status" ], ]; } - public function getViewFields(): array - { - return [ - 'fields' => [ - 'clientinfo_uid', - 'serviceinfo_uid', - "type", - 'title', - 'price', - 'amount', - "serverpartinfo", - "ipinfo_uid", - "csinfo_uid", - 'manufactur_at', - "format_at", - 'status' - ], - 'filters' => [ - 'clientinfo_uid', - 'serviceinfo_uid', - 'type', - "ipinfo_uid", - "csinfo_uid", - 'status' - ], - ]; - } public function getIndexFields(): array { return [ @@ -204,6 +179,7 @@ class ServerService extends EquipmentService public function create(array $formDatas): ServerEntity { $entity = parent::create($formDatas); + dd($entity); //ServerPart정보 생성 foreach ($this->getServerPartService()->createByServer($entity, $formDatas) as $serverPartEntity) { $entity->addServerPartEntity($serverPartEntity->getType(), $serverPartEntity); @@ -214,13 +190,13 @@ class ServerService extends EquipmentService } public function modify(mixed $entity, array $formDatas): ServerEntity { - $entity = parent::create($formDatas); - //ServerPart정보 생성 - foreach ($this->getServerPartService()->createByServer($entity, $formDatas) as $serverPartEntity) { - $entity->addServerPartEntity($serverPartEntity->getType(), $serverPartEntity); - }; - //IP정보 생성 - $entity->addIPEntity($this->getIPService()->createByServer($entity, $formDatas)); + $entity = parent::modify($entity, $formDatas); + // //ServerPart정보 생성 + // foreach ($this->getServerPartService()->modifyByServer($entity, $formDatas) as $serverPartEntity) { + // $entity->addServerPartEntity($serverPartEntity->getType(), $serverPartEntity); + // }; + // //IP정보 생성 + // $entity->addIPEntity($this->getIPService()->modifyByServer($entity, $formDatas)); return $entity; } diff --git a/app/Views/admin/server/create_form.php b/app/Views/admin/server/create_form.php new file mode 100644 index 0000000..90f4dd0 --- /dev/null +++ b/app/Views/admin/server/create_form.php @@ -0,0 +1,37 @@ +extend(LAYOUTS[$viewDatas['layout']]['path']) ?> +section('content') ?> +alert($error) ?> +
+
include("templates/{$viewDatas['layout']}/form_content_top"); ?>
+ +
+ + + + + + + + + + + + + +
getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?> + getFieldForm($field, old($field) ?? ($viewDatas['control']['field_default_values'][$field] ?? null), $viewDatas) ?> + +
getFieldLabel("partinfo_uid_{$type}", lang("{$viewDatas['class_path']}.label.partinfo_uid_{$type}"), $viewDatas) ?> + getFieldForm("partinfo_uid_{$type}", old("partinfo_uid_{$type}") ?? ($viewDatas['control']['field_default_values']["partinfo_uid_{$type}"] ?? null), $viewDatas) ?> + + + + + +
+
"btn btn-outline btn-primary")); ?>
+ +
+
include("templates/{$viewDatas['layout']}/form_content_bottom"); ?>
+
+endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/server/index.php b/app/Views/admin/server/index.php new file mode 100644 index 0000000..ef660bb --- /dev/null +++ b/app/Views/admin/server/index.php @@ -0,0 +1,61 @@ +extend(LAYOUTS[$viewDatas['layout']]['path']) ?> +section('content') ?> +alert($error) ?> +
include(LAYOUTS[$viewDatas['layout']]['path'] . '/top'); ?>
+ + + + + + +
+ + include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu'); ?> + + + +
include("templates/{$viewDatas['layout']}/index_header"); ?>
+
+ +
+ include("templates/{$viewDatas['layout']}/index_content_top"); ?> + 'batchjob_form', 'method' => "post"]) ?> + + + + + + + + + + + + + + getStatus() === $viewDatas['entity']::DEFAULT_STATUS ? "" : 'class="table-danger"' ?>> + + + + + + + + + + +
번호getListLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?>작업
getListButton('modify', '', $viewDatas) ?>getFieldView($field, $entity->$field, $viewDatas) ?> + getListButton('view', '', $viewDatas) ?>  + getListButton('history', '', $viewDatas) ?>  + getListButton('delete', '', $viewDatas) ?> +
+ include("templates/{$viewDatas['layout']}/index_content_bottom"); ?> + +
+
+ + +
+ +
include(LAYOUTS[$viewDatas['layout']]['path'] . '/bottom'); ?>
+endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/server/modify_form.php b/app/Views/admin/server/modify_form.php new file mode 100644 index 0000000..d99de5c --- /dev/null +++ b/app/Views/admin/server/modify_form.php @@ -0,0 +1,37 @@ +extend(LAYOUTS[$viewDatas['layout']]['path']) ?> +section('content') ?> +alert($error) ?> +
+
include("templates/{$viewDatas['layout']}/form_content_top"); ?>
+ +
+ + + + + + + + + + + + + +
getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?> + getFieldForm($field, old($field) ?? ($viewDatas['entity']->$field ?? null), $viewDatas) ?> + +
getFieldLabel("partinfo_uid_{$type}", lang("{$viewDatas['class_path']}.label.partinfo_uid_{$type}"), $viewDatas) ?> + getFieldForm("partinfo_uid_{$type}", old("partinfo_uid_{$type}") ?? ($viewDatas['entity']->getServerPartEntity($type)->getPartInfoUID()), $viewDatas) ?> + getServerPartEntity($type)->getCnt()) . "개" ?> + + getServerPartEntity($type)->getExtra()) ?> + + +
+
"btn btn-outline btn-primary")); ?>
+ +
+
include("templates/{$viewDatas['layout']}/form_content_bottom"); ?>
+
+endSection() ?> \ No newline at end of file