{% extends "base.html" %}
{% block title %}Planning interventions — GMAO{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1><i class="bi bi-calendar-week"></i> Planning des interventions</h1>
        <a href="{{ url_for('interventions.create') }}" class="btn btn-primary">
            <i class="bi bi-plus-circle"></i> Nouvelle intervention
        </a>
    </div>

    <div class="card">
        <div class="card-body">
            {% if interventions %}
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>Date</th>
                            <th>Intervention</th>
                            <th>Équipement</th>
                            <th>Priorité</th>
                            <th>Statut</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for intervention in interventions %}
                        <tr>
                            <td>{{ intervention.scheduled_date if intervention.scheduled_date else '-' }}</td>
                            <td><a href="{{ url_for('interventions.detail', id=intervention.id) }}">{{ intervention.title }}</a></td>
                            <td>{{ intervention.equipment.name if intervention.equipment else ('Salle : ' ~ intervention.room.name if intervention.room else 'Localisation non renseignée') }}</td>
                            <td><span class="badge bg-{{ 'danger' if intervention.priority == 'haute' else 'warning' if intervention.priority == 'normale' else 'secondary' }}">{{ intervention.priority }}</span></td>
                            <td><span class="badge bg-info">{{ intervention.status }}</span></td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            {% else %}
            <p class="text-muted text-center">Aucune intervention planifiée.</p>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}
