{% extends "base.html" %}
{% block title %}Logements de fonction — GMAO{% endblock %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4"><div><h1 class="h3"><i class="bi bi-house-door"></i> Logements de fonction</h1><p class="text-muted mb-0">Occupation, pièces et patrimoine technique des logements.</p></div><a class="btn btn-primary" href="{{ url_for('housing.create') }}"><i class="bi bi-plus-lg"></i> Nouveau logement</a></div>
<div class="row g-3">{% for unit in units %}<div class="col-md-6 col-xl-4"><div class="card h-100"><div class="card-body"><div class="d-flex justify-content-between"><h2 class="h5">{{ unit.name }}</h2><span class="badge {% if unit.occupancy_status == 'occupe' %}text-bg-success{% elif unit.occupancy_status == 'travaux' %}text-bg-warning{% else %}text-bg-secondary{% endif %}">{{ unit.occupancy_status|replace('_',' ') }}</span></div><div class="text-muted small">{{ unit.building.site.name if unit.building.site else 'Site non renseigné' }} · {{ unit.building.name }}</div><hr><div><strong>Occupant :</strong> {{ unit.occupant_name or 'Aucun' }}</div><div><strong>Pièces :</strong> {{ unit.rooms.count() }}</div></div><div class="card-footer"><a href="{{ url_for('housing.detail', unit_id=unit.id) }}" class="btn btn-sm btn-outline-primary">Ouvrir</a></div></div></div>{% else %}<div class="col-12"><div class="alert alert-info">Aucun logement enregistré.</div></div>{% endfor %}</div>
{% endblock %}
