94 lines
3.1 KiB
PHP
94 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin\Customer;
|
|
|
|
use App\Helpers\Customer\ServicePartHelper;
|
|
use App\Services\Customer\ServicePartService;
|
|
use App\Services\Equipment\PartService;
|
|
|
|
use CodeIgniter\HTTP\RedirectResponse;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class ServicePartController extends CustomerController
|
|
{
|
|
private ?PartService $_partService = null;
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
$this->uri_path .= strtolower($this->getService()->getClassName()) . '/';
|
|
$this->class_path = $this->getService()->getClassPath();
|
|
$this->title = lang("{$this->getService()->getClassPath()}.title");
|
|
$this->helper = $this->getHelper();
|
|
}
|
|
public function getService(): ServicePartService
|
|
{
|
|
if (!$this->_service) {
|
|
$this->_service = new ServicePartService($this->request);
|
|
}
|
|
return $this->_service;
|
|
}
|
|
public function getHelper(): mixed
|
|
{
|
|
if (!$this->_helper) {
|
|
$this->_helper = new ServicePartHelper($this->request);
|
|
}
|
|
return $this->_helper;
|
|
}
|
|
final public function getPartService(): PartService
|
|
{
|
|
if (!$this->_partService) {
|
|
$this->_partService = new PartService($this->request);
|
|
}
|
|
return $this->_partService;
|
|
}
|
|
protected function getFormFieldOption(string $field, array $options): array
|
|
{
|
|
switch ($field) {
|
|
case 'serviceinfo_uid':
|
|
$options[$field] = $this->getServiceService()->getFormFieldOption($field,);
|
|
break;
|
|
case 'partinfo_uid':
|
|
$options[$field] = $this->getPartService()->getFormFieldOption($field,);
|
|
break;
|
|
default:
|
|
$options = parent::getFormFieldOption($field, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
|
|
{
|
|
switch ($action) {
|
|
case 'index':
|
|
case 'view':
|
|
$this->getHelper()->setViewDatas($this->getViewDatas());
|
|
$result = view($this->view_path . "popup" . DIRECTORY_SEPARATOR . $action, ['viewDatas' => $this->getViewDatas()]);
|
|
break;
|
|
default:
|
|
$result = parent::getResultPageByActon($action, $message);
|
|
break;
|
|
}
|
|
return $result;
|
|
}
|
|
//Index,FieldForm관련
|
|
|
|
|
|
protected function setOrderByForList()
|
|
{
|
|
//OrderBy 처리
|
|
$this->getService()->getModel()->orderBy('serviceinfo_uid', 'ASC', false);
|
|
parent::setOrderByForList();
|
|
}
|
|
protected function index_process(): array
|
|
{
|
|
$fields = [
|
|
'fields' => ['serviceinfo_uid', 'billing_type', 'partinfo_uid'],
|
|
];
|
|
$this->init('index', $fields);
|
|
$this->modal_type = 'modal_iframe';
|
|
return parent::index_process();
|
|
}
|
|
}
|