<?php require 'includes/auth.php'; ?>
<?php require_once '../app/db.php'; ?>

<?php include 'includes/header.php'; ?>
<?php include 'includes/sidebar.php'; ?>

<?php
$stmt = $pdo->query("
SELECT b.*, c.name 
FROM bookings b
JOIN customers c ON b.customer_id=c.id
ORDER BY b.created_at DESC
");
?>

<div class="content-wrapper">
<section class="content pt-4">
<div class="container-fluid">

<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Code</th>
<th>Customer</th>
<th>Service</th>
<th>Price</th>
<th>Status</th>
<th>Payment</th>
<th>Action</th>
</tr>
</thead>

<tbody>
<?php foreach($stmt as $row): ?>
<tr>
<td><?= $row['booking_code'] ?></td>
<td><?= $row['name'] ?></td>
<td><?= $row['service_type'] ?></td>
<td>$<?= $row['estimated_price'] ?></td>
<td><?= $row['status'] ?></td>
<td><?= $row['payment_status'] ?></td>
<td>
<a href="booking_view.php?id=<?= $row['id'] ?>" class="btn btn-sm btn-primary">View</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

</div>
</section>
</div>

<?php include 'includes/footer.php'; ?>
