dbmsv4 init...1

This commit is contained in:
최준흠 2025-11-24 17:54:41 +09:00
parent bd31409d0c
commit a7caf53c86
20 changed files with 153 additions and 118 deletions

View File

@ -2,9 +2,6 @@
namespace App\Cells\Customer; namespace App\Cells\Customer;
use App\Helpers\Equipment\ServerPartHelper;
use App\Services\PaymentService;
class ServiceCell extends CustomerCell class ServiceCell extends CustomerCell
{ {
public function __construct() public function __construct()
@ -18,12 +15,7 @@ class ServiceCell extends CustomerCell
//서비스별 미납 Count //서비스별 미납 Count
$unPaids = service('paymentservice')->getUnPaids('serviceinfo_uid', ['clientinfo_uid' => $params['clientinfo_uid']]); $unPaids = service('paymentservice')->getUnPaids('serviceinfo_uid', ['clientinfo_uid' => $params['clientinfo_uid']]);
//서비스별 서버리스트 //서비스별 서버리스트
$entities = []; $entities = $this->getService()->getEntities(['clientinfo_uid' => $params['clientinfo_uid']]);
$childServers = [];
foreach ($this->getService()->getEntities(['clientinfo_uid' => $params['clientinfo_uid']]) as $entity) {
$entities[] = $entity;
$childServers[$entity->getPK()] = service('equipment_serverservice')->getEntities(['serviceinfo_uid' => $entity->getPK()]);
}
$template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__; $template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__;
return view('cells/service/' . $template, [ return view('cells/service/' . $template, [
'serviceCellDatas' => [ 'serviceCellDatas' => [
@ -32,8 +24,6 @@ class ServiceCell extends CustomerCell
'helper' => $this->getService()->getHelper(), 'helper' => $this->getService()->getHelper(),
'unPaids' => $unPaids, 'unPaids' => $unPaids,
'entities' => $entities, 'entities' => $entities,
'childServers' => $childServers,
'serverPartHelper' => new ServerPartHelper(),
] ]
]); ]);
} }

View File

@ -2,6 +2,7 @@
namespace App\Cells\Equipment; namespace App\Cells\Equipment;
use App\Helpers\Equipment\ServerPartHelper;
use App\Services\Equipment\ServerService; use App\Services\Equipment\ServerService;
class ServerCell extends EquipmentCell class ServerCell extends EquipmentCell
@ -65,4 +66,25 @@ class ServerCell extends EquipmentCell
], ],
]); ]);
} }
public function detail(array $params): string
{
$this->getService()->action_init_process(__FUNCTION__);
if (!array_key_exists('serviceEntity', $params)) {
return __METHOD__ . "에서 오류발생: 서비스 정보가 정의되지 않았습니다.";
}
$serviceEntity = $params['serviceEntity'];
$entities = $this->getService()->getEntities(['serviceinfo_uid' => $params['serviceEntity']->getPK()]);
$template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__;
return view('cells/server/' . $template, [
'serverCellDatas' => [
'formFilters' => $this->getService()->getFormService()->getFormFilters(),
'formOptions' => $this->getService()->getFormService()->getFormOptions(),
'helper' => $this->getService()->getHelper(),
'entities' => $entities,
'serviceEntity' => $serviceEntity,
'serverPartHelper' => new ServerPartHelper(),
]
]);
}
} }

View File

