{% extends "base.html" %}
{% block content %}<div class="container-fluid py-3" style="max-width:1100px">
<h1 class="h3">Horaires des techniciens</h1><p class="text-muted">Les horaires sont propres à chaque technicien. Sans ligne configurée, Ma journée affiche clairement « horaires non configurés ».</p>
<form method="get" class="row g-2 mb-3"><div class="col-md-5"><label class="form-label" for="user_id">Technicien</label><select id="user_id" name="user_id" class="form-select">{% for user in users %}<option value="{{ user.id }}" {% if user.id == target.id %}selected{% endif %}>{{ user.full_name or user.username }}</option>{% endfor %}</select></div><div class="col-md-2"><label class="form-label" for="academic_year">Année</label><input id="academic_year" class="form-control" name="academic_year" value="{{ year }}"></div><div class="col-md-2 align-self-end"><button class="btn btn-outline-primary">Afficher</button></div></form>
<form method="post"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}"><input type="hidden" name="user_id" value="{{ target.id }}"><input type="hidden" name="academic_year" value="{{ year }}"><div class="table-responsive"><table class="table align-middle"><thead><tr><th>Jour</th><th>Début</th><th>Fin</th><th>Pause début</th><th>Pause fin</th></tr></thead><tbody>{% for day in days %}{% set row = rows.get(loop.index0) %}<tr><th>{{ day }}</th><td><input class="form-control" type="time" name="start_{{ loop.index0 }}" value="{{ row.start_time.strftime('%H:%M') if row and row.start_time else '' }}"></td><td><input class="form-control" type="time" name="end_{{ loop.index0 }}" value="{{ row.end_time.strftime('%H:%M') if row and row.end_time else '' }}"></td><td><input class="form-control" type="time" name="lunch_start_{{ loop.index0 }}" value="{{ row.lunch_start.strftime('%H:%M') if row and row.lunch_start else '' }}"></td><td><input class="form-control" type="time" name="lunch_end_{{ loop.index0 }}" value="{{ row.lunch_end.strftime('%H:%M') if row and row.lunch_end else '' }}"></td></tr>{% endfor %}</tbody></table></div><button class="btn btn-primary">Enregistrer les horaires</button></form></div>{% endblock %}
