67 lines
2.9 KiB
PHP
67 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Helpers\Customer;
|
|
|
|
use App\Models\Customer\ServiceItemModel;
|
|
use App\Entities\Equipment\Part\DomainEntity;
|
|
use App\Entities\Equipment\Part\IpEntity;
|
|
|
|
class ServiceItemHelper extends CustomerHelper
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->setTitleField(field: ServiceItemModel::TITLE);
|
|
}
|
|
|
|
//ItemType에 따른 조건부 추가 Index Page
|
|
final function getFieldFormByByItemType(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
|
{
|
|
// dd($viewDatas['control']);
|
|
$item_type = $viewDatas['control']['item_type'];
|
|
//Field는 item_uid이지만 , item_tpe에 따라 filter_options가 달라진다.
|
|
switch ($item_type) {
|
|
case "IP":
|
|
// $options = ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'];
|
|
// // index_content_top_filter가 있으면 disabled를 설정하지 않음
|
|
// // action이 modify_form이면 disabled로 설정하지 않음
|
|
// if (array_key_exists('index_content_top_filter', $extras) || ($viewDatas['control']['action'] == "modify_form" && $value == $filterEntity->getPK())) {
|
|
// $disabledKeys = [];
|
|
// }
|
|
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
|
$form = $this->form_dropdown_disabled($field, $value, $viewDatas['control']['filter_optons'][$item_type], $extras, IpEntity::STATUS_OCCUPIED);
|
|
break;
|
|
case 'DOMAIN':
|
|
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
|
$form = $this->form_dropdown_disabled($field, $value, $viewDatas['control']['filter_optons'][$item_type], $extras, DomainEntity::STATUS_OCCUPIED);
|
|
break;
|
|
case "LINE":
|
|
case "SERVER":
|
|
case "CPU":
|
|
case "RAM":
|
|
case "STORAGE":
|
|
case "SOFTWARE":
|
|
case "DEFENCE":
|
|
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
|
$form = $this->form_dropdown_disabled($field, $value, $viewDatas['control']['filter_optons'][$item_type], $extras);
|
|
break;
|
|
default:
|
|
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
|
break;
|
|
}
|
|
return $form;
|
|
}
|
|
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
|
{
|
|
switch ($field) {
|
|
case 'item_uid':
|
|
$form = $this->getFieldFormByByItemType($field, $value, $viewDatas, $extras);
|
|
break;
|
|
default:
|
|
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
|
break;
|
|
}
|
|
return $form;
|
|
}
|
|
}
|