{% block title %}{{ 'Modifier' if unit else 'Nouveau' }} logement — GMAO{% endblock %}
{% block content %}<divclass="container"style="max-width:900px"><h1class="h3 mb-4">{{ 'Modifier le' if unit else 'Nouveau' }} logement</h1><formmethod="post"class="card"><divclass="card-body row g-3">
<divclass="col-md-8"><labelclass="form-label">Nom *</label><inputname="name"class="form-control"value="{{ unit.name if unit else '' }}"placeholder="Ex. Logement 1"required></div><divclass="col-md-4"><labelclass="form-label">Code</label><inputname="code"class="form-control"value="{{ unit.code if unit and unit.code else '' }}"></div>
<divclass="col-md-6"><labelclass="form-label">Bâtiment *</label><selectname="building_id"class="form-select"required><optionvalue="">—</option>{% for building in buildings %}<optionvalue="{{ building.id }}"{%ifunitandunit.building_id ==building.id%}selected{%endif%}>{{ building.site.name ~ ' · ' if building.site else '' }}{{ building.name }}</option>{% endfor %}</select></div><divclass="col-md-3"><labelclass="form-label">Type</label><selectname="housing_type"class="form-select"><optionvalue="fonction">Fonction</option><optionvalue="gardien">Gardien</option><optionvalue="temporaire">Temporaire</option></select></div><divclass="col-md-3"><labelclass="form-label">État</label><selectname="occupancy_status"class="form-select">{% for value,label in [('vacant','Vacant'),('occupe','Occupé'),('travaux','En travaux'),('indisponible','Indisponible')] %}<optionvalue="{{ value }}"{%ifunitandunit.occupancy_status ==value%}selected{%endif%}>{{ label }}</option>{% endfor %}</select></div>
<divclass="col-md-6"><labelclass="form-label">Occupant</label><inputname="occupant_name"class="form-control"value="{{ unit.occupant_name if unit and unit.occupant_name else '' }}"></div><divclass="col-md-6"><labelclass="form-label">Contact</label><inputname="occupant_contact"class="form-control"value="{{ unit.occupant_contact if unit and unit.occupant_contact else '' }}"></div><divclass="col-md-3"><labelclass="form-label">Début d'occupation</label><inputtype="date"name="occupancy_start"class="form-control"value="{{ unit.occupancy_start.isoformat() if unit and unit.occupancy_start else '' }}"></div><divclass="col-md-3"><labelclass="form-label">Fin prévue/réelle</label><inputtype="date"name="occupancy_end"class="form-control"value="{{ unit.occupancy_end.isoformat() if unit and unit.occupancy_end else '' }}"></div><divclass="col-md-6"><labelclass="form-label">Notes techniques</label><textareaname="notes"class="form-control">{{ unit.notes if unit and unit.notes else '' }}</textarea></div>
<divclass="col-md-3"><labelclass="form-label">Nombre de clés remises</label><inputtype="number"min="0"name="key_count"class="form-control"value="0"></div><divclass="col-md-9"><labelclass="form-label">État des lieux d’entrée</label><textareaname="entry_condition"class="form-control"rows="2"></textarea></div>
{% if unit %}<divclass="col-md-12"><labelclass="form-label">État des lieux de sortie</label><textareaname="exit_condition"class="form-control"rows="2"placeholder="À renseigner lors du départ ou du changement d’occupant"></textarea></div>{% endif %}