From 18b412e7a4cbbeef63edbe8277c80368b038db8a Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Tue, 24 Jun 2025 16:53:20 +0900 Subject: [PATCH] dbms_init...1 --- app/Controllers/Admin/Home.php | 15 ++-- app/Services/Customer/ServiceService.php | 39 ++++++++-- app/Views/admin/welcome_message.php | 4 +- app/Views/templates/admin/welcome_total.php | 81 +++++---------------- 4 files changed, 61 insertions(+), 78 deletions(-) diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php index 6323f90..d031dbf 100644 --- a/app/Controllers/Admin/Home.php +++ b/app/Controllers/Admin/Home.php @@ -64,23 +64,22 @@ class Home extends AdminController } return $result; } + + //Index,FieldForm관련 public function index(): RedirectResponse|string { $this->initAction(__FUNCTION__); - //최근 inverval(default : 7일)일간 신규서버 정보 + //Total 서버 현황 + $this->totalCounts = $this->getService()->getTotalCountsByType(); //LINE,IP,SERVER등 추가 FilterOption 셋팅용 foreach (SERVICE_ITEM_TYPES as $item_type => $label) { $this->setFilterFieldOption($item_type, $this->getService()->getFilterOptionsByItemType($item_type)); } + //interval을 기준으로 최근 신규 서비스정보 가져오기 $this->interval = intval($this->request->getVar('interval') ?? SERVICE_NEW_INTERVAL); - $entities = []; - foreach ($this->getService()->getEntitiesByNewService($this->interval) as $entity) { - $entities[$entity->getPK()] = $this->getService()->setItemEntitiesByService($entity); - } - $this->newServiceEntities = $entities; - $this->newServiceCount = count($this->newServiceEntities); - + $this->newServiceEntities = $this->getService()->getEntitiesByNewService($this->interval); + $this->newServiceCount = count($this->newServiceEntities); //미납 서버 정보 $this->unPaidEntities = $this->getServicePaymentService()->getEntitiesByUnPaid(); $this->unPaidCount = count($this->unPaidEntities); diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index e03677d..76e8cb7 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -138,16 +138,45 @@ class ServiceService extends CustomerService foreach (SERVICE_ITEM_TYPES as $item_type => $label) { $entity->setItemEntities( $item_type, - $this->getServiceItemService()->getEntities(['serviceinfo_uid' => $entity->getPK(), 'item_type' => $item_type]) + $this->getServiceItemService()->getEntities([ + 'serviceinfo_uid' => $entity->getPK(), + 'item_type' => $item_type + ]) ); } return $entity; } - //interval을 기준으로 신규서비스 가져오기 - final public function getEntitiesByNewService(int $interval, string $status = DEFAULTS['STATUS']) + //interval을 기준으로 최근 신규 서비스정보 가져오기 + final public function getEntitiesByNewService(int $interval, string $status = DEFAULTS['STATUS']): array { - $where = sprintf("start_at >= NOW()-INTERVAL {$interval} DAY AND status = '%s'", DEFAULTS['STATUS']); - return $this->getEntities($where); + $where = sprintf("start_at >= NOW()-INTERVAL {$interval} DAY AND status = '%s'", $status); + $entities = []; + foreach ($this->getEntities($where) as $entity) { + $entities[$entity->getPK()] = $this->setItemEntitiesByService($entity); + }; + return $entities; + } + //서비스 방식에 따른 서비스별 Count + final public function getTotalCountsByType(): array + { + $sql = "SELECT type, + COUNT(CASE WHEN location = 'default' THEN 1 END) AS chiba, + COUNT(CASE WHEN location = 'tokyo' THEN 1 END) AS tokyo, + COUNT(CASE WHEN location IN ('default', 'tokyo') THEN 1 END) AS total + FROM serviceinfo GROUP BY type;"; + + $totalCounts = ['chiba_total' => 0, 'tokyo_total' => 0, 'all_total' => 0]; + foreach ($this->getModel()->query($sql)->getResult() as $row) { + $totalCounts[$row->type] = [ + 'chiba' => $row->chiba, + 'tokyo' => $row->tokyo, + 'total' => $row->total, + ]; + $totalCounts['chiba_total'] += $row->chiba; + $totalCounts['tokyo_total'] += $row->tokyo; + } + $totalCounts['all_total'] = $totalCounts['chiba_total'] + $totalCounts['tokyo_total']; + return $totalCounts; } //다음 달로 결제일을 연장합니다. final public function extendBillingAt(string $billing_at, string $status): bool diff --git a/app/Views/admin/welcome_message.php b/app/Views/admin/welcome_message.php index 62f5ab3..ce96ed0 100644 --- a/app/Views/admin/welcome_message.php +++ b/app/Views/admin/welcome_message.php @@ -14,10 +14,10 @@ include("templates/{$viewDatas['layout']}/welcome_banner"); ?>
-
+
include("templates/{$viewDatas['layout']}/welcome_total"); ?>
-
+
include("templates/{$viewDatas['layout']}/welcome_new"); ?>
diff --git a/app/Views/templates/admin/welcome_total.php b/app/Views/templates/admin/welcome_total.php index 89790d3..c7f00ea 100644 --- a/app/Views/templates/admin/welcome_total.php +++ b/app/Views/templates/admin/welcome_total.php @@ -16,7 +16,7 @@ 방어 전용 대체 - 테스트 + 테스트 합계 @@ -30,6 +30,7 @@ 치바 도쿄 치바 + 합계 도쿄 치바 합계 @@ -37,68 +38,21 @@ - prime - 4 - 192 - 0 - 0 - 0 - 12 - 0 - 0 - 3 - 3 - 4 - 204 - 208 - - - itsolution - 10 - 206 - 6 - 0 - 0 - 0 - 0 - 0 - 1 - 1 - 16 - 206 - 222 - - - gdidc - 5 - 38 - 0 - 0 - 0 - 7 - 0 - 0 - 3 - 3 - 5 - 45 - 50 - - - gamewing - 12 - 121 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 12 - 121 - 133 + PRIME + + + + + + + + + + + + + + @@ -112,6 +66,7 @@ 19 0 0 + 0 7 7 37