dbms/app/Controllers/Admin/Home.php
2025-06-20 18:50:52 +09:00

89 lines
3.5 KiB
PHP

<?php
namespace App\Controllers\Admin;
use App\Helpers\HomeHelper;
use App\Services\Customer\ServiceService;
use App\Services\Customer\ServicePaymentService;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class Home extends AdminController
{
private $_service = null;
private ?ServiceService $_serviceService = 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;
}
final public function getService(): ServicePaymentService
{
if (!$this->_service) {
$this->_service = new ServicePaymentService($this->request);
}
return $this->_service;
}
public function getHelper(): mixed
{
if (!$this->_helper) {
$this->_helper = new HomeHelper($this->request);
}
return $this->_helper;
}
final public function getServiceService(): ServiceService
{
if (!$this->_serviceService) {
$this->_serviceService = new ServiceService($this->request);
}
return $this->_serviceService;
}
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{
switch ($this->getAction()) {
case 'index':
$this->control = $this->getControlDatas();
$this->getHelper()->setViewDatas($this->getViewDatas());
$actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate;
if ($actionTemplate) {
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getAction();
} else {
$view_file = $this->view_path . 'welcome_message';
}
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
break;
default:
$result = parent::getResultSuccess($message, $actionTemplate);
}
return $result;
}
//Index,FieldForm관련
public function index(): RedirectResponse|string
{
$this->initAction(__FUNCTION__);
//신규서비스정보
$this->interval = $this->request->getVar('interval') ?? SERVICE_NEW_INTERVAL;
$this->newServiceEntities = $this->getServiceService()->getNewService(intval($this->interval));
$this->newServiceCount = count($this->newServiceEntities);
//미지금서버Count
$this->item_type = $this->request->getVar('item_type') ?? SERVICE_UNPAID_ITEM_TYPE;
$this->unPaidCount = $this->getService()->getUnPaid($this->item_type);
//LINE,IP,SERVER등 추가 FilterOption 셋팅용
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
$options = $this->getService()->getServiceItemLinkService($item_type)->getEntities();
$this->setFilterFieldOption($item_type, $options);
}
helper(['form']);
return $this->getResultSuccess();
}
}