110 lines
3.6 KiB
PHP
110 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin\Customer;
|
|
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
use App\Helpers\Customer\ServiceHelper;
|
|
use App\Services\Customer\ServiceService;
|
|
|
|
use App\Services\Equipment\LineService;
|
|
use App\Services\Equipment\ServerService;
|
|
use App\Services\Equipment\IpService;
|
|
|
|
|
|
class ServiceController extends CustomerController
|
|
{
|
|
private ?LineService $_lineService = null;
|
|
private ?ServerService $_serverService = null;
|
|
private ?IpService $_ipService = null;
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
$this->title = lang("{$this->getService()->getClassName()}.title");
|
|
$this->class_path .= $this->getService()->getClassName();
|
|
$this->uri_path .= strtolower($this->getService()->getClassName('/')) . '/';
|
|
// $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR;
|
|
|
|
}
|
|
public function getService(): ServiceService
|
|
{
|
|
if (!$this->_service) {
|
|
$this->_service = new ServiceService($this->request);
|
|
}
|
|
return $this->_service;
|
|
}
|
|
public function getHelper(): mixed
|
|
{
|
|
if (!$this->_helper) {
|
|
$this->_helper = new ServiceHelper($this->request);
|
|
}
|
|
return $this->_helper;
|
|
}
|
|
final public function getLineService(): LineService
|
|
{
|
|
if (!$this->_lineService) {
|
|
$this->_lineService = new LineService();
|
|
}
|
|
return $this->_lineService;
|
|
}
|
|
final public function getServerService(): ServerService
|
|
{
|
|
if (!$this->_serverService) {
|
|
$this->_serverService = new ServerService();
|
|
}
|
|
return $this->_serverService;
|
|
}
|
|
final public function getIpService(): IpService
|
|
{
|
|
if (!$this->_ipService) {
|
|
$this->_ipService = new IpService();
|
|
}
|
|
return $this->_ipService;
|
|
}
|
|
protected function getFormFieldOption(string $field, array $options): array
|
|
{
|
|
switch ($field) {
|
|
case 'lineinfo_uid':
|
|
$temps = [];
|
|
foreach ($this->getLineService()->getEntities() as $entity) {
|
|
$temps[$entity->getPK()] = $entity->getTitle();
|
|
}
|
|
$options[$field] = $temps;
|
|
// dd($options);
|
|
break;
|
|
case 'serverinfo_uid':
|
|
$temps = [];
|
|
foreach ($this->getServerService()->getEntities() as $entity) {
|
|
$temps[$entity->getPK()] = $entity->getTitle();
|
|
}
|
|
$options[$field] = $temps;
|
|
// dd($options);
|
|
break;
|
|
default:
|
|
$options = parent::getFormFieldOption($field, $options);
|
|
break;
|
|
}
|
|
// dd($options);
|
|
return $options;
|
|
}
|
|
//Index,FieldForm관련
|
|
|
|
protected function create_process(): mixed
|
|
{
|
|
$entity = parent::create_process();
|
|
//사용중인 서버로 변경
|
|
$this->getServerService()->setOccupied($this->getServerService()->getEntity($entity->getServerInfoUID()));
|
|
return $entity;
|
|
}
|
|
protected function index_process(): array
|
|
{
|
|
$fields = [
|
|
'fields' => ['type', 'clientinfo_uid', 'rack', 'lineinfo_uid', 'serverinfo_uid', 'IP', 'CPU', 'RAM', 'DISK', 'SOFTWARE', 'DEFENCE', 'billing_at', 'start_at', 'status'],
|
|
];
|
|
$this->init('index', $fields);
|
|
return parent::index_process();
|
|
}
|
|
}
|