82 lines
3.0 KiB
PHP
82 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin\Customer;
|
|
|
|
use App\Helpers\Customer\ServiceHelper;
|
|
use App\Services\Customer\ServiceService;
|
|
use App\Services\Customer\ServiceItemService;
|
|
|
|
use CodeIgniter\HTTP\RedirectResponse;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class ServiceController extends CustomerController
|
|
{
|
|
private ?ServiceItemService $_serviceItemService = 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(): ServiceHelper
|
|
{
|
|
if (!$this->_helper) {
|
|
$this->_helper = new ServiceHelper($this->request);
|
|
}
|
|
// dd($this->_helper);
|
|
return $this->_helper;
|
|
}
|
|
public function getServiceItemService(): ServiceItemService
|
|
{
|
|
if (!$this->_serviceItemService) {
|
|
$this->_serviceItemService = new ServiceItemService($this->request);
|
|
}
|
|
return $this->_serviceItemService;
|
|
}
|
|
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
|
|
{
|
|
switch ($action) {
|
|
case 'index':
|
|
$this->getHelper()->setViewDatas($this->getViewDatas());
|
|
$result = view($this->view_path . 'service' . DIRECTORY_SEPARATOR . $action, ['viewDatas' => $this->getViewDatas()]);
|
|
break;
|
|
default:
|
|
$result = parent::getResultPageByActon($action, $message);
|
|
break;
|
|
}
|
|
return $result;
|
|
}
|
|
//Index,FieldForm관련
|
|
protected function index_process(): array
|
|
{
|
|
$fields = [
|
|
'fields' => ['clientinfo_uid', 'location', 'switch', 'code', 'type', 'raid', 'billing_at', 'start_at', 'status'],
|
|
];
|
|
$this->init('index', $fields);
|
|
$this->item_types = lang($this->getServiceItemService()->getClassName() . '.' . strtoupper('ITEM_TYPE'));
|
|
$entities = [];
|
|
foreach (parent::index_process() as $entity) {
|
|
foreach ($this->item_types as $field => $label) {
|
|
$itemEntities = $this->getServiceItemService()->getEntities(['item_type' => $field]);
|
|
// dd($itemEntities);
|
|
$entity->setItemEntities($field, $itemEntities);
|
|
}
|
|
$entities[] = $entity;
|
|
}
|
|
// $this->modal_type = 'modal_fetch_v2'; //기본은 modal_iframe임
|
|
return $entities;
|
|
}
|
|
}
|