diff --git a/app/Cells/Customer/ServiceCell.php b/app/Cells/Customer/ServiceCell.php
index 15889bb..fc83d2f 100644
--- a/app/Cells/Customer/ServiceCell.php
+++ b/app/Cells/Customer/ServiceCell.php
@@ -4,6 +4,7 @@ namespace App\Cells\Customer;
use App\Services\Customer\PaymentService;
use App\Services\Customer\ServiceService;
+use App\Services\Equipment\ServerPartService;
class ServiceCell extends CustomerCell
{
@@ -21,7 +22,7 @@ class ServiceCell extends CustomerCell
$this->getService()->setFormOptions();
$entities = $this->getService()->getEntities(['clientinfo_uid' => $params['userinfo_uid']]);
return view('cells/service/detail', [
- 'cellDatas' => [
+ 'serviceCellDatas' => [
'control' => $this->getService()->getControlDatas(),
'service' => $this->getService(),
'entities' => $entities,
diff --git a/app/Cells/Equipment/EquipmentCell.php b/app/Cells/Equipment/EquipmentCell.php
new file mode 100644
index 0000000..09eb1a6
--- /dev/null
+++ b/app/Cells/Equipment/EquipmentCell.php
@@ -0,0 +1,15 @@
+getService()->setAction(__FUNCTION__);
+ $this->getService()->setFormFields();
+ $this->getService()->setFormFilters();
+ $this->getService()->setFormRules();
+ $this->getService()->setFormOptions();
+ $serverPartEntities = $this->getService()->getEntities(['serverinfo_uid' => $params['serverinfo_uid']]);
+ $entities = [];
+ foreach ($serverPartEntities as $entity) {
+ if (!array_key_exists($entity->getType(), $entities)) {
+ $entities[$entity->getType()] = [];
+ }
+ $entities[$entity->getType()][] = $entity;
+ }
+ $template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__;
+ return view('cells/serverpart/' . $template, [
+ 'serverPartCellDatas' => [
+ 'control' => $this->getService()->getControlDatas(),
+ 'service' => $this->getService(),
+ 'entities' => $entities,
+ 'serverinfo_uid' => $params['serverinfo_uid'],
+ 'types' => $params['types'],
+ ]
+ ]);
+ }
+}
diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 8d7ced1..a688ded 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -70,6 +70,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'ClientController::batchjob_delete');
$routes->get('download/(:alpha)', 'ClientController::download/$1');
$routes->get('detail/(:num)', 'ClientController::detail/$1');
+ $routes->post('history/(:num)', 'ClientController::history/$1');
});
$routes->group('account', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
$routes->get('/', 'AccountController::index');
@@ -122,6 +123,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob', 'ServiceController::batchjob');
$routes->post('batchjob_delete', 'ServiceController::batchjob_delete');
$routes->get('download/(:alpha)', 'ServiceController::download/$1');
+ $routes->post('history/(:num)', 'ServiceController::history/$1');
});
$routes->group('serviceitem', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
$routes->get('/', 'ServiceItemController::index');
diff --git a/app/Controllers/Admin/Customer/ClientController.php b/app/Controllers/Admin/Customer/ClientController.php
index 20f8728..03d294a 100644
--- a/app/Controllers/Admin/Customer/ClientController.php
+++ b/app/Controllers/Admin/Customer/ClientController.php
@@ -86,6 +86,9 @@ class ClientController extends CustomerController
}
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
break;
+ case 'history':
+ $result = redirect()->to($this->request->getGET('return_url'))->with('error', $message);
+ break;
default:
$result = parent::getResultSuccess($message, $actionTemplate);
break;
@@ -124,4 +127,31 @@ class ClientController extends CustomerController
// return $this->getResultFail($e->getMessage());
}
}
+
+ public function history(int $uid): RedirectResponse|string
+ {
+ //Transaction Start
+ $db = \Config\Database::connect();
+ $db->transStart();
+ try {
+ $this->getService()->setAction(__FUNCTION__);
+ $this->getService()->setFormFields(['history']);
+ $this->getService()->setFormFilters();
+ $this->getService()->setFormRules();
+ //전달값정의
+ $this->setFormDatas($this->request->getPost());
+ $this->doValidations();
+ //기존 Entity 가져오기
+ $entity = $this->getService()->getEntity($uid);
+ if (!$entity) {
+ throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
+ }
+ $this->entity = $this->getService()->history($entity, $this->getFormDatas());
+ $db->transCommit();
+ return $this->getResultSuccess('고객 비고가 수정되었습니다.');
+ } catch (\Exception $e) {
+ $db->transRollback();
+ return $this->getResultFail($e->getMessage());
+ }
+ }
}
diff --git a/app/Controllers/Admin/Customer/ServiceController.php b/app/Controllers/Admin/Customer/ServiceController.php
index e8447e1..eabff09 100644
--- a/app/Controllers/Admin/Customer/ServiceController.php
+++ b/app/Controllers/Admin/Customer/ServiceController.php
@@ -55,6 +55,9 @@ class ServiceController extends CustomerController
}
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
break;
+ case 'history':
+ $result = redirect()->to($this->request->getGET('return_url'))->with('error', $message);
+ break;
default:
$result = parent::getResultSuccess($message, $actionTemplate);
break;
@@ -62,6 +65,22 @@ class ServiceController extends CustomerController
return $result;
}
//생성관련
+ protected function create_form_process(): void
+ {
+ $format = env("Server.Prefix.code.format", false);
+ if (!$format) {
+ throw new \Exception(__METHOD__ . "에서 code의 format[Server.Prefix.code.format]이 정의되지 않았습니다.");
+ }
+ //기본값정의
+ $this->setFormDatas([
+ 'location' => 'chiba',
+ 'type' => 'normal',
+ 'billing_at' => date("Y-m-d"),
+ 'start_at' => date("Y-m-d"),
+ 'status' => ServiceEntity::DEFAULT_STATUS,
+ ]);
+ parent::create_form_process();
+ }
protected function create_process(array $formDatas): ServiceEntity
{
// 관리자 UID는 현재 인증된 사용자로 설정
@@ -88,4 +107,31 @@ class ServiceController extends CustomerController
//부모함수처리
return parent::index_process($entities);
}
+
+ public function history(int $uid): RedirectResponse|string
+ {
+ //Transaction Start
+ $db = \Config\Database::connect();
+ $db->transStart();
+ try {
+ $this->getService()->setAction(__FUNCTION__);
+ $this->getService()->setFormFields(['history']);
+ $this->getService()->setFormFilters();
+ $this->getService()->setFormRules();
+ //전달값정의
+ $this->setFormDatas($this->request->getPost());
+ $this->doValidations();
+ //기존 Entity 가져오기
+ $entity = $this->getService()->getEntity($uid);
+ if (!$entity) {
+ throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
+ }
+ $this->entity = $this->getService()->history($entity, $this->getFormDatas());
+ $db->transCommit();
+ return $this->getResultSuccess('서비스객 비고가 수정되었습니다.');
+ } catch (\Exception $e) {
+ $db->transRollback();
+ return $this->getResultFail($e->getMessage());
+ }
+ }
}
diff --git a/app/Controllers/Admin/Equipment/ServerPartController.php b/app/Controllers/Admin/Equipment/ServerPartController.php
index 2282887..efa9a1b 100644
--- a/app/Controllers/Admin/Equipment/ServerPartController.php
+++ b/app/Controllers/Admin/Equipment/ServerPartController.php
@@ -24,5 +24,4 @@ class ServerPartController extends EquipmentController
}
return $this->_service;
}
- //Index,FieldForm관련
}
diff --git a/app/Entities/CommonEntity.php b/app/Entities/CommonEntity.php
index fca306c..6320de3 100644
--- a/app/Entities/CommonEntity.php
+++ b/app/Entities/CommonEntity.php
@@ -17,34 +17,43 @@ abstract class CommonEntity extends Entity
parent::__construct($data);
}
- public function getPK(): int|string|null
+ final public function __call($name, $arguments): string
+ {
+ return "";
+ }
+
+ public function getPK(): int|string
{
$field = constant("static::PK");
- return $this->attributes[$field];
+ return $this->attributes[$field] ?? "";
}
public function getTitle(): string
{
$field = constant("static::TITLE");
- return $this->attributes[$field];
+ return $this->attributes[$field] ?? "";
}
public function getCustomTitle(): string
{
return $this->getTitle();
}
- public function getStatus(): string|null
+ final public function getCode(): string
{
- return $this->attributes['status'] ?? null;
+ return $this->attributes['code'] ?? "";
}
- final public function getUpdatedAt(): string|null
+ public function getStatus(): string
{
- return $this->attributes['updated_at'] ?? null;
+ return $this->attributes['status'] ?? "";
+ }
+ final public function getUpdatedAt(): string
+ {
+ return $this->attributes['updated_at'] ?? "";
}
final public function getCreatedAt(): string
{
- return $this->attributes['created_at'];
+ return $this->attributes['created_at'] ?? "";
}
final public function getDeletedAt(): string
{
- return $this->attributes['deleted_at'] ?? null;
+ return $this->attributes['deleted_at'] ?? "";
}
}
diff --git a/app/Entities/Customer/ClientEntity.php b/app/Entities/Customer/ClientEntity.php
index 3050e36..1635981 100644
--- a/app/Entities/Customer/ClientEntity.php
+++ b/app/Entities/Customer/ClientEntity.php
@@ -10,17 +10,13 @@ class ClientEntity extends CustomerEntity
const TITLE = ClientModel::TITLE;
const DEFAULT_STATUS = STATUS['AVAILABLE'];
//타 객체정의 부분
- public function getCode(): string
- {
- return $this->attributes['code'] ?? "null";
- }
public function getName(): string
{
- return $this->attributes['name'];
+ return $this->attributes['name'] ?? "";
}
public function getRole(): string
{
- return $this->attributes['role'];
+ return $this->attributes['role'] ?? "";
}
public function getSaleRate(): int
{
@@ -28,15 +24,15 @@ class ClientEntity extends CustomerEntity
}
public function getAccountBalance(): int
{
- return $this->attributes['account_balance'];
+ return $this->attributes['account_balance'] ?? 0;
}
public function getCouponBalance(): int
{
- return $this->attributes['coupon_balance'];
+ return $this->attributes['coupon_balance'] ?? 0;
}
public function getPointBalance(): int
{
- return $this->attributes['point_balance'];
+ return $this->attributes['point_balance'] ?? 0;
}
public function getHistory(): string
{
diff --git a/app/Entities/Customer/PaymentEntity.php b/app/Entities/Customer/PaymentEntity.php
index c9848fd..c8b6b9d 100644
--- a/app/Entities/Customer/PaymentEntity.php
+++ b/app/Entities/Customer/PaymentEntity.php
@@ -12,19 +12,19 @@ class PaymentEntity extends CustomerEntity
const DEFAULT_STATUS = STATUS['UNPAID'];
public function getBilling(): string
{
- return $this->attributes['billing'];
+ return $this->attributes['billing'] ?? "";
}
public function getAmount(): int
{
- return $this->attributes['amount'];
+ return $this->attributes['amount'] ?? 0;
}
public function getBillingAt(): string
{
- return $this->attributes['billing_at'];
+ return $this->attributes['billing_at'] ?? "";
}
public function getPay(): string
{
- return $this->attributes['pay'];
+ return $this->attributes['pay'] ?? "";
}
public function getCountDueAt(): string
{
diff --git a/app/Entities/Customer/ServiceEntity.php b/app/Entities/Customer/ServiceEntity.php
index dc4be3f..ae4aca0 100644
--- a/app/Entities/Customer/ServiceEntity.php
+++ b/app/Entities/Customer/ServiceEntity.php
@@ -38,25 +38,21 @@ class ServiceEntity extends CustomerEntity
{
return $this->attributes['serverEntity'];
}
- public function getCode(): string|null
- {
- return $this->attributes['code'];
- }
final public function getSite(): string
{
- return $this->attributes['site'];
+ return $this->attributes['site'] ?? "";
}
public function getType(): string
{
- return $this->attributes['type'];
+ return $this->attributes['type'] ?? "";
}
final public function getLocation(): string
{
- return $this->attributes['location'];
+ return $this->attributes['location'] ?? "";
}
final public function getBillingAt(): string
{
- return $this->attributes['billing_at'];
+ return $this->attributes['billing_at'] ?? "";
}
final public function getAmount(): int
{
diff --git a/app/Entities/Equipment/ServerEntity.php b/app/Entities/Equipment/ServerEntity.php
index 6be9494..fe28961 100644
--- a/app/Entities/Equipment/ServerEntity.php
+++ b/app/Entities/Equipment/ServerEntity.php
@@ -2,7 +2,6 @@
namespace App\Entities\Equipment;
-use App\Entities\Equipment\ServerPartEntity;
use App\Models\Equipment\ServerModel;
class ServerEntity extends EquipmentEntity
@@ -10,46 +9,13 @@ class ServerEntity extends EquipmentEntity
const PK = ServerModel::PK;
const TITLE = ServerModel::TITLE;
const DEFAULT_STATUS = STATUS['AVAILABLE'];
- public function addServerPartEntity(string $partType, ServerPartEntity $entity): ServerEntity
- {
- if (!array_key_exists('serverPartEntities', $this->attributes)) {
- $this->attributes['serverPartEntities'] = [];
- }
- if (!array_key_exists($partType, $this->attributes['serverPartEntities'])) {
- $this->attributes['serverPartEntities'][$partType] = [];
- }
- $this->attributes['serverPartEntities'][$partType][] = $entity;
- return $this;
- }
- public function setServerPartEntities(string $partType, array $serverPartEntities): ServerEntity
- {
- if (!array_key_exists('serverPartEntities', $this->attributes)) {
- $this->attributes['serverPartEntities'] = [];
- }
- $this->attributes['serverPartEntities'][$partType] = $serverPartEntities;
- return $this;
- }
- public function getServerPartEntities(string $partType): array
- {
- if (!array_key_exists('serverPartEntities', $this->attributes)) {
- return [];
- }
- if (!array_key_exists($partType, $this->attributes['serverPartEntities'])) {
- return [];
- }
- return $this->attributes['serverPartEntities'][$partType];
- }
//기본기능용
- public function getCode(): string
- {
- return $this->attributes['code'];
- }
public function getCustomTitle(): string
{
return sprintf("[%s] %s", $this->getCode(), $this->getTitle());
}
public function getPrice(): int
{
- return $this->attributes['price'];
+ return $this->attributes['price'] ?? 0;
}
}
diff --git a/app/Entities/Equipment/ServerPartEntity.php b/app/Entities/Equipment/ServerPartEntity.php
index 2f01e8c..ca9d718 100644
--- a/app/Entities/Equipment/ServerPartEntity.php
+++ b/app/Entities/Equipment/ServerPartEntity.php
@@ -34,26 +34,26 @@ class ServerPartEntity extends EquipmentEntity
//기본기능용
public function getPartUID(): int
{
- return $this->attributes['part_uid'];
+ return $this->attributes['part_uid'] ?? 0;
}
public function getType(): string
{
- return $this->attributes['type'];
+ return $this->attributes['type'] ?? "";
}
public function getBilling(): string
{
- return $this->attributes['billing'];
+ return $this->attributes['billing'] ?? "";
}
public function getAmount(): int
{
- return $this->attributes['amount'];
+ return $this->attributes['amount'] ?? 0;
}
public function getCnt(): int
{
- return $this->attributes['cnt'];
+ return $this->attributes['cnt'] ?? 0;
}
- public function getExtra(): string|null
+ public function getExtra(): string
{
- return $this->attributes['extra'] ?? null;
+ return $this->attributes['extra'] ?? "";
}
}
diff --git a/app/Entities/Equipment/SwitchEntity.php b/app/Entities/Equipment/SwitchEntity.php
index d454383..71efbb5 100644
--- a/app/Entities/Equipment/SwitchEntity.php
+++ b/app/Entities/Equipment/SwitchEntity.php
@@ -10,13 +10,8 @@ class SwitchEntity extends EquipmentEntity
const TITLE = SwitchModel::TITLE;
const DEFAULT_STATUS = STATUS['AVAILABLE'];
- public function getCode(): string
- {
- return $this->attributes['code'];
- }
-
public function getPrice(): int
{
- return $this->attributes['price'];
+ return $this->attributes['price'] ?? 0;
}
}
diff --git a/app/Entities/UserEntity.php b/app/Entities/UserEntity.php
index 5fdce70..d416de3 100644
--- a/app/Entities/UserEntity.php
+++ b/app/Entities/UserEntity.php
@@ -13,14 +13,14 @@ class UserEntity extends CommonEntity
public function getID(): string
{
- return $this->attributes['id'];
+ return $this->attributes['id'] ?? "";
}
public function getPassword(): string
{
- return $this->attributes['passwd'];
+ return $this->attributes['passwd'] ?? "";
}
public function getRole(): string
{
- return $this->attributes['role'];
+ return $this->attributes['role'] ?? "";
}
}
diff --git a/app/Entities/UserSNSEntity.php b/app/Entities/UserSNSEntity.php
index 7dbd3c9..ccb9698 100644
--- a/app/Entities/UserSNSEntity.php
+++ b/app/Entities/UserSNSEntity.php
@@ -17,14 +17,14 @@ class UserSNSEntity extends CommonEntity
}
public function getID(): string
{
- return $this->attributes['id'];
+ return $this->attributes['id'] ?? "";
}
public function getSite(): string
{
- return $this->attributes['site'];
+ return $this->attributes['site'] ?? "";
}
public function getEmail(): string
{
- return $this->attributes['email'];
+ return $this->attributes['email'] ?? "";
}
}
diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php
index ede7d75..5ad2078 100644
--- a/app/Helpers/CommonHelper.php
+++ b/app/Helpers/CommonHelper.php
@@ -196,7 +196,7 @@ class CommonHelper
return $ips;
}
- final public function form_dropdown_common(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
+ final public function form_dropdown_common(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
// 필터 옵션이 없으면 빈 배열로 초기화
if (!array_key_exists($field, $viewDatas['control']['field_optons'])) {
@@ -208,7 +208,7 @@ class CommonHelper
}
// $formOptions는 필터 옵션 배열로, key는 필터 엔티티의 PK, value는 필터 엔티티 객체
$html = sprintf("';
return $html;
}
@@ -225,25 +225,19 @@ class CommonHelper
return $label;
}
// header.php에서 getFieldForm_Helper사용
- protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
+ protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
switch ($field) {
default:
$html = "";
foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) {
$isSelected = $key == $value ? ' selected' : '';
- $attribute = "";
- foreach ($attributes as $attribute_tag => $attribute_value) {
- switch ($attribute_tag) {
- case 'disabled':
- $attribute .= in_array($viewDatas['control']['action'], ['create_form', 'index']) && $entity->getStatus() !== ($attribute_value ?? $entity::DEFAULT_STATUS) ? ' disabled' : '';
- break;
- default:
- $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity->$attribute_value);
- break;
- }
+ $isDisabled = "";
+ if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
+ if ($entity->getStatus() != $entity::DEFAULT_STATUS)
+ $isDisabled = ' disabled';
}
- $html .= sprintf("", $key, $isSelected, $attribute, $entity->getCustomTitle());
+ $html .= sprintf("", $key, $isSelected, $isDisabled, $entity->getCustomTitle());
}
break;
}
@@ -300,8 +294,7 @@ class CommonHelper
case 'serviceinfo_uid':
case 'serverinfo_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
- $attributes = ['disabled' => null];
- $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
+ $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
break;
default:
if (in_array($field, $viewDatas['control']['actionFilters'])) {
@@ -377,8 +370,7 @@ class CommonHelper
case 'serviceinfo_uid':
case 'serverinfo_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
- $attributes = ['disabled' => null];
- $filter = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
+ $filter = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
break;
default:
if (in_array($field, $viewDatas['control']['actionFilters'])) {
@@ -431,7 +423,7 @@ class CommonHelper
$checkbox = form_checkbox([
"id" => "checkbox_uid_{$viewDatas['entity']->getPK()}",
"name" => "batchjob_uids[]",
- "value" => $viewDatas['entity']->getPK(),
+ "value" => $label ? $label : $viewDatas['entity']->getPK(),
"class" => "batchjobuids_checkboxs",
"checked" => in_array($viewDatas['entity']->getPK(), $oldBatchJobUids)
]);
diff --git a/app/Helpers/Customer/ClientHelper.php b/app/Helpers/Customer/ClientHelper.php
index b9f8ae7..b83a2bd 100644
--- a/app/Helpers/Customer/ClientHelper.php
+++ b/app/Helpers/Customer/ClientHelper.php
@@ -57,6 +57,9 @@ class ClientHelper extends CustomerHelper
]
);
break;
+ case 'history':
+ $value = nl2br($value);
+ break;
default:
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
break;
diff --git a/app/Helpers/Customer/ServiceHelper.php b/app/Helpers/Customer/ServiceHelper.php
index 83121cf..1de9ae7 100644
--- a/app/Helpers/Customer/ServiceHelper.php
+++ b/app/Helpers/Customer/ServiceHelper.php
@@ -40,7 +40,7 @@ class ServiceHelper extends CustomerHelper
$value = "" . $viewDatas['control']['field_optons'][$field][$value]->getTitle() . "";
break;
case 'serverinfo_uid':
- $value = array_key_exists('entity', $viewDatas) ? $viewDatas['entity']->getServerEntity()->getCustomTitle() : "지정된서버없음";
+ $value = array_key_exists('entity', $viewDatas) ? $viewDatas['entity']->getServerEntity()->getCode() : "지정된서버없음";
break;
case 'billing_at':
if (array_key_exists('unPaids', $viewDatas)) {
@@ -49,17 +49,8 @@ class ServiceHelper extends CustomerHelper
}
}
break;
- case 'CPU':
- case 'RAM':
- case 'DISK':
- case 'OS':
- case 'DB':
- case 'SOFTWARE':
- case 'SWITCH':
- case 'IP':
- case 'CS':
- $viewDatas['serverEntity'] = $viewDatas['entity']->getServerEntity();
- $value = $this->getServerHelper()->getFieldView($field, $value, $viewDatas, $extras);
+ case 'history':
+ $value = nl2br($value);
break;
default:
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
@@ -91,18 +82,6 @@ class ServiceHelper extends CustomerHelper
]
);
break;
- case 'SWITCH':
- case 'IP':
- case 'CS':
- case 'CPU':
- case 'RAM':
- case 'DISK':
- case 'OS':
- case 'DB':
- case 'SOFTWARE':
- $viewDatas['serverEntity'] = $viewDatas['entity']->getServerEntity();
- $action = $this->getServerHelper()->getListButton($action, $label, $viewDatas, $extras);
- break;
default:
$action = parent::getListButton($action, $label, $viewDatas, $extras);
break;
diff --git a/app/Helpers/Equipment/ServerHelper.php b/app/Helpers/Equipment/ServerHelper.php
index d48977e..35b5195 100644
--- a/app/Helpers/Equipment/ServerHelper.php
+++ b/app/Helpers/Equipment/ServerHelper.php
@@ -6,16 +6,10 @@ use App\Models\Equipment\ServerModel;
class ServerHelper extends EquipmentHelper
{
- private ?ServerPartHelper $_serverPartHelper = null;
public function __construct()
{
parent::__construct();
$this->setTitleField(field: ServerModel::TITLE);
- $this->_serverPartHelper = new ServerPartHelper();
- }
- private function getServerPartHelper(): ServerPartHelper
- {
- return $this->_serverPartHelper;
}
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
@@ -29,15 +23,6 @@ class ServerHelper extends EquipmentHelper
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender';
$form = form_input($field, $value ?? "", $extras);
break;
- case 'CPU':
- case 'CPU_cnt':
- case 'RAM':
- case 'RAM_cnt':
- case 'DISK':
- case 'DISK_cnt':
- case 'DISK_extra':
- $form = $this->getServerPartHelper()->getFieldForm($field, $value, $viewDatas, $extras);
- break;
default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
break;
@@ -51,19 +36,6 @@ class ServerHelper extends EquipmentHelper
case 'format_at':
$value = $value ? date("Y-m-d", strtotime($value)) : "";
break;
- case 'CPU':
- case 'RAM':
- case 'DISK':
- case 'OS':
- case 'DB':
- case 'SOFTWARE':
- case 'SWITCH':
- case 'IP':
- case 'CS':
- $serverEntity = array_key_exists('serverEntity', $viewDatas) ? $viewDatas['serverEntity'] : $viewDatas['entity'];
- $viewDatas['serverPartEntities'] = $serverEntity->getServerPartEntities($field);
- $value = $this->getServerPartHelper()->getFieldView($field, $value, $viewDatas, $extras);
- break;
default:
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
break;
@@ -93,19 +65,6 @@ class ServerHelper extends EquipmentHelper
]
);
break;
- case 'SWITCH':
- case 'IP':
- case 'CS':
- case 'CPU':
- case 'RAM':
- case 'DISK':
- case 'OS':
- case 'DB':
- case 'SOFTWARE':
- $serverEntity = array_key_exists('serverEntity', $viewDatas) ? $viewDatas['serverEntity'] : $viewDatas['entity'];
- $viewDatas['serverinfo_uid'] = $serverEntity->getPK();
- $action = $this->getServerPartHelper()->getListButton($action, $label, $viewDatas, $extras);
- break;
default:
$action = parent::getListButton($action, $label, $viewDatas, $extras);
break;
diff --git a/app/Helpers/Equipment/ServerPartHelper.php b/app/Helpers/Equipment/ServerPartHelper.php
index 544f30e..4ec0784 100644
--- a/app/Helpers/Equipment/ServerPartHelper.php
+++ b/app/Helpers/Equipment/ServerPartHelper.php
@@ -2,7 +2,6 @@
namespace App\Helpers\Equipment;
-use App\Entities\FormOptionEntity;
use App\Models\Equipment\ServerPartModel;
class ServerPartHelper extends EquipmentHelper
@@ -12,29 +11,18 @@ class ServerPartHelper extends EquipmentHelper
parent::__construct();
$this->setTitleField(field: ServerPartModel::TITLE);
}
- protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
+ protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
switch ($field) {
- case 'part_uid':
+ case 'serverinfo_uid':
$html = "";
foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) {
$isSelected = $key == $value ? ' selected' : '';
- $attribute = "";
- foreach ($attributes as $attribute_tag => $attribute_value) {
- switch ($attribute_tag) {
- case 'disabled':
- $attribute .= in_array($viewDatas['control']['action'], ['create_form', 'index']) && $entity->getStatus() !== ($attribute_value ?? $entity::DEFAULT_STATUS) ? ' disabled' : '';
- break;
- default:
- $attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity->$attribute_value);
- break;
- }
- }
- $html .= sprintf("", $key, $isSelected, $attribute, $entity->getCustomTitle());
+ $html .= sprintf("", $key, $isSelected, $entity->getCustomTitle());
}
break;
default:
- $html = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes);
+ $html = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras);
break;
}
return $html;
@@ -54,27 +42,9 @@ class ServerPartHelper extends EquipmentHelper
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
break;
- case 'CPU_cnt':
- case 'RAM_cnt':
- case 'DISK_cnt':
- case 'DB_cnt':
- case 'OS_cnt':
- case 'SOFTWARE_cnt':
- $form = "*" . form_dropdown($field, SERVERPART['CNT_RANGE'], $value, $extras) . "개";
- break;
- case 'DISK_extra':
- $formOptionDatas = lang("Equipment/ServerPart.EXTRA");
- if (!is_array($formOptionDatas)) {
- throw new \Exception(__FUNCTION__ . "에서 {$field}}의 formOptionDatas 값이 array가 아닙니다.\n" . var_export($formOptionDatas, true));
- }
- $options = ["" => lang("Equipment/ServerPart.label.extra") . " 선택", ...$formOptionDatas];
- $form = form_dropdown($field, $options, $value, $extras);
- break;
case 'part_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
- $extras['onChange'] = "document.getElementById('amount').value=this.options[this.selectedIndex].getAttribute('data-price')";
- $attributes = ['disabled' => null, 'data-price' => 'getPrice'];
- $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
+ $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
break;
default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
@@ -94,13 +64,16 @@ class ServerPartHelper extends EquipmentHelper
case 'SWITCH':
case 'IP':
case 'CS':
+ if (!array_key_exists($field, $viewDatas['entities'])) {
+ return "";
+ }
$temps = [];
- foreach ($viewDatas['serverPartEntities'] as $partEntity) {
+ foreach ($viewDatas['entities'][$field] as $entity) {
$modal = form_label(
ICONS['SETUP'],
$field,
[
- "data-src" => "/admin/equipment/serverpart/modify/{$partEntity->getPK()}?type={$partEntity->getType()}&ActionTemplate=popup",
+ "data-src" => "/admin/equipment/serverpart/modify/{$entity->getPK()}?type={$entity->getType()}&ActionTemplate=popup",
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
"class" => "btn btn-sm btn-outline btn-circle",
@@ -110,13 +83,25 @@ class ServerPartHelper extends EquipmentHelper
$temps[] = sprintf(
"%s%s*%s개%s",
$modal,
- $partEntity->getTitle(),
- $partEntity->getCnt(),
- !$partEntity->getExtra() ? "" : "/" . $partEntity->getExtra()
+ $entity->getTitle(),
+ $entity->getCnt(),
+ !$entity->getExtra() ? "" : "/" . $entity->getExtra()
);
}
$value = implode("
", $temps);
break;
+ case 'SWITCH_SERVICE':
+ case 'IP_SERVICE':
+ case 'OS_SERVICE':
+ $field = str_replace('_SERVICE', '', $field);
+ if (!array_key_exists($field, $viewDatas['entities'])) {
+ return "";
+ }
+ foreach ($viewDatas['entities'][$field] as $entity) {
+ $temps[] = $entity->getTitle();
+ }
+ $value = implode(",", $temps);
+ break;
default:
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
break;
diff --git a/app/Services/Customer/ClientService.php b/app/Services/Customer/ClientService.php
index e46d6f9..c36324d 100644
--- a/app/Services/Customer/ClientService.php
+++ b/app/Services/Customer/ClientService.php
@@ -153,4 +153,11 @@ class ClientService extends CustomerService
$this->getModel()->orderBy("site ASC,name ASC");
parent::setOrderBy($field, $value);
}
+ //History
+ public function history(mixed $entity, array $formDatas): ClientEntity
+ {
+ //서비스 정보수정
+ $entity = $this->getModel()->modify($entity, $formDatas);
+ return $entity;
+ }
}
diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php
index fc290ea..ceac681 100644
--- a/app/Services/Customer/ServiceService.php
+++ b/app/Services/Customer/ServiceService.php
@@ -113,7 +113,7 @@ class ServiceService extends CustomerService
//서버정보 정의
$serverEntity = $this->getServerService()->getEntity(['serviceinfo_uid' => $entity->getPK()]);
if (!($serverEntity instanceof ServerEntity)) {
- throw new \Exception("{$entity->getPK()}에 해당하는 서버정보를 찾을수 없습니다.");
+ $serverEntity = new ServerEntity();
}
return $entity->setServerEntity($serverEntity);
}
@@ -266,4 +266,11 @@ class ServiceService extends CustomerService
);
return parent::delete($entity);
}
+ //History
+ public function history(mixed $entity, array $formDatas): ServiceEntity
+ {
+ //서비스 정보수정
+ $entity = $this->getModel()->modify($entity, $formDatas);
+ return $entity;
+ }
}
diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php
index d324387..9e39d04 100644
--- a/app/Services/Equipment/ServerService.php
+++ b/app/Services/Equipment/ServerService.php
@@ -37,9 +37,6 @@ class ServerService extends EquipmentService
"serviceinfo_uid",
"type",
"title",
- "CPU",
- "RAM",
- "DISK",
"status"
];
}
@@ -83,38 +80,10 @@ class ServerService extends EquipmentService
if (!($entity instanceof ServerEntity)) {
throw new \Exception(__METHOD__ . "에서 형식오류:ServerEntity만 허용됩니다.");
}
- foreach (SERVERPART['PARTTYPES'] as $partType) {
- foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK(), 'type' => $partType]) as $serverPartEntity) {
- $entity = $entity->addServerPartEntity($partType, $serverPartEntity);
- }
- }
return $entity;
}
//기본 기능부분
//FieldForm관련용
- public function getFormOption(string $field, array $options = []): array
- {
- switch ($field) {
- case 'CPU':
- case 'RAM':
- case 'DISK':
- case 'OS':
- case 'DB':
- case 'SOFTWARE':
- case 'SWITCH':
- case 'IP':
- case 'CS':
- $options = $this->getServerPartService()->getFormOption($field, $options);
- break;
- default:
- $options = parent::getFormOption($field, $options);
- break;
- }
- if (!is_array($options)) {
- throw new \Exception(__FUNCTION__ . "에서 {$field}의 options 값이 array가 아닙니다.\n" . var_export($options, true));
- }
- return $options;
- }
//create용 장비코드 마지막번호 가져오기
final public function getLastestCode(string $format, int $default): string
{
@@ -134,23 +103,6 @@ class ServerService extends EquipmentService
throw new \Exception("Server코드[{$formDatas['code']}의 형식이 맞지않습니다");
}
}
- //생성
- public function create(array $formDatas): ServerEntity
- {
- $entity = parent::create($formDatas);
- //신규 ServerPart정보 생성
- // foreach (SERVERPART['SERVER_PARTTYPES'] as $partType) {
- // $serverPartFormDatas = [];
- // $serverPartFormDatas['serverEntity'] = $entity;
- // $serverPartFormDatas['type'] = $partType;
- // $serverPartFormDatas['part_uid'] = $partType . "_uid";
- // $serverPartFormDatas["billing"] = array_key_exists("{$partType}_billing", $formDatas) ? $formDatas["{$partType}_billing"] : null;
- // $serverPartFormDatas["cnt"] = array_key_exists("{$partType}_cnt", $formDatas) ? $formDatas["{$partType}_cnt"] : 1;
- // $serverPartFormDatas["extra"] = array_key_exists("{$partType}_extra", $formDatas) ? $formDatas["{$partType}_extra"] : null;
- // $this->getServerPartService()->create($serverPartFormDatas);
- // }
- return $this->getEntity_process($entity);
- }
//Service별 수정
public function modify(mixed $entity, array $formDatas): ServerEntity
{
diff --git a/app/Views/admin/client/detail.php b/app/Views/admin/client/detail.php
index bc96374..384eb9d 100644
--- a/app/Views/admin/client/detail.php
+++ b/app/Views/admin/client/detail.php
@@ -15,11 +15,20 @@
|
= $viewDatas['entity']->getTitle() ?>
@@ -58,17 +67,19 @@
|
|---|
| = $viewDatas['service']->getHelper()->getListButton($partType, $partType, $viewDatas) ?> | -= $viewDatas['service']->getHelper()->getFieldView($partType, "", $viewDatas) ?> | -
|---|
| = $viewDatas['service']->getHelper()->getListButton($partType, $partType, $viewDatas) ?> | -= $viewDatas['service']->getHelper()->getFieldView($partType, "", $viewDatas) ?> | -
|---|
| = $viewDatas['service']->getHelper()->getListButton($partType, $partType, $viewDatas) ?> | -= $viewDatas['service']->getHelper()->getFieldView($partType, "", $viewDatas) ?> | -
|---|
| = $viewDatas['service']->getHelper()->getListButton($partType, $partType, $viewDatas) ?> | -= $viewDatas['service']->getHelper()->getFieldView($partType, "", $viewDatas) ?> | -
|---|
| = $serverPartCellDatas['service']->getHelper()->getListButton($type, $type, $serverPartCellDatas) ?> | += $serverPartCellDatas['service']->getHelper()->getFieldView($type, "", $serverPartCellDatas) ?> | +
|---|
| [상세정보] | -사이트 | -위치 | -형식 | -CPU | -메모리 | -저장장치 | -OS | -SOFTWARE | -IP주소 | -CS | -결제처리 | +[상세정보] | +사이트/위치/형식 | +CPU / 메모리 / 저장장치 | +OS / SOFTWARE | +IP주소 | +CS | +서비스 비고 | +결제처리 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| + | |||||||||||||||||||
|
= $entity->getCode() ?>
= $entity->getServerEntity()->getCode() ?>
|
- = $cellDatas['service']->getHelper()->getFieldView('site', $entity->getSite(), $cellDatas) ?> | -= $cellDatas['service']->getHelper()->getFieldView('location', $entity->getLocation(), $cellDatas) ?> | -= $cellDatas['service']->getHelper()->getFieldView('type', $entity->getType(), $cellDatas) ?> | -= $cellDatas['service']->getHelper()->getFieldView('CPU', "", $cellDatas) ?> | -= $cellDatas['service']->getHelper()->getFieldView('RAM', "", $cellDatas) ?> | -= $cellDatas['service']->getHelper()->getFieldView('DISK', "", $cellDatas) ?> | -= $cellDatas['service']->getHelper()->getFieldView('OS', "", $cellDatas) ?> | -= $cellDatas['service']->getHelper()->getFieldView('SOFTWARE', "", $cellDatas) ?> | -= $cellDatas['service']->getHelper()->getFieldView('IP', "", $cellDatas) ?> | -= $cellDatas['service']->getHelper()->getFieldView('CS', "", $cellDatas) ?> | +
+ = $serviceCellDatas['service']->getHelper()->getFieldView('site', $entity->getSite(), $serviceCellDatas) ?>
+ = $serviceCellDatas['service']->getHelper()->getFieldView('location', $entity->getLocation(), $serviceCellDatas) ?>
+ = $serviceCellDatas['service']->getHelper()->getFieldView('type', $entity->getType(), $serviceCellDatas) ?>
+ |
+ = view_cell("\App\Cells\Equipment\ServerPartCell::parttable", ['serverinfo_uid' => $entity->getServerEntity()->getPK(), 'types' => SERVERPART['SERVICE_PARTTYPES'], 'template' => 'partdetail']) ?>
+
+ = form_open("/admin/customer/service/history/{$entity->getPK()}?return_url=" . urlencode(current_url()), ['method' => "post"]) ?>
+
+
+ = form_close() ?>
+
+
+
+
+ = form_submit('', '저장', array("class" => "btn btn-outline btn-primary")); ?>
+
+ |
- |