198 lines
8.1 KiB
PHP
198 lines
8.1 KiB
PHP
<?php
|
|
|
|
namespace lib\Controllers\DBMS;
|
|
|
|
use lib\Services\MemberService;
|
|
use lib\Services\ClientService;
|
|
use lib\Services\VPCService;
|
|
use lib\Services\KCSService;
|
|
use lib\Services\HistoryService;
|
|
use lib\Helpers\ServiceHelper;
|
|
|
|
class DashboardController extends DBMSController
|
|
{
|
|
private ?MemberService $_memberService = null;
|
|
private ?ClientService $_clientService = null;
|
|
private ?VPCService $_vpcService = null;
|
|
private ?KCSService $_kcsService = null;
|
|
private ?HistoryService $_historyService = null;
|
|
|
|
public function __construct(array $params = [])
|
|
{
|
|
parent::__construct($params);
|
|
$this->getView()->setPath('dashboard');
|
|
$this->helper = new ServiceHelper();
|
|
} //
|
|
public function getMemberService(): MemberService
|
|
{
|
|
if ($this->_memberService === null) {
|
|
$this->_memberService = new MemberService();
|
|
}
|
|
return $this->_memberService;
|
|
}
|
|
|
|
public function getClientService(): ClientService
|
|
{
|
|
if ($this->_clientService === null) {
|
|
$this->_clientService = new ClientService();
|
|
}
|
|
return $this->_clientService;
|
|
}
|
|
|
|
public function getVPCService(): VPCService
|
|
{
|
|
if ($this->_vpcService === null) {
|
|
$this->_vpcService = new VPCService();
|
|
}
|
|
return $this->_vpcService;
|
|
}
|
|
public function getKCSService(): KCSService
|
|
{
|
|
if ($this->_kcsService === null) {
|
|
$this->_kcsService = new KCSService();
|
|
}
|
|
return $this->_kcsService;
|
|
}
|
|
public function getHistoryService(): HistoryService
|
|
{
|
|
if ($this->_historyService === null) {
|
|
$this->_historyService = new HistoryService();
|
|
}
|
|
return $this->_historyService;
|
|
}
|
|
//Dashboard , default_alert.php
|
|
//CLI 접속방법 : php index.php site/dashboard/topboard
|
|
//WEB 접속방법 : http://localhost/site/dashboard/topboard
|
|
public function topboard()
|
|
{
|
|
// 최근7일 신규서버수
|
|
//예외,service_line = "test","substitution"
|
|
$excepts = ["test", "substitution"];
|
|
$this->day = intval(DBMS_SITE_DASHBOARD_DAY);
|
|
$this->newServers = $this->getServiceService()->getLatestCount($this->day, $excepts);
|
|
// 금일기준 미납서버수
|
|
//예외,service_line = "test","substitution",C012:게임윙,C116:WinIDC,C219:IDC-JP
|
|
$excepts = ["test", "substitution", 'C116', 'C012', 'C219'];
|
|
$this->unPayments = $this->getServiceService()->getUnPaymentCount($excepts);
|
|
return $this->render(__FUNCTION__);
|
|
}
|
|
|
|
//서비스카운팅 , total_counting.php
|
|
//CLI 접속방법 : php index.php site/dashboard/totalcount/sitekey/도메인
|
|
//WEB 접속방법 : http://localhost/site/dashboard/totalcount/sitekey/도메인
|
|
public function totalcount()
|
|
{
|
|
$sitekey = $this->request->get('sitekey');
|
|
if (!$sitekey) {
|
|
throw new \Exception("sitekey 값이 정의되지 않았습니다.");
|
|
}
|
|
$this->siteInfo = DBMS_SITEINFOS[$sitekey];
|
|
$this->totalcount = $this->getServiceService()->getTotalCountForDashboard($this->siteInfo);
|
|
$summary = array();
|
|
foreach ($this->siteInfo['totalcount_types'] as $type) {
|
|
$summary[$type] = array("Tokyo" => 0, "Chiba" => 0);
|
|
}
|
|
foreach ($this->totalcount as $company => $service) {
|
|
$summary[$company] = array("Tokyo" => 0, "Chiba" => 0);
|
|
foreach ($service as $name => $location) {
|
|
$summary[$company]['Tokyo'] += $location['Tokyo'];
|
|
$summary[$name]['Tokyo'] += $location['Tokyo'];
|
|
$summary[$company]['Chiba'] += $location['Chiba'];
|
|
$summary[$name]['Chiba'] += $location['Chiba'];
|
|
}
|
|
}
|
|
$total = array("Tokyo" => 0, "Chiba" => 0);
|
|
foreach ($this->siteInfo['totalcount_types'] as $type) {
|
|
$total['Tokyo'] += $summary[$type]['Tokyo'];
|
|
$total['Chiba'] += $summary[$type]['Chiba'];
|
|
}
|
|
$this->summary = $summary;
|
|
$this->total = $total;
|
|
return $this->render(__FUNCTION__);
|
|
}
|
|
//신규서버현황 new_server_list.php
|
|
//CLI 접속방법 : php index.php site/dashboard/latest_service/limit/5
|
|
//WEB 접속방법 : http://localhost/site/dashboard/latest_service/limit/5
|
|
public function latest_service()
|
|
{
|
|
//신규서버정보
|
|
$this->limit = intval($this->request->get('limit', 5));
|
|
$this->entities = $this->getServiceService()->getLatest($this->limit);
|
|
// echo $this->getServiceervice()->getModel()->getLastQuery();
|
|
//전체 관리자정보(등록자)
|
|
$this->members = $this->getMemberService()->getEntities();
|
|
$clients = [];
|
|
$vpcs = [];
|
|
$kcss = [];
|
|
$cnt = 1;
|
|
foreach ($this->entities as $entity) {
|
|
$serviceCode = $entity->getServiceCode();
|
|
//해당 고객정보
|
|
$client = $this->getClientService()->getEntityByCode($entity->getClientCode());
|
|
if (!$client) {
|
|
throw new \Exception("{$entity->getClientCode()}에 해당하는 고객정보가 존재하지 않습니다.");
|
|
}
|
|
$clients[$serviceCode] = $client;
|
|
//VPC정보갯수
|
|
$vpcs[$serviceCode] = $this->getVPCService()->getCountByServiceCode($serviceCode);
|
|
//KCS정보갯수
|
|
$kcss[$serviceCode] = $this->getKCSService()->getCountByServiceCode($serviceCode);
|
|
$cnt++;
|
|
}
|
|
// dd($this->entitys);
|
|
$this->clients = $clients;
|
|
$this->vpcs = $vpcs;
|
|
$this->kcss = $kcss;
|
|
return $this->render(__FUNCTION__);
|
|
}
|
|
//CLI 접속방법 : php index.php site/dashboard/latest_history/limit/5
|
|
//WEB 접속방법 : http://localhost/site/dashboard/latest_history/limit/5
|
|
public function latest_history(): string
|
|
{
|
|
//신규서버정보
|
|
$this->limit = intval($this->request->get('limit', 5));
|
|
$this->entitys = $this->getHistoryService()->getLatest($this->limit);
|
|
//전체 서비스정보
|
|
$this->services = $this->getServiceService()->getEntities();
|
|
//services 고객정보
|
|
$this->clients = $this->getClientService()->getEntities();
|
|
return $this->render(__FUNCTION__);
|
|
}
|
|
//service_list_cs_count.php
|
|
//CLI 접속방법 : php index.php site/dashboard/cscount/service_code/서비스코드/client_code/고객코드
|
|
//WEB 접속방법 : http://localhost/site/dashboard/cscount/service_code/서비스코드/client_code/고객코드
|
|
public function cscount(): string
|
|
{
|
|
$service_code = $this->request->get('service_code');
|
|
if (!$service_code) {
|
|
throw new \Exception("service_code 값이 정의되지 않았습니다.");
|
|
}
|
|
$service = $this->getServiceService()->getEntityByCode($service_code);
|
|
if (!$service) {
|
|
throw new \Exception("[$service_code]에 해당하는 서비스정보가 존재하지 않습니다.");
|
|
}
|
|
$this->service = $service;
|
|
//VPC정보갯수
|
|
$this->vpc = $this->getVPCService()->getCountByServiceCode($service->getServiceCode());
|
|
//KCS정보갯수
|
|
$this->kcs = $this->getKCSService()->getCountByServiceCode($service->getServiceCode());
|
|
return $this->render(__FUNCTION__);
|
|
}
|
|
//service_list_cs_count.php
|
|
//CLI 접속방법 : php index.php site/dashboard/cscount/service_code/서비스코드/client_code/고객코드
|
|
//WEB 접속방법 : http://localhost/site/dashboard/cscount/service_code/서비스코드/client_code/고객코드
|
|
public function coupon(): string
|
|
{
|
|
$service_code = $this->request->get('service_code');
|
|
if (!$service_code) {
|
|
throw new \Exception("service_code 값이 정의되지 않았습니다.");
|
|
}
|
|
$service = $this->getServiceService()->getEntityByCode($service_code);
|
|
if (!$service) {
|
|
throw new \Exception("[$service_code]에 해당하는 서비스정보가 존재하지 않습니다.");
|
|
}
|
|
$this->entity = $service;
|
|
return $this->render(__FUNCTION__);
|
|
}
|
|
} //Class
|