{% extends "crm/base.html" %}

{% block content %}
<div class="container bubble">
    <h2>Prospects</h2>

    <div class="card mb-4">
        <div class="card-body">
            <form method="get" class="row g-3">
                {{ filter.form }}
                <div class="col-12">
                    <button type="submit" class="btn btn-primary">Filter</button>
                    <a href="{% url 'crm:prospect-list' %}" class="btn btn-secondary">Clear</a>
                </div>
            </form>
        </div>
    </div>

    <div class="mb-3">
        <a href="{% url 'crm:prospect-import' %}" class="btn btn-success">Import CSV</a>
        <a href="{% url 'crm:send-bulk-email' %}" class="btn btn-primary">Send Email</a>
    </div>

    <div class="table-responsive">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th><input type="checkbox" id="select-all"></th>
                    <th>Name</th>
                    <th>Email</th>
                    <th>Region</th>
                    <th>Status</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                {% for prospect in prospects %}
                <tr>
                    <td><input type="checkbox" name="selected_prospects" value="{{ prospect.id }}"></td>
                    <td>{{ prospect.name }}</td>
                    <td>{{ prospect.email }}</td>
                    <td>{{ prospect.region }}</td>
                    <td>
                        {% for status in prospect.prospectstatus_set.all %}
                            <span class="badge bg-primary">{{ status.status.name }}</span>
                        {% endfor %}
                    </td>
                    <td>
                        <button class="btn btn-sm btn-secondary">Edit</button>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}
