dbms_init...1

This commit is contained in:
choi.jh 2025-06-18 16:50:27 +09:00
parent 47f4267fce
commit 4bb3c3ab6b
30 changed files with 325 additions and 255 deletions

View File

@ -4,7 +4,6 @@ namespace App\Controllers\Admin\Customer;
use App\Controllers\Admin\AdminController; use App\Controllers\Admin\AdminController;
use App\Entities\Equipment\Part\IpEntity; use App\Entities\Equipment\Part\IpEntity;
use App\Services\Customer\ClientService;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
@ -12,60 +11,9 @@ use Psr\Log\LoggerInterface;
abstract class CustomerController extends AdminController abstract class CustomerController extends AdminController
{ {
private ?ClientService $_clientService = null;
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);
} }
final public function getClientService(): ClientService
{
if (!$this->_clientService) {
$this->_clientService = new ClientService($this->request);
}
return $this->_clientService;
}
//ServiceController,ServiceItemController,ServicePaymentController등에서 사용됨
final protected function initServiceItemOptions(): void
{
//$item_type(CPU,RAM,STORAGE등)에 따라 선언된 getFormFieldOption용
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
if ($item_type == 'IP') {
$occupied_ips = [];
$forbidden_ips = [];
}
$options = [];
foreach ($this->getService()->getServiceItemLinkService($item_type)->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
if ($item_type == 'IP') {
if ($entity->getStatus() === IpEntity::STATUS_OCCUPIED) {
$occupied_ips[] = $entity->getPK();
}
if ($entity->getStatus() === IpEntity::STATUS_FORBIDDEN) {
$forbidden_ips[] = $entity->getPK();
}
$this->occupied_ips = $occupied_ips;
$this->forbidden_ips = $forbidden_ips;
}
}
$this->setFilterFieldOption($item_type, $options);
}
}
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'clientinfo_uid':
case 'ownerinfo_uid':
foreach ($this->getClientService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
//Index,FieldForm관련 //Index,FieldForm관련
} }

View File

