85 lines
3.0 KiB
PHP
85 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Front\Billing;
|
|
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class DepositController extends BillingController
|
|
{
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
$this->_viewDatas['className'] = 'Deposit';
|
|
$this->_viewPath .= '/' . strtolower($this->_viewDatas['className']);
|
|
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
|
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
|
helper($this->_viewDatas['className']);
|
|
}
|
|
|
|
public function getFields(string $action = ""): array
|
|
{
|
|
switch ($action) {
|
|
case 'update':
|
|
return ["email", "phone"];
|
|
break;
|
|
default:
|
|
return [];
|
|
break;
|
|
}
|
|
}
|
|
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
|
{
|
|
switch ($field) {
|
|
case "email":
|
|
$rules[$field] = 'required|valid_email';
|
|
break;
|
|
case "phone":
|
|
$rules[$field] = 'required|regex_match[/^[0-9]{3}-[0-9]{4}-[0-9]{4}/]';
|
|
break;
|
|
default:
|
|
$rules = parent::getFieldRule($field, $rules, $action);
|
|
break;
|
|
}
|
|
return $rules;
|
|
}
|
|
public function getFieldFilters(): array
|
|
{
|
|
return [];
|
|
}
|
|
public function getFieldBatchFilters(): array
|
|
{
|
|
return parent::getFieldBatchFilters();
|
|
}
|
|
|
|
//Update관련
|
|
public function update_form($uid)
|
|
{
|
|
try {
|
|
$this->_viewDatas = $this->init(__FUNCTION__);
|
|
//청구서정보 가져오기
|
|
$this->_viewDatas['entity'] = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
|
//청구서 연결 주문정보 가져오기
|
|
$this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity);
|
|
if (!count($this->_viewDatas['orders'])) {
|
|
throw new \Exception("해당하는 주문정보가 없습니다.");
|
|
}
|
|
$this->update_form_process($entity);
|
|
helper(['form']);
|
|
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
|
return view($this->_viewPath . '/update', ['viewDatas' => $this->_viewDatas]);
|
|
} catch (\Exception $e) {
|
|
log_message("error", $e->getMessage());
|
|
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
|
|
}
|
|
}
|
|
//무통장입금결제처리
|
|
protected function update_process($entity)
|
|
{
|
|
$this->_viewDatas['fieldDatas']["type"] = $this->_viewDatas['className'];
|
|
//결제처리
|
|
return parent::update_process($entity);
|
|
}
|
|
}
|