diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php
index 5ad2078..8fcd028 100644
--- a/app/Helpers/CommonHelper.php
+++ b/app/Helpers/CommonHelper.php
@@ -196,7 +196,7 @@ class CommonHelper
return $ips;
}
- final public function form_dropdown_common(string $field, mixed $value, array $viewDatas, array $extras = []): string
+ final public function form_dropdown_common(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
{
// 필터 옵션이 없으면 빈 배열로 초기화
if (!array_key_exists($field, $viewDatas['control']['field_optons'])) {
@@ -208,7 +208,7 @@ class CommonHelper
}
// $formOptions는 필터 옵션 배열로, key는 필터 엔티티의 PK, value는 필터 엔티티 객체
$html = sprintf("';
return $html;
}
@@ -225,7 +225,7 @@ class CommonHelper
return $label;
}
// header.php에서 getFieldForm_Helper사용
- protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = []): string
+ protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
{
switch ($field) {
default:
@@ -237,7 +237,11 @@ class CommonHelper
if ($entity->getStatus() != $entity::DEFAULT_STATUS)
$isDisabled = ' disabled';
}
- $html .= sprintf("", $key, $isSelected, $isDisabled, $entity->getCustomTitle());
+ $attribute = "";
+ foreach ($attributes as $attribute_tag => $attribute_value) {
+ $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $attribute_value);
+ }
+ $html .= sprintf("", $key, $isSelected, $isDisabled, $attribute, $entity->getCustomTitle());
}
break;
}
diff --git a/app/Helpers/Customer/ServiceHelper.php b/app/Helpers/Customer/ServiceHelper.php
index 1de9ae7..6d42329 100644
--- a/app/Helpers/Customer/ServiceHelper.php
+++ b/app/Helpers/Customer/ServiceHelper.php
@@ -2,30 +2,56 @@
namespace App\Helpers\Customer;
-use App\Helpers\Equipment\ServerHelper;
+use App\Entities\Equipment\ServerEntity;
use App\Models\Customer\ServiceModel;
class ServiceHelper extends CustomerHelper
{
- private ?ServerHelper $_serverHelper = null;
public function __construct()
{
parent::__construct();
$this->setTitleField(field: ServiceModel::TITLE);
- $this->_serverHelper = new ServerHelper();
}
- private function getServerHelper(): ServerHelper
+ protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
{
- return $this->_serverHelper;
+ 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());
+ }
+ 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) {
+ case 'site':
+ $extras['onChange'] = "$('select[name=\'clientinfo_uid\']').select2('open')";
+ $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
+ break;
case 'serverinfo_uid':
if ($value === null && array_key_exists('entity', $viewDatas)) {
$value = $viewDatas['entity']->getServerEntity()->getPK();
}
- $form = parent::getFieldForm($field, $value, $viewDatas, $extras);
+ $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-price' => 'getPrice'];
+ $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
break;
default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
diff --git a/app/Helpers/Equipment/ServerPartHelper.php b/app/Helpers/Equipment/ServerPartHelper.php
index 4ec0784..af9ad1b 100644
--- a/app/Helpers/Equipment/ServerPartHelper.php
+++ b/app/Helpers/Equipment/ServerPartHelper.php
@@ -11,7 +11,7 @@ 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 = []): string
+ protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
{
switch ($field) {
case 'serverinfo_uid':
@@ -97,8 +97,22 @@ class ServerPartHelper extends EquipmentHelper
if (!array_key_exists($field, $viewDatas['entities'])) {
return "";
}
+ $temps = [];
foreach ($viewDatas['entities'][$field] as $entity) {
- $temps[] = $entity->getTitle();
+ $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;
@@ -129,7 +143,7 @@ class ServerPartHelper extends EquipmentHelper
$label ? $label : ICONS['SETUP'],
$action,
[
- "data-src" => "/admin/equipment/serverpart/create?serverinfo_uid={$viewDatas['serverinfo_uid']}&type={$action}&ActionTemplate=popup",
+ "data-src" => "/admin/equipment/serverpart?serverinfo_uid={$viewDatas['serverinfo_uid']}&type={$action}&ActionTemplate=popup",
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras,