dbmsv4/app/Controllers/Admin/Customer/ServiceController.php
2025-11-28 17:55:22 +09:00

57 lines
2.1 KiB
PHP

<?php
namespace App\Controllers\Admin\Customer;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class ServiceController extends CustomerController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
if ($this->service === null) {
$this->service = service('customer_serviceservice');
}
$this->addActionPaths(path: 'service');
$this->layouts['footerScripts'][] = '<script src="/js/admin/clipboard.js"></script>';
$this->layouts['footerScripts'][] = '<script src="/js/admin/service.js"></script>';
}
//기본 함수 작업
//Custom 추가 함수
public function create_form_process(array $formDatas = []): array
{
$formDatas = parent::create_form_process($formDatas);
$formDatas['location'] = 'chiba';
$formDatas['rack'] = '100000';
$formDatas['line'] = '300000';
$formDatas['sale'] = 0;
$formDatas['billing_at'] = date("Y-m-d");
$formDatas['start_at'] = date("Y-m-d");
$formDatas['status'] = STATUS['AVAILABLE'];
return $formDatas;
}
protected function index_process(string $action): void
{
//서비스별 미납 Count
$this->addViewDatas('unPaids', service('paymentservice')->getUnPaids('serviceinfo_uid'));
parent::index_process($action);
}
public function history(int $uid): RedirectResponse|string
{
try {
$action = __FUNCTION__;
$fields = ['history'];
$this->service->getFormService()->setFormFields($fields);
$this->service->getFormService()->setFormRules($action, $fields);
$this->addViewDatas('entity', $this->service->modify($uid, $this->service->createDTO($this->request->getPost())));
return $this->action_redirect_process('error', "{$this->getTitle()}에서 비고설정이 완료되었습니다.");
} catch (\Throwable $e) {
return $this->action_redirect_process('error', "{$this->getTitle()}에서 비고 오류:" . $e->getMessage());
}
}
}