@ -12,35 +12,39 @@ class Home extends AbstractWebController
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);
if ($this->service === null) {
$this->service = service('customer_serviceservice');
}
$this->addActionPaths('home');
}
protected function action_init_process(string $action, ?object $entity = null): void
{
// $this->service->action_init_process($action, $entity);
parent::action_init_process($action, $entity);
$this->addViewDatas('layout', LAYOUTS['admin']);
} }
//Index,FieldForm관련 //Index,FieldForm관련
public function welcome(): string public function welcome(): string
{ {
$action = __FUNCTION__;
$this->action_init_process($action);
//요청업무 //요청업무
$boardRequestTaskCount = service('boardservice')->getRequestTaskCount($this->getAuthContext()->getUID()); $this->addViewDatas('boardRequestTaskCount', service('boardservice')->getRequestTaskCount($this->getAuthContext()->getUID()));
//Total 서버 현황 //Total 서버 현황
//interval을 기준으로 최근 신규 서비스정보 가져오기 //interval을 기준으로 최근 신규 서비스정보 가져오기
$interval = intval($this->request->getVar('interval') ?? SERVICE['NEW_INTERVAL']); $interval = intval($this->request->getVar('interval') ?? SERVICE['NEW_INTERVAL']);
$newServiceEntities = service('customer_serviceservice')->getNewServiceEntities($interval); $this->addViewDatas('interval', $interval);
$newServiceCount = count($newServiceEntities); $newServiceEntities = $this->service->getNewServiceEntities($interval);
$this->addViewDatas('newServiceEntities', $newServiceEntities);
$this->addViewDatas('newServiceCount', count($newServiceEntities));
//서비스별 미납 Count //서비스별 미납 Count
$unPaidTotalCount = $unPaidTotalAmount = 0; $unPaidTotalCount = $unPaidTotalAmount = 0;
foreach (array_values(service('paymentservice')->getUnPaids('serviceinfo_uid')) as $unPaid) { foreach (array_values(service('paymentservice')->getUnPaids('serviceinfo_uid')) as $unPaid) {
$unPaidTotalCount += $unPaid['cnt']; $unPaidTotalCount += $unPaid['cnt'];
$unPaidTotalAmount += $unPaid['amount']; $unPaidTotalAmount += $unPaid['amount'];
} }
return $this->action_render_process( $this->addViewDatas('unPaidTotalCount', $unPaidTotalCount);
__FUNCTION__, $this->addViewDatas('unPaidTotalAmount', $unPaidTotalAmount);
[ return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate'));
'authContext' => $this->getAuthContext(),
'layout' => 'admin',
'boardRequestTaskCount' => $boardRequestTaskCount,
'interval' => $interval,
'newServiceEntities' => $newServiceEntities,
'newServiceCount' => $newServiceCount,
'unPaidTotalCount' => $unPaidTotalCount,
'unPaidTotalAmount' => $unPaidTotalAmount,
]
);
} }
} }

View File

@ -9,7 +9,7 @@ class ServerDTO extends CommonDTO
public ?int $uid = null; public ?int $uid = null;
public ?string $code = null; public ?string $code = null;
public ?string $type = null; public ?string $type = null;
public ?string $switch = null; public ?int $switchinfo_uid = null;
public ?string $ip = null; public ?string $ip = null;
public ?string $os = null; public ?string $os = null;
public ?string $title = null; public ?string $title = null;

File diff suppressed because one or more lines are too long

View File

