dbmsv2 init...1
This commit is contained in:
parent
9c24acce0a
commit
3d9e27ee29
@ -388,11 +388,13 @@ define("SERVICE", [
|
|||||||
define("SERVERPART", [
|
define("SERVERPART", [
|
||||||
"CNT_RANGE" => array_combine(range(1, 10), range(1, 10)),
|
"CNT_RANGE" => array_combine(range(1, 10), range(1, 10)),
|
||||||
"SERVER_PARTTTYPES" => ['CPU', 'RAM', 'DISK'],
|
"SERVER_PARTTTYPES" => ['CPU', 'RAM', 'DISK'],
|
||||||
|
"SERVICE_PARTTTYPES" => ['SWITCH', 'IP', 'OS', 'SOFTWARE'],
|
||||||
"PARTTYPES" => ['CPU', 'RAM', 'DISK', 'OS', 'DB', 'SOFTWARE', 'SWITCH', 'IP', 'CS'],
|
"PARTTYPES" => ['CPU', 'RAM', 'DISK', 'OS', 'DB', 'SOFTWARE', 'SWITCH', 'IP', 'CS'],
|
||||||
]);
|
]);
|
||||||
//결제 관련
|
//결제 관련
|
||||||
define("PAYMENT", [
|
define("PAYMENT", [
|
||||||
'BILLING' => [
|
'BILLING' => [
|
||||||
|
'BASE' => 'base',
|
||||||
'MONTH' => 'month',
|
'MONTH' => 'month',
|
||||||
'ONETIME' => 'onetime'
|
'ONETIME' => 'onetime'
|
||||||
],
|
],
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class ServiceHelper extends CustomerHelper
|
|||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'serverinfo_uid':
|
case 'serverinfo_uid':
|
||||||
if (array_key_exists('entity', $viewDatas)) {
|
if (array_key_exists('entity', $viewDatas)) {
|
||||||
$value = $viewDatas['entity']->getServerEntity() !== null ? $viewDatas['entity']->getServerEntity()->getPK() : $value;
|
$value = $viewDatas['entity']->getServerEntity()->getPK();
|
||||||
}
|
}
|
||||||
$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 = $this->form_dropdown_custom($field, $value, $viewDatas, $extras);
|
$form = $this->form_dropdown_custom($field, $value, $viewDatas, $extras);
|
||||||
@ -37,6 +37,9 @@ class ServiceHelper extends CustomerHelper
|
|||||||
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
|
case 'serverinfo_uid':
|
||||||
|
$value = $viewDatas['control']['field_optons'][$field][$viewDatas['entity']->getServerEntity()->getPK()]->getTitle();
|
||||||
|
break;
|
||||||
case 'billing_at':
|
case 'billing_at':
|
||||||
if (array_key_exists('unPaids', $viewDatas)) {
|
if (array_key_exists('unPaids', $viewDatas)) {
|
||||||
if (array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids'])) {
|
if (array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids'])) {
|
||||||
|
|||||||
@ -12,11 +12,11 @@ class ServerPartHelper extends EquipmentHelper
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->setTitleField(field: ServerPartModel::TITLE);
|
$this->setTitleField(field: ServerPartModel::TITLE);
|
||||||
}
|
}
|
||||||
private function getServerPartForm(string $field, mixed $value, array $viewDatas, array $extras, string $partType): string
|
private function getServerPartForm(string $field, mixed $value, array $viewDatas, array $extras): string
|
||||||
{
|
{
|
||||||
$form = "";
|
$form = "";
|
||||||
if (array_key_exists('entity', $viewDatas)) {
|
if (array_key_exists('entity', $viewDatas)) {
|
||||||
foreach ($viewDatas['entity']->getServerPartEntities($partType) as $serverPartEntity) {
|
foreach ($viewDatas['entity']->getServerPartEntities($field) as $serverPartEntity) {
|
||||||
//기존 입력화면에서 return 된것인지?
|
//기존 입력화면에서 return 된것인지?
|
||||||
if ($value === null && $serverPartEntity !== null) {
|
if ($value === null && $serverPartEntity !== null) {
|
||||||
$value = $serverPartEntity->getPartUID();
|
$value = $serverPartEntity->getPartUID();
|
||||||
@ -40,7 +40,7 @@ class ServerPartHelper extends EquipmentHelper
|
|||||||
case 'DB':
|
case 'DB':
|
||||||
case 'OS':
|
case 'OS':
|
||||||
case 'SOFTWARE':
|
case 'SOFTWARE':
|
||||||
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, $field);
|
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras);
|
||||||
break;
|
break;
|
||||||
case 'CPU_cnt':
|
case 'CPU_cnt':
|
||||||
case 'RAM_cnt':
|
case 'RAM_cnt':
|
||||||
@ -68,13 +68,35 @@ class ServerPartHelper extends EquipmentHelper
|
|||||||
}
|
}
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'CPU':
|
case 'CPU':
|
||||||
case 'RAM':
|
case 'RAM':
|
||||||
case 'DISK':
|
case 'DISK':
|
||||||
|
$temps = [];
|
||||||
|
foreach ($viewDatas['serverPartEntities'] as $partEntity) {
|
||||||
|
$modal = form_label(
|
||||||
|
ICONS['SETUP'],
|
||||||
|
$field,
|
||||||
|
[
|
||||||
|
"data-src" => "/admin/equipment/serverpart/modify/{$partEntity->getPK()}?type={$partEntity->getType()}&ActionTemplate=popup",
|
||||||
|
"data-bs-toggle" => "modal",
|
||||||
|
"data-bs-target" => "#index_action_form",
|
||||||
|
"class" => "btn btn-sm btn-outline btn-circle",
|
||||||
|
"target" => "_self"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$temps[] = sprintf(
|
||||||
|
"%s%s*%s개%s",
|
||||||
|
$modal,
|
||||||
|
$partEntity->getTitle(),
|
||||||
|
$partEntity->getCnt(),
|
||||||
|
$partEntity->getExtra() !== null ? "/" . $partEntity->getExtra() : ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$value = implode("<BR>", $temps);
|
||||||
|
break;
|
||||||
case 'OS':
|
case 'OS':
|
||||||
case 'DB':
|
case 'DB':
|
||||||
case 'SOFTWARE':
|
case 'SOFTWARE':
|
||||||
@ -95,14 +117,12 @@ class ServerPartHelper extends EquipmentHelper
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
$temps[] = sprintf(
|
$temps[] = sprintf(
|
||||||
"%s%s*%s개 %s",
|
"%s%s",
|
||||||
$modal,
|
$modal,
|
||||||
$partEntity->getTitle(),
|
$partEntity->getTitle(),
|
||||||
$partEntity->getCnt(),
|
|
||||||
$partEntity->getExtra() ?? ""
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$value .= implode("<BR>", $temps);
|
$value = implode("<BR>", $temps);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
|
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
|
||||||
|
|||||||
@ -16,6 +16,7 @@ return [
|
|||||||
'deleted_at' => "삭제일",
|
'deleted_at' => "삭제일",
|
||||||
],
|
],
|
||||||
"BILLING" => [
|
"BILLING" => [
|
||||||
|
PAYMENT['BILLING']["BASE"] => "기본",
|
||||||
PAYMENT['BILLING']["MONTH"] => "매월",
|
PAYMENT['BILLING']["MONTH"] => "매월",
|
||||||
PAYMENT['BILLING']["ONETIME"] => "일회성",
|
PAYMENT['BILLING']["ONETIME"] => "일회성",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -192,7 +192,7 @@ class ServiceService extends CustomerService
|
|||||||
$serverFormDatas["serviceinfo_uid"] = null;
|
$serverFormDatas["serviceinfo_uid"] = null;
|
||||||
$serverFormDatas["status"] = STATUS['AVAIABLE'];
|
$serverFormDatas["status"] = STATUS['AVAIABLE'];
|
||||||
$serverEntity = $this->getServerService()->modify($serverEntity, $serverFormDatas);
|
$serverEntity = $this->getServerService()->modify($serverEntity, $serverFormDatas);
|
||||||
// $entity->setServerEntity(null);
|
$entity->setServerEntity($serverEntity);
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,7 +140,7 @@ class ServerPartService extends EquipmentService
|
|||||||
}
|
}
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
private function action_process(ServerPartEntity $entity, array $formDatas): mixed
|
private function action_process(ServerPartEntity $entity, mixed $part_uid, string $status): mixed
|
||||||
{
|
{
|
||||||
//Type에 따른 부품서비스 정의
|
//Type에 따른 부품서비스 정의
|
||||||
switch ($entity->getType()) {
|
switch ($entity->getType()) {
|
||||||
@ -158,18 +158,29 @@ class ServerPartService extends EquipmentService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//부품정보가져오기
|
//부품정보가져오기
|
||||||
$partEntity = $partService->getEntity($entity->getPartUID());
|
$partEntity = $partService->getEntity($part_uid);
|
||||||
if (!$partEntity) {
|
if (!$partEntity) {
|
||||||
throw new \Exception(__METHOD__ . "에서 오류:{$entity->getPartUID()}에 해닫하는 {$entity->getType()}정보가 없습니다.");
|
throw new \Exception(__METHOD__ . "에서 오류:{$part_uid}에 해닫하는 {$entity->getType()}정보가 없습니다.");
|
||||||
}
|
}
|
||||||
|
$formDatas = [];
|
||||||
switch ($entity->getType()) {
|
switch ($entity->getType()) {
|
||||||
case 'SWITCH':
|
|
||||||
case 'CS':
|
|
||||||
$partEntity = $partService->modify($partEntity, $formDatas);
|
|
||||||
break;
|
|
||||||
case 'IP':
|
case 'IP':
|
||||||
//기존IP 사용자로 고객정보 설정
|
//기존IP 사용자로 고객정보 설정
|
||||||
$formDatas['old_clientinfo_uid'] = $partEntity->getClientInfoUID();
|
$formDatas['old_clientinfo_uid'] = $partEntity->getClientInfoUID();
|
||||||
|
case 'SWITCH':
|
||||||
|
case 'CS':
|
||||||
|
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
||||||
|
if ($status === STATUS['OCCUPIED']) {
|
||||||
|
$formDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
||||||
|
$formDatas['serviceinfo_uid'] = $entity->getServiceInfoUID();
|
||||||
|
$formDatas['serverinfo_uid'] = $entity->getServerInfoUID();
|
||||||
|
} else {
|
||||||
|
$formDatas['clientinfo_uid'] = null;
|
||||||
|
$formDatas['serviceinfo_uid'] = null;
|
||||||
|
$formDatas['serverinfo_uid'] = null;
|
||||||
|
}
|
||||||
|
$formDatas['part_uid'] = $part_uid;
|
||||||
|
$formDatas['status'] = $status;
|
||||||
$partEntity = $partService->modify($partEntity, $formDatas);
|
$partEntity = $partService->modify($partEntity, $formDatas);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -179,55 +190,29 @@ class ServerPartService extends EquipmentService
|
|||||||
public function create(array $formDatas): ServerPartEntity
|
public function create(array $formDatas): ServerPartEntity
|
||||||
{
|
{
|
||||||
$entity = parent::create($formDatas);
|
$entity = parent::create($formDatas);
|
||||||
//서버정보가져오기
|
|
||||||
$serverEntity = $this->getServerService()->getEntity($entity->getServerInfoUID());
|
|
||||||
if (!$serverEntity) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류:{$entity->getServerInfoUID()}에 해닫하는 서버정보가 없습니다.");
|
|
||||||
}
|
|
||||||
//부품연결정보에 부품정보 정의
|
//부품연결정보에 부품정보 정의
|
||||||
$partFormDatas = [
|
$entity->setPartEntity($this->action_process($entity, $entity->getPartUID(), STATUS['OCCUPIED']));
|
||||||
'clientinfo_uid' => $serverEntity->getClientInfoUID(),
|
|
||||||
'serviceinfo_uid' => $serverEntity->getServiceInfoUID(),
|
|
||||||
'serverinfo_uid' => $serverEntity->getPK(),
|
|
||||||
'status' => STATUS['OCCUPIED']
|
|
||||||
];
|
|
||||||
$entity->setPartEntity($this->action_process($entity, $partFormDatas));
|
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//수정
|
//수정
|
||||||
public function modify(mixed $entity, array $formDatas): ServerPartEntity
|
public function modify(mixed $entity, array $formDatas): ServerPartEntity
|
||||||
{
|
{
|
||||||
$entity = parent::modify($entity, $formDatas);
|
//기존과 신규의 Type이 같고, 기존 Part_UID와 신규 Part_UID가 다르면 부품정보에 서버정보 설정 및 서비스,고객정보 정의 기존 Part정보 사용가능으로 변경
|
||||||
if (!array_key_exists('status', $formDatas)) {
|
if ($entity->getType() == $formDatas['type'] && $entity->getPartUID() != $formDatas['part_uid']) {
|
||||||
throw new \Exception(__METHOD__ . "에서 상태정보가 정의되지 않았습니다.");
|
$entity->setPartEntity($this->action_process($entity, $entity->getPartUID(), STATUS['AVAIABLE']));
|
||||||
}
|
}
|
||||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
//기존 정보변경
|
||||||
$partFormDatas = [
|
$entity = parent::modify($entity, $formDatas);
|
||||||
'status' => $formDatas['status'],
|
//기존과 신규의 Type이 같고, 기존 Part_UID와 신규 Part_UID가 다르면 부품정보에 서버정보 설정 및 서비스,고객정보 정의 Part정보 사용중으로 변경
|
||||||
];
|
if ($entity->getType() == $formDatas['type'] && $entity->getPartUID() != $formDatas['part_uid']) {
|
||||||
if ($partFormDatas['status'] === STATUS['OCCUPIED']) {
|
$entity->setPartEntity($this->action_process($entity, $formDatas['part_uid'], STATUS['OCCUPIED']));
|
||||||
$partFormDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
|
||||||
$partFormDatas['serviceinfo_uid'] = $entity->getServiceInfoUID();
|
|
||||||
$partFormDatas['serverinfo_uid'] = $entity->getServerInfoUID();
|
|
||||||
$entity->setPartEntity($this->action_process($entity, $partFormDatas));
|
|
||||||
} else {
|
|
||||||
$partFormDatas['clientinfo_uid'] = null;
|
|
||||||
$partFormDatas['serviceinfo_uid'] = null;
|
|
||||||
$partFormDatas['serverinfo_uid'] = null;
|
|
||||||
$entity->setPartEntity($this->action_process($entity, $partFormDatas));
|
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//삭제
|
//삭제
|
||||||
public function delete(mixed $entity): ServerPartEntity
|
public function delete(mixed $entity): ServerPartEntity
|
||||||
{
|
{
|
||||||
$partFormDatas = [
|
$this->action_process($entity, $entity->getPartUID(), STATUS['AVAIABLE']);
|
||||||
'status' => STATUS['AVAIABLE'],
|
|
||||||
];
|
|
||||||
$partFormDatas['clientinfo_uid'] = null;
|
|
||||||
$partFormDatas['serviceinfo_uid'] = null;
|
|
||||||
$partFormDatas['serverinfo_uid'] = null;
|
|
||||||
$this->action_process($entity, $partFormDatas);
|
|
||||||
return parent::delete($entity);
|
return parent::delete($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,7 +86,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td nowrap>
|
<td nowrap>
|
||||||
<table class="table table-bordered table-striped m-0 p-0">
|
<table class="table table-bordered table-striped m-0 p-0">
|
||||||
<?php foreach (SERVERPART['PARTTYPES'] as $partType): ?>
|
<?php foreach (SERVERPART['SERVICE_PARTTTYPES'] as $partType): ?>
|
||||||
<tr class="m-0 p-0">
|
<tr class="m-0 p-0">
|
||||||
<th class="m-0 p-0"><?= $viewDatas['helper']->getListButton($partType, $partType, $viewDatas) ?></th>
|
<th class="m-0 p-0"><?= $viewDatas['helper']->getListButton($partType, $partType, $viewDatas) ?></th>
|
||||||
<td class="m-0 p-0"><?= $viewDatas['helper']->getFieldView($partType, "", $viewDatas) ?></td>
|
<td class="m-0 p-0"><?= $viewDatas['helper']->getFieldView($partType, "", $viewDatas) ?></td>
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<?php foreach (["code", "type", "title", "price", "amount", "manufactur_at", "format_at", "status",] as $field): ?>
|
<?php foreach ($viewDatas['control']['actionFields'] as $field): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
|
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
|
||||||
<td nowrap class="text-start">
|
<td nowrap class="text-start">
|
||||||
@ -25,19 +25,13 @@
|
|||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered table-striped m-0 p-0">
|
||||||
<?php foreach (SERVERPART['PARTTYPES'] as $partType): ?>
|
<?php foreach (SERVERPART['PARTTYPES'] as $partType): ?>
|
||||||
<tr>
|
<tr class="m-0 p-0">
|
||||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel("{$partType}", lang("{$viewDatas['class_path']}.label.{$partType}"), $viewDatas) ?></th>
|
<th class="m-0 p-0"><?= $viewDatas['helper']->getListButton($partType, $partType, $viewDatas) ?></th>
|
||||||
<td nowrap class="text-start">
|
<td class="m-0 p-0"><?= $viewDatas['helper']->getFieldView($partType, "", $viewDatas) ?></td>
|
||||||
<?= $viewDatas['helper']->getFieldView("{$partType}", old("{$partType}") ?? ($viewDatas['entity']->getServerPartEntity($partType) ? $viewDatas['entity']->getServerPartEntity($partType)->getPartInfoUID() : ($viewDatas['control']['form_datas']["{$partType}"] ?? null)), $viewDatas) ?>
|
|
||||||
<?= $viewDatas['helper']->getFieldView("{$partType}_cnt", old("{$partType}_cnt") ?? ($viewDatas['entity']->getServerPartEntity($partType) ? $viewDatas['entity']->getServerPartEntity($partType)->getCnt() : ($viewDatas['control']['form_datas']["{$partType}_cnt"] ?? null)), $viewDatas) ?>
|
|
||||||
<?php if ($partType === "DISK"): ?>
|
|
||||||
<?= $viewDatas['helper']->getFieldView("{$partType}_extra", old("{$partType}_extra") ?? ($viewDatas['entity']->getServerPartEntity($partType) ? $viewDatas['entity']->getServerPartEntity($partType)->getExtra() : ($viewDatas['control']['form_datas']["{$partType}_extra"] ?? null)), $viewDatas) ?>
|
|
||||||
<?php endif ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach ?>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user