dbmsv2 init...1

This commit is contained in:
choi.jh 2025-09-16 16:47:46 +09:00
parent 5369def63f
commit 09530b370f
11 changed files with 108 additions and 79 deletions

View File

@ -385,6 +385,10 @@ define("STATUS", [
'PAID' => 'paid',
'UNPAID' => 'unpaid',
]);
define("STATUS_ICONS", [
'AVAILABLE' => "",
'NOT_AVAILABLE' => "x."
]);
//서버 관련
define("SERVER", []);
//서비스 관련

View File

@ -65,18 +65,13 @@ class ServiceController extends CustomerController
//생성관련
protected function create_form_process(): void
{
//Form 기본값정의
$format = env("Server.Prefix.code.format", false);
if (!$format) {
throw new \Exception(__METHOD__ . "에서 code의 format[Server.Prefix.code.format]이 정의되지 않았습니다.");
}
$this->getService()->setFormDatas([
'location' => 'chiba',
'type' => 'normal',
'billing_at' => date("Y-m-d"),
'start_at' => date("Y-m-d"),
'status' => ServiceEntity::DEFAULT_STATUS,
]);
$formDatas = $this->getService()->getFormDatas();
$formDatas['location'] = 'chiba';
$formDatas['type'] = 'normal';
$formDatas['billing_at'] = date("Y-m-d");
$formDatas['start_at'] = date("Y-m-d");
$formDatas['status'] = ServiceEntity::DEFAULT_STATUS;
$this->getService()->setFormDatas($formDatas);
parent::create_form_process();
}
protected function create_process(array $formDatas): ServiceEntity

View File

@ -57,12 +57,12 @@ class ServerController extends EquipmentController
if (!$format) {
throw new \Exception(__METHOD__ . "에서 code의 format[Server.Prefix.code.format]이 정의되지 않았습니다.");
}
$this->getService()->setFormDatas([
'code' => $this->getService()->getLastestCode(
$format,
(int)env("Server.Default.code", 0)
)
]);
$formDatas = $this->getService()->getFormDatas();
$formDatas['code'] = $this->getService()->getLastestCode(
$format,
(int)env("Server.Default.code", 0)
);
$this->getService()->setFormDatas($formDatas);
parent::create_form_process();
}
//생성

View File

@ -51,4 +51,15 @@ class ServerPartController extends EquipmentController
}
return $result;
}
//생성관련
protected function create_form_process(): void
{
//Form 기본값정의
$formDatas = $this->getService()->getFormDatas();
$formDatas['billing'] = 'base';
$formDatas['cnt'] = 1;
$this->getService()->setFormDatas($formDatas);
parent::create_form_process();
}
}

View File

