From df7ce1443b2e6d85c5a790dba3fdffba79d40947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Sat, 13 Sep 2025 09:20:06 +0900 Subject: [PATCH] dbmsv2 init...1 --- app/Helpers/CommonHelper.php | 36 ++++++++++++---------- app/Helpers/Customer/ServiceHelper.php | 24 +++++++++++---- app/Helpers/Equipment/ServerPartHelper.php | 25 +++++++++++---- 3 files changed, 56 insertions(+), 29 deletions(-) diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php index 637ed82..6fe4edd 100644 --- a/app/Helpers/CommonHelper.php +++ b/app/Helpers/CommonHelper.php @@ -208,19 +208,9 @@ class CommonHelper } // $formOptions는 필터 옵션 배열로, key는 필터 엔티티의 PK, value는 필터 엔티티 객체 $html = sprintf("'; return $html; } @@ -237,17 +227,29 @@ class CommonHelper return $label; } // header.php에서 getFieldForm_Helper사용 - protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = [], mixed $entity): string + protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string { - $attribute = ""; + $html = ""; switch ($field) { default: - foreach ($attributes as $attribute_tag => $attribute_value) { - $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $attribute_value); + foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) { + $isSelected = $key == $value ? ' selected' : ''; + $isDisabled = ""; + if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) { + if ($entity->getStatus() != $entity::DEFAULT_STATUS) + $isDisabled = " disabled"; + } + $attribute = ""; + foreach ($attributes as $attribute_tag => $attribute_value) { + $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $attribute_value); + } + $title = $entity->getStatus() != $entity::DEFAULT_STATUS ? "X." : ""; + $title .= $entity->getCustomTitle(); + $html .= sprintf("", $key, $isSelected, $isDisabled, $attribute, $title); } break; } - return $attribute; + return $html; } public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string { diff --git a/app/Helpers/Customer/ServiceHelper.php b/app/Helpers/Customer/ServiceHelper.php index 3b5e149..2fd51bf 100644 --- a/app/Helpers/Customer/ServiceHelper.php +++ b/app/Helpers/Customer/ServiceHelper.php @@ -12,21 +12,33 @@ 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 = [], mixed $entity): string + protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string { - $attribute = ""; + $html = ""; switch ($field) { case 'serverinfo_uid': $attribute = ""; - foreach ($attributes as $attribute_tag => $attribute_value) { - $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity instanceof ServerEntity ? $entity->$attribute_value() : $attribute_value); + foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) { + $isSelected = $key == $value ? ' selected' : ''; + $isDisabled = ""; + if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) { + if ($entity->getStatus() != $entity::DEFAULT_STATUS) + $isDisabled = " disabled"; + } + $attribute = ""; + foreach ($attributes as $attribute_tag => $attribute_value) { + $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity instanceof ServerEntity ? $entity->$attribute_value() : $attribute_value); + } + $title = $entity->getStatus() != $entity::DEFAULT_STATUS ? "X." : ""; + $title .= $entity->getCustomTitle(); + $html .= sprintf("", $key, $isSelected, $isDisabled, $attribute, $title); } break; default: - $attribute = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes, $entity); + $html = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes); break; } - return $attribute; + return $html; } public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string { diff --git a/app/Helpers/Equipment/ServerPartHelper.php b/app/Helpers/Equipment/ServerPartHelper.php index a7ef7ce..b95d2db 100644 --- a/app/Helpers/Equipment/ServerPartHelper.php +++ b/app/Helpers/Equipment/ServerPartHelper.php @@ -12,20 +12,33 @@ class ServerPartHelper extends EquipmentHelper parent::__construct(); $this->setTitleField(field: ServerPartModel::TITLE); } - protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = [], mixed $entity): string + protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string { - $attribute = ""; + $html = ""; switch ($field) { case 'part_uid': - foreach ($attributes as $attribute_tag => $attribute_value) { - $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity instanceof PartEntity ? $entity->$attribute_value() : $attribute_value); + $attribute = ""; + foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) { + $isSelected = $key == $value ? ' selected' : ''; + $isDisabled = ""; + if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) { + if ($entity->getStatus() != $entity::DEFAULT_STATUS) + $isDisabled = " disabled"; + } + $attribute = ""; + foreach ($attributes as $attribute_tag => $attribute_value) { + $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity instanceof PartEntity ? $entity->$attribute_value() : $attribute_value); + } + $title = $entity->getStatus() != $entity::DEFAULT_STATUS ? "X." : ""; + $title .= $entity->getCustomTitle(); + $html .= sprintf("", $key, $isSelected, $isDisabled, $attribute, $title); } break; default: - $attribute = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes, $entity); + $html = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes); break; } - return $attribute; + return $html; } public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string {