{% extends "base.html" %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="h2">Attività</h1>
    <a href="{% url 'activity_create' %}" class="btn btn-primary">Aggiungi Attività</a>
</div>

<div class="card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th scope="col">Titolo</th>
                        <th scope="col">Cliente</th>
                        <th scope="col">Stato</th>
                        <th scope="col">Data Creazione</th>
                        <th scope="col"></th>
                    </tr>
                </thead>
                <tbody>
                    {% for activity in activities %}
                    <tr>
                        <td>{{ activity.title }}</td>
                        <td><a href="{% url 'client_detail' activity.client.pk %}">{{ activity.client.name }}</a></td>
                        <td><span class="badge bg-primary">{{ activity.get_status_display }}</span></td>
                        <td>{{ activity.created_at|date:"d/m/Y" }}</td>
                        <td>
                            <a href="{% url 'activity_detail' activity.pk %}" class="btn btn-sm btn-outline-primary">Dettagli</a>
                        </td>
                    </tr>
                    {% empty %}
                    <tr>
                        <td colspan="5" class="text-center">Nessuna attività trovata.</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}