daemon-idc init
This commit is contained in:
parent
f4091f475c
commit
8d14be8a75
@ -20,18 +20,18 @@ class GoogleForm extends CommonForm
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->setFormFields($fields);
|
$this->setFormFields($fields);
|
||||||
$this->setFormRules($action, $fields);
|
$this->setFormRules($fields);
|
||||||
$this->setFormFilters($filters);
|
$this->setFormFilters($filters);
|
||||||
$this->setFormOptions($action, $filters);
|
$this->setFormOptions($filters);
|
||||||
$this->setBatchjobFilters($filters);
|
$this->setBatchjobFilters($filters);
|
||||||
}
|
}
|
||||||
public function getFormRule(string $action, string $field, array $formRules): array
|
public function getFormRule(string $field, array $formRules): array
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case "access_code":
|
case "access_code":
|
||||||
$formRules[$field] = "required|trim|string";
|
$formRules[$field] = "required|trim|string";
|
||||||
default:
|
default:
|
||||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
$formRules = parent::getFormRule($field, $formRules);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $formRules;
|
return $formRules;
|
||||||
|
|||||||
@ -20,22 +20,22 @@ class LocalForm extends CommonForm
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->setFormFields($fields);
|
$this->setFormFields($fields);
|
||||||
$this->setFormRules($action, $fields);
|
$this->setFormRules($fields);
|
||||||
$this->setFormFilters($filters);
|
$this->setFormFilters($filters);
|
||||||
$this->setFormOptions($action, $filters);
|
$this->setFormOptions($filters);
|
||||||
$this->setBatchjobFilters($filters);
|
$this->setBatchjobFilters($filters);
|
||||||
}
|
}
|
||||||
public function getFormRule(string $action, string $field, array $formRules): array
|
public function getFormRule(string $field, array $formRules): array
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case "id":
|
case "id":
|
||||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($this->_action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||||
break;
|
break;
|
||||||
case "passwd":
|
case "passwd":
|
||||||
$formRules[$field] = in_array($action, ["create", "create_form"]) ? "required|trim|string" : "permit_empty|trim|string";
|
$formRules[$field] = in_array($this->_action, ["create", "create_form"]) ? "required|trim|string" : "permit_empty|trim|string";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
$formRules = parent::getFormRule($field, $formRules);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $formRules;
|
return $formRules;
|
||||||
|
|||||||
@ -59,13 +59,13 @@ class BoardForm extends CommonForm
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->setFormFields($fields);
|
$this->setFormFields($fields);
|
||||||
$this->setFormRules($action, $fields);
|
$this->setFormRules($fields);
|
||||||
$this->setFormFilters($filters);
|
$this->setFormFilters($filters);
|
||||||
$this->setFormOptions($action, $filters, $formDatas);
|
$this->setFormOptions($filters, $formDatas);
|
||||||
$this->setIndexFilters($indexFilter);
|
$this->setIndexFilters($indexFilter);
|
||||||
$this->setBatchjobFilters($batchjobFilters);
|
$this->setBatchjobFilters($batchjobFilters);
|
||||||
}
|
}
|
||||||
public function getFormRule(string $action, string $field, array $formRules): array
|
public function getFormRule(string $field, array $formRules): array
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case "category":
|
case "category":
|
||||||
@ -82,24 +82,24 @@ class BoardForm extends CommonForm
|
|||||||
$formRules[$field] = "permit_empty|string";
|
$formRules[$field] = "permit_empty|string";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
$formRules = parent::getFormRule($field, $formRules);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $formRules;
|
return $formRules;
|
||||||
}
|
}
|
||||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||||
{
|
{
|
||||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'worker_uid':
|
case 'worker_uid':
|
||||||
foreach ($this->getFormOption_process(service('userservice'), $action, $field, $formDatas) as $tempEntity) {
|
foreach ($this->getFormOption_process(service('userservice'), $field, $formDatas) as $tempEntity) {
|
||||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||||
}
|
}
|
||||||
$options['options'] = $tempOptions;
|
$options['options'] = $tempOptions;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
$options = parent::getFormOption($field, $formDatas, $options);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $options;
|
return $options;
|
||||||
|
|||||||
@ -32,7 +32,7 @@ abstract class CommonForm
|
|||||||
private array $_actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
|
private array $_actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
|
||||||
private array $_batchjobButtons = ['batchjob' => '일괄처리', 'batchjob_delete' => '일괄삭제'];
|
private array $_batchjobButtons = ['batchjob' => '일괄처리', 'batchjob_delete' => '일괄삭제'];
|
||||||
protected $validation = null;
|
protected $validation = null;
|
||||||
|
protected string $_action = '';
|
||||||
protected function __construct()
|
protected function __construct()
|
||||||
{
|
{
|
||||||
$this->validation = service('validation');
|
$this->validation = service('validation');
|
||||||
@ -40,6 +40,7 @@ abstract class CommonForm
|
|||||||
|
|
||||||
public function action_init_process(string $action, array &$formDatas = []): void
|
public function action_init_process(string $action, array &$formDatas = []): void
|
||||||
{
|
{
|
||||||
|
$this->_action = $action;
|
||||||
$actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
|
$actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
|
||||||
$batchjobButtons = [];
|
$batchjobButtons = [];
|
||||||
$this->setActionButtons($actionButtons);
|
$this->setActionButtons($actionButtons);
|
||||||
@ -75,10 +76,10 @@ abstract class CommonForm
|
|||||||
return array_intersect_key($this->_formFields, array_flip($fields));
|
return array_intersect_key($this->_formFields, array_flip($fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setFormRules(string $action, array $fields, $formRules = []): void
|
public function setFormRules(array $fields, $formRules = []): void
|
||||||
{
|
{
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$formRules = $this->getFormRule($action, $field, $formRules);
|
$formRules = $this->getFormRule($field, $formRules);
|
||||||
}
|
}
|
||||||
$this->_formRules = $formRules;
|
$this->_formRules = $formRules;
|
||||||
}
|
}
|
||||||
@ -91,10 +92,10 @@ abstract class CommonForm
|
|||||||
return array_intersect_key($this->_formRules, array_flip($fields));
|
return array_intersect_key($this->_formRules, array_flip($fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function setFormOptions(string $action, array $fields, array $formDatas = [], $formOptions = []): void
|
final public function setFormOptions(array $fields, array $formDatas = [], $formOptions = []): void
|
||||||
{
|
{
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$formOptions[$field] = $formOptions[$field] ?? $this->getFormOption($action, $field, $formDatas);
|
$formOptions[$field] = $formOptions[$field] ?? $this->getFormOption($this->_action, $field, $formDatas);
|
||||||
}
|
}
|
||||||
$this->_formOptions = $formOptions;
|
$this->_formOptions = $formOptions;
|
||||||
}
|
}
|
||||||
@ -168,7 +169,7 @@ abstract class CommonForm
|
|||||||
* - 실패 시 FormValidationException(errors 배열)을 throw
|
* - 실패 시 FormValidationException(errors 배열)을 throw
|
||||||
* (AJAX에서 422로 내려보내기 위함)
|
* (AJAX에서 422로 내려보내기 위함)
|
||||||
*/
|
*/
|
||||||
final public function validate(string $action, array &$formDatas): void
|
final public function validate(array &$formDatas): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// 1) 전체 룰/필드
|
// 1) 전체 룰/필드
|
||||||
@ -184,7 +185,7 @@ abstract class CommonForm
|
|||||||
// - modify 계열: 전달받은 formDatas 키에 해당하는 룰만
|
// - modify 계열: 전달받은 formDatas 키에 해당하는 룰만
|
||||||
$targetFields = [];
|
$targetFields = [];
|
||||||
|
|
||||||
if (in_array($action, ['modify', 'modify_form'], true)) {
|
if (in_array($this->_action, ['modify', 'modify_form'], true)) {
|
||||||
// 전달받은 필드만 검증
|
// 전달받은 필드만 검증
|
||||||
$targetFields = array_keys($formDatas);
|
$targetFields = array_keys($formDatas);
|
||||||
|
|
||||||
@ -276,14 +277,14 @@ abstract class CommonForm
|
|||||||
return $label;
|
return $label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormRule(string $action, string $field, array $formRules): array
|
public function getFormRule(string $field, array $formRules): array
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case $this->getAttribute('pk_field'):
|
case $this->getAttribute('pk_field'):
|
||||||
if (!$this->getAttribute('useAutoIncrement')) {
|
if (!$this->getAttribute('useAutoIncrement')) {
|
||||||
$formRules[$field] = sprintf(
|
$formRules[$field] = sprintf(
|
||||||
"required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]%s",
|
"required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]%s",
|
||||||
in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
in_array($this->_action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$formRules[$field] = "required|numeric";
|
$formRules[$field] = "required|numeric";
|
||||||
@ -293,14 +294,14 @@ abstract class CommonForm
|
|||||||
case $this->getAttribute('title_field'):
|
case $this->getAttribute('title_field'):
|
||||||
$formRules[$field] = sprintf(
|
$formRules[$field] = sprintf(
|
||||||
"required|trim|string%s",
|
"required|trim|string%s",
|
||||||
in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
in_array($this->_action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "code":
|
case "code":
|
||||||
$formRules[$field] = sprintf(
|
$formRules[$field] = sprintf(
|
||||||
"required|regex_match[/^[a-zA-Z0-9가-힣\-\_]+$/]|min_length[4]%s",
|
"required|regex_match[/^[a-zA-Z0-9가-힣\-\_]+$/]|min_length[4]%s",
|
||||||
in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
in_array($this->_action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -334,13 +335,13 @@ abstract class CommonForm
|
|||||||
* Options
|
* Options
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
protected function getFormOption_process($service, string $action, string $field, array $formDatas = []): array
|
protected function getFormOption_process($service, string $field, array $formDatas = []): array
|
||||||
{
|
{
|
||||||
$entities = [];
|
$entities = [];
|
||||||
|
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
default:
|
default:
|
||||||
if (in_array($action, ['create_form', 'modify_form', 'alternative_create_form'])) {
|
if (in_array($this->_action, ['create_form', 'modify_form', 'alternative_create_form'])) {
|
||||||
if (array_key_exists($field, $formDatas)) {
|
if (array_key_exists($field, $formDatas)) {
|
||||||
$where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], $this->getAttribute('pk_field'), $formDatas[$field]);
|
$where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], $this->getAttribute('pk_field'), $formDatas[$field]);
|
||||||
} else {
|
} else {
|
||||||
@ -356,20 +357,20 @@ abstract class CommonForm
|
|||||||
return $entities;
|
return $entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||||
{
|
{
|
||||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||||
|
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'user_uid':
|
case 'user_uid':
|
||||||
foreach ($this->getFormOption_process(service('userservice'), $action, $field, $formDatas) as $entity) {
|
foreach ($this->getFormOption_process(service('userservice'), $field, $formDatas) as $entity) {
|
||||||
$tempOptions[$entity->getPK()] = $entity->getTitle();
|
$tempOptions[$entity->getPK()] = $entity->getTitle();
|
||||||
}
|
}
|
||||||
$options['options'] = $tempOptions;
|
$options['options'] = $tempOptions;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'clientinfo_uid':
|
case 'clientinfo_uid':
|
||||||
foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $formDatas) as $entity) {
|
foreach ($this->getFormOption_process(service('customer_clientservice'), $field, $formDatas) as $entity) {
|
||||||
$tempOptions[$entity->getPK()] = $entity->getCustomTitle();
|
$tempOptions[$entity->getPK()] = $entity->getCustomTitle();
|
||||||
}
|
}
|
||||||
$options['options'] = $tempOptions;
|
$options['options'] = $tempOptions;
|
||||||
|
|||||||
@ -53,14 +53,14 @@ class InquiryForm extends CommonForm
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->setFormFields($fields);
|
$this->setFormFields($fields);
|
||||||
$this->setFormRules($action, $fields);
|
$this->setFormRules($fields);
|
||||||
$this->setFormFilters($filters);
|
$this->setFormFilters($filters);
|
||||||
$this->setFormOptions($action, $filters, $formDatas);
|
$this->setFormOptions($filters, $formDatas);
|
||||||
$this->setIndexFilters($indexFilter);
|
$this->setIndexFilters($indexFilter);
|
||||||
$this->setBatchjobFilters($batchjobFilters);
|
$this->setBatchjobFilters($batchjobFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormRule(string $action, string $field, array $formRules): array
|
public function getFormRule(string $field, array $formRules): array
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case "title":
|
case "title":
|
||||||
@ -68,13 +68,13 @@ class InquiryForm extends CommonForm
|
|||||||
$formRules[$field] = "required|trim|string";
|
$formRules[$field] = "required|trim|string";
|
||||||
break;
|
break;
|
||||||
case "email":
|
case "email":
|
||||||
$formRules[$field] = sprintf("required|trim|valid_email%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
$formRules[$field] = sprintf("required|trim|valid_email%s", in_array($this->_action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||||
break;
|
break;
|
||||||
case "status":
|
case "status":
|
||||||
$formRules[$field] = "permit_empty|trim|string";
|
$formRules[$field] = "permit_empty|trim|string";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
$formRules = parent::getFormRule($field, $formRules);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $formRules;
|
return $formRules;
|
||||||
|
|||||||
@ -35,26 +35,26 @@ class UserForm extends CommonForm
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->setFormFields($fields);
|
$this->setFormFields($fields);
|
||||||
$this->setFormRules($action, $fields);
|
$this->setFormRules($fields);
|
||||||
$this->setFormFilters($filters);
|
$this->setFormFilters($filters);
|
||||||
$this->setFormOptions($action, $filters, $formDatas);
|
$this->setFormOptions($filters, $formDatas);
|
||||||
$this->setIndexFilters($indexFilter);
|
$this->setIndexFilters($indexFilter);
|
||||||
$this->setBatchjobFilters($batchjobFilters);
|
$this->setBatchjobFilters($batchjobFilters);
|
||||||
}
|
}
|
||||||
public function getFormRule(string $action, string $field, array $formRules): array
|
public function getFormRule(string $field, array $formRules): array
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case "id":
|
case "id":
|
||||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($this->_action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||||
break;
|
break;
|
||||||
case "passwd":
|
case "passwd":
|
||||||
$formRules[$field] = sprintf("%s|%s", in_array($action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string");
|
$formRules[$field] = sprintf("%s|%s", in_array($this->_action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string");
|
||||||
break;
|
break;
|
||||||
case "confirmpassword":
|
case "confirmpassword":
|
||||||
$formRules[$field] = sprintf("%s|%s", in_array($action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string|matches[passwd]");
|
$formRules[$field] = sprintf("%s|%s", in_array($this->_action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string|matches[passwd]");
|
||||||
break;
|
break;
|
||||||
case "email":
|
case "email":
|
||||||
$formRules[$field] = sprintf("required|trim|valid_email%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
$formRules[$field] = sprintf("required|trim|valid_email%s", in_array($this->_action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||||
break;
|
break;
|
||||||
case "role":
|
case "role":
|
||||||
// $formRules[$field] = 'required|trim|string';
|
// $formRules[$field] = 'required|trim|string';
|
||||||
@ -62,7 +62,7 @@ class UserForm extends CommonForm
|
|||||||
$formRules['role.*'] = 'permit_empty|trim|in_list[manager,cloudflare,firewall,security,director,master]';
|
$formRules['role.*'] = 'permit_empty|trim|in_list[manager,cloudflare,firewall,security,director,master]';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
$formRules = parent::getFormRule($field, $formRules);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $formRules;
|
return $formRules;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user