Restaurant Dashboard
Recent Orders
0): ?>Customer:
Items:
You have no recent orders.
You do not have a restaurant associated with your account.
prepare("SELECT id, name FROM restaurants WHERE user_id = ?");
$stmt->execute([$_SESSION['user_id']]);
$restaurant = $stmt->fetch(PDO::FETCH_ASSOC);
$orders = [];
$menu_items = [];
if ($restaurant) {
$stmt_orders = $pdo->prepare(
"SELECT o.*, GROUP_CONCAT(CONCAT(oi.quantity, ' x ', mi.name) SEPARATOR '
') as items
FROM orders o
JOIN order_items oi ON o.id = oi.order_id
JOIN menu_items mi ON oi.menu_item_id = mi.id
WHERE o.restaurant_id = ?
GROUP BY o.id
ORDER BY o.created_at DESC
LIMIT 20"
);
$stmt_orders->execute([$restaurant['id']]);
$orders = $stmt_orders->fetchAll(PDO::FETCH_ASSOC);
$stmt_menu = $pdo->prepare("SELECT id, name, description, price FROM menu_items WHERE restaurant_id = ? ORDER BY id DESC");
$stmt_menu->execute([$restaurant['id']]);
$menu_items = $stmt_menu->fetchAll(PDO::FETCH_ASSOC);
}
?>
Customer:
Items:
You have no recent orders.
You do not have a restaurant associated with your account.