diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php
index 8fcd028..637ed82 100644
--- a/app/Helpers/CommonHelper.php
+++ b/app/Helpers/CommonHelper.php
@@ -208,7 +208,19 @@ class CommonHelper
}
// $formOptions는 필터 옵션 배열로, key는 필터 엔티티의 PK, value는 필터 엔티티 객체
$html = sprintf("';
return $html;
}
@@ -225,27 +237,17 @@ class CommonHelper
return $label;
}
// header.php에서 getFieldForm_Helper사용
- protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
+ protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = [], mixed $entity): string
{
+ $attribute = "";
switch ($field) {
default:
- $html = "";
- 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);
- }
- $html .= sprintf("", $key, $isSelected, $isDisabled, $attribute, $entity->getCustomTitle());
+ foreach ($attributes as $attribute_tag => $attribute_value) {
+ $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $attribute_value);
}
break;
}
- return $html;
+ return $attribute;
}
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 6d42329..3b5e149 100644
--- a/app/Helpers/Customer/ServiceHelper.php
+++ b/app/Helpers/Customer/ServiceHelper.php
@@ -12,30 +12,21 @@ 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
+ protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = [], mixed $entity): string
{
+ $attribute = "";
switch ($field) {
case 'serverinfo_uid':
- $html = "";
- 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);
- }
- $html .= sprintf("", $key, $isSelected, $isDisabled, $attribute, $entity->getCustomTitle());
+ $attribute = "";
+ foreach ($attributes as $attribute_tag => $attribute_value) {
+ $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity instanceof ServerEntity ? $entity->$attribute_value() : $attribute_value);
}
break;
default:
- $html = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes);
+ $attribute = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes, $entity);
break;
}
- return $html;
+ return $attribute;
}
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 af9ad1b..a7ef7ce 100644
--- a/app/Helpers/Equipment/ServerPartHelper.php
+++ b/app/Helpers/Equipment/ServerPartHelper.php
@@ -2,6 +2,7 @@
namespace App\Helpers\Equipment;
+use App\Entities\Equipment\PartEntity;
use App\Models\Equipment\ServerPartModel;
class ServerPartHelper extends EquipmentHelper
@@ -11,21 +12,20 @@ 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 = []): string
+ protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = [], mixed $entity): string
{
+ $attribute = "";
switch ($field) {
- case 'serverinfo_uid':
- $html = "";
- foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) {
- $isSelected = $key == $value ? ' selected' : '';
- $html .= sprintf("", $key, $isSelected, $entity->getCustomTitle());
+ case 'part_uid':
+ foreach ($attributes as $attribute_tag => $attribute_value) {
+ $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity instanceof PartEntity ? $entity->$attribute_value() : $attribute_value);
}
break;
default:
- $html = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras);
+ $attribute = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes, $entity);
break;
}
- return $html;
+ return $attribute;
}
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
@@ -39,12 +39,14 @@ class ServerPartHelper extends EquipmentHelper
case 'DB':
case 'OS':
case 'SOFTWARE':
- $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
- $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
- break;
case 'part_uid':
+ if ($value === null && array_key_exists('entity', $viewDatas)) {
+ $value = $viewDatas['entity']->getServerEntity()->getPK();
+ }
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
- $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
+ $extras['onChange'] = "document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')";
+ $attributes = ['data-price' => 'getPrice'];
+ $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
break;
default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
@@ -64,13 +66,17 @@ class ServerPartHelper extends EquipmentHelper
case 'SWITCH':
case 'IP':
case 'CS':
+ case 'part_uid':
if (!array_key_exists($field, $viewDatas['entities'])) {
return "";
}
$temps = [];
foreach ($viewDatas['entities'][$field] as $entity) {
- $modal = form_label(
- ICONS['SETUP'],
+ $title = $entity->getTitle();
+ $title .= $entity->getCnt() > 1 ? "*" . $entity->getCnt() . "개" : "";
+ $title .= $entity->getExtra() !== "" ? "/" . $entity->getExtra() : "";
+ $temps[] = form_label(
+ $title,
$field,
[
"data-src" => "/admin/equipment/serverpart/modify/{$entity->getPK()}?type={$entity->getType()}&ActionTemplate=popup",
@@ -80,39 +86,6 @@ class ServerPartHelper extends EquipmentHelper
"target" => "_self"
]
);
- $temps[] = sprintf(
- "%s%s*%s개%s",
- $modal,
- $entity->getTitle(),
- $entity->getCnt(),
- !$entity->getExtra() ? "" : "/" . $entity->getExtra()
- );
- }
- $value = implode("
", $temps);
- break;
- case 'SWITCH_SERVICE':
- case 'IP_SERVICE':
- case 'OS_SERVICE':
- $field = str_replace('_SERVICE', '', $field);
- if (!array_key_exists($field, $viewDatas['entities'])) {
- return "";
- }
- $temps = [];
- foreach ($viewDatas['entities'][$field] as $entity) {
- $modal = form_label(
- $entity->getTitle(),
- $field,
- [
- "data-src" => "/admin/equipment/serverpart/modify/{$entity->getPK()}?type={$entity->getType()}&ActionTemplate=popup",
- "data-bs-toggle" => "modal",
- "data-bs-target" => "#index_action_form",
- "class" => "btn btn-sm btn-outline btn-circle",
- "target" => "_self"
- ]
- );
- $cnt = $entity->getCnt() > 1 ? "*" . $entity->getCnt() . "개" : "";
- $extra = !$entity->getExtra() ? "" : "/";
- $temps[] = $modal . $cnt . $extra;
}
$value = implode(",", $temps);
break;
diff --git a/app/Views/cells/serverpart/partservice.php b/app/Views/cells/serverpart/partservice.php
index 2971580..79aebd6 100644
--- a/app/Views/cells/serverpart/partservice.php
+++ b/app/Views/cells/serverpart/partservice.php
@@ -1,3 +1,3 @@
-= $serverPartCellDatas['service']->getHelper()->getFieldView('SWITCH_SERVICE', "", $serverPartCellDatas) ?> /
-= $serverPartCellDatas['service']->getHelper()->getFieldView('IP_SERVICE', "", $serverPartCellDatas) ?> /
-= $serverPartCellDatas['service']->getHelper()->getFieldView('OS_SERVICE', "", $serverPartCellDatas) ?>
\ No newline at end of file
+= $serverPartCellDatas['service']->getHelper()->getFieldView('SWITCH', "", $serverPartCellDatas) ?> /
+= $serverPartCellDatas['service']->getHelper()->getFieldView('IP', "", $serverPartCellDatas) ?> /
+= $serverPartCellDatas['service']->getHelper()->getFieldView('OS', "", $serverPartCellDatas) ?>
\ No newline at end of file