shoppingmallv2/app/Controllers/Admin/OrderController.php
2023-08-17 12:03:51 +09:00

61 lines
2.2 KiB
PHP

<?php
namespace App\Controllers\Admin;
use App\Models\OrderModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class OrderController extends AdminController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->_model = new OrderModel();
$this->_viewDatas['className'] = 'Order';
$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']);
}
final public function getFields(string $action = ""): array
{
switch ($action) {
case 'update':
return ['product_uid', "paymentday", "cost", "sale", "quantity", "status"];
break;
case "index":
case "excel":
return ["user_uid", "name", "cost", "sale", "quantity", "price", "status", "updated_at", "created_at"];
break;
case "view":
return ["user_uid", 'product_uid', "name", "cost", "sale", "quantity", "price", "status", "updated_at", "created_at"];
break;
default:
return [];
break;
}
}
final public function getFieldFilters(): array
{
return ["user_uid", 'product_uid', "status"];
}
final public function getFieldBatchFilters(): array
{
return [];
}
//가격이나,할인가,수량 변경했을경우 다시 계산해서 Price에 넣기위해
protected function update_process($entity)
{
//가격이나,할인가,수량 변경했을경우 다시 계산해서 결제금액(price)에 넣기위해
$this->_viewDatas['fieldDatas']['price'] =
($this->_viewDatas['fieldDatas']['cost'] -
$this->_viewDatas['fieldDatas']['sale']) *
$this->_viewDatas['fieldDatas']['quantity'];
return parent::update_process($entity);
}
}