113 lines
3.7 KiB
PHP
113 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace App\Forms\Equipment;
|
|
|
|
class CHASSISForm extends EquipmentForm
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
public function action_init_process(string $action, array $formDatas = []): void
|
|
{
|
|
$fields = [
|
|
"title",
|
|
"price",
|
|
"used",
|
|
"stock",
|
|
"cpuinfo_uid",
|
|
"cpu_cnt",
|
|
"raminfo_uid",
|
|
"ram_cnt",
|
|
"diskinfo_uid",
|
|
"disk_cnt",
|
|
];
|
|
$filters = [
|
|
"cpuinfo_uid",
|
|
"raminfo_uid",
|
|
"diskinfo_uid",
|
|
"status",
|
|
];
|
|
$indexFilter = $filters;
|
|
$batchjobFilters = ['status'];
|
|
$actionButtons = ['view' => ICONS['SEARCH']];
|
|
$batchjobButtons = ['batchjob' => '일괄처리'];
|
|
switch ($action) {
|
|
case 'create':
|
|
case 'create_form':
|
|
case 'modify':
|
|
case 'modify_form':
|
|
$fields = [...$fields, 'status'];
|
|
break;
|
|
case 'view':
|
|
$fields = [...$fields, 'status', 'created_at'];
|
|
break;
|
|
case 'index':
|
|
case 'download':
|
|
$fields = [...$fields, 'status', 'created_at'];
|
|
break;
|
|
}
|
|
$this->setFormFields($fields);
|
|
$this->setFormRules($action, $fields);
|
|
$this->setFormFilters($filters);
|
|
$this->setFormOptions($action, $filters, $formDatas);
|
|
$this->setIndexFilters($indexFilter);
|
|
$this->setBatchjobFilters($batchjobFilters);
|
|
$this->setActionButtons($actionButtons);
|
|
$this->setBatchjobButtons($batchjobButtons);
|
|
}
|
|
public function getFormRule(string $action, string $field, array $formRules): array
|
|
{
|
|
switch ($field) {
|
|
case "used":
|
|
case "price":
|
|
case "stock":
|
|
$formRules[$field] = "required|numeric";
|
|
break;
|
|
case "cpuinfo_uid":
|
|
case "raminfo_uid":
|
|
case "diskinfo_uid":
|
|
case "cpu_cnt":
|
|
case "ram_cnt":
|
|
case "disk_cnt":
|
|
$formRules[$field] = "permit_empty|numeric";
|
|
break;
|
|
default:
|
|
$formRules = parent::getFormRule($action, $field, $formRules);
|
|
break;
|
|
}
|
|
return $formRules;
|
|
}
|
|
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
|
{
|
|
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
|
switch ($field) {
|
|
case "cpuinfo_uid":
|
|
foreach ($this->getFormOption_process(service('part_cpuservice'), $action, $field, $formDatas) as $tempEntity) {
|
|
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
|
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
|
|
}
|
|
$options['options'] = $tempOptions;
|
|
break;
|
|
case "raminfo_uid":
|
|
foreach ($this->getFormOption_process(service('part_ramservice'), $action, $field, $formDatas) as $tempEntity) {
|
|
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
|
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
|
|
}
|
|
$options['options'] = $tempOptions;
|
|
break;
|
|
case "diskinfo_uid":
|
|
foreach ($this->getFormOption_process(service('part_diskservice'), $action, $field, $formDatas) as $tempEntity) {
|
|
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
|
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
|
|
}
|
|
$options['options'] = $tempOptions;
|
|
break;
|
|
default:
|
|
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
}
|