127 lines
3.3 KiB
PHP
127 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Forms\Customer;
|
|
|
|
class ServiceForm extends CustomerForm
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
public function action_init_process(string $action, array &$formDatas = []): void
|
|
{
|
|
$fields = [
|
|
"site",
|
|
"location",
|
|
"clientinfo_uid",
|
|
'serverinfo_uid',
|
|
"rack",
|
|
"line",
|
|
"title",
|
|
"start_at",
|
|
"billing_at",
|
|
"status",
|
|
'sale',
|
|
"history",
|
|
];
|
|
$filters = [
|
|
'site',
|
|
'location',
|
|
"rack",
|
|
"line",
|
|
'clientinfo_uid',
|
|
'serverinfo_uid',
|
|
'user_uid',
|
|
'status',
|
|
];
|
|
$indexFilter = $filters;
|
|
$batchjobFilters = [
|
|
'site',
|
|
'location',
|
|
'clientinfo_uid',
|
|
'status'
|
|
];
|
|
switch ($action) {
|
|
case 'view':
|
|
$fields = [...$fields, 'created_at'];
|
|
break;
|
|
case 'index':
|
|
case 'download':
|
|
$fields = [
|
|
'site',
|
|
'location',
|
|
'clientinfo_uid',
|
|
'serverinfo_uid',
|
|
'sale',
|
|
'amount',
|
|
'billing_at',
|
|
'status',
|
|
'start_at',
|
|
'created_at'
|
|
];
|
|
break;
|
|
case 'alternative_create_form':
|
|
$fields = ['serverinfo_uid'];
|
|
break;
|
|
}
|
|
$this->setFormFields($fields);
|
|
$this->setFormRules($action, $fields);
|
|
$this->setFormFilters($filters);
|
|
$this->setFormOptions($action, $filters, $formDatas);
|
|
$this->setIndexFilters($indexFilter);
|
|
$this->setBatchjobFilters($batchjobFilters);
|
|
}
|
|
public function getFormRule(string $action, string $field, array $formRules): array
|
|
{
|
|
switch ($field) {
|
|
case "clientinfo_uid":
|
|
case "serverinfo_uid":
|
|
case "amount":
|
|
case "rack":
|
|
case "line":
|
|
$formRules[$field] = "required|numeric";
|
|
break;
|
|
case "sale":
|
|
$formRules[$field] = "permit_empty|numeric";
|
|
break;
|
|
case "site":
|
|
case "location":
|
|
$formRules[$field] = "required|trim|string";
|
|
break;
|
|
case "billing_at":
|
|
case "start_at":
|
|
$formRules[$field] = "required|valid_date";
|
|
break;
|
|
case "end_at":
|
|
$formRules[$field] = "permit_empty|valid_date";
|
|
break;
|
|
case 'title':
|
|
case "history":
|
|
$formRules[$field] = "permit_empty|trim|string";
|
|
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 'serverinfo_uid':
|
|
foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $formDatas) as $tempEntity) {
|
|
$tempOptions[$tempEntity->getPK()] = $tempEntity->getCustomTitle();
|
|
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
|
}
|
|
$options['options'] = $tempOptions;
|
|
break;
|
|
default:
|
|
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
}
|