shoppingmallv2/app/Controllers/Front/BillingController.php
2023-08-16 19:26:53 +09:00

73 lines
2.6 KiB
PHP

<?php
namespace App\Controllers\Front;
use App\Models\BillingModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class BillingController extends FrontController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->_model = new BillingModel();
$this->_viewDatas['className'] = 'Billing';
$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']);
//Default 회원정보 Category
$this->_category = DEFAULTS['CATEGORY_BILLING'];
$this->isRole('index');
}
final public function getFields(string $action = ""): array
{
switch ($action) {
case 'update':
return ['order_uid', "email", "phone", "title", "upload_file", "status"];
break;
case "index":
case "excel":
return ["order_uid", "email", "phone", "title", "upload_file", "status", "updated_at", "created_at"];
break;
case "view":
return ['order_uid', "email", "phone", "title", "upload_file", "status", "updated_at", "created_at", 'response'];
break;
default:
return [];
break;
}
}
final public function getFieldFilters(): array
{
return ['order_uid', "status"];
}
final public function getFieldBatchFilters(): array
{
return ["status"];
}
//Index관련
protected function index_setCondition()
{
//사용자정보(user_uid)에 맞는 Biiling정보 가져오기
$this->_model->where('user_uid', $this->_session->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']]);
$this->_model->where("status", DEFAULTS['STATUS']);
parent::index_setCondition();
}
//Download관련
public function download_process($field, $entity)
{
list($filename, $uploaded_filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field);
if (!is_file(PATHS['BILLING'] . "/" . $uploaded_filename)) {
throw new \Exception("첨부파일이 확인되지 않습니다.\n");
}
return $this->response->download(PATHS['BILLING'] . "/" . $uploaded_filename, null)->setFileName(date("Ymd") . '_' . $filename);
}
}