From 09530b370f343dfcc51a47637f42be0cf8bed9c2 Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Tue, 16 Sep 2025 16:47:46 +0900 Subject: [PATCH] dbmsv2 init...1 --- app/Config/Constants.php | 4 ++ .../Admin/Customer/ServiceController.php | 19 +++---- .../Admin/Equipment/ServerController.php | 12 ++--- .../Admin/Equipment/ServerPartController.php | 11 ++++ app/Helpers/CommonHelper.php | 22 +++++--- app/Helpers/Customer/ClientHelper.php | 5 +- app/Helpers/Customer/ServiceHelper.php | 41 +++++++++++++-- app/Helpers/Equipment/ServerPartHelper.php | 51 ++++--------------- app/Services/Customer/ServiceService.php | 4 +- app/Services/Equipment/ServerPartService.php | 4 +- app/Views/cells/serverpart/parttable.php | 14 ++++- 11 files changed, 108 insertions(+), 79 deletions(-) diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 19d1695..3b569b3 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -385,6 +385,10 @@ define("STATUS", [ 'PAID' => 'paid', 'UNPAID' => 'unpaid', ]); +define("STATUS_ICONS", [ + 'AVAILABLE' => "", + 'NOT_AVAILABLE' => "x." +]); //서버 관련 define("SERVER", []); //서비스 관련 diff --git a/app/Controllers/Admin/Customer/ServiceController.php b/app/Controllers/Admin/Customer/ServiceController.php index a540a26..6f44210 100644 --- a/app/Controllers/Admin/Customer/ServiceController.php +++ b/app/Controllers/Admin/Customer/ServiceController.php @@ -65,18 +65,13 @@ class ServiceController extends CustomerController //생성관련 protected function create_form_process(): void { - //Form 기본값정의 - $format = env("Server.Prefix.code.format", false); - if (!$format) { - throw new \Exception(__METHOD__ . "에서 code의 format[Server.Prefix.code.format]이 정의되지 않았습니다."); - } - $this->getService()->setFormDatas([ - 'location' => 'chiba', - 'type' => 'normal', - 'billing_at' => date("Y-m-d"), - 'start_at' => date("Y-m-d"), - 'status' => ServiceEntity::DEFAULT_STATUS, - ]); + $formDatas = $this->getService()->getFormDatas(); + $formDatas['location'] = 'chiba'; + $formDatas['type'] = 'normal'; + $formDatas['billing_at'] = date("Y-m-d"); + $formDatas['start_at'] = date("Y-m-d"); + $formDatas['status'] = ServiceEntity::DEFAULT_STATUS; + $this->getService()->setFormDatas($formDatas); parent::create_form_process(); } protected function create_process(array $formDatas): ServiceEntity diff --git a/app/Controllers/Admin/Equipment/ServerController.php b/app/Controllers/Admin/Equipment/ServerController.php index 26b71ee..0656b7f 100644 --- a/app/Controllers/Admin/Equipment/ServerController.php +++ b/app/Controllers/Admin/Equipment/ServerController.php @@ -57,12 +57,12 @@ class ServerController extends EquipmentController if (!$format) { throw new \Exception(__METHOD__ . "에서 code의 format[Server.Prefix.code.format]이 정의되지 않았습니다."); } - $this->getService()->setFormDatas([ - 'code' => $this->getService()->getLastestCode( - $format, - (int)env("Server.Default.code", 0) - ) - ]); + $formDatas = $this->getService()->getFormDatas(); + $formDatas['code'] = $this->getService()->getLastestCode( + $format, + (int)env("Server.Default.code", 0) + ); + $this->getService()->setFormDatas($formDatas); parent::create_form_process(); } //생성 diff --git a/app/Controllers/Admin/Equipment/ServerPartController.php b/app/Controllers/Admin/Equipment/ServerPartController.php index 0314c6b..21f5ef5 100644 --- a/app/Controllers/Admin/Equipment/ServerPartController.php +++ b/app/Controllers/Admin/Equipment/ServerPartController.php @@ -51,4 +51,15 @@ class ServerPartController extends EquipmentController } return $result; } + + //생성관련 + protected function create_form_process(): void + { + //Form 기본값정의 + $formDatas = $this->getService()->getFormDatas(); + $formDatas['billing'] = 'base'; + $formDatas['cnt'] = 1; + $this->getService()->setFormDatas($formDatas); + parent::create_form_process(); + } } diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php index 7eb8b21..62a92a6 100644 --- a/app/Helpers/CommonHelper.php +++ b/app/Helpers/CommonHelper.php @@ -239,11 +239,12 @@ class CommonHelper $attribute = ""; $label = ""; if ($option_value instanceof CommonEntity) { - if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) { - if ($option_value->getStatus() != $option_value::DEFAULT_STATUS) - $html = " disabled"; - } - $label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? "X." : ""; + // if (in_array($viewDatas['control']['action'], ['create_form'])) { + // if ($option_value->getStatus() != $option_value::DEFAULT_STATUS) { + // $isDisabled = " disabled"; + // } + // } + $label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? STATUS_ICONS['NOT_AVAILABLE'] : STATUS_ICONS['AVAILABLE']; $label .= $option_value->getCustomTitle(); } else { $label = $option_value; @@ -295,8 +296,9 @@ class CommonHelper break; case 'description': case 'content': + case 'detail': case 'history': - $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' tinymce' : 'tinymce'; + // $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' tinymce' : 'tinymce'; $form = form_textarea($field, $value ?? "", $extras); break; case 'user_uid': @@ -349,6 +351,14 @@ class CommonHelper $value = array_key_exists($value, $viewDatas['control']['field_optons'][$field]) && $viewDatas['control']['field_optons'][$field][$value] ? $viewDatas['control']['field_optons'][$field][$value]->getTitle() : ""; break; + case 'description': + case 'content': + case 'history': + case 'detail': + if (in_array($viewDatas['control']['action'], ['view', 'index'])) { + $value = nl2br($value); + } + break; default: if (in_array($field, $viewDatas['control']['actionFilters'])) { //index 액션에서만 filter_options를 변경시 선택된 값을 변경하는 기능 diff --git a/app/Helpers/Customer/ClientHelper.php b/app/Helpers/Customer/ClientHelper.php index 19a75c7..7b99a3e 100644 --- a/app/Helpers/Customer/ClientHelper.php +++ b/app/Helpers/Customer/ClientHelper.php @@ -57,9 +57,6 @@ class ClientHelper extends CustomerHelper ] ); break; - case 'history': - $value = nl2br($value); - break; default: $value = parent::getFieldView($field, $value, $viewDatas, $extras); break; @@ -91,7 +88,7 @@ class ClientHelper extends CustomerHelper $label ? $label : ICONS['HISTORY'], $action, [ - "data-src" => "/admin/customer/clienthistory?clientinfo_uid={$viewDatas['entity']->getPK()}", + "data-src" => "/admin/customer/client/history?clientinfo_uid={$viewDatas['entity']->getPK()}", "data-bs-toggle" => "modal", "data-bs-target" => "#index_action_form", ...$extras diff --git a/app/Helpers/Customer/ServiceHelper.php b/app/Helpers/Customer/ServiceHelper.php index 40795b0..5e0475c 100644 --- a/app/Helpers/Customer/ServiceHelper.php +++ b/app/Helpers/Customer/ServiceHelper.php @@ -2,6 +2,7 @@ namespace App\Helpers\Customer; +use App\Entities\CommonEntity; use App\Entities\Equipment\ServerEntity; use App\Models\Customer\ServiceModel; @@ -12,6 +13,41 @@ class ServiceHelper extends CustomerHelper parent::__construct(); $this->setTitleField(field: ServiceModel::TITLE); } + + protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string + { + $html = ""; + switch ($field) { + case "serverinfo_uid": + foreach ($viewDatas['control']['field_optons'][$field] as $option_key => $option_value) { + $isSelected = $option_key == $value ? ' selected' : ''; + $isDisabled = ""; + $attribute = ""; + $label = ""; + if ($option_value instanceof CommonEntity) { + if (in_array($viewDatas['control']['action'], ['create_form'])) { + if ($option_value->getStatus() != $option_value::DEFAULT_STATUS) { + $isDisabled = " disabled"; + } + } + foreach ($attributes as $attribute_name => $attribute_value) { + $attribute = sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value()); + } + $label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? STATUS_ICONS['NOT_AVAILABLE'] : STATUS_ICONS['AVAILABLE']; + $label .= $option_value->getCustomTitle(); + } else { + $label = $option_value; + } + $html .= sprintf("", $option_key, $isSelected, $isDisabled, $attribute, $label); + } + break; + default: + $html = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes); + break; + } + return $html; + } + public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string { switch ($field) { @@ -47,9 +83,6 @@ class ServiceHelper extends CustomerHelper } } break; - case 'history': - $value = nl2br($value); - break; default: $value = parent::getFieldView($field, $value, $viewDatas, $extras); break; @@ -72,7 +105,7 @@ class ServiceHelper extends CustomerHelper $label ? $label : ICONS['HISTORY'], $action, [ - "data-src" => "/admin/customer/servicehistory?serviceinfo_uid={$viewDatas['entity']->getPK()}&serviceinfo_uid={$viewDatas['entity']->getPK()}&ActionTemplate=popup", + "data-src" => "/admin/customer/service/history?serviceinfo_uid={$viewDatas['entity']->getPK()}&serviceinfo_uid={$viewDatas['entity']->getPK()}&ActionTemplate=popup", "data-bs-toggle" => "modal", "data-bs-target" => "#index_action_form", ...$extras diff --git a/app/Helpers/Equipment/ServerPartHelper.php b/app/Helpers/Equipment/ServerPartHelper.php index 1f6c606..0428a78 100644 --- a/app/Helpers/Equipment/ServerPartHelper.php +++ b/app/Helpers/Equipment/ServerPartHelper.php @@ -16,33 +16,6 @@ class ServerPartHelper extends EquipmentHelper { $html = ""; switch ($field) { - case 'SWITCH': - case 'IP': - case 'CS': - case 'CPU': - case 'RAM': - case 'DISK': - case 'DB': - case 'OS': - case 'SOFTWARE': - foreach ($viewDatas['control']['field_optons'][$field] as $option_key => $option_value) { - $isSelected = $option_key == $value ? ' selected' : ''; - $isDisabled = ""; - $attribute = ""; - $label = ""; - if ($option_value instanceof CommonEntity) { - if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) { - if ($option_value->getStatus() != $option_value::DEFAULT_STATUS) - $html = " disabled"; - } - $label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? "X." : ""; - $label .= $option_value->getCustomTitle(); - } else { - $label = $option_value; - } - $html .= sprintf("", $option_key, $isSelected, $isDisabled, $attribute, $label); - } - break; case 'part_uid': if (!array_key_exists('type', $viewDatas['control']['form_datas']) || !$viewDatas['control']['form_datas']['type']) { throw new \Exception(__METHOD__ . "에서 오류발생: Type가 정의되지 않았습니다."); @@ -53,11 +26,15 @@ class ServerPartHelper extends EquipmentHelper $attribute = ""; $label = ""; if ($option_value instanceof CommonEntity) { - if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) { - if ($option_value->getStatus() != $option_value::DEFAULT_STATUS) - $html = " disabled"; + // if (in_array($viewDatas['control']['action'], ['create_form'])) { + // if ($option_value->getStatus() != $option_value::DEFAULT_STATUS) { + // $isDisabled = " disabled"; + // } + // } + foreach ($attributes as $attribute_name => $attribute_value) { + $attribute = sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value()); } - $label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? "X." : ""; + $label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? STATUS_ICONS['NOT_AVAILABLE'] : STATUS_ICONS['AVAILABLE']; $label .= $option_value->getCustomTitle(); } else { $label = $option_value; @@ -74,18 +51,10 @@ class ServerPartHelper extends EquipmentHelper public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string { switch ($field) { - case 'SWITCH': - case 'IP': - case 'CS': - case 'CPU': - case 'RAM': - case 'DISK': - case 'DB': - case 'OS': - case 'SOFTWARE': + case 'part_uid': $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; $extras['onChange'] = "document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')"; - $attributes = ['data-type' => 'getType', 'data-price' => 'getPrice']; + $attributes = ['data-price' => 'getPrice']; $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes); break; default: diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index 092a9f9..e3515be 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -28,9 +28,9 @@ class ServiceService extends CustomerService "type", "clientinfo_uid", 'serverinfo_uid', + "start_at", "billing_at", "amount", - "start_at", "status", "history", ]; @@ -235,7 +235,7 @@ class ServiceService extends CustomerService throw new \Exception("신규 서버가 지정되지 않았습니다."); } //기존서버정보 사용가능으로 설정 - if ($entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) { + if ($entity->getServerInfoUID() && $entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) { $entity = $this->setServer_process( $entity, $entity->getServerEntity()->getPK(), diff --git a/app/Services/Equipment/ServerPartService.php b/app/Services/Equipment/ServerPartService.php index 976aca1..955bedc 100644 --- a/app/Services/Equipment/ServerPartService.php +++ b/app/Services/Equipment/ServerPartService.php @@ -24,11 +24,11 @@ class ServerPartService extends EquipmentService return [ "serverinfo_uid", "type", - "part_uid", "billing", - "amount", + "part_uid", "cnt", "extra", + "amount", ]; } public function getFormFilters(): array diff --git a/app/Views/cells/serverpart/parttable.php b/app/Views/cells/serverpart/parttable.php index 198ee33..6a5cb08 100644 --- a/app/Views/cells/serverpart/parttable.php +++ b/app/Views/cells/serverpart/parttable.php @@ -1,8 +1,18 @@ + + + + + + + getHelper()->getFieldView($type, $entity->getPK(), $serverPartCellDatas) ?> + + + - - + +
getHelper()->getListButton($type, $type, $serverPartCellDatas) ?>getHelper()->getFieldView($type, "", $serverPartCellDatas) ?>getHelper()->getListButton($type, '', $serverPartCellDatas) ?>
\ No newline at end of file