85 lines
4.2 KiB
PHP
85 lines
4.2 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
$restaurant_id = $_GET['id'] ?? null;
|
|
$restaurant = null;
|
|
$menu_items = [];
|
|
|
|
if ($restaurant_id) {
|
|
$stmt = db()->prepare("SELECT * FROM restaurants WHERE id = ?");
|
|
$stmt->execute([$restaurant_id]);
|
|
$restaurant = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
}
|
|
|
|
if ($restaurant) {
|
|
$stmt = db()->prepare("SELECT * FROM menu_items WHERE restaurant_id = ?");
|
|
$stmt->execute([$restaurant_id]);
|
|
$menu_items = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
}
|
|
|
|
include 'header.php';
|
|
?>
|
|
|
|
<main>
|
|
<div class="container">
|
|
<?php if ($restaurant): ?>
|
|
<section class="restaurant-hero-menu" style="background-image: url('<?= htmlspecialchars($restaurant['image_url']) ?>');">
|
|
<div class="restaurant-hero-menu-content">
|
|
<h1><?= htmlspecialchars($restaurant['name']) ?></h1>
|
|
<p><?= htmlspecialchars($restaurant['cuisine']) ?></p>
|
|
<div class="rating-display">
|
|
<span class="star">★</span>
|
|
<span><?= htmlspecialchars(number_format($restaurant['rating'], 1)) ?></span>
|
|
<span class="rating-count">(<?= htmlspecialchars($restaurant['rating_count']) ?> ratings)</span>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<div class="menu-search-container">
|
|
<input type="text" id="menu-search-input" class="search-bar" placeholder="Search menu items...">
|
|
</div>
|
|
|
|
<section class="menu-grid" id="menu-grid">
|
|
<?php foreach ($menu_items as $item): ?>
|
|
<div class="menu-item-card" data-name="<?= htmlspecialchars(strtolower($item['name'])) ?>" data-description="<?= htmlspecialchars(strtolower($item['description'])) ?>">
|
|
<img src="<?= htmlspecialchars($item['image_url']) ?>" alt="<?= htmlspecialchars($item['name']) ?>">
|
|
<div class="menu-item-card-content">
|
|
<h3><?= htmlspecialchars($item['name']) ?></h3>
|
|
<p class="description"><?= htmlspecialchars($item['description']) ?></p>
|
|
<p class="price">$<?= htmlspecialchars(number_format($item['price'], 2)) ?></p>
|
|
<form action="cart_actions.php" method="POST" class="add-to-cart-form">
|
|
<input type="hidden" name="action" value="add">
|
|
<input type="hidden" name="menu_item_id" value="<?= $item['id'] ?>">
|
|
<input type="hidden" name="restaurant_id" value="<?= $restaurant['id'] ?>">
|
|
<div class="form-row">
|
|
<input type="number" name="quantity" value="1" min="1" class="quantity-input">
|
|
<button type="submit" class="add-to-cart-btn">Add to Cart</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</section>
|
|
|
|
<section class="rating-form-container">
|
|
<h2>Rate your experience</h2>
|
|
<form action="rate.php" method="POST" class="rate-form">
|
|
<input type="hidden" name="restaurant_id" value="<?= $restaurant['id'] ?>">
|
|
<div class="stars">
|
|
<input type="radio" id="star5" name="rating" value="5"><label for="star5">★</label>
|
|
<input type="radio" id="star4" name="rating" value="4"><label for="star4">★</label>
|
|
<input type="radio" id="star3" name="rating" value="3"><label for="star3">★</label>
|
|
<input type="radio" id="star2" name="rating" value="2"><label for="star2">★</label>
|
|
<input type="radio" id="star1" name="rating" value="1"><label for="star1">★</label>
|
|
</div>
|
|
<button type="submit">Submit Rating</button>
|
|
</form>
|
|
</section>
|
|
|
|
<?php else: ?>
|
|
<p>Restaurant not found.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</main>
|
|
|
|
<?php include 'footer.php'; // Assuming you might create a footer file ?>
|