Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
<?php
session_start();
require_once 'classes/model/database.php';
// if (isset($_SESSION['session_id']) && $_SESSION['session_id'] == session_id()) {
// // Ingelogd
// }
$db = new Database();
$conn = $db->getConnection();
// Fetch all deals
$stmt = $conn->prepare("SELECT * FROM products WHERE category = 'deal'");
$stmt->execute();
$deals = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Fetch Popular products
$popular = [];
$stmt = $conn->prepare("SELECT * FROM products WHERE popular = TRUE");
if ($stmt->execute()) {
$popular = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
// Fetch New Drop products
$newDrops = [];
$stmt = $conn->prepare("SELECT * FROM products ORDER BY id DESC LIMIT 5;");
if ($stmt->execute()) {
$newDrops = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="Pages/public/styles/index.css">
<title>Home</title>
<style>
.slideshow-container {
position: relative;
max-width: 100%;
margin: auto;
}
.slides {
display: none;
text-align: center;
}
.prev {
cursor: pointer;
position: absolute;
left: 0;
top: 50%;
width: auto;
margin-top: -22px;
padding: 16px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
.next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
margin-top: -22px;
padding: 16px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
right: 0;
border-radius: 3px 0 0 3px;
}
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
}
</style>
</head>
<?php include '../burgerbudy/classes/components/header.php'; ?>
<body>
<div class="deal-van-de-week">
<div class="deal-van-de-week-titel">
<h1>Deal van de week</h1>
</div>
<div class="slideshow-container">
<?php foreach ($deals as $index => $deal): ?>
<div class="slides">
<div class="deal-van-de-week-container">
<div class="deal-van-de-week-image">
<img src="/burgerbudy/uploads/<?= htmlspecialchars($deal['image']) ?>" alt="<?= htmlspecialchars($deal['name']) ?>">
</div>
<div class="deal-van-de-week-text">
<h2><?= htmlspecialchars($deal['name']) ?></h2>
<p><?= htmlspecialchars($deal['description']) ?></p>
<p>€ <?= htmlspecialchars(number_format($deal['price'], 2)) ?></p>
<form action="/burgerbudy/Functions/products/add_to_cart.php" method="POST">
<input type="hidden" name="product_id" value="<?= htmlspecialchars($deal['id']) ?>">
<input type="hidden" name="source" value="index">
<button type="submit">Bestel nu</button>
</form>
</div>
</div>
</div>
<?php endforeach; ?>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
</div>
<div class="content">
<h2>Populair</h2>
<?php if ($popular): ?>
<?php foreach ($popular as $item): ?>
<div class="popular-item">
<img src="/burgerbudy/uploads/<?= htmlspecialchars($item['image']) ?>" alt="<?= htmlspecialchars($item['name']) ?>">
<h3><?= htmlspecialchars($item['name']) ?></h3>
<p>€ <?= htmlspecialchars(number_format($item['price'], 2)) ?></p>
<form action="/burgerbudy/Functions/products/add_to_cart.php" method="POST">
<input type="hidden" name="product_id" value="<?= htmlspecialchars($item['id']) ?>">
<input type="hidden" name="source" value="index">
<button type="submit">Add to Cart</button>
</form>
</div>
<?php endforeach; ?>
<?php else: ?>
<p>Geen populaire producten beschikbaar.</p>
<?php endif; ?>
</div>
<div class="new-drop-text">
<h2>New Drop</h2>
</div>
<div class="new-drop">
<?php if ($newDrops): ?>
<?php foreach ($newDrops as $item): ?>
<div class="new-drop-item">
<img src="/burgerbudy/uploads/<?= htmlspecialchars($item['image']) ?>" alt="<?= htmlspecialchars($item['name']) ?>">
<div class="new-drop-details">
<h3><?= htmlspecialchars($item['name']) ?></h3>
<p>€ <?= htmlspecialchars(number_format($item['price'], 2)) ?></p>
<form action="/burgerbudy/Functions/products/add_to_cart.php" method="POST">
<input type="hidden" name="product_id" value="<?= htmlspecialchars($item['id']) ?>">
<input type="hidden" name="source" value="index">
<button type="submit">Add to Cart</button>
</form>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
<p>Geen nieuwe producten beschikbaar.</p>
<?php endif; ?>
</div>
<button class="meer-button"><a href="/burgerbudy/Pages/public/assortiment.php">Meer</a></button>
<?php include '../burgerbudy/classes/components/footer.php'; ?>
<script>
let slideIndex = 1;
let timer;
showSlides(slideIndex);
function plusSlides(n) {
clearTimeout(timer);
showSlides(slideIndex += n);
}
function currentSlide(n) {
clearTimeout(timer);
showSlides(slideIndex = n);
}
function showSlides(n) {
let slides = document.getElementsByClassName("slides");
if (n > slides.length) { slideIndex = 1 }
if (n < 1) { slideIndex = slides.length }
for (let i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slides[slideIndex - 1].style.display = "block";
timer = setTimeout(() => showSlides(slideIndex += 1), 10000); // Change image every 10 seconds
}
</script>
</body>
</html>