@ -239,11 +239,12 @@ class CommonHelper
$attribute = "";
$label = "";
if ($option_value instanceof CommonEntity) {
if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
if ($option_value->getStatus() != $option_value::DEFAULT_STATUS)
$html = " disabled";
}
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? "X." : "";
// if (in_array($viewDatas['control']['action'], ['create_form'])) {
// if ($option_value->getStatus() != $option_value::DEFAULT_STATUS) {
// $isDisabled = " disabled";
// }
// }
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? STATUS_ICONS['NOT_AVAILABLE'] : STATUS_ICONS['AVAILABLE'];
$label .= $option_value->getCustomTitle();
} else {
$label = $option_value;
@ -295,8 +296,9 @@ class CommonHelper
break;
case 'description':
case 'content':
case 'detail':
case 'history':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' tinymce' : 'tinymce';
// $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' tinymce' : 'tinymce';
$form = form_textarea($field, $value ?? "", $extras);
break;
case 'user_uid':
@ -349,6 +351,14 @@ class CommonHelper
$value = array_key_exists($value, $viewDatas['control']['field_optons'][$field]) &&
$viewDatas['control']['field_optons'][$field][$value] ? $viewDatas['control']['field_optons'][$field][$value]->getTitle() : "";
break;
case 'description':
case 'content':
case 'history':
case 'detail':
if (in_array($viewDatas['control']['action'], ['view', 'index'])) {
$value = nl2br($value);
}
break;
default:
if (in_array($field, $viewDatas['control']['actionFilters'])) {
//index 액션에서만 filter_options를 변경시 선택된 값을 변경하는 기능

View File

@ -57,9 +57,6 @@ class ClientHelper extends CustomerHelper
]
);
break;
case 'history':
$value = nl2br($value);
break;
default:
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
break;
@ -91,7 +88,7 @@ class ClientHelper extends CustomerHelper
$label ? $label : ICONS['HISTORY'],
$action,
[
"data-src" => "/admin/customer/clienthistory?clientinfo_uid={$viewDatas['entity']->getPK()}",
"data-src" => "/admin/customer/client/history?clientinfo_uid={$viewDatas['entity']->getPK()}",
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras

View File

@ -2,6 +2,7 @@
namespace App\Helpers\Customer;
use App\Entities\CommonEntity;
use App\Entities\Equipment\ServerEntity;
use App\Models\Customer\ServiceModel;
@ -12,6 +13,41 @@ class ServiceHelper extends CustomerHelper
parent::__construct();
$this->setTitleField(field: ServiceModel::TITLE);
}
protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
{
$html = "";
switch ($field) {
case "serverinfo_uid":
foreach ($viewDatas['control']['field_optons'][$field] as $option_key => $option_value) {
$isSelected = $option_key == $value ? ' selected' : '';
$isDisabled = "";
$attribute = "";
$label = "";
if ($option_value instanceof CommonEntity) {
if (in_array($viewDatas['control']['action'], ['create_form'])) {
if ($option_value->getStatus() != $option_value::DEFAULT_STATUS) {
$isDisabled = " disabled";
}
}
foreach ($attributes as $attribute_name => $attribute_value) {
$attribute = sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value());
}
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? STATUS_ICONS['NOT_AVAILABLE'] : STATUS_ICONS['AVAILABLE'];
$label .= $option_value->getCustomTitle();
} else {
$label = $option_value;
}
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $option_key, $isSelected, $isDisabled, $attribute, $label);
}
break;
default:
$html = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes);
break;
}
return $html;
}
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
switch ($field) {
@ -47,9 +83,6 @@ class ServiceHelper extends CustomerHelper
}
}
break;
case 'history':
$value = nl2br($value);
break;
default:
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
break;
@ -72,7 +105,7 @@ class ServiceHelper extends CustomerHelper
$label ? $label : ICONS['HISTORY'],
$action,
[
"data-src" => "/admin/customer/servicehistory?serviceinfo_uid={$viewDatas['entity']->getPK()}&serviceinfo_uid={$viewDatas['entity']->getPK()}&ActionTemplate=popup",
"data-src" => "/admin/customer/service/history?serviceinfo_uid={$viewDatas['entity']->getPK()}&serviceinfo_uid={$viewDatas['entity']->getPK()}&ActionTemplate=popup",
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras

View File

@ -16,33 +16,6 @@ class ServerPartHelper extends EquipmentHelper
{
$html = "";
switch ($field) {
case 'SWITCH':
case 'IP':
case 'CS':
case 'CPU':
case 'RAM':
case 'DISK':
case 'DB':
case 'OS':
case 'SOFTWARE':
foreach ($viewDatas['control']['field_optons'][$field] as $option_key => $option_value) {
$isSelected = $option_key == $value ? ' selected' : '';
$isDisabled = "";
$attribute = "";
$label = "";
if ($option_value instanceof CommonEntity) {
if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
if ($option_value->getStatus() != $option_value::DEFAULT_STATUS)
$html = " disabled";
}
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? "X." : "";
$label .= $option_value->getCustomTitle();
} else {
$label = $option_value;
}
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $option_key, $isSelected, $isDisabled, $attribute, $label);
}
break;
case 'part_uid':
if (!array_key_exists('type', $viewDatas['control']['form_datas']) || !$viewDatas['control']['form_datas']['type']) {
throw new \Exception(__METHOD__ . "에서 오류발생: Type가 정의되지 않았습니다.");
@ -53,11 +26,15 @@ class ServerPartHelper extends EquipmentHelper
$attribute = "";
$label = "";
if ($option_value instanceof CommonEntity) {
if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
if ($option_value->getStatus() != $option_value::DEFAULT_STATUS)
$html = " disabled";
// if (in_array($viewDatas['control']['action'], ['create_form'])) {
// if ($option_value->getStatus() != $option_value::DEFAULT_STATUS) {
// $isDisabled = " disabled";
// }
// }
foreach ($attributes as $attribute_name => $attribute_value) {
$attribute = sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value());
}
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? "X." : "";
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? STATUS_ICONS['NOT_AVAILABLE'] : STATUS_ICONS['AVAILABLE'];
$label .= $option_value->getCustomTitle();
} else {
$label = $option_value;
@ -74,18 +51,10 @@ class ServerPartHelper extends EquipmentHelper
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
switch ($field) {
case 'SWITCH':
case 'IP':
case 'CS':
case 'CPU':
case 'RAM':
case 'DISK':
case 'DB':
case 'OS':
case 'SOFTWARE':
case 'part_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$extras['onChange'] = "document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')";
$attributes = ['data-type' => 'getType', 'data-price' => 'getPrice'];
$attributes = ['data-price' => 'getPrice'];
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
break;
default:

View File

@ -28,9 +28,9 @@ class ServiceService extends CustomerService
"type",
"clientinfo_uid",
'serverinfo_uid',
"start_at",
"billing_at",
"amount",
"start_at",
"status",
"history",
];
@ -235,7 +235,7 @@ class ServiceService extends CustomerService
throw new \Exception("신규 서버가 지정되지 않았습니다.");
}
//기존서버정보 사용가능으로 설정
if ($entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) {
if ($entity->getServerInfoUID() && $entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) {
$entity = $this->setServer_process(
$entity,
$entity->getServerEntity()->getPK(),

View File

@ -24,11 +24,11 @@ class ServerPartService extends EquipmentService
return [
"serverinfo_uid",
"type",
"part_uid",
"billing",
"amount",
"part_uid",
"cnt",
"extra",
"amount",
];
}
public function getFormFilters(): array

View File

@ -1,8 +1,18 @@
<?php $htmls ?>
<?php foreach ($serverPartCellDatas['types'] as $type): ?>
<?php $htmls[$type] = [] ?>
<?php foreach ($serverPartCellDatas['entities'][$type] as $entities): ?>
<?php foreach ($entities as $entity): ?>
<?php $serverPartCellDatas['entity'] = $entity ?>
<?php $htmls[$type][] = $serverPartCellDatas['service']->getHelper()->getFieldView($type, $entity->getPK(), $serverPartCellDatas) ?>
<?php endforeach ?>
<?php endforeach ?>
<?php endforeach ?>
<table class="table table-bordered table-striped m-0 p-0">
<?php foreach ($serverPartCellDatas['types'] as $type): ?>
<tr class="m-0 p-0">
<th class="text-end m-0 p-0" width="15%"><?= $serverPartCellDatas['service']->getHelper()->getListButton($type, $type, $serverPartCellDatas) ?></th>
<td class="text-start m-0 p-0"><?= $serverPartCellDatas['service']->getHelper()->getFieldView($type, "", $serverPartCellDatas) ?></td>
<th class="text-end m-0 p-0" width="15%"><?= $serverPartCellDatas['service']->getHelper()->getListButton($type, '', $serverPartCellDatas) ?></th>
<td class="text-start m-0 p-0"><?= implode(",", $htmls[$type]) ?></td>
</tr>
<?php endforeach ?>
</table>