dbmsv2 init...1
This commit is contained in:
parent
ba6dfd23b4
commit
51c1dbf72e
@ -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("<select name=\"%s\" %s>", $field, $extra);
|
||||
$html .= $this->form_dropdown_common_process($field, $value, $viewDatas, $extras);
|
||||
$html .= $this->form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes);
|
||||
$html .= '</select>';
|
||||
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("<option value=\"%s\"%s%s>%s</option>", $key, $isSelected, $isDisabled, $entity->getCustomTitle());
|
||||
$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());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -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 = "<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());
|
||||
}
|
||||
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);
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user