{% extends "base.html" %}
{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">Properties</h3>
                </div>
                <div class="card-body">
                    <div class="row mb-3">
                        <div class="col-md-12">
                            <form method="get">
                                <div class="row">
                                    <div class="col-md-3">
                                        <input type="text" name="q" class="form-control" placeholder="Search..." value="{{ request.GET.q }}">
                                    </div>
                                    <div class="col-md-2">
                                        <select name="status" class="form-control">
                                            <option value="">Status</option>
                                            {% for status in statuses %}
                                            <option value="{{ status.0 }}" {% if request.GET.status == status.0 %}selected{% endif %}>{{ status.1 }}</option>
                                            {% endfor %}
                                        </select>
                                    </div>
                                    <div class="col-md-2">
                                        <select name="property_type" class="form-control">
                                            <option value="">Property Type</option>
                                            {% for pt in property_types %}
                                            <option value="{{ pt.0 }}" {% if request.GET.property_type == pt.0 %}selected{% endif %}>{{ pt.1 }}</option>
                                            {% endfor %}
                                        </select>
                                    </div>
                                    <div class="col-md-2">
                                        <input type="date" name="start_date" class="form-control" value="{{ request.GET.start_date }}">
                                    </div>
                                    <div class="col-md-2">
                                        <input type="date" name="end_date" class="form-control" value="{{ request.GET.end_date }}">
                                    </div>
                                    <div class="col-md-1">
                                        <button type="submit" class="btn btn-primary">Filter</button>
                                    </div>
                                    <div class="col-md-2 text-right">
                                        <a href="#" class="btn btn-success">Add New Property</a>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>Name</th>
                                <th>City</th>
                                <th>Status</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for property in properties %}
                            <tr>
                                <td>{{ property.name }}</td>
                                <td>{{ property.city }}</td>
                                <td>{{ property.get_status_display }}</td>
                                <td>
                                    <a href="#" class="btn btn-sm btn-primary">View</a>
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
