diff --git a/app/Cells/Equipment/ServerCell.php b/app/Cells/Equipment/ServerCell.php index 05f3632..920df61 100644 --- a/app/Cells/Equipment/ServerCell.php +++ b/app/Cells/Equipment/ServerCell.php @@ -15,13 +15,45 @@ class ServerCell extends EquipmentCell //서비스 방식에 따른 서비스별 Count final public function totalCountDashboard(array $params): string { - $totalCounts = $this->getService()->getTotalServiceCount(array_key_exists('where', $params) ? $params['where'] : []); + $totalCounts = [ + 'all' => [ + 'normal' => ['tokyo' => 0, 'chiba' => 0], + 'defence' => ['tokyo' => 0, 'chiba' => 0], + 'dedicated' => ['tokyo' => 0, 'chiba' => 0], + 'alternative' => ['tokyo' => 0, 'chiba' => 0], + 'vpn' => ['tokyo' => 0, 'chiba' => 0], + 'event' => ['tokyo' => 0, 'chiba' => 0], + 'test' => ['tokyo' => 0, 'chiba' => 0], + 'summary_tokyo' => 0, + 'summary_chiba' => 0, + 'summary_all' => 0, + ] + ]; + foreach (array_keys(SITES) as $site) { + $totalCounts[$site] = $this->getService()->getTotalServiceCount(['serviceinfo.site' => $site]); + $totalCounts['all']['normal']['tokyo'] += $totalCounts[$site]['normal']['tokyo']; + $totalCounts['all']['normal']['chiba'] += $totalCounts[$site]['normal']['chiba']; + $totalCounts['all']['defence']['tokyo'] += $totalCounts[$site]['defence']['tokyo']; + $totalCounts['all']['defence']['chiba'] += $totalCounts[$site]['defence']['chiba']; + $totalCounts['all']['dedicated']['tokyo'] += $totalCounts[$site]['dedicated']['tokyo']; + $totalCounts['all']['dedicated']['chiba'] += $totalCounts[$site]['dedicated']['chiba']; + $totalCounts['all']['alternative']['tokyo'] += $totalCounts[$site]['alternative']['tokyo']; + $totalCounts['all']['alternative']['chiba'] += $totalCounts[$site]['alternative']['chiba']; + $totalCounts['all']['vpn']['tokyo'] += $totalCounts[$site]['vpn']['tokyo']; + $totalCounts['all']['vpn']['chiba'] += $totalCounts[$site]['vpn']['chiba']; + $totalCounts['all']['event']['tokyo'] += $totalCounts[$site]['event']['tokyo']; + $totalCounts['all']['event']['chiba'] += $totalCounts[$site]['event']['chiba']; + $totalCounts['all']['test']['tokyo'] += $totalCounts[$site]['test']['tokyo']; + $totalCounts['all']['test']['chiba'] += $totalCounts[$site]['test']['chiba']; + $totalCounts['all']['summary_tokyo'] += $totalCounts[$site]['tokyo_summary']; + $totalCounts['all']['summary_chiba'] += $totalCounts[$site]['chiba_summary']; + $totalCounts['all']['summary_all'] = $totalCounts['all']['summary_tokyo'] + $totalCounts['all']['summary_chiba']; + } $template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__; return view('cells/server/' . $template, [ 'serviceCellDatas' => [ 'control' => $this->getService()->getControlDatas(), 'service' => $this->getService(), - 'label' => $params['where']['serviceinfo.site'], 'totalCounts' => $totalCounts, ] ]); diff --git a/app/Controllers/Admin/BoardController.php b/app/Controllers/Admin/BoardController.php index 7544eb3..8564f65 100644 --- a/app/Controllers/Admin/BoardController.php +++ b/app/Controllers/Admin/BoardController.php @@ -31,17 +31,9 @@ class BoardController extends AdminController //전달값정의 $this->getService()->setFormDatas($this->request->getGet()); $formDatas = $this->getSErvice()->getFormDatas(); - $datas = []; - foreach ( - $this->getService()->latest( - [ - 'category' => array_key_exists('category', $formDatas) && $formDatas['category'] ? $formDatas['category'] : 'notice' - ], - array_key_exists('limit', $formDatas) ? $formDatas['limit'] : 3 - ) as $entity - ) { - $datas[] = $entity->toArray(); - } - return $this->response->setJSON($datas); + return $this->response->setJSON($this->getService()->latest( + ['category' => array_key_exists('category', $formDatas) && $formDatas['category'] ? $formDatas['category'] : 'notice'], + array_key_exists('limit', $formDatas) ? $formDatas['limit'] : 3 + )); } } diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php index 0fa1c65..f7ebf41 100644 --- a/app/Controllers/Admin/Home.php +++ b/app/Controllers/Admin/Home.php @@ -74,8 +74,7 @@ class Home extends AdminController $this->newServiceEntities = $this->getService()->getEntitiesByNewService($this->interval); $this->newServiceCount = count($this->newServiceEntities); //서비스별 미납 Count - $totalUnPaidCount = 0; - $totalUnPaidAmount = 0; + $totalUnPaidCount = $totalUnPaidAmount = 0; foreach ($this->getPaymentService()->getUnPaids('serviceinfo_uid') as $key => $datas) { $totalUnPaidCount += $datas['cnt']; $totalUnPaidAmount += $datas['amount']; diff --git a/app/Controllers/Admin/SearchController.php b/app/Controllers/Admin/SearchController.php index 7d9e43c..ab9378a 100644 --- a/app/Controllers/Admin/SearchController.php +++ b/app/Controllers/Admin/SearchController.php @@ -62,29 +62,11 @@ class SearchController extends AdminController if (!$keyword) { throw new \Exception("[{$keyword}] 검색어가 지정되지 않았습니다. "); } - $db = \Config\Database::connect(); - $builder = $db->table('serverinfo s') - ->distinct() - ->select('s.serviceinfo_uid AS serviceinfo_uid') - ->join('clientinfo c', 'c.uid = s.clientinfo_uid') - ->join('serverpartinfo sp', 'sp.clientinfo_uid = c.uid', 'left') - ->groupStart() - ->like('c.name', $keyword, 'both', null, true) // escape=true - ->orLike('s.code', $keyword, 'both', null, true) - ->orLike('s.ip', $keyword, 'both', null, true) - ->orLike('s.title', $keyword, 'both', null, true) - ->orLike('sp.title', $keyword, 'both', null, true) - ->groupEnd(); - // SQL 확인용 (실제 운영에서는 주석 처리) - // echo $builder->getCompiledSelect(); - // exit; - $results = $builder->get()->getResultArray(); - if (!count($results)) { - return []; - } + //검색어에 따른 서버정보를 검색 후 해당하는 서비스리스트를 가져온다. + $rows = $this->getServerService()->getSearchServices($keyword); $uids = []; - foreach ($results as $result) { - $uids[] = "'{$result['serviceinfo_uid']}'"; + foreach ($rows as $row) { + $uids[] = "'{$row->serviceinfo_uid}'"; } //서비스별 서버리스트 $childServers = []; diff --git a/app/Entities/BoardEntity.php b/app/Entities/BoardEntity.php index a508177..c7acb12 100644 --- a/app/Entities/BoardEntity.php +++ b/app/Entities/BoardEntity.php @@ -10,4 +10,8 @@ class BoardEntity extends CommonEntity const PK = Model::PK; const TITLE = Model::TITLE; const DEFAULT_STATUS = STATUS['AVAILABLE']; + final public function getUserUID(): int|null + { + return $this->attributes['user_uid'] ?? null; + } } diff --git a/app/Language/en/Board.php b/app/Language/en/Board.php index ee65889..d226b25 100644 --- a/app/Language/en/Board.php +++ b/app/Language/en/Board.php @@ -3,6 +3,7 @@ return [ 'title' => "게시판정보", 'label' => [ 'uid' => "번호", + 'user_uid' => "작성자", 'category' => "구분", 'title' => "제목", 'content' => "내용", diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php index 1e7246a..637ade8 100644 --- a/app/Models/BoardModel.php +++ b/app/Models/BoardModel.php @@ -14,6 +14,7 @@ class BoardModel extends CommonModel protected $returnType = BoardEntity::class; protected $allowedFields = [ "uid", + "user_uid", "category", "title", "content", @@ -34,6 +35,9 @@ class BoardModel extends CommonModel case "title": $rule = "required|trim|string"; break; + case "user_uid": + $rule = "required|number"; + break; case "content": $rule = "permit_empty|string"; break; @@ -43,4 +47,10 @@ class BoardModel extends CommonModel } return $rule; } + final public function create(array $formDatas): BoardEntity + { + // 관리자 UID는 현재 인증된 사용자로 설정 + $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); + return parent::create($formDatas); + } } diff --git a/app/Services/BoardService.php b/app/Services/BoardService.php index b75675b..36874ad 100644 --- a/app/Services/BoardService.php +++ b/app/Services/BoardService.php @@ -24,6 +24,7 @@ class BoardService extends CommonService public function getFormFilters(): array { return [ + 'user_uid', 'category', 'status', ]; @@ -33,18 +34,29 @@ class BoardService extends CommonService return [ 'category', 'title', + 'user_uid', 'status', 'created_at', ]; } public function getBatchjobFields(): array { - return ['category', 'status']; + return ['user_uid', 'category', 'status']; } public function latest(array $where, int $limit = 3): array { + //관리자정보 + $userEntities = $this->getUserService()->getEntities(); $this->getModel()->limit($limit); - return $this->getEntities($where); + $datas = []; + foreach ($this->getEntities($where) as $entity) { + $datas[] = [ + 'title' => "", + 'created_at' => date('Y-m-d H:m', strtotime($entity->getCreatedAT())), + 'user' => $userEntities[$entity->getUserUID()]->getTitle(), + ]; + } + return $datas; } //기본 기능부분 } diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php index 97d9658..98e1798 100644 --- a/app/Services/CommonService.php +++ b/app/Services/CommonService.php @@ -191,14 +191,14 @@ abstract class CommonService throw new \Exception($message); } } // - public function getUserService(): UserService + final public function getUserService(): UserService { if (!$this->_userService) { $this->_userService = new UserService(); } return $this->_userService; } - public function getClientService(): ClientService + final public function getClientService(): ClientService { if (!$this->_clientService) { $this->_clientService = new ClientService(); diff --git a/app/Services/Customer/ClientService.php b/app/Services/Customer/ClientService.php index 9fa1bfb..20e532d 100644 --- a/app/Services/Customer/ClientService.php +++ b/app/Services/Customer/ClientService.php @@ -11,7 +11,6 @@ use App\Services\PaymentService; class ClientService extends CustomerService { - private ?ClientService $_clientService = null; private ?ServiceService $_serviceService = null; private ?ServerService $_serverService = null; private ?PaymentService $_paymentService = null; @@ -58,13 +57,6 @@ class ClientService extends CustomerService { return ['site', 'role', 'status']; } - final public function getClientService(): ClientService - { - if (!$this->_clientService) { - $this->_clientService = new ClientService(); - } - return $this->_clientService; - } final public function getServiceService(): ServiceService { if ($this->_serviceService === null) { diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index 476f624..04ee29c 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -122,25 +122,26 @@ class ServerService extends EquipmentService implements ServiceInterface 'normal' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0], 'defence' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0], 'dedicated' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0], + 'alternative' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0], 'vpn' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0], 'event' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0], 'test' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0], - 'alternative' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0], ]; - $rows = $this->getModel() - ->select("serverinfo.type, + $builder = $this->getModel()->select("serverinfo.type, COUNT(CASE WHEN serviceinfo.location = 'chiba' THEN 1 END) AS chiba, COUNT(CASE WHEN serviceinfo.location = 'tokyo' THEN 1 END) AS tokyo, COUNT(CASE WHEN serviceinfo.location IN ('chiba', 'tokyo') THEN 1 END) AS summary") - ->join('serviceinfo', 'serviceinfo.uid = serverinfo.serviceinfo_uid') // JOIN 조건 + ->join('serviceinfo', 'serviceinfo.uid = serverinfo.serviceinfo_uid') ->where($where) ->groupBy('serverinfo.type') - ->get() - ->getResult(); + ->builder(); + // echo $builder->getCompiledSelect(false) . "
"; //초기화 없이 SQL만 보고 싶을 때: getCompiledSelect(false) ← 꼭 false! + $rows = $builder->get()->getResult(); + // dd($rows); foreach ($rows as $row) { $totalCounts[$row->type]['chiba'] = $row->chiba; $totalCounts[$row->type]['tokyo'] = $row->tokyo; - $totalCounts[$row->type]['summary'] = $row->summary; + $totalCounts[$row->type]['summary'] += $row->summary; $totalCounts['chiba_summary'] += $row->chiba; $totalCounts['tokyo_summary'] += $row->tokyo; $totalCounts['all_summary'] = $totalCounts['chiba_summary'] + $totalCounts['tokyo_summary']; @@ -148,6 +149,27 @@ class ServerService extends EquipmentService implements ServiceInterface // dd($totalCounts); return $totalCounts; } + //검색어에 따른 서버정보를 검색 후 해당하는 서비스리스트를 가져온다. + final public function getSearchServices(string $keyword): array + { + $builder = $this->getModel()->distinct()->select('serverinfo.serviceinfo_uid AS serviceinfo_uid') + ->join('clientinfo', 'clientinfo.uid = serverinfo.clientinfo_uid') + ->join('serverpartinfo', 'serverpartinfo.clientinfo_uid = clientinfo.uid', 'left') + ->groupStart() + ->like('clientinfo.name', $keyword, 'both', null, true) // escape=true + ->orLike('serverinfo.code', $keyword, 'both', null, true) + ->orLike('serverinfo.ip', $keyword, 'both', null, true) + ->orLike('serverinfo.title', $keyword, 'both', null, true) + ->orLike('serverpartinfo.title', $keyword, 'both', null, true) + ->groupEnd() + ->builder(); + // echo $builder->getCompiledSelect(false); //초기화 없이 SQL만 보고 싶을 때: getCompiledSelect(false) ← 꼭 false! + $rows = $builder->get()->getResult(); + if (!count($rows)) { + return []; + } + return $rows; + } //서비스정보 설정 public function setService(string $action, ServiceEntity $serviceEntity, array $serviceFormDatas): ServiceEntity { diff --git a/app/Services/Part/CSService.php b/app/Services/Part/CSService.php index 6963668..f1c86a9 100644 --- a/app/Services/Part/CSService.php +++ b/app/Services/Part/CSService.php @@ -6,13 +6,11 @@ use App\Entities\Equipment\ServerPartEntity; use App\Entities\Part\CSEntity; use App\Helpers\Part\CSHelper; use App\Models\Part\CSModel; -use App\Services\Customer\ClientService; use App\Services\Customer\ServiceService; use App\Services\Equipment\ServerService; class CSService extends PartService { - private ?ClientService $_clientService = null; private ?ServiceService $_serviceService = null; private ?ServerService $_serverService = null; public function __construct() @@ -58,13 +56,6 @@ class CSService extends PartService { return ['type', 'status']; } - final public function getClientService(): ClientService - { - if (!$this->_clientService) { - $this->_clientService = new ClientService(); - } - return $this->_clientService; - } public function getServiceService(): ServiceService { if (!$this->_serviceService) { diff --git a/app/Services/Part/IPService.php b/app/Services/Part/IPService.php index 3a1717b..302f9bc 100644 --- a/app/Services/Part/IPService.php +++ b/app/Services/Part/IPService.php @@ -8,7 +8,6 @@ use App\Entities\Part\IPEntity; use App\Helpers\Part\IPHelper; use App\Interfaces\Equipment\ServerInterface; use App\Models\Part\IPModel; -use App\Services\Customer\ClientService; use App\Services\Customer\ServiceService; use App\Services\Equipment\LineService; use App\Services\Equipment\ServerService; @@ -17,7 +16,6 @@ use App\Services\Part\PartService; class IPService extends PartService implements ServerInterface { private ?LineService $_lineService = null; - private ?ClientService $_clientService = null; private ?ServiceService $_serviceService = null; private ?ServerService $_serverService = null; public function __construct() @@ -67,13 +65,6 @@ class IPService extends PartService implements ServerInterface } return $this->_lineService; } - final public function getClientService(): ClientService - { - if (!$this->_clientService) { - $this->_clientService = new ClientService(); - } - return $this->_clientService; - } public function getServiceService(): ServiceService { if (!$this->_serviceService) { diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 771dca7..b994e91 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -78,20 +78,6 @@ class PaymentService extends CommonService implements ServiceInterface, ServerPa 'invoice' => '청구서 발행', ]; } - final public function getClientService(): ClientService - { - if (!$this->_clientService) { - $this->_clientService = new ClientService(); - } - return $this->_clientService; - } - final public function getUSerService(): UserService - { - if (!$this->_userService) { - $this->_userService = new UserService(); - } - return $this->_userService; - } final public function getServiceService(): ServiceService { if ($this->_serviceService === null) { diff --git a/app/Views/admin/welcome/banner.php b/app/Views/admin/welcome/banner.php index b66c920..dbab1f5 100644 --- a/app/Views/admin/welcome/banner.php +++ b/app/Views/admin/welcome/banner.php @@ -64,33 +64,27 @@
-
-
+
+
-
- -
+
0
-
새 쪽지 알림
+
요청업무 알림
-
- -
+
-
+
-
- -
+
최근 일간 신규서버수
@@ -98,48 +92,23 @@
- -
-
-
-
-
- -
-
-
0
-
요청업무 알림
-
-
-
- -
-
- -
+
-
- -
+
-
건/
+
건/
금일 기준 미납 서비스
diff --git a/app/Views/admin/welcome/total_service.php b/app/Views/admin/welcome/total_service.php index 074056a..5b80e71 100644 --- a/app/Views/admin/welcome/total_service.php +++ b/app/Views/admin/welcome/total_service.php @@ -8,52 +8,38 @@
- +
- - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - ['serviceinfo.site' => 'PRIME']]) ?> - ['serviceinfo.site' => 'ITSOLUTION']]) ?> - ['serviceinfo.site' => 'GDIDC']]) ?> - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
고객명일반방어전용대체테스트합계사이트일반방어전용대체VPN이벤트테스트합계
도쿄치바도쿄치바도쿄치바도쿄치바도쿄치바합계도쿄치바합계
총합계00000000000000도쿄치바도쿄치바도쿄치바도쿄치바도쿄치바도쿄치바도쿄치바도쿄치바합계
\ No newline at end of file diff --git a/app/Views/cells/server/totalCountDashboard.php b/app/Views/cells/server/totalCountDashboard.php index 2df8bf8..6cf2891 100644 --- a/app/Views/cells/server/totalCountDashboard.php +++ b/app/Views/cells/server/totalCountDashboard.php @@ -1,17 +1,42 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + 총합계 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/Views/layouts/admin/top.php b/app/Views/layouts/admin/top.php index a1412ca..be6d5b9 100644 --- a/app/Views/layouts/admin/top.php +++ b/app/Views/layouts/admin/top.php @@ -24,9 +24,9 @@ - + @@ -93,7 +93,7 @@ notices.forEach(n => { const item = document.createElement("li"); item.classList.add("dropdown-item"); - item.innerHTML = `[${n.created_at.date.replace(/\.\d+$/, '')}] ${n.title}
`; + item.innerHTML = `[${n.user}/${n.created_at}] ${n.title}
`; notice_list.appendChild(item); }); } catch (err) {