{% extends "base.html" %}

{% block title %}Personnel — GMAO{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row mb-4">
        <div class="col">
            <h1 class="h3">
                <i class="fas fa-users me-2"></i>Personnel
            </h1>
        </div>
        <div class="col-auto">
            <a href="{{ url_for('admin.user_new') }}" class="btn btn-primary">
                <i class="fas fa-plus me-1"></i>Ajouter
            </a>
        </div>
    </div>

    {% if staff %}
    <div class="card">
        <div class="card-body">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>Nom</th>
                        <th>Prénom</th>
                        <th>Fonction</th>
                        <th>Service</th>
                        <th>Email</th>
                        <th>Téléphone</th>
                        <th>Actif</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    {% for s in staff %}
                    <tr>
                        <td>{{ s.last_name or '—' }}</td>
                        <td>{{ s.first_name or '—' }}</td>
                        <td>{{ s.function or '—' }}</td>
                        <td>{{ s.department or '—' }}</td>
                        <td>{{ s.email or '—' }}</td>
                        <td>{{ s.phone or '—' }}</td>
                        <td>
                            {% if s.is_active %}
                            <span class="badge bg-success">Actif</span>
                            {% else %}
                            <span class="badge bg-secondary">Inactif</span>
                            {% endif %}
                        </td>
                        <td>
                            <a href="{{ url_for('admin.user_edit', user_id=s.id) }}" class="btn btn-sm btn-outline-primary">
                                <i class="fas fa-edit"></i>
                            </a>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
    {% else %}
    <div class="alert alert-info">
        <i class="fas fa-info-circle me-2"></i>Aucun membre du personnel enregistré.
    </div>
    {% endif %}
</div>
{% endblock %}