prepare("SELECT value FROM settings WHERE name = ?"); $stmt_shutdown->execute(['emergency_shutdown']); $shutdown_active = ($stmt_shutdown->fetchColumn() === 'true'); $restaurant_id = isset($_GET['restaurant_id']) ? (int)$_GET['restaurant_id'] : 0; if ($restaurant_id === 0) { header('Location: index.php'); exit; } require_once 'header.php'; try { // Fetch restaurant details $stmt = db()->prepare("SELECT r.id, r.name, r.image_url, c.name as cuisine_name FROM restaurants r LEFT JOIN restaurant_cuisines rc ON r.id = rc.restaurant_id LEFT JOIN cuisines c ON rc.cuisine_id = c.id WHERE r.id = :id"); $stmt->bindParam(':id', $restaurant_id, PDO::PARAM_INT); $stmt->execute(); $restaurant_data = $stmt->fetchAll(PDO::FETCH_ASSOC); if (!$restaurant_data) { throw new Exception("Restaurant not found."); } $restaurant = [ 'id' => $restaurant_data[0]['id'], 'name' => $restaurant_data[0]['name'], 'image_url' => $restaurant_data[0]['image_url'], 'cuisines' => array_column($restaurant_data, 'cuisine_name') ]; // Fetch menu items $menu_stmt = db()->prepare("SELECT id, name, description, price, image_url FROM menu_items WHERE restaurant_id = :restaurant_id"); $menu_stmt->bindParam(':restaurant_id', $restaurant_id, PDO::PARAM_INT); $menu_stmt->execute(); $menu_items = $menu_stmt->fetchAll(PDO::FETCH_ASSOC); // Fetch ratings and calculate average $ratings_stmt = db()->prepare("SELECT r.rating, r.review, r.created_at, u.name as user_name FROM ratings r JOIN users u ON r.user_id = u.id WHERE r.restaurant_id = :restaurant_id ORDER BY r.created_at DESC"); $ratings_stmt->bindParam(':restaurant_id', $restaurant_id, PDO::PARAM_INT); $ratings_stmt->execute(); $ratings = $ratings_stmt->fetchAll(PDO::FETCH_ASSOC); $average_rating = 0; $rating_count = count($ratings); if ($rating_count > 0) { $total_rating = array_sum(array_column($ratings, 'rating')); $average_rating = round($total_rating / $rating_count, 1); } // Check if this restaurant is a favorite for the current user $is_favorite = false; if (isset($_SESSION['user_id'])) { $fav_stmt = db()->prepare("SELECT COUNT(*) FROM favorite_restaurants WHERE user_id = :user_id AND restaurant_id = :restaurant_id"); $fav_stmt->bindParam(':user_id', $_SESSION['user_id'], PDO::PARAM_INT); $fav_stmt->bindParam(':restaurant_id', $restaurant_id, PDO::PARAM_INT); $fav_stmt->execute(); $is_favorite = $fav_stmt->fetchColumn() > 0; } } catch (Exception $e) { echo "
" . $e->getMessage() . "
Due to severe weather conditions, we have temporarily suspended all delivery services. The safety of our drivers and customers is our top priority.
We apologize for any inconvenience and will resume operations as soon as it is safe to do so.