diff --git a/app/Cells/Customer/ServiceCell.php b/app/Cells/Customer/ServiceCell.php index 754db33..271ef60 100644 --- a/app/Cells/Customer/ServiceCell.php +++ b/app/Cells/Customer/ServiceCell.php @@ -29,15 +29,23 @@ class ServiceCell extends CustomerCell $this->getService()->setFormFilters(); $this->getService()->setFormRules(); $this->getService()->setFormOptions(); + //서비스별 미납 Count $unPaids = $this->getPaymentService()->getUnPaids('serviceinfo_uid', ['clientinfo_uid' => $params['clientinfo_uid']]); - $entities = $this->getService()->getEntities(['clientinfo_uid' => $params['clientinfo_uid']]); + //서비스별 서버리스트 + $entities = []; + $childServers = []; + foreach ($this->getService()->getEntities(['clientinfo_uid' => $params['clientinfo_uid']]) as $entity) { + $entities[] = $entity; + $childServers[$entity->getPK()] = $this->getService()->getServerService()->getEntities(['serviceinfo_uid' => $entity->getPK()]); + } $template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__; return view('cells/service/' . $template, [ 'serviceCellDatas' => [ 'control' => $this->getService()->getControlDatas(), 'service' => $this->getService(), - 'entities' => $entities, 'unPaids' => $unPaids, + 'entities' => $entities, + 'childServers' => $childServers, 'serverPartHelper' => new ServerPartHelper(), ] ]); diff --git a/app/Controllers/Admin/Customer/ServiceController.php b/app/Controllers/Admin/Customer/ServiceController.php index 756300d..797b16b 100644 --- a/app/Controllers/Admin/Customer/ServiceController.php +++ b/app/Controllers/Admin/Customer/ServiceController.php @@ -13,7 +13,6 @@ use Psr\Log\LoggerInterface; class ServiceController extends CustomerController { - private ?ServerService $_serverService = null; private ?PaymentService $_paymentService = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { @@ -31,20 +30,6 @@ class ServiceController extends CustomerController } return $this->_service; } - public function getServerService(): ServerService - { - if ($this->_serverService === null) { - $this->_serverService = new ServerService(); - } - return $this->_serverService; - } - public function getPaymentService(): PaymentService - { - if ($this->_paymentService === null) { - $this->_paymentService = new PaymentService(); - } - return $this->_paymentService; - } //Index,FieldForm관련 protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string { @@ -88,28 +73,16 @@ class ServiceController extends CustomerController $this->getService()->setFormDatas($formDatas); parent::create_form_process(); } - private function getChildServers(ServiceEntity $entity): array - { - $servers = []; - foreach ($this->getServerService()->getEntities(['serviceinfo_uid' => $entity->getPK()]) as $serverEntity) { - $servers[] = view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [ - 'serverinfo_uid' => $serverEntity->getPK(), - 'types' => SERVERPART['SERVICE_PARTTYPES'], - 'serviceinfo_serverinfo_uid' => $entity->getServerEntity()->getPK(), - 'template' => 'partlist_service' - ]); - } - return $servers; - } //List 관련 protected function index_process(array $entities = []): array { //서비스별 미납 Count + $this->unPaids = $this->getService()->getPaymentService()->getUnPaids('serviceinfo_uid'); + //서비스별 서버리스트 $childServers = []; - $this->unPaids = $this->getPaymentService()->getUnPaids('serviceinfo_uid'); foreach ($this->getService()->getEntities() as $entity) { $entities[] = $entity; - $childServers[$entity->getPK()] = $this->getChildServers($entity); + $childServers[$entity->getPK()] = $this->getService()->getServerService()->getEntities(['serviceinfo_uid' => $entity->getPK()]); } $this->childServers = $childServers; return $entities; @@ -157,11 +130,9 @@ class ServiceController extends CustomerController if (!$entity instanceof ServiceEntity) { throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); } - $formDatas = $this->getService()->getFormDatas(); - $formDatas['type'] = 'alternative'; //대체서버로 등록하기위해 필요 - $this->entity = $this->getService()->addServer($entity, $formDatas); + $this->entity = $this->getService()->addServer($entity, $this->getService()->getFormDatas()); $db->transCommit(); - return "대체서버추가가 완료되었습니다."; + return ""; } catch (\Exception $e) { $db->transRollback(); return $this->getResultFail($e->getMessage()); diff --git a/app/Controllers/Admin/SearchController.php b/app/Controllers/Admin/SearchController.php index c0f813e..7d9e43c 100644 --- a/app/Controllers/Admin/SearchController.php +++ b/app/Controllers/Admin/SearchController.php @@ -56,34 +56,12 @@ class SearchController extends AdminController } return $result; } - private function getChildServers(ServiceEntity $entity): array - { - $servers = []; - foreach ($this->getServerService()->getEntities(['serviceinfo_uid' => $entity->getPK()]) as $serverEntity) { - $servers[] = view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [ - 'serverinfo_uid' => $serverEntity->getPK(), - 'types' => SERVERPART['SERVICE_PARTTYPES'], - 'serviceinfo_serverinfo_uid' => $entity->getServerEntity()->getPK(), - 'template' => 'partlist_service' - ]); - } - return $servers; - } protected function index_process(array $entities = []): array { $keyword = $this->request->getGet('keyword'); // 검색어 if (!$keyword) { throw new \Exception("[{$keyword}] 검색어가 지정되지 않았습니다. "); } - // ->select([ - // 's.serviceinfo_uid', - // 's.uid AS server_uid', - // 's.title AS server_title', - // 'c.uid AS client_uid', - // 'c.name AS client_name', - // 'sp.uid AS part_uid', - // 'sp.title AS part_title' - // ]) $db = \Config\Database::connect(); $builder = $db->table('serverinfo s') ->distinct() @@ -108,11 +86,11 @@ class SearchController extends AdminController foreach ($results as $result) { $uids[] = "'{$result['serviceinfo_uid']}'"; } - //서비스별 미납 Count + //서비스별 서버리스트 $childServers = []; foreach ($this->getService()->getEntities("uid IN (" . implode(",", $uids) . ")") as $entity) { $entities[] = $entity; - $childServers[$entity->getPK()] = $this->getChildServers($entity); + $childServers[$entity->getPK()] = $this->getService()->getServerService()->getEntities(['serviceinfo_uid' => $entity->getPK()]); } $this->childServers = $childServers; return $entities; diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index a00136e..04244b2 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -221,15 +221,6 @@ class ServiceService extends CustomerService case 'serverinfo_uid': $options = $this->getServerService()->getEntities(); break; - case 'CPU': - case 'RAM': - case 'DISK': - case 'SOFTWARE': - case 'SWITCH': - case 'IP': - case 'CS': - $options = $this->getServerService()->getFormOption($field, $options); - break; default: $options = parent::getFormOption($field, $options); break; @@ -285,8 +276,11 @@ class ServiceService extends CustomerService //대체서버추가(가격변동은 없음) public function addServer(ServiceEntity $entity, array $formDatas): ServiceEntity { - //대체서버추가 및 결제처리는 하지않음 - return $this->getServerService()->setService('create', $entity, ['type' => SERVER['TYPES']['ALTERNATIVE']]); + if (!array_key_exists('serverinfo_uid', $formDatas)) { + throw new \Exception(__METHOD__ . "에서 오류발생:대체서버가 지정되지 않았습니다."); + } + $formDatas['type'] = 'alternative'; //대체서버로 등록하기위해 필요 + return $this->getServerService()->setService('create', $entity, $formDatas); } //대체서버를 메인서버로 설정 public function changeServer(ServiceEntity $entity, array $formDatas): ServiceEntity diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index 6394ae4..a65ae88 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -154,7 +154,7 @@ class ServerService extends EquipmentService implements ServiceInterface switch ($action) { case 'create': if (!array_key_exists('serverinfo_uid', $serviceFormDatas)) { - throw new \Exception(__METHOD__ . "에서 {$action}오류발생: 서버가 지정되지 않았습니다."); + throw new \Exception(__METHOD__ . "에서 {$action}오류발생: 서버가 지정되지 않았습니다.\n" . var_export($serviceFormDatas, true)); } $entity = $this->getEntity($serviceFormDatas['serverinfo_uid']); if (!$entity instanceof ServerEntity || $entity->getStatus() != STATUS['AVAILABLE']) { diff --git a/app/Views/admin/client/detail.php b/app/Views/admin/client/detail.php index 1ca404b..e56b9ad 100644 --- a/app/Views/admin/client/detail.php +++ b/app/Views/admin/client/detail.php @@ -1,6 +1,16 @@ = $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?> = $this->section('content') ?> + getHelper()->alert($error) ?>
| 서비스정보 | -서버정보 | -- = $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()]) ?> - | -= $serviceCellDatas['serverPartHelper']->getListButton('IP', '추가IP', ['serverinfo_uid' => $serverEntity->getPK()]) ?> | -= $serviceCellDatas['serverPartHelper']->getListButton('CS', 'CS', ['serverinfo_uid' => $serverEntity->getPK()]) ?> | -서비스 비고 | +서버 | +서비스 비고 | 결제처리 |
|---|---|---|---|---|---|---|---|---|
| = view('cells/service/server', ['serverEntities' => $serviceCellDatas['childServers'][$entity->getPK()]]) ?> |
- = $serviceCellDatas['serverPartHelper']->getFieldView('SERVER', "", ['serverEntity' => $serverEntity]) ?>
- [= $serverEntity->getTitle() ?>]
- [= $serverEntity->getIP() ?>]
- [= $serverEntity->getOS() ?>]
- |
- = view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
- 'serverinfo_uid' => $serverEntity->getPK(),
- 'types' => SERVERPART['ALL_PARTTYPES'],
- 'template' => 'part_detail'
- ]) ?>
-
= form_open("/admin/customer/service/history/{$entity->getPK()}?return_url=" . urlencode(current_url()), ['method' => "post"]) ?>
-
-
-
+
+ = form_submit('', '저장', array("class" => "btn btn-outline btn-primary m-3")); ?>
= form_close() ?>
= form_submit('', '저장', array("class" => "btn btn-outline btn-primary")); ?>
- |
diff --git a/app/Views/cells/service/server.php b/app/Views/cells/service/server.php
new file mode 100644
index 0000000..d9c5b6a
--- /dev/null
+++ b/app/Views/cells/service/server.php
@@ -0,0 +1,27 @@
+
|