@ -16,10 +16,14 @@ class ServerEntity extends EquipmentEntity
{ {
return $this->attributes['serviceinfo_uid'] ?? null; return $this->attributes['serviceinfo_uid'] ?? null;
} }
final public function getSwitchInfoUID(): int|null
{
return $this->attributes['switchinfo_uid'] ?? null;
}
//기본기능용 //기본기능용
public function getCustomTitle(mixed $title = null): string public function getCustomTitle(mixed $title = null): string
{ {
return sprintf("[%s]%s / %s / %s", $this->getCode(), $title ? $title : $this->getIP(), $this->getSwitch(), $this->getOS()); return sprintf("[%s]%s / %s", $this->getCode(), $title ? $title : $this->getIP(), $this->getOS());
} }
final public function getCode(): string final public function getCode(): string
{ {
@ -33,10 +37,6 @@ class ServerEntity extends EquipmentEntity
{ {
return $this->attributes['type']; return $this->attributes['type'];
} }
public function getSwitch(): string|null
{
return $this->attributes['switch'] ?? null;
}
public function getIP(): string|null public function getIP(): string|null
{ {
return $this->attributes['ip'] ?? null; return $this->attributes['ip'] ?? null;

View File

@ -191,7 +191,7 @@ abstract class CommonForm
$entities = $service->getEntities(['status' => STATUS['AVAILABLE']]); $entities = $service->getEntities(['status' => STATUS['AVAILABLE']]);
break; break;
case 'modify_form': case 'modify_form':
$where = sprintf("status = '%s' OR %s=%s", STATUS['AVAILABLE'], $this->getAttribute('pk_field'), $entity->$field); $where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], $this->getAttribute('pk_field'), $entity->$field);
$entities = $service->getEntities([$where => null]); $entities = $service->getEntities([$where => null]);
break; break;
default: default:

View File

@ -45,6 +45,26 @@ class ServerForm extends EquipmentForm
} }
return $rule; return $rule;
} }
protected function getFormOption_process($service, string $action, string $field, ?object $entity = null): array
{
$entities = [];
switch ($action) {
case 'modify_form':
if ($field === 'ip') {
$where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], "ip", $entity->$field);
$entities = $service->getEntities([$where => null]);
} else {
$entities = parent::getFormOption_process($service, $action, $field, $entity);
}
break;
default:
$entities = parent::getFormOption_process($service, $action, $field, $entity);
break;
}
return $entities;
}
public function getFormOption(string $action, string $field, ?object $entity = null, array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array public function getFormOption(string $action, string $field, ?object $entity = null, array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array
{ {
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
@ -56,15 +76,15 @@ class ServerForm extends EquipmentForm
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
break; break;
case 'switch': case 'switchinfo_uid':
foreach ($this->getFormOption_process(service('part_switchservice'), $action, $field, $entity) as $tempEntity) { foreach ($this->getFormOption_process(service('part_switchservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$tempEntity->getTitle()] = $tempEntity->getTitle(); $tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }
$options['options'] = $tempOptions; $options['options'] = $tempOptions;
// dd($options); // dd($options);
break; break;
case 'ip': case 'ip': //key=value이 같음주의
foreach ($this->getFormOption_process(service('part_ipservice'), $action, $field, $entity) as $tempEntity) { foreach ($this->getFormOption_process(service('part_ipservice'), $action, $field, $entity) as $tempEntity) {
$tempOptions[$tempEntity->getTitle()] = $tempEntity->getTitle(); $tempOptions[$tempEntity->getTitle()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];

View File

@ -184,8 +184,6 @@ abstract class CommonHelper
if (in_array($field, $viewDatas['formFilters'])) { if (in_array($field, $viewDatas['formFilters'])) {
if ($value) { if ($value) {
if (!array_key_exists($value, $viewDatas['formOptions'][$field]['options'])) { if (!array_key_exists($value, $viewDatas['formOptions'][$field]['options'])) {
echo "VALUE:{$value}";
dd($viewDatas['formOptions'][$field]['options']);
throw new \Exception(__METHOD__ . "에서 오류발생: {$field}에서 {$value}에 해당하는 값이 존재하지 않습니다."); throw new \Exception(__METHOD__ . "에서 오류발생: {$field}에서 {$value}에 해당하는 값이 존재하지 않습니다.");
} }
$value = !$value ? "" : $viewDatas['formOptions'][$field]['options'][$value]; $value = !$value ? "" : $viewDatas['formOptions'][$field]['options'][$value];

View File

@ -24,7 +24,6 @@ class ServiceHelper extends CustomerHelper
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras); $form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
break; break;
case 'amount': case 'amount':
$form = form_input($field, 0, ["readonly" => "readonly", ...$extras]); $form = form_input($field, 0, ["readonly" => "readonly", ...$extras]);
break; break;

View File

@ -13,18 +13,15 @@ class ServerHelper extends EquipmentHelper
switch ($field) { switch ($field) {
case 'clientinfo_uid': case 'clientinfo_uid':
case 'serviceinfo_uid': case 'serviceinfo_uid':
$form = parent::getFieldForm($field, $value, $viewDatas, $extras); case 'switchinfo_uid':
if (in_array($viewDatas['control']['action'], ['modify_form']) && $value) { $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$form = $this->getFieldView($field, $value, $viewDatas, $extras); $form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
$form .= form_hidden($field, (string)$value);
}
break; break;
case 'manufactur_at': case 'manufactur_at':
case 'format_at': case 'format_at':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender';
$form = form_input($field, $value ?? "", $extras); $form = form_input($field, $value ?? "", $extras);
break; break;
case 'switch':
case 'ip': case 'ip':
case 'title': case 'title':
$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';

View File

@ -6,7 +6,7 @@ return [
'serviceinfo_uid' => "서비스번호", 'serviceinfo_uid' => "서비스번호",
'code' => "장비번호", 'code' => "장비번호",
'type' => "형식", 'type' => "형식",
'switch' => "스위치", 'switchinfo_uid' => "스위치",
'ip' => "IP", 'ip' => "IP",
'os' => "OS", 'os' => "OS",
'title' => "모델명", 'title' => "모델명",

View File

@ -20,7 +20,7 @@ class ServerModel extends EquipmentModel
"serviceinfo_uid", "serviceinfo_uid",
"code", "code",
"type", "type",
"switch", "switchinfo_uid",
"ip", "ip",
"os", "os",
"title", "title",

View File

@ -76,6 +76,8 @@ class ServiceService extends CustomerService
$filters = [ $filters = [
'site', 'site',
'location', 'location',
"rack",
"line",
'clientinfo_uid', 'clientinfo_uid',
'serverinfo_uid', 'serverinfo_uid',
'user_uid', 'user_uid',

View File

@ -59,7 +59,7 @@ class ServerService extends EquipmentService
$fields = [ $fields = [
"code", "code",
"type", "type",
"switch", "switchinfo_uid",
"ip", "ip",
"title", "title",
"os", "os",
@ -71,13 +71,13 @@ class ServerService extends EquipmentService
"clientinfo_uid", "clientinfo_uid",
'title', 'title',
'type', 'type',
'switch', 'switchinfo_uid',
'ip', 'ip',
'os', 'os',
"status", "status",
]; ];
$indexFilter = $filters; $indexFilter = $filters;
$batchjobFilters = ['type', 'title', 'switch', 'ip', 'os', 'status']; $batchjobFilters = ['type', 'title', 'switchinfo_uid', 'ip', 'os', 'status'];
switch ($action) { switch ($action) {
case 'create': case 'create':
case 'create_form': case 'create_form':

View File

@ -12,14 +12,14 @@
</td> </td>
<td class="layout_right"> <td class="layout_right">
<!-- Layout Right Start --> <!-- Layout Right Start -->
<?= $this->include("{$viewDatas['layout']}/welcome/banner"); ?> <?= $this->include("{$viewDatas['layout']['path']}/welcome/banner"); ?>
<div class="row align-items-start mt-3"> <div class="row align-items-start mt-3">
<div class="col-8"> <div class="col-8">
<?= $this->include("{$viewDatas['layout']}/welcome/total_service"); ?> <?= $this->include("{$viewDatas['layout']['path']}/welcome/total_service"); ?>
<?= $this->include("{$viewDatas['layout']}/welcome/new_service"); ?> <?= $this->include("{$viewDatas['layout']['path']}/welcome/new_service"); ?>
<?= $this->include("{$viewDatas['layout']}/welcome/stock"); ?> <?= $this->include("{$viewDatas['layout']['path']}/welcome/stock"); ?>
</div> </div>
<div class="col-4"><?= $this->include("{$viewDatas['layout']}/welcome/mylog"); ?></div> <div class="col-4"><?= $this->include("{$viewDatas['layout']['path']}/welcome/mylog"); ?></div>
</div> </div>
<!-- Layout Right End --> <!-- Layout Right End -->
</td> </td>

View File

@ -0,0 +1,32 @@
<table class="table table-bordered table-striped">
<?php foreach ($serverCellDatas['entities'] as $entity): ?>
<?php $serverCellDatas['entity'] = $entity ?>
<tr class="text-center">
<th style="width: 250px">
<?= $serverCellDatas['serviceEntity']->getServerInfoUID() == $entity->getPK() ? "📌" : "<a href=\"/admin/customer/service/changeServer/{$serverCellDatas['serviceEntity']->getPK()}?serverinfo_uid={$entity->getPK()}\">✔️</a>" ?>
<?= $serverCellDatas['serverPartHelper']->getFieldView('SERVER', "", ['serverEntity' => $entity]) ?>
<?= $serverCellDatas['serviceEntity']->getServerInfoUID() != $entity->getPK() ? "<a href=\"/admin/customer/service/terminateServer/{$serverCellDatas['serviceEntity']->getPK()}?serverinfo_uid={$entity->getPK()}\">❌</a>" : "" ?>
</th>
<th style="width: 250px">
<?= $serverCellDatas['serverPartHelper']->getListButton('CPU', 'CPU', ['serverinfo_uid' => $entity->getPK()]) ?>
/ <?= $serverCellDatas['serverPartHelper']->getListButton('RAM', 'RAM', ['serverinfo_uid' => $entity->getPK()]) ?>
/ <?= $serverCellDatas['serverPartHelper']->getListButton('DISK', 'DISK', ['serverinfo_uid' => $entity->getPK()]) ?>
</th>
<th style="width: 200px"><?= $serverCellDatas['serverPartHelper']->getListButton('IP', '추가IP', ['serverinfo_uid' => $entity->getPK()]) ?></th>
<th style="width: 200px"><?= $serverCellDatas['serverPartHelper']->getListButton('CS', 'CS', ['serverinfo_uid' => $entity->getPK()]) ?></th>
</tr>
<tr class="text-center">
<td nowrap>
<div><?= $serverCellDatas['helper']->getFieldView('switchinfo_uid', $entity->getSwitchInfoUID(), $serverCellDatas) ?></div>
<div><?= $entity->getTitle() ?></div>
<div><?= $entity->getIP() ?></div>
<div><?= $entity->getOS() ?></div>
</td>
<?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
'serverinfo_uid' => $entity->getPK(),
'types' => SERVERPART['ALL_PARTTYPES'],
'template' => 'detail'
]) ?>
</tr>
<?php endforeach; ?>
</table>

View File

@ -16,7 +16,7 @@
<div><?= $serviceCellDatas['helper']->getFieldView('location', $entity->getLocation(), $serviceCellDatas) ?></div> <div><?= $serviceCellDatas['helper']->getFieldView('location', $entity->getLocation(), $serviceCellDatas) ?></div>
<div class="mt-3"><?= $serviceCellDatas['helper']->getListButton('addServer', '대체서버추가', ['entity' => $entity], ['class' => 'btn btn-sm btn-primary']) ?></div> <div class="mt-3"><?= $serviceCellDatas['helper']->getListButton('addServer', '대체서버추가', ['entity' => $entity], ['class' => 'btn btn-sm btn-primary']) ?></div>
</td> </td>
<td class="text-center" nowrap><?= view('cells/service/server', ['serviceEntity' => $entity, 'serverEntities' => $serviceCellDatas['childServers'][$entity->getPK()]]) ?></td> <td class="text-center" nowrap><?= view_cell("\App\Cells\Equipment\ServerCell::detail", ['serviceEntity' => $entity]) ?></td>
<td class="text-center" nowrap> <td class="text-center" nowrap>
<?= form_open("/admin/customer/service/history/{$entity->getPK()}?return_url=" . urlencode(current_url()), ['method' => "post"]) ?> <?= form_open("/admin/customer/service/history/{$entity->getPK()}?return_url=" . urlencode(current_url()), ['method' => "post"]) ?>
<textarea name="history" class="form-control note-box"><?= $entity->getHistory() ?></textarea> <textarea name="history" class="form-control note-box"><?= $entity->getHistory() ?></textarea>

View File

@ -1,30 +0,0 @@
<table class="table table-bordered table-striped">
<?php foreach ($serverEntities as $serverEntity): ?>
<tr class="text-center">
<th style="width: 250px">
<?= $serviceEntity->getServerInfoUID() == $serverEntity->getPK() ? "📌" : "<a href=\"/admin/customer/service/changeServer/{$serviceEntity->getPK()}?serverinfo_uid={$serverEntity->getPK()}\">✔️</a>" ?>
<?= $serviceCellDatas['serverPartHelper']->getFieldView('SERVER', "", ['serverEntity' => $serverEntity]) ?>
<?= $serviceEntity->getServerInfoUID() != $serverEntity->getPK() ? "<a href=\"/admin/customer/service/terminateServer/{$serviceEntity->getPK()}?serverinfo_uid={$serverEntity->getPK()}\">❌</a>" : "" ?>
</th>
<th style="width: 250px">
<?= $serviceCellDatas['serverPartHelper']->getListButton('CPU', 'CPU', ['serverinfo_uid' => $serverEntity->getPK()]) ?>
/ <?= $serviceCellDatas['serverPartHelper']->getListButton('RAM', 'RAM', ['serverinfo_uid' => $serverEntity->getPK()]) ?>
/ <?= $serviceCellDatas['serverPartHelper']->getListButton('DISK', 'DISK', ['serverinfo_uid' => $serverEntity->getPK()]) ?>
</th>
<th style="width: 200px"><?= $serviceCellDatas['serverPartHelper']->getListButton('IP', '추가IP', ['serverinfo_uid' => $serverEntity->getPK()]) ?></th>
<th style="width: 200px"><?= $serviceCellDatas['serverPartHelper']->getListButton('CS', 'CS', ['serverinfo_uid' => $serverEntity->getPK()]) ?></th>
</tr>
<tr class="text-center">
<td nowrap>
<div><?= $serverEntity->getTitle() ?></div>
<div><?= $serverEntity->getIP() ?></div>
<div><?= $serverEntity->getOS() ?></div>
</td>
<?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
'serverinfo_uid' => $serverEntity->getPK(),
'types' => SERVERPART['ALL_PARTTYPES'],
'template' => 'partlist_detail'
]) ?>
</tr>
<?php endforeach; ?>
</table>