146 lines
7.1 KiB
PHP
146 lines
7.1 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
// Check if logged in
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
$user_id = $_SESSION['user_id'];
|
|
$user_name = $_SESSION['user_name'];
|
|
|
|
// Fetch user bookings
|
|
try {
|
|
$stmt = db()->prepare("
|
|
SELECT b.*, c.brand, c.model, c.year, c.price, c.main_image
|
|
FROM bookings b
|
|
JOIN cars c ON b.car_id = c.id
|
|
WHERE b.user_id = ?
|
|
ORDER BY b.booking_date DESC
|
|
");
|
|
$stmt->execute([$user_id]);
|
|
$bookings = $stmt->fetchAll();
|
|
} catch (PDOException $e) {
|
|
$bookings = [];
|
|
}
|
|
|
|
include 'includes/header.php';
|
|
?>
|
|
|
|
<main class="container mt-5">
|
|
<div class="row" style="display: flex; gap: 20px; flex-wrap: wrap;">
|
|
<!-- User Sidebar Info -->
|
|
<div style="flex: 1; min-width: 300px;">
|
|
<div class="glass-card">
|
|
<div style="text-align: center; margin-bottom: 20px;">
|
|
<div style="width: 80px; height: 80px; background: var(--accent-gold); border-radius: 50%; margin: 0 auto 15px; display: flex; align-items: center; justify-content: center; font-size: 2rem; color: #1a1a1a; font-weight: bold;">
|
|
<?php echo strtoupper(substr($user_name, 0, 1)); ?>
|
|
</div>
|
|
<h3><?php echo htmlspecialchars($user_name); ?></h3>
|
|
<p style="color: var(--text-muted);">Premium Member</p>
|
|
</div>
|
|
<hr style="border: none; border-top: 1px solid var(--glass-border); margin: 20px 0;">
|
|
<ul style="list-style: none; padding: 0;">
|
|
<li style="margin-bottom: 15px;">
|
|
<a href="#" style="color: var(--accent-gold); text-decoration: none; display: flex; align-items: center; gap: 10px;">
|
|
<span>📊</span> My Overview
|
|
</a>
|
|
</li>
|
|
<li style="margin-bottom: 15px;">
|
|
<a href="cars.php" style="color: white; text-decoration: none; display: flex; align-items: center; gap: 10px;">
|
|
<span>🚗</span> Browse Cars
|
|
</a>
|
|
</li>
|
|
<li style="margin-bottom: 15px;">
|
|
<a href="logout.php" style="color: #ff4444; text-decoration: none; display: flex; align-items: center; gap: 10px;">
|
|
<span>🚪</span> Logout
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Main Content -->
|
|
<div style="flex: 3; min-width: 300px;">
|
|
<div style="margin-bottom: 20px;">
|
|
<a href="index.php" style="display: inline-flex; align-items: center; gap: 8px; color: var(--accent-gold); text-decoration: none; font-weight: 500;">
|
|
<span>←</span> Back to Website
|
|
</a>
|
|
</div>
|
|
<div class="glass-card mb-4">
|
|
<h2>Welcome to your Dashboard</h2>
|
|
<p style="color: var(--text-muted);">Manage your bookings and view your saved cars.</p>
|
|
</div>
|
|
|
|
<div class="glass-card">
|
|
<h3 style="margin-bottom: 20px;">My Booking Requests</h3>
|
|
|
|
<?php if (empty($bookings)): ?>
|
|
<div style="text-align: center; padding: 40px; border: 1px dashed var(--glass-border); border-radius: 12px;">
|
|
<p style="color: var(--text-muted); margin-bottom: 20px;">You haven't made any booking requests yet.</p>
|
|
<a href="cars.php" class="btn btn-primary">Browse Available Cars</a>
|
|
</div>
|
|
<?php else: ?>
|
|
<div style="overflow-x: auto;">
|
|
<table style="width: 100%; border-collapse: collapse; text-align: left;">
|
|
<thead>
|
|
<tr style="border-bottom: 2px solid var(--glass-border);">
|
|
<th style="padding: 15px 10px;">Car</th>
|
|
<th style="padding: 15px 10px;">Price</th>
|
|
<th style="padding: 15px 10px;">Date</th>
|
|
<th style="padding: 15px 10px;">Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($bookings as $booking): ?>
|
|
<tr style="border-bottom: 1px solid var(--glass-border);">
|
|
<td style="padding: 15px 10px;">
|
|
<div style="display: flex; align-items: center; gap: 15px;">
|
|
<img src="<?php echo htmlspecialchars($booking['main_image']); ?>" alt="Car" style="width: 60px; height: 40px; object-fit: cover; border-radius: 4px;">
|
|
<div>
|
|
<strong><?php echo htmlspecialchars($booking['brand'] . ' ' . $booking['model']); ?></strong>
|
|
<div style="font-size: 0.8rem; color: var(--text-muted);"><?php echo $booking['year']; ?></div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td style="padding: 15px 10px;">$<?php echo number_format($booking['price']); ?></td>
|
|
<td style="padding: 15px 10px;"><?php echo date('M d, Y', strtotime($booking['booking_date'])); ?></td>
|
|
<td style="padding: 15px 10px;">
|
|
<?php
|
|
$statusClass = '';
|
|
if ($booking['status'] === 'approved') $statusClass = 'color: #10b981;';
|
|
elseif ($booking['status'] === 'rejected') $statusClass = 'color: #ef4444;';
|
|
else $statusClass = 'color: #f59e0b;';
|
|
?>
|
|
<span style="<?php echo $statusClass; ?> font-weight: bold; text-transform: capitalize;">
|
|
<?php echo $booking['status']; ?>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<style>
|
|
.glass-card {
|
|
background: rgba(255, 255, 255, 0.03);
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
border-radius: 16px;
|
|
padding: 25px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.mt-5 { margin-top: 3rem; }
|
|
.mb-4 { margin-bottom: 1.5rem; }
|
|
</style>
|
|
|
|
<?php include 'includes/footer.php'; ?>
|