@ -10,7 +10,6 @@ use Psr\Log\LoggerInterface;
use App\Helpers\Customer\ServiceHelper; use App\Helpers\Customer\ServiceHelper;
use App\Services\Customer\ServiceService; use App\Services\Customer\ServiceService;
use App\Services\Customer\ServiceItemService; use App\Services\Customer\ServiceItemService;
use App\Entities\Equipment\CodeEntity;
use App\Services\Equipment\CodeService; use App\Services\Equipment\CodeService;
class ServiceController extends CustomerController class ServiceController extends CustomerController
@ -54,37 +53,6 @@ class ServiceController extends CustomerController
} }
return $this->_serviceItemService; return $this->_serviceItemService;
} }
protected function initAction(string $action): void
{
//$item_type(CPU,RAM,STORAGE등)에 따라 선언된 getFormFieldOption용 사용됨 (initAction보다 먼저 호출해야 됨)
$this->initServiceItemOptions();
parent::initAction($action);
}
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'ownerinfo_uid':
foreach ($this->getClientService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
case 'code':
$occupied_codes = [];
foreach ($this->getCodeService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
if ($entity->getStatus() === CodeEntity::STATUS_OCCUPIED) {
$occupied_codes[] = $entity->getPK();
}
}
//code의 경우 사용중인 filter_options코드전달용
$this->occupied_codes = $occupied_codes;
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{ {
switch ($this->getAction()) { switch ($this->getAction()) {
@ -112,6 +80,11 @@ class ServiceController extends CustomerController
//Index,FieldForm관련 //Index,FieldForm관련
protected function index_process(): array protected function index_process(): array
{ {
//LINE,IP,SERVER등 추가 FilterOption 셋팅용
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
$options = $this->getService()->getServiceItemLinkService($item_type)->getEntities();
$this->setFilterFieldOption($item_type, $options);
}
$entities = []; $entities = [];
foreach (parent::index_process() as $entity) { foreach (parent::index_process() as $entity) {
foreach (SERVICE_ITEM_TYPES as $item_type => $label) { foreach (SERVICE_ITEM_TYPES as $item_type => $label) {

View File

@ -46,20 +46,6 @@ class ServiceHistoryController extends CustomerController
return $this->_serviceService; return $this->_serviceService;
} }
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'serviceinfo_uid':
foreach ($this->getServiceService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{ {
switch ($this->getAction()) { switch ($this->getAction()) {

View File

@ -48,20 +48,21 @@ class ServiceItemController extends CustomerController
} }
return $this->_serviceService; return $this->_serviceService;
} }
protected function initAction(string $action): void protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{ {
//$item_type(CPU,RAM,STORAGE등)에 따라 선언된 getFormFieldOption용 사용됨 (initAction보다 먼저 호출해야 됨) switch ($this->getAction()) {
$this->initServiceItemOptions(); case 'index':
parent::initAction($action); $result = parent::getResultSuccess($message, $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'popup');
break;
default:
$result = parent::getResultSuccess($message, $actionTemplate);
break;
} }
protected function getFormFieldOption(string $field, array $options = []): array return $result;
}
public function getFormFieldOption(string $field, array $options = []): array
{ {
switch ($field) { switch ($field) {
case 'serviceinfo_uid':
foreach ($this->getServiceService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
case 'item_uid': case 'item_uid':
$item_type = $this->request->getVar('item_type'); $item_type = $this->request->getVar('item_type');
if (!$item_type) { if (!$item_type) {
@ -76,20 +77,18 @@ class ServiceItemController extends CustomerController
} }
return $options; return $options;
} }
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{
switch ($this->getAction()) {
case 'index':
$result = parent::getResultSuccess($message, $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'popup');
break;
default:
$result = parent::getResultSuccess($message, $actionTemplate);
break;
}
return $result;
}
//Index,FieldForm관련 //Index,FieldForm관련
protected function create_form_process(): void
{
//LINE,IP,SERVER등 추가 FilterOption 셋팅용
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
$options = $this->getService()->getServiceItemLinkService($item_type)->getEntities();
$this->setFilterFieldOption($item_type, $options);
}
parent::create_form_process();
}
//도메인의 경우 domaininfo에 등록 후 ServiceItemEntity의 item_uid에 넣고 create해야함 //도메인의 경우 domaininfo에 등록 후 ServiceItemEntity의 item_uid에 넣고 create해야함
private function createDomain(ServiceEntity $serviceEntity, array $formDatas): array private function createDomain(ServiceEntity $serviceEntity, array $formDatas): array
{ {
@ -114,4 +113,24 @@ class ServiceItemController extends CustomerController
} }
return parent::create_process($formDatas); return parent::create_process($formDatas);
} }
protected function modify_form_process(mixed $entity): mixed
{
//LINE,IP,SERVER등 추가 FilterOption 셋팅용
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
$options = $this->getService()->getServiceItemLinkService($item_type)->getEntities();
$this->setFilterFieldOption($item_type, $options);
}
return parent::modify_form_process($entity);
}
protected function index_process(): array
{
//LINE,IP,SERVER등 추가 FilterOption 셋팅용
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
$options = $this->getService()->getServiceItemLinkService($item_type)->getEntities();
$this->setFilterFieldOption($item_type, $options);
}
return parent::index_process();
}
} }

View File

@ -48,29 +48,6 @@ class ServicePaymentController extends CustomerController
} }
return $this->_serviceService; return $this->_serviceService;
} }
protected function initAction(string $action): void
{
//$item_type(CPU,RAM,STORAGE등)에 따라 선언된 getFormFieldOption용 사용됨 (initAction보다 먼저 호출해야 됨)
$this->initServiceItemOptions();
parent::initAction($action);
}
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'serviceinfo_uid':
foreach ($this->getServiceService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
case 'item_uid':
$options = [];
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{ {
switch ($this->getAction()) { switch ($this->getAction()) {
@ -95,7 +72,17 @@ class ServicePaymentController extends CustomerController
return $result; return $result;
} }
//Index,FieldForm관련 //Index,FieldForm관련
private function getOwners(ClientEntity $ownerEntity): array protected function index_process(): array
{
//LINE,IP,SERVER등 추가 FilterOption 셋팅용
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
$options = $this->getService()->getServiceItemLinkService($item_type)->getEntities();
$this->setFilterFieldOption($item_type, $options);
}
return parent::index_process();
}
private function getOwnersForInvoice(ClientEntity $ownerEntity): array
{ {
$temps = [ $temps = [
'name' => $ownerEntity->getName(), 'name' => $ownerEntity->getName(),
@ -104,7 +91,7 @@ class ServicePaymentController extends CustomerController
]; ];
return $temps; return $temps;
} }
private function getServices(ServiceEntity $serviceEntity): array private function getServicesForInvoice(ServiceEntity $serviceEntity): array
{ {
$temps = [ $temps = [
'code' => $serviceEntity->getTitle(), 'code' => $serviceEntity->getTitle(),
@ -113,7 +100,7 @@ class ServicePaymentController extends CustomerController
]; ];
return $temps; return $temps;
} }
private function getItems(ServicePaymentEntity $entity): array private function getItemsForInvoice(ServicePaymentEntity $entity): array
{ {
// dd($this->getFilterFieldOptions()); // dd($this->getFilterFieldOptions());
$temps = [ $temps = [
@ -143,18 +130,18 @@ class ServicePaymentController extends CustomerController
$ownerEntity = $entity->getOwner(); $ownerEntity = $entity->getOwner();
if ($ownerEntity->getPK() !== $owner_pk) { if ($ownerEntity->getPK() !== $owner_pk) {
if (!array_key_exists($ownerEntity->getPK(), $entities)) { if (!array_key_exists($ownerEntity->getPK(), $entities)) {
$entities[$ownerEntity->getPK()] = $this->getOwners($ownerEntity); $entities[$ownerEntity->getPK()] = $this->getOwnersForInvoice($ownerEntity);
} }
$owner_pk = $ownerEntity->getPK(); $owner_pk = $ownerEntity->getPK();
} }
//entities에 서비스 설정 //entities에 서비스 설정
$serviceEntity = $entity->getService(); $serviceEntity = $entity->getService();
if (!array_key_exists($serviceEntity->getPK(), $entities[$owner_pk]['services'])) { if (!array_key_exists($serviceEntity->getPK(), $entities[$owner_pk]['services'])) {
$entities[$owner_pk]['services'][$serviceEntity->getPK()] = $this->getServices($serviceEntity); $entities[$owner_pk]['services'][$serviceEntity->getPK()] = $this->getServicesForInvoice($serviceEntity);
} }
//entities에 서비스 Item Type,Item 설정 //entities에 서비스 Item Type,Item 설정
if (!array_key_exists($entity->getPK(), $entities[$owner_pk]['services'][$serviceEntity->getPK()])) { if (!array_key_exists($entity->getPK(), $entities[$owner_pk]['services'][$serviceEntity->getPK()])) {
$entities[$owner_pk]['services'][$serviceEntity->getPK()]['items'][] = $this->getItems($entity); $entities[$owner_pk]['services'][$serviceEntity->getPK()]['items'][] = $this->getItemsForInvoice($entity);
} }
//entities에 총 결제금액 설정 //entities에 총 결제금액 설정
$entities[$ownerEntity->getPK()]['total_amount'] += $entity->getAmount(); $entities[$ownerEntity->getPK()]['total_amount'] += $entity->getAmount();

View File

@ -23,18 +23,4 @@ abstract class EquipmentController extends AdminController
return $this->_clientService; return $this->_clientService;
} }
//Index,FieldForm관련 //Index,FieldForm관련
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'clientinfo_uid':
foreach ($this->getClientService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
} }

View File

@ -44,20 +44,6 @@ class IpController extends PartController
} }
return $this->_lineService; return $this->_lineService;
} }
protected function getFormFieldOption(string $field, $options = []): array
{
switch ($field) {
case 'lineinfo_uid':
foreach ($this->getLineService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
//Index,FieldForm관련 //Index,FieldForm관련
protected function setOrderByForList() protected function setOrderByForList()
{ {

View File

@ -14,19 +14,5 @@ abstract class PartController extends EquipmentController
{ {
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
} }
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'clientinfo_uid':
foreach ($this->getClientService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
//Index,FieldForm관련 //Index,FieldForm관련
} }

View File

@ -9,12 +9,10 @@ use Psr\Log\LoggerInterface;
use App\Services\MyLogService; use App\Services\MyLogService;
use App\Helpers\MyLogHelper; use App\Helpers\MyLogHelper;
use App\Services\UserService;
class MyLogController extends AdminController class MyLogController extends AdminController
{ {
private $_helper = null; private $_helper = null;
private $_userService = null;
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);
@ -38,28 +36,5 @@ class MyLogController extends AdminController
} }
return $this->_helper; return $this->_helper;
} }
public function getUserService(): UserService
{
if (!$this->_userService) {
$this->_userService = new UserService($this->request);
}
return $this->_userService;
}
//Index,FieldForm관련
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'user_uid':
foreach ($this->getUserService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
// dd($options);
return $options;
}
//Index,FieldForm관련 //Index,FieldForm관련
} }

