dbms/app/Controllers/Admin/Customer/ServiceController.php
2025-06-23 11:40:52 +09:00

83 lines
2.9 KiB
PHP

<?php
namespace App\Controllers\Admin\Customer;
use CodeIgniter\HTTP\RedirectResponse;
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\CodeService;
class ServiceController extends CustomerController
{
private ?CodeService $_codeService = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->content_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(): ServiceHelper
{
if (!$this->_helper) {
$this->_helper = new ServiceHelper($this->request);
}
return $this->_helper;
}
public function getCodeService(): CodeService
{
if (!$this->_codeService) {
$this->_codeService = new CodeService($this->request);
}
return $this->_codeService;
}
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{
switch ($this->getAction()) {
case 'index':
$result = parent::getResultSuccess($message, $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'service');
break;
default:
$result = parent::getResultSuccess($message, $actionTemplate);
break;
}
return $result;
}
protected function setWordConditionForList(): void
{
$this->word = $this->request->getVar('word');
if ($this->word !== null && $this->word !== '') {
if ($this->getHelper()->isIPAddress($this->word, 'ipv4')) {
$this->getService()->setSearchIp($this->word);
} else {
$this->getService()->getModel()->setList_WordFilter($this->word);
}
}
}
//Index,FieldForm관련
protected function index_process(): array
{
//LINE,IP,SERVER등 추가 FilterOption 셋팅용
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
$options = $this->getService()->getServiceItemLinkService($item_type)->getEntities();
$this->setFilterFieldOption($item_type, $options);
}
// dd($this->getFilterFieldOptions());
return parent::index_process();
}
}