File manager - Edit - /home/webapp69.cm.in.th/u69319090028/Shop/app/Controllers/AdminOrderController.php
Back
<?php /** * AdminOrderController * Cross-store order monitoring and investigation notes (read-only, no status changes) */ require_once __DIR__ . '/../Core/Controller.php'; require_once __DIR__ . '/../Services/AdminOrderService.php'; require_once __DIR__ . '/../Middleware/AdminMiddleware.php'; require_once __DIR__ . '/../Helpers/Auth.php'; require_once __DIR__ . '/../Helpers/Session.php'; class AdminOrderController extends Controller { private AdminOrderService $orderService; public function __construct() { $this->orderService = new AdminOrderService(); } public function index(): void { AdminMiddleware::requirePermission('order.view'); $filters = [ 'q' => trim($_GET['q'] ?? ''), 'status' => $_GET['status'] ?? 'all', 'payment_status' => $_GET['payment_status'] ?? 'all', 'store_id' => $_GET['store_id'] ?? '', 'date_from' => $_GET['date_from'] ?? '', 'date_to' => $_GET['date_to'] ?? '', ]; $page = max(1, (int)($_GET['page'] ?? 1)); $data = $this->orderService->getOrders($filters, $page); $this->render('admin/orders/index', array_merge($data, [ 'filters' => $filters, 'stats' => $this->orderService->getOrderStats(), 'pageTitle' => 'ติดตามคำสั่งซื้อ — CARGOO Admin', 'activeNav' => 'orders', ]), 'admin'); } public function show(string $order_no): void { AdminMiddleware::requirePermission('order.view'); $order = $this->orderService->getOrderDetail($order_no); if (!$order) { Session::setFlash('danger', 'ไม่พบคำสั่งซื้อ'); $this->redirect('/admin/orders'); } $history = $this->orderService->getOrderInvestigationHistory((int)$order['id']); require_once __DIR__ . '/../Services/PaymentService.php'; $payment = (new PaymentService())->getPaymentForAdmin($order_no); $this->render('admin/orders/show', [ 'order' => $order, 'history' => $history, 'payment' => $payment, 'pageTitle' => 'รายละเอียดออเดอร์ #' . e($order_no) . ' — CARGOO Admin', 'activeNav' => 'orders', ], 'admin'); } public function addNote(string $order_no): void { AdminMiddleware::requirePermission('order.investigate'); $note = trim($_POST['note'] ?? ''); $result = $this->orderService->addInvestigationNote($order_no, $note, Auth::id()); Session::setFlash($result['success'] ? 'success' : 'danger', $result['message']); $this->redirect('/admin/orders/' . $order_no); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.23 |
proxy
|
phpinfo
|
Settings