View File

@ -17,7 +17,7 @@ abstract class CommonEntity extends Entity
parent::__construct($data); parent::__construct($data);
} }
final public function getPK(): string public function getPK(): string
{ {
$field = constant("static::PK"); $field = constant("static::PK");
return $this->attributes[$field]; return $this->attributes[$field];

View File

@ -8,4 +8,7 @@ class DomainEntity extends EquipmentEntity
{ {
const PK = DomainModel::PK; const PK = DomainModel::PK;
const TITLE = DomainModel::TITLE; const TITLE = DomainModel::TITLE;
const STATUS_AVAILABLE = "default";
const STATUS_OCCUPIED = "occupied";
const STATUS_FORBIDDEN = "forbidden";
} }

View File

@ -0,0 +1,15 @@
<?php
namespace App\Entities;
class FormOptionEntity extends CommonEntity
{
public function getPK(): string
{
return $this->attributes['uid'];
}
public function getTitle(): string
{
return $this->attributes['title'];
}
}

View File

@ -8,10 +8,14 @@ class CommonHelper
{ {
private $_viewDatas = []; private $_viewDatas = [];
private $_titleField = ""; private $_titleField = "";
protected ?IncomingRequest $request = null; private ?IncomingRequest $_request = null;
protected function __construct(?IncomingRequest $request = null) protected function __construct(?IncomingRequest $request = null)
{ {
$this->request = $request; $this->_request = $request;
}
final public function getRequest(): IncomingRequest|null
{
return $this->_request;
} }
final public function setTitleField(string $field): void final public function setTitleField(string $field): void
{ {
@ -229,15 +233,15 @@ class CommonHelper
// create, modify, create_form, modify_form일때 checkbox로 표시 // create, modify, create_form, modify_form일때 checkbox로 표시
if (in_array($viewDatas['control']['action'], ['create', 'modify', 'create_form', 'modify_form'])) { if (in_array($viewDatas['control']['action'], ['create', 'modify', 'create_form', 'modify_form'])) {
$forms = []; $forms = [];
foreach ($viewDatas['control']['filter_optons'][$field] as $key => $label) { foreach ($viewDatas['control']['filter_optons'][$field] as $key => $filterEntity) {
$values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value); $values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value);
$forms[] = form_checkbox("{$field}[]", $key, in_array($key, $values)) . $label; $forms[] = form_checkbox("{$field}[]", $key, in_array($key, $values)) . $filterEntity->getTitle();
} }
$form = implode(" ", $forms); $form = implode(" ", $forms);
} else { } else {
$formOptions = ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택']; $formOptions = ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'];
foreach ($viewDatas['control']['filter_optons'][$field] as $key => $label) { foreach ($viewDatas['control']['filter_optons'][$field] as $key => $filterEntity) {
$formOptions[$key] = $label; $formOptions[$key] = $filterEntity->getTitle();
} }
$form = form_dropdown($field, $formOptions, $value, $extras); $form = form_dropdown($field, $formOptions, $value, $extras);
} }
@ -261,8 +265,9 @@ class CommonHelper
throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다."); throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다.");
} }
$formOptions = ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택']; $formOptions = ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'];
foreach ($viewDatas['control']['filter_optons'][$field] as $key => $label) { // dd($viewDatas['control']['filter_optons'][$field]);
$formOptions[$key] = $label; foreach ($viewDatas['control']['filter_optons'][$field] as $key => $filterEntity) {
$formOptions[$key] = $filterEntity->getTitle();
} }
$extra_class = isset($extras['class']) ? $extras['class'] . ' select-field' : 'select-field'; $extra_class = isset($extras['class']) ? $extras['class'] . ' select-field' : 'select-field';
// create, modify, create_form, modify_form 액션에서는 기본값:DEFAULTS['STATUS']을 설정 // create, modify, create_form, modify_form 액션에서는 기본값:DEFAULTS['STATUS']을 설정
@ -284,7 +289,7 @@ class CommonHelper
case 'role': case 'role':
$roles = []; $roles = [];
foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) { foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) {
$roles[] = $viewDatas['control']['filter_optons'][$field][$key] ?? ""; $roles[] = $viewDatas['control']['filter_optons'][$field][$key]->getTitle() ?? "";
} }
$value = implode(" , ", $roles); $value = implode(" , ", $roles);
break; break;
@ -316,7 +321,7 @@ class CommonHelper
); );
$value = $this->getFieldForm($field, $value, $viewDatas, $extras); $value = $this->getFieldForm($field, $value, $viewDatas, $extras);
} else { } else {
$value = $viewDatas['control']['filter_optons'][$field][$value]; $value = $viewDatas['control']['filter_optons'][$field][$value]->getTitle();
} }
} }
break; break;
@ -340,7 +345,7 @@ class CommonHelper
if (isset($viewDatas['order_field']) && $viewDatas['order_field'] == $field) { if (isset($viewDatas['order_field']) && $viewDatas['order_field'] == $field) {
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"]; $label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"];
} }
$query = $this->request->getUri()->getQuery(['except' => ['order_field', 'order_value']]); $query = $this->getRequest()->getUri()->getQuery(['except' => ['order_field', 'order_value']]);
$query .= empty($query) ? "" : "&"; $query .= empty($query) ? "" : "&";
$query .= "order_field={$field}&order_value="; $query .= "order_field={$field}&order_value=";
$query .= isset($viewDatas['order_value']) && $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC"; $query .= isset($viewDatas['order_value']) && $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
@ -354,13 +359,13 @@ class CommonHelper
{ {
switch ($action) { switch ($action) {
case 'create': case 'create':
// echo current_url() . '/' . $action . '?' . $this->request->getUri()->getQuery(); // echo current_url() . '/' . $action . '?' . $this->getRequest()->getUri()->getQuery();
$extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
$action = form_label( $action = form_label(
ICONS['ADD'], ICONS['ADD'],
$action, $action,
[ [
"data-src" => current_url() . '/' . $action . '?' . $this->request->getUri()->getQuery(), "data-src" => current_url() . '/' . $action . '?' . $this->getRequest()->getUri()->getQuery(),
"data-bs-toggle" => "modal", "data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form", "data-bs-target" => "#index_action_form",
...$extras ...$extras
@ -381,7 +386,7 @@ class CommonHelper
$viewDatas['cnt'], $viewDatas['cnt'],
$action, $action,
[ [
"data-src" => current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK() . '?' . $this->request->getUri()->getQuery(), "data-src" => current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK() . '?' . $this->getRequest()->getUri()->getQuery(),
"data-bs-toggle" => "modal", "data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form", "data-bs-target" => "#index_action_form",
...$extras ...$extras

View File

@ -2,6 +2,7 @@
namespace App\Helpers\Customer; namespace App\Helpers\Customer;
use App\Entities\Equipment\CodeEntity;
use App\Models\Customer\ServiceModel; use App\Models\Customer\ServiceModel;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
@ -57,13 +58,13 @@ class ServiceHelper extends CustomerHelper
//CodeIgniter 4의 form_dropdown()은 options 배열로만 값을 받기 때문에, disabled 속성 같은 개별 옵션에 대한 HTML 속성 추가는 기본적으로 지원하지 않습니다. //CodeIgniter 4의 form_dropdown()은 options 배열로만 값을 받기 때문에, disabled 속성 같은 개별 옵션에 대한 HTML 속성 추가는 기본적으로 지원하지 않습니다.
$form_temps = ["<select name=\"{$field}\" class=\"select-field\"" . (isset($extras['onChange']) ? " onChange=\"{$extras['onChange']}\"" : "") . ">"]; $form_temps = ["<select name=\"{$field}\" class=\"select-field\"" . (isset($extras['onChange']) ? " onChange=\"{$extras['onChange']}\"" : "") . ">"];
$form_temps[] = "<option value=\"\">" . lang($viewDatas['class_path'] . '.label.' . $field) . " 선택</option>"; $form_temps[] = "<option value=\"\">" . lang($viewDatas['class_path'] . '.label.' . $field) . " 선택</option>";
foreach ($viewDatas['control']['filter_optons'][$field] as $key => $label) { foreach ($viewDatas['control']['filter_optons'][$field] as $key => $filterEntity) {
$disabled = ""; $disabled = "";
if (!array_key_exists('index_content_top_filter', $extras)) { if (!array_key_exists('index_content_top_filter', $extras)) {
$disabled = in_array($key, $viewDatas['occupied_codes']) ? 'disabled="disabled"' : ''; $disabled = $filterEntity->getStatus() === CodeEntity::STATUS_OCCUPIED ? 'disabled="disabled"' : '';
} }
$selected = ($value === $key) ? 'selected="selected"' : ''; $selected = ($value === $key) ? 'selected="selected"' : '';
$form_temps[] = "<option value=\"{$key}\"{$selected} {$disabled}>{$label}</option>"; $form_temps[] = "<option value=\"{$key}\"{$selected} {$disabled}>{$filterEntity->getTitle()}</option>";
} }
$form_temps[] = '</select>'; $form_temps[] = '</select>';
$form = implode("", $form_temps); $form = implode("", $form_temps);
@ -88,10 +89,11 @@ class ServiceHelper extends CustomerHelper
case "DOMAIN": case "DOMAIN":
$temps = ["<ul>"]; $temps = ["<ul>"];
foreach ($viewDatas['entity']->getItemEntities($field) as $itemEntity) { foreach ($viewDatas['entity']->getItemEntities($field) as $itemEntity) {
// dd($viewDatas['control']['filter_optons'][$field]);
$temps[] = sprintf( $temps[] = sprintf(
"<li title=\"%s\">%s&nbsp;%s&nbsp;%s</li>", "<li title=\"%s\">%s&nbsp;%s&nbsp;%s</li>",
$itemEntity->getView_Price(), $itemEntity->getView_Price(),
$viewDatas['control']['filter_optons'][$field][$itemEntity->getItemUid()], $viewDatas['control']['filter_optons'][$field][$itemEntity->getItemUid()]->getTitle(),
$itemEntity->getView_BillingCycle(), $itemEntity->getView_BillingCycle(),
$itemEntity->getView_Sale() $itemEntity->getView_Sale()
); );

View File

@ -2,6 +2,8 @@
namespace App\Helpers\Customer; namespace App\Helpers\Customer;
use App\Entities\Equipment\DomainEntity;
use App\Entities\Equipment\Part\IpEntity;
use App\Models\Customer\ServiceItemModel; use App\Models\Customer\ServiceItemModel;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
@ -15,7 +17,7 @@ class ServiceItemHelper extends CustomerHelper
} }
//ItemType에 따른 조건부 추가 Index Page //ItemType에 따른 조건부 추가 Index Page
public function getFieldFormByItemType(string $field, mixed $value, array $viewDatas, array $extras = []): string private function getFieldFormByItemType(string $field, mixed $value, array $viewDatas, array $extras = []): string
{ {
$form = ""; $form = "";
if (in_array($viewDatas['control']['action'], ['create', 'modify', 'create_form', 'modify_form'])) { if (in_array($viewDatas['control']['action'], ['create', 'modify', 'create_form', 'modify_form'])) {
@ -26,20 +28,52 @@ class ServiceItemHelper extends CustomerHelper
if (in_array($viewDatas['control']['action'], ['create', 'modify', 'create_form', 'modify_form'])) { if (in_array($viewDatas['control']['action'], ['create', 'modify', 'create_form', 'modify_form'])) {
$form = form_input($field, $value ?? "", ["placeholder" => "예)example.com", ...$extras]); $form = form_input($field, $value ?? "", ["placeholder" => "예)example.com", ...$extras]);
} else { } else {
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
}
break;
case 'IP':
if (!is_array($viewDatas['control']['filter_optons'][$field])) { if (!is_array($viewDatas['control']['filter_optons'][$field])) {
throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다."); throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다.");
} }
//CodeIgniter 4의 form_dropdown()은 options 배열로만 값을 받기 때문에, disabled 속성 같은 개별 옵션에 대한 HTML 속성 추가는 기본적으로 지원하지 않습니다. //CodeIgniter 4의 form_dropdown()은 options 배열로만 값을 받기 때문에, disabled 속성 같은 개별 옵션에 대한 HTML 속성 추가는 기본적으로 지원하지 않습니다.
$form_temps = ["<select name=\"{$field}\" class=\"select-field\"" . (isset($extras['onChange']) ? " onChange=\"{$extras['onChange']}\"" : "") . ">"]; $form_temps = ["<select name=\"{$field}\" class=\"select-field\"" . (isset($extras['onChange']) ? " onChange=\"{$extras['onChange']}\"" : "") . ">"];
$form_temps[] = "<option value=\"\">" . lang($viewDatas['class_path'] . '.label.' . $field) . " 선택</option>"; $form_temps[] = "<option value=\"\">" . lang($viewDatas['class_path'] . '.label.' . $field) . " 선택</option>";
foreach ($viewDatas['control']['filter_optons'][$field] as $key => $label) { foreach ($viewDatas['control']['filter_optons'][$field] as $key => $filterEntity) {
$disabled = in_array($key, $viewDatas['occupied_ips']) || in_array($key, $viewDatas['forbidden_ips']) ? 'disabled="disabled"' : ''; $disabled = in_array($filterEntity->getStatus(), [DomainEntity::STATUS_OCCUPIED, DomainEntity::STATUS_FORBIDDEN]) ? 'disabled="disabled"' : '';
$selected = ($value === $key) ? 'selected="selected"' : ''; $selected = ($value === $key) ? 'selected="selected"' : '';
$form_temps[] = "<option value=\"{$key}\"{$selected} {$disabled}>{$label}</option>"; $form_temps[] = "<option value=\"{$key}\"{$selected} {$disabled}>{$filterEntity->getTitle()}</option>";
}
$form_temps[] = '</select>';
$form = implode("", $form_temps);
}
case "LINE":
case "SERVER":
case "CPU":
case "RAM":
case "STORAGE":
case "SOFTWARE":
case "DEFENCE":
if (!is_array($viewDatas['control']['filter_optons'][$field])) {
throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다.");
}
//CodeIgniter 4의 form_dropdown()은 options 배열로만 값을 받기 때문에, disabled 속성 같은 개별 옵션에 대한 HTML 속성 추가는 기본적으로 지원하지 않습니다.
$form_temps = ["<select name=\"{$field}\" class=\"select-field\"" . (isset($extras['onChange']) ? " onChange=\"{$extras['onChange']}\"" : "") . ">"];
$form_temps[] = "<option value=\"\">" . lang($viewDatas['class_path'] . '.label.' . $field) . " 선택</option>";
foreach ($viewDatas['control']['filter_optons'][$field] as $key => $filterEntity) {
$disabled = '';
$selected = ($value === $key) ? 'selected="selected"' : '';
$form_temps[] = "<option value=\"{$key}\"{$selected} {$disabled}>{$filterEntity->getTitle()}</option>";
}
$form_temps[] = '</select>';
$form = implode("", $form_temps);
break;
case "IP":
if (!is_array($viewDatas['control']['filter_optons'][$field])) {
throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다.");
}
//CodeIgniter 4의 form_dropdown()은 options 배열로만 값을 받기 때문에, disabled 속성 같은 개별 옵션에 대한 HTML 속성 추가는 기본적으로 지원하지 않습니다.
$form_temps = ["<select name=\"{$field}\" class=\"select-field\"" . (isset($extras['onChange']) ? " onChange=\"{$extras['onChange']}\"" : "") . ">"];
$form_temps[] = "<option value=\"\">" . lang($viewDatas['class_path'] . '.label.' . $field) . " 선택</option>";
foreach ($viewDatas['control']['filter_optons'][$field] as $key => $filterEntity) {
$disabled = in_array($filterEntity->getStatus(), [IpEntity::STATUS_OCCUPIED, IpEntity::STATUS_FORBIDDEN]) ? 'disabled="disabled"' : '';
$selected = ($value === $key) ? 'selected="selected"' : '';
$form_temps[] = "<option value=\"{$key}\"{$selected} {$disabled}>{$filterEntity->getTitle()}</option>";
} }
$form_temps[] = '</select>'; $form_temps[] = '</select>';
$form = implode("", $form_temps); $form = implode("", $form_temps);
@ -58,7 +92,7 @@ class ServiceItemHelper extends CustomerHelper
} }
switch ($field) { switch ($field) {
case 'item_uid': case 'item_uid':
$form = $this->getFieldFormByItemType($field, $value, $viewDatas, $extras); $form = $this->getFieldFormByItemType($this->getRequest()->getVar('item_type'), $value, $viewDatas, $extras);
break; break;
default: default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras); $form = parent::getFieldForm($field, $value, $viewDatas, $extras);

View File

@ -21,7 +21,7 @@ class ServicePaymentHelper extends CustomerHelper
$value = $viewDatas['entity']->getView_CounDueAt(); $value = $viewDatas['entity']->getView_CounDueAt();
break; break;
case 'item_uid': case 'item_uid':
$value = $viewDatas['control']['filter_optons'][$viewDatas['entity']->getItemType()][$value]; $value = $viewDatas['control']['filter_optons'][$viewDatas['entity']->getItemType()][$value]->getTitle();
break; break;
case 'amount': case 'amount':
$value = number_format($value); $value = number_format($value);
@ -31,7 +31,7 @@ class ServicePaymentHelper extends CustomerHelper
break; break;
default: default:
if (in_array($field, $viewDatas['control']['filter_fields'])) { if (in_array($field, $viewDatas['control']['filter_fields'])) {
$value = $viewDatas['control']['filter_optons'][$field][$value]; $value = $viewDatas['control']['filter_optons'][$field][$value]->getTitle();
} }
break; break;
} }
@ -62,7 +62,7 @@ class ServicePaymentHelper extends CustomerHelper
$viewDatas['cnt'], $viewDatas['cnt'],
$action, $action,
[ [
"data-src" => current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK() . '?' . $this->request->getUri()->getQuery(), "data-src" => current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK() . '?' . $this->getRequest()->getUri()->getQuery(),
"data-bs-toggle" => "modal", "data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form", "data-bs-target" => "#index_action_form",
...$extras ...$extras

View File

@ -21,7 +21,7 @@ class MyLogHelper extends CommonHelper
break; break;
default: default:
if (in_array($field, $viewDatas['control']['filter_fields'])) { if (in_array($field, $viewDatas['control']['filter_fields'])) {
$value = $viewDatas['control']['filter_optons'][$field][$value]; $value = $viewDatas['control']['filter_optons'][$field][$value]->getTitle();
} }
break; break;
} }

View File

@ -13,6 +13,15 @@ return [
'updated_at' => "수정일", 'updated_at' => "수정일",
'created_at' => "신청일", 'created_at' => "신청일",
'deleted_at' => "삭제일", 'deleted_at' => "삭제일",
'SERVER' => "서버",
'LINE' => "회선",
'IP' => "IP",
'CPU' => "CPU",
'RAM' => "메모리",
'STORAGE' => "저장장치",
'SOFTWARE' => "SOFTWARE",
'DEFENCE' => "방어(CS)",
'DOMAIN' => "도메인",
], ],
'DEFAULTS' => [ 'DEFAULTS' => [
'item_type' => "server", 'item_type' => "server",

View File

@ -16,6 +16,7 @@ return [
'default' => "사용가능", 'default' => "사용가능",
"pause" => "일시정지", "pause" => "일시정지",
"occupied" => "사용중", "occupied" => "사용중",
"forbidden" => "금지됨",
"delete" => "삭제", "delete" => "삭제",
], ],
]; ];

View File

@ -2,6 +2,7 @@
namespace App\Services; namespace App\Services;
use App\Entities\FormOptionEntity;
use App\Libraries\LogCollector; use App\Libraries\LogCollector;
abstract class CommonService abstract class CommonService
@ -95,12 +96,16 @@ abstract class CommonService
{ {
switch ($field) { switch ($field) {
default: default:
$options = lang($this->getClassName() . '.' . strtoupper($field)); $options = [];
foreach (lang($this->getClassName() . '.' . strtoupper($field)) as $key => $value) {
$options[$key] = new FormOptionEntity(['uid' => $key, 'title' => $value]);
}
break; break;
} }
if (!is_array($options)) { if (!is_array($options)) {
throw new \Exception(__FUNCTION__ . "에서 field의 options 값이 array가 아닙니다.\n" . var_export($options, true)); throw new \Exception(__FUNCTION__ . "에서 field의 options 값이 array가 아닙니다.\n" . var_export($options, true));
} }
// dd($options);
return $options; return $options;
} }
public function getFormFieldRule(string $action, string $field): string public function getFormFieldRule(string $action, string $field): string

View File

@ -74,6 +74,20 @@ abstract class CustomerService extends CommonService
return $this->_equipmentService[$key]; return $this->_equipmentService[$key];
} }
//기본기능 //기본기능
//FieldForm관련용
public function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'clientinfo_uid':
case 'ownerinfo_uid':
$options = $this->getClientService()->getEntities();
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
final public function getClient(int $uid): ClientEntity final public function getClient(int $uid): ClientEntity
{ {
$entity = $this->getClientService()->getEntity($uid); $entity = $this->getClientService()->getEntity($uid);

View File

@ -57,4 +57,18 @@ class ServiceHistoryService extends CustomerService
return parent::setRelatedEntity($entity); return parent::setRelatedEntity($entity);
} }
//기본 기능부분 //기본 기능부분
//FieldForm관련용
public function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'serviceinfo_uid':
$options = $this->getServiceService()->getEntities();
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
} }

View File

@ -24,10 +24,7 @@ class ServiceItemLinkIpService extends ServiceItemLinkService
public function getFormFieldOption(string $field, array $options = []): array public function getFormFieldOption(string $field, array $options = []): array
{ {
foreach ($this->getIpService()->getEntities() as $entity) { return $this->getIpService()->getEntities();
$options[$entity->getPK()] = $entity->getTitle();
}
return $options;
} }
public function create(array $formDatas, mixed $entity = null): ServiceItemEntity public function create(array $formDatas, mixed $entity = null): ServiceItemEntity

View File

@ -71,6 +71,19 @@ class ServiceItemService extends CustomerService
return parent::setRelatedEntity($entity); return parent::setRelatedEntity($entity);
} }
//기본 기능부분 //기본 기능부분
//FieldForm관련용
public function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'serviceinfo_uid':
$options = $this->getServiceService()->getEntities();
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
public function create(array $formDatas, mixed $entity = null): ServiceItemEntity public function create(array $formDatas, mixed $entity = null): ServiceItemEntity
{ {
$entity = parent::create($formDatas, $entity); $entity = parent::create($formDatas, $entity);

View File

@ -67,7 +67,22 @@ class ServicePaymentService extends CustomerService
return parent::setRelatedEntity($entity); return parent::setRelatedEntity($entity);
} }
//기본 기능부분 //기본 기능부분
//FieldForm관련용
public function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'serviceinfo_uid':
$options = $this->getServiceService()->getEntities();
break;
case 'item_uid':
$options = [];
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
//ServiceItemService에서 사용 //ServiceItemService에서 사용
public function createPaymentByServiceItem(ServiceItemEntity $serviceItemEntity): ServicePaymentEntity public function createPaymentByServiceItem(ServiceItemEntity $serviceItemEntity): ServicePaymentEntity
{ {

View File

@ -89,7 +89,22 @@ class ServiceService extends CustomerService
return parent::findAllDatas($columns); return parent::findAllDatas($columns);
} }
//기본 기능부분 //기본 기능부분
//FieldForm관련용
public function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'ownerinfo_uid':
$options = $this->getClientService()->getEntities();
break;
case 'code':
$options = $this->getCodeService()->getEntities();
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
//다음 달로 결제일을 연장합니다. //다음 달로 결제일을 연장합니다.
final public function extendBillingAt(string $billing_at, string $status): bool final public function extendBillingAt(string $billing_at, string $status): bool
{ {

View File

@ -3,12 +3,35 @@
namespace App\Services\Equipment; namespace App\Services\Equipment;
use App\Services\CommonService; use App\Services\CommonService;
use App\Services\Customer\ClientService;
abstract class EquipmentService extends CommonService abstract class EquipmentService extends CommonService
{ {
private ?ClientService $_clientService = null;
public function __construct(mixed $request = null) public function __construct(mixed $request = null)
{ {
parent::__construct($request); parent::__construct($request);
$this->addClassName('Equipment'); $this->addClassName('Equipment');
} }
final public function getClientService(): ClientService
{
if (!$this->_clientService) {
$this->_clientService = new ClientService($this->request);
}
return $this->_clientService;
}
//FieldForm관련용
public function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'clientinfo_uid':
$options = $this->getClientService()->getEntities();
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
} }

View File

@ -5,9 +5,11 @@ namespace App\Services\Equipment\Part;
use App\Entities\Equipment\Part\IpEntity; use App\Entities\Equipment\Part\IpEntity;
use App\Entities\Equipment\Part\LineEntity; use App\Entities\Equipment\Part\LineEntity;
use App\Models\Equipment\Part\IpModel; use App\Models\Equipment\Part\IpModel;
use App\Services\Equipment\Part\LineService;
class IpService extends PartService class IpService extends PartService
{ {
private ?LineService $_lineService = null;
public function __construct(mixed $request = null) public function __construct(mixed $request = null)
{ {
parent::__construct($request); parent::__construct($request);
@ -41,7 +43,27 @@ class IpService extends PartService
{ {
return ['lineinfo_uid', 'ip', 'status']; return ['lineinfo_uid', 'ip', 'status'];
} }
final public function getLineService(): LineService
{
if (!$this->_lineService) {
$this->_lineService = new LineService($this->request);
}
return $this->_lineService;
}
//기본기능
//FieldForm관련용
public function getFormFieldOption(string $field, $options = []): array
{
switch ($field) {
case 'lineinfo_uid':
$options = $this->getLineService()->getEntities();
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
public function createByLineInfo(LineEntity $entity, string $ip): IpEntity public function createByLineInfo(LineEntity $entity, string $ip): IpEntity
{ {
$formDatas = []; $formDatas = [];

View File

@ -11,4 +11,17 @@ abstract class PartService extends EquipmentService
parent::__construct($request); parent::__construct($request);
$this->addClassName('Part'); $this->addClassName('Part');
} }
//FieldForm관련용
public function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'clientinfo_uid':
$options = $this->getClientService()->getEntities();
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
} }

View File

@ -6,9 +6,11 @@ use App\Entities\MyLogEntity;
use App\Models\MyLogModel; use App\Models\MyLogModel;
use App\Services\Auth\AuthService; use App\Services\Auth\AuthService;
use App\Libraries\LogCollector; use App\Libraries\LogCollector;
use App\Services\UserService;
class MyLogService extends CommonService class MyLogService extends CommonService
{ {
private $_userService = null;
public function __construct(mixed $request = null) public function __construct(mixed $request = null)
{ {
parent::__construct($request); parent::__construct($request);
@ -46,6 +48,28 @@ class MyLogService extends CommonService
{ {
return ['user_uid', 'class_name', 'method_name', 'title', 'status', 'created_at']; return ['user_uid', 'class_name', 'method_name', 'title', 'status', 'created_at'];
} }
public function getUserService(): UserService
{
if (!$this->_userService) {
$this->_userService = new UserService($this->request);
}
return $this->_userService;
}
//기본기능
//FieldForm관련용
public function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'user_uid':
$options = $this->getUserService()->getEntities();
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
// dd($options);
return $options;
}
public function save($service, string $method, AuthService $myauth, string $title): MyLogEntity public function save($service, string $method, AuthService $myauth, string $title): MyLogEntity
{ {
$formDatas = [ $formDatas = [