dbmsv2 init...1
This commit is contained in:
parent
51c1dbf72e
commit
2cfd1a00d4
@ -208,7 +208,19 @@ class CommonHelper
|
||||
}
|
||||
// $formOptions는 필터 옵션 배열로, key는 필터 엔티티의 PK, value는 필터 엔티티 객체
|
||||
$html = sprintf("<select name=\"%s\" %s>", $field, $extra);
|
||||
$html .= $this->form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes);
|
||||
$html .= "<option value=\"\">" . lang("{$viewDatas['class_path']}.label.{$field}") . " 선택" . "</option>";
|
||||
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 = $this->form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes, $entity);
|
||||
$title = $entity->getStatus() != $entity::DEFAULT_STATUS ? "X." : "";
|
||||
$title .= $entity->getCustomTitle();
|
||||
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $key, $isSelected, $isDisabled, $attribute, $title);
|
||||
}
|
||||
$html .= '</select>';
|
||||
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 = "<option value=\"\">" . lang("{$viewDatas['class_path']}.label.{$field}") . " 선택" . "</option>";
|
||||
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("<option value=\"%s\"%s%s%s>%s</option>", $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
|
||||
{
|
||||
|
||||
@ -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 = "<option value=\"\">" . lang("{$viewDatas['class_path']}.label.{$field}") . " 선택" . "</option>";
|
||||
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("<option value=\"%s\"%s%s%s>%s</option>", $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
|
||||
{
|
||||
|
||||
@ -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 = "<option value=\"\">" . lang("{$viewDatas['class_path']}.label.{$field}") . " 선택" . "</option>";
|
||||
foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) {
|
||||
$isSelected = $key == $value ? ' selected' : '';
|
||||
$html .= sprintf("<option value=\"%s\"%s>%s</option>", $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("<BR>", $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;
|
||||
|
||||
@ -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) ?>
|
||||
<?= $serverPartCellDatas['service']->getHelper()->getFieldView('SWITCH', "", $serverPartCellDatas) ?> /
|
||||
<?= $serverPartCellDatas['service']->getHelper()->getFieldView('IP', "", $serverPartCellDatas) ?> /
|
||||
<?= $serverPartCellDatas['service']->getHelper()->getFieldView('OS', "", $serverPartCellDatas) ?>
|
||||
Loading…
Reference in New Issue
Block a user