dbmsv4 init...1

This commit is contained in:
최준흠 2025-11-24 15:48:02 +09:00
parent aeff69ca44
commit bd31409d0c
14 changed files with 97 additions and 80 deletions

View File

@ -10,18 +10,18 @@ use Psr\Log\LoggerInterface;
abstract class AdminController extends CommonController abstract class AdminController extends CommonController
{ {
private $_layout = 'admin'; private $_layout = 'admin';
protected $layouts = [];
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
$this->addActionPaths($this->_layout); $this->addActionPaths($this->_layout);
$this->layouts = LAYOUTS[$this->_layout];
} }
protected function action_init_process(string $action, ?object $entity = null): void protected function action_init_process(string $action, ?object $entity = null): void
{ {
$this->service->action_init_process($action, $entity); $this->service->action_init_process($action, $entity);
parent::action_init_process($action, $entity); parent::action_init_process($action, $entity);
$layouts = LAYOUTS[$this->_layout]; $this->addViewDatas('layout', $this->layouts);
array_push($layouts['javascripts'], '<script src="/js/admin/clipboard.js"></script>');
$this->addViewDatas('layout', $layouts);
$this->addViewDatas('title', $this->getTitle()); $this->addViewDatas('title', $this->getTitle());
$this->addViewDatas('helper', $this->service->getHelper()); $this->addViewDatas('helper', $this->service->getHelper());
$this->addViewDatas('formFields', $this->service->getFormService()->getFormFields()); $this->addViewDatas('formFields', $this->service->getFormService()->getFormFields());

View File

@ -22,6 +22,11 @@ class ServiceController extends CustomerController
return ServiceEntity::class; return ServiceEntity::class;
} }
//기본 함수 작업 //기본 함수 작업
protected function action_init_process(string $action, ?object $entity = null): void
{
$this->layouts['javascripts'][] = '<script src="/js/admin/clipboard.js"></script>';
parent::action_init_process($action, $entity);
}
//Custom 추가 함수 //Custom 추가 함수
public function create_form_process(array $formDatas = []): array public function create_form_process(array $formDatas = []): array
{ {

View File

@ -49,9 +49,9 @@ class BoardForm extends CommonForm
$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, $entity) as $entity) { foreach ($this->getFormOption_process(service('userservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$entity->getPK()] = $entity->getTitle(); $tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
break; break;

View File

@ -51,9 +51,9 @@ class ServiceForm extends CustomerForm
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) { switch ($field) {
case 'serverinfo_uid': case 'serverinfo_uid':
foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $entity) as $entity) { foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$entity->getPK()] = $entity->getCustomTitle(); $tempOptions[$tempEntity->getPK()] = $tempEntity->getCustomTitle();
// $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
break; break;

View File

@ -50,9 +50,24 @@ class ServerForm extends EquipmentForm
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) { switch ($field) {
case 'serviceinfo_uid': case 'serviceinfo_uid':
foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $entity) as $entity) { foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$entity->getPK()] = $entity->getTitle(); $tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
case 'switch':
foreach ($this->getFormOption_process(service('part_switchservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$tempEntity->getTitle()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
// dd($options);
break;
case 'ip':
foreach ($this->getFormOption_process(service('part_ipservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$tempEntity->getTitle()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
break; break;

View File

@ -50,24 +50,24 @@ class ServerPartForm extends EquipmentForm
foreach (SERVERPART['ALL_PARTTYPES'] as $type) { foreach (SERVERPART['ALL_PARTTYPES'] as $type) {
$partService = $this->getPartService($type); $partService = $this->getPartService($type);
$tempOptions[$type] = [lang("{$this->getAttribute('class_path')}.TYPE.{$type}") . " 선택"]; $tempOptions[$type] = [lang("{$this->getAttribute('class_path')}.TYPE.{$type}") . " 선택"];
foreach ($partService->getEntities(['status' => STATUS['AVAILABLE']]) as $entity) { foreach ($partService->getEntities(['status' => STATUS['AVAILABLE']]) as $tempEntity) {
$tempOptions[$type][$entity->getPK()] = $entity->getTitle(); $tempOptions[$type][$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$type][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; // $options['attributes'][$type][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
break; break;
case 'serverinfo_uid': case 'serverinfo_uid':
foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $entity) as $entity) { foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$entity->getPK()] = $entity->getTitle(); $tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
break; break;
case 'serviceinfo_uid': case 'serviceinfo_uid':
foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $entity) as $entity) { foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$entity->getPK()] = $entity->getTitle(); $tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
break; break;

View File

@ -32,16 +32,16 @@ class IPForm extends PartForm
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) { switch ($field) {
case 'lineinfo_uid': case 'lineinfo_uid':
foreach ($this->getFormOption_process(service('equipment_lineservice'), $action, $field, $entity) as $entity) { foreach ($this->getFormOption_process(service('equipment_lineservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$entity->getPK()] = $entity->getTitle(); $tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
break; break;
case 'old_clientinfo_uid': case 'old_clientinfo_uid':
foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $entity) as $entity) { foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$entity->getPK()] = $entity->getTitle(); $tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
// dd($tempOptions); // dd($tempOptions);
$options['options'] = $tempOptions; $options['options'] = $tempOptions;

View File

@ -40,16 +40,16 @@ abstract class PartForm extends CommonForm
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) { switch ($field) {
case 'serviceinfo_uid': case 'serviceinfo_uid':
foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $entity) as $entity) { foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$entity->getPK()] = $entity->getTitle(); $tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
break; break;
case 'serverinfo_uid': case 'serverinfo_uid':
foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $entity) as $entity) { foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$entity->getPK()] = $entity->getTitle(); $tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
break; break;

View File

@ -46,9 +46,9 @@ class PaymentForm extends CommonForm
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) { switch ($field) {
case 'serviceinfo_uid': case 'serviceinfo_uid':
foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $entity) as $entity) { foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$entity->getPK()] = $entity->getTitle(); $tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
break; break;

View File

@ -184,7 +184,8 @@ abstract class CommonHelper
if (in_array($field, $viewDatas['formFilters'])) { if (in_array($field, $viewDatas['formFilters'])) {
if ($value) { if ($value) {
if (!array_key_exists($value, $viewDatas['formOptions'][$field]['options'])) { if (!array_key_exists($value, $viewDatas['formOptions'][$field]['options'])) {
// dd($viewDatas['formOptions'][$field]['options']); echo "VALUE:{$value}";
dd($viewDatas['formOptions'][$field]['options']);
throw new \Exception(__METHOD__ . "에서 오류발생: {$field}에서 {$value}에 해당하는 값이 존재하지 않습니다."); throw new \Exception(__METHOD__ . "에서 오류발생: {$field}에서 {$value}에 해당하는 값이 존재하지 않습니다.");
} }
$value = !$value ? "" : $viewDatas['formOptions'][$field]['options'][$value]; $value = !$value ? "" : $viewDatas['formOptions'][$field]['options'][$value];
@ -197,6 +198,12 @@ abstract class CommonHelper
public function getListFilter(string $field, mixed $value, array $viewDatas, array $extras = []): string public function getListFilter(string $field, mixed $value, array $viewDatas, array $extras = []): string
{ {
switch ($field) { switch ($field) {
case 'user_uid':
case 'clientinfo_uid':
case 'serverinfo_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$filter = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
break;
default: default:
$filter = ""; $filter = "";
if (in_array($field, $viewDatas['formFilters'])) { if (in_array($field, $viewDatas['formFilters'])) {

View File

@ -20,6 +20,11 @@ class ServiceHelper extends CustomerHelper
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras); $form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
break; break;
case 'clientinfo_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
break;
case 'amount': case 'amount':
$form = form_input($field, 0, ["readonly" => "readonly", ...$extras]); $form = form_input($field, 0, ["readonly" => "readonly", ...$extras]);
break; break;
@ -34,7 +39,7 @@ class ServiceHelper extends CustomerHelper
switch ($field) { switch ($field) {
case 'serverinfo_uid': case 'serverinfo_uid':
$value = $viewDatas['formOptions'][$field]['options'][$value]; $value = $viewDatas['formOptions'][$field]['options'][$value];
$value = "<span class=\"serverparts\" style=\"cursor:pointer;\" onClick=\"copyServerPartToClipboard('{$value}?>')\" text-data=\"{$value}\">📋</span>{$value}"; $value = "<span class=\"serverparts\" style=\"cursor:pointer;\" onClick=\"copyServerPartToClipboard('{$value}')\" text-data=\"{$value}\">📋</span>{$value}";
break; break;
case 'amount': case 'amount':
case 'sale': case 'sale':

View File

@ -19,34 +19,17 @@ class ServerHelper extends EquipmentHelper
$form .= form_hidden($field, (string)$value); $form .= form_hidden($field, (string)$value);
} }
break; break;
case 'ip': //값 그대료 표시
$form = "<div class=\"ac-wrap\" style=\"position:relative;\">";
$form .= form_input($field, $value ?? "", [
'id' => 'ipInput',
"list" => "ipList",
"placeholder" => "예: 27.125.207.100",
"autocomplete" => "off",
...$extras
]);
$form .= "<div id=\"ipPanel\" class=\"ac-panel\" hidden></div>";
$form .= "</div>";
break;
case 'switch': //값 그대료 표시
$form = "<div class=\"ac-wrap\" style=\"position:relative;\">";
$form .= form_input($field, $value ?? "", [
'id' => 'switchInput',
"placeholder" => "Switch 코드 입력",
"autocomplete" => "off",
...$extras
]);
$form .= "<div id=\"switchPanel\" class=\"ac-panel\" hidden></div>";
$form .= "</div>";
break;
case 'manufactur_at': case 'manufactur_at':
case 'format_at': case 'format_at':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender';
$form = form_input($field, $value ?? "", $extras); $form = form_input($field, $value ?? "", $extras);
break; break;
case 'switch':
case 'ip':
case 'title':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
break;
default: default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras); $form = parent::getFieldForm($field, $value, $viewDatas, $extras);
break; break;
@ -74,12 +57,24 @@ class ServerHelper extends EquipmentHelper
} }
return $value; return $value;
} }
public function getListFilter(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
switch ($field) {
case 'switch':
case 'ip':
case 'title':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$filter = parent::getListFilter($field, $value, $viewDatas, $extras);
default:
$filter = parent::getListFilter($field, $value, $viewDatas, $extras);
break;
}
return $filter;
}
public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string
{ {
switch ($action) { switch ($action) {
case 'modify':
$action = parent::getListButton($action, $viewDatas['entity']->getCode(), $viewDatas, $extras);
break;
case 'history': case 'history':
$action = $label ? $label : form_label( $action = $label ? $label : form_label(
$label ? $label : ICONS['HISTORY'], $label ? $label : ICONS['HISTORY'],

View File

@ -8,16 +8,4 @@ class SWITCHHelper extends PartHelper
{ {
parent::__construct(); parent::__construct();
} }
public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string
{
switch ($action) {
case 'modify':
$action = parent::getListButton($action, $viewDatas['entity']->getCode(), $viewDatas, $extras);
break;
default:
$action = parent::getListButton($action, $label, $viewDatas, $extras);
break;
}
return $action;
}
} }

View File

@ -61,8 +61,8 @@ class ServerService extends EquipmentService
"type", "type",
"switch", "switch",
"ip", "ip",
"os",
"title", "title",
"os",
"price", "price",
"manufactur_at", "manufactur_at",
"format_at", "format_at",
@ -71,11 +71,13 @@ class ServerService extends EquipmentService
"clientinfo_uid", "clientinfo_uid",
'title', 'title',
'type', 'type',
'switch',
'ip',
'os', 'os',
"status", "status",
]; ];
$indexFilter = $filters; $indexFilter = $filters;
$batchjobFilters = ['type', 'title', 'os', 'status']; $batchjobFilters = ['type', 'title', 'switch', 'ip', 'os', 'status'];
switch ($action) { switch ($action) {
case 'create': case 'create':
case 'create_form': case 'create_form':
@ -84,11 +86,11 @@ class ServerService extends EquipmentService
$fields = [...$fields, 'status']; $fields = [...$fields, 'status'];
break; break;
case 'view': case 'view':
$fields = [...$fields, 'status', 'created_at']; $fields = ['clientinfo_uid', ...$fields, 'status', 'created_at'];
break; break;
case 'index': case 'index':
case 'download': case 'download':
$fields = [...$fields, 'status', 'created_at']; $fields = ['clientinfo_uid', ...$fields, 'status', 'created_at'];
break; break;
} }
$this->getFormService()->setFormFields($fields); $this->getFormService()->setFormFields($fields);