File manager - Edit - /home/webapp69.cm.in.th/u69319090028/Shop/app/Controllers/SellerInventoryController.php
Back
<?php /** * SellerInventoryController * Handles inventory overview and quick stock adjustment */ require_once __DIR__ . '/../Core/Controller.php'; require_once __DIR__ . '/../Services/SellerInventoryService.php'; require_once __DIR__ . '/../Helpers/Auth.php'; require_once __DIR__ . '/../Helpers/Session.php'; require_once __DIR__ . '/../Helpers/Url.php'; class SellerInventoryController extends Controller { private SellerInventoryService $inventoryService; public function __construct() { $this->inventoryService = new SellerInventoryService(); } public function index(): void { $userId = Auth::id(); $filters = [ 'q' => $_GET['q'] ?? '', 'stock_state' => $_GET['stock_state'] ?? 'all' ]; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $data = $this->inventoryService->getInventory($userId, $filters, $page, 20); $this->render('seller/inventory/index', array_merge($data, [ 'pageTitle' => 'จัดการสต็อกสินค้า (Inventory) - ศูนย์ผู้ขาย CARGOO', 'activeNav' => 'inventory' ]), 'seller'); } public function updateStock(): void { $userId = Auth::id(); $productId = (int)($_POST['product_id'] ?? 0); $skuId = !empty($_POST['sku_id']) ? (int)$_POST['sku_id'] : null; $newStock = (int)($_POST['stock'] ?? 0); $result = $this->inventoryService->quickAdjustStock($userId, $productId, $newStock, $skuId); if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') { $this->json($result); } if (!$result['success']) { Session::setFlash('danger', $result['message']); } else { Session::setFlash('success', $result['message']); } $this->redirect('/seller/inventory'); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.23 |
proxy
|
phpinfo
|
Settings