{% extends "admin_base.html" %}

{% block title %}Manage Bookings{% endblock %}

{% block content %}
<h1 class="mb-4">Manage Bookings</h1>

<table class="table table-striped">
    <thead>
        <tr>
            <th>ID</th>
            <th>Customer Name</th>
            <th>Email</th>
            <th>Start Date</th>
            <th>End Date</th>
            <th>Car</th>
            <th>Tour</th>
            <th>Created At</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        {% for booking in bookings %}
        <tr>
            <td>{{ booking.id }}</td>
            <td>{{ booking.customer_name }}</td>
            <td>{{ booking.customer_email }}</td>
            <td>{{ booking.start_date.strftime('%Y-%m-%d') }}</td>
            <td>{{ booking.end_date.strftime('%Y-%m-%d') }}</td>
            <td>{{ booking.car.name if booking.car else 'N/A' }}</td>
            <td>{{ booking.tour.name if booking.tour else 'N/A' }}</td>
            <td>{{ booking.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
            <td>
                <a href="{{ url_for('admin.view_booking', id=booking.id) }}" class="btn btn-sm btn-info">View</a>
                <a href="{{ url_for('admin.delete_booking', id=booking.id) }}" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure you want to delete this booking?')">Delete</a>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>

{% endblock %}