setTitleField(field: ServerPartModel::TITLE); } protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string { $html = ""; switch ($field) { case 'part_uid': foreach ($viewDatas['control']['field_optons'][$field] as $option_key => $option_value) { $isSelected = $option_key == $value ? ' selected' : ''; $isDisabled = ""; $attribute = ""; $label = ""; if ($option_value instanceof CommonEntity) { if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) { if ($option_value->getStatus() != $option_value::DEFAULT_STATUS) $html = " disabled"; } $label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? "X." : ""; $label .= $option_value->getCustomTitle(); } else { $label = $option_value; } $html .= sprintf("", $option_key, $isSelected, $isDisabled, $attribute, $label); } 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 'SWITCH': case 'IP': case 'CS': case 'CPU': case 'RAM': case 'DISK': case 'DB': case 'OS': case 'SOFTWARE': 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'; $extras['onChange'] = "document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')"; $attributes = ['data-type' => 'getType', 'data-price' => 'getPrice']; $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes); break; default: $form = parent::getFieldForm($field, $value, $viewDatas, $extras); break; } echo "Field:{$field}"; return $form; } public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null { switch ($field) { case 'CPU': case 'RAM': case 'DISK': case 'OS': case 'DB': case 'SOFTWARE': case 'SWITCH': case 'IP': case 'CS': case 'part_uid': if (!array_key_exists($field, $viewDatas['entities'])) { return ""; } $temps = []; foreach ($viewDatas['entities'][$field] as $entity) { $title = $entity->getTitle(); $title .= $entity->getCnt() > 1 ? "*" . $entity->getCnt() . "개" : ""; $title .= $entity->getExtra() !== "" ? "/" . $entity->getExtra() : ""; if (array_key_exists('return_type', $extras) && $extras['return_type'] === 'text') { $temps[] = $title; } else { $temps[] = form_label( $title, $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" ] ); } } $value = implode(",", $temps); break; default: $value = parent::getFieldView($field, $value, $viewDatas, $extras); break; } if (is_array($value)) { echo __METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다"; exit; } return $value; } public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string { switch ($action) { case 'SWITCH': case 'IP': case 'CS': case 'CPU': case 'RAM': case 'DISK': case 'OS': case 'DB': case 'SOFTWARE': $extras = [ "class" => "btn btn-sm btn-outline btn-circle", "target" => "_self", ...$extras, ]; $action = form_label( $label ? $label : ICONS["SERVER_ITEM_{$action}"], $action, [ "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, ] ); break; default: $action = parent::getListButton($action, $label, $viewDatas, $extras); break; } return $action; } }