dbmsv2 init...1

This commit is contained in:
최준흠 2025-09-13 09:20:06 +09:00
parent 99e15544c4
commit df7ce1443b
3 changed files with 56 additions and 29 deletions

View File

@ -208,19 +208,9 @@ 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;
}
@ -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("<option value=\"%s\"%s%s%s>%s</option>", $key, $isSelected, $isDisabled, $attribute, $title);
}
break;
}
return $attribute;
return $html;
}
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
{

View File

@ -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("<option value=\"%s\"%s%s%s>%s</option>", $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
{

View File

@ -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("<option value=\"%s\"%s%s%s>%s</option>", $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
{