37650-vm/index.php
Flatlogic Bot 73e14b3353 sad
2026-01-21 17:27:41 +00:00

106 lines
5.5 KiB
PHP

<?php
require_once __DIR__ . '/db/config.php';
// Fetch Featured Cars
$cars = [];
try {
$pdo = db();
// Fetch more cars to showcase the design
$stmt = $pdo->query("SELECT * FROM cars WHERE status = 'approved' ORDER BY created_at DESC LIMIT 8");
$cars = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (Exception $e) {
error_log("DB Error: " . $e->getMessage());
}
$pageTitle = "Home";
include 'partials/header.php';
?>
<!-- Hero Section -->
<header class="container-fluid vh-100 d-flex align-items-center justify-content-center text-white text-center" style="background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('https://images.pexels.com/photos/3764984/pexels-photo-3764984.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2') no-repeat center center/cover;">
<div class="col-lg-8">
<h1 class="display-3">Your Dream Car Awaits</h1>
<p class="lead my-4">Discover the best deals on new and used cars in Afghanistan. Quality, trust, and transparency guaranteed.</p>
<a href="#featured-cars" class="btn btn-primary btn-lg">Explore Cars</a>
<a href="car_list.php" class="btn btn-secondary btn-lg">View All Listings</a>
</div>
</header>
<!-- Featured Cars Section -->
<section id="featured-cars" class="section-padding py-5">
<div class="container">
<div class="text-center mb-5">
<h2 class="h1">Featured Vehicles</h2>
<p class="lead text-muted">Hand-picked selection of our finest cars available right now.</p>
</div>
<div class="row g-4">
<?php if (!empty($cars)): ?>
<?php foreach (array_slice($cars, 0, 4) as $car): // Show only 4 featured ?>
<div class="col-md-6 col-lg-3 d-flex align-items-stretch">
<div class="card w-100 shadow-sm border-0">
<div class="position-relative">
<img src="<?php echo htmlspecialchars($car['image_url'] ?: 'https://via.placeholder.com/400x300?text=No+Image'); ?>" class="card-img-top" alt="<?php echo htmlspecialchars($car['make'] . ' ' . $car['model']); ?>" style="height: 200px; object-fit: cover;">
<?php if ($car['status'] == 'sold'): ?>
<div class="position-absolute top-0 start-0 w-100 h-100 d-flex align-items-center justify-content-center bg-dark bg-opacity-75 text-white">
<h2 class="fw-bold text-uppercase">SOLD</h2>
</div>
<?php endif; ?>
</div>
<div class="card-body d-flex flex-column">
<h5 class="card-title"><?php echo htmlspecialchars($car['make'] . ' ' . $car['model']); ?></h5>
<p class="card-text text-muted small"><?php echo htmlspecialchars($car['year']); ?> &bull; <?php echo number_format($car['mileage']); ?> km</p>
<h4 class="mt-auto mb-3 text-primary">$<?php echo number_format($car['price']); ?></h4>
<a href="car_detail.php?id=<?php echo $car['id']; ?>" class="btn btn-outline-primary w-100">View Details</a>
</div>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
<div class="col-12">
<div class="alert alert-info text-center">No featured cars available at the moment. Please check back soon!</div>
</div>
<?php endif; ?>
</div>
</div>
</section>
<!-- How It Works Section -->
<section class="section-padding py-5 bg-light">
<div class="container">
<div class="text-center mb-5">
<h2 class="h1">How It Works</h2>
<p class="lead text-muted">A simple, transparent, and secure process.</p>
</div>
<div class="row g-4 text-center">
<div class="col-md-4">
<div class="card p-4 h-100 border-0 shadow-sm">
<i class="bi bi-search fs-1 text-primary mb-3"></i>
<h3>1. Find Your Car</h3>
<p>Browse our curated selection of high-quality vehicles. Use filters to narrow down your perfect match.</p>
</div>
</div>
<div class="col-md-4">
<div class="card p-4 h-100 border-0 shadow-sm">
<i class="bi bi-journal-check fs-1 text-primary mb-3"></i>
<h3>2. Request Purchase</h3>
<p>Found a car you like? Request to purchase it directly through our platform safely.</p>
</div>
</div>
<div class="col-md-4">
<div class="card p-4 h-100 border-0 shadow-sm">
<i class="bi bi-patch-check-fill fs-1 text-primary mb-3"></i>
<h3>3. Secure Your Deal</h3>
<p>Finalize your purchase with our secure payment system and drive away in your new car.</p>
</div>
</div>
</div>
</div>
</section>
</main> <!-- End Main -->
<?php include 'partials/footer.php'; ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>