{% extends "base.html" %}
{% block title %}Relevé — {{ occurrence.schedule.meter.name }}{% endblock %}
{% block content %}
<div class="container py-3"><a href="{{ url_for('planning.my_day', date=occurrence.operational_date.isoformat()) }}">← Ma journée</a><div class="card mt-3"><div class="card-body"><h1 class="h4">{{ occurrence.schedule.meter.name }}</h1><p class="mb-1">Échéance cible : <strong>{{ occurrence.target_date.strftime('%d/%m/%Y') }}</strong></p><p class="mb-1">Date opérationnelle : {{ occurrence.operational_date.strftime('%d/%m/%Y') }}</p><p class="mb-1">Durée estimée : {{ occurrence.schedule.duration_minutes }} min</p><p class="text-muted">{{ occurrence.schedule.meter.usage or 'Usage non précisé' }}</p>
{% if occurrence.status == 'À FAIRE' %}<form method="post" enctype="multipart/form-data" action="{{ url_for('planning.meter_occurrence_reading', occurrence_id=occurrence.id) }}" class="mt-3"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}"><label class="form-label" for="value">Nouvelle valeur ({{ occurrence.schedule.meter.unit }})</label><input class="form-control" type="number" step="0.01" inputmode="decimal" id="value" name="value" value="{{ occurrence.schedule.meter.current_value }}" required><label class="form-label mt-2" for="notes">Notes</label><textarea class="form-control" id="notes" name="notes"></textarea><label class="form-label mt-2" for="photo">Photo facultative</label><input class="form-control" type="file" id="photo" name="photo" accept="image/jpeg,image/png,image/gif"><button class="btn btn-primary mt-3">Valider le relevé</button></form><hr id="sans-releve"><form method="post" action="{{ url_for('planning.meter_occurrence_without_reading', occurrence_id=occurrence.id) }}" class="mt-3"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}"><label class="form-label" for="reason">Traiter sans relevé</label><select class="form-select" id="reason" name="reason" required>{% for key, label in no_reading_reasons.items() %}<option value="{{ key }}">{{ label }}</option>{% endfor %}</select><textarea class="form-control mt-2" name="comment" placeholder="Commentaire facultatif"></textarea><button class="btn btn-outline-secondary mt-2">Traiter sans relevé</button></form>{% else %}<div class="alert alert-info">{{ occurrence.status }}{% if occurrence.no_reading_reason %} — {{ no_reading_reasons.get(occurrence.no_reading_reason, occurrence.no_reading_reason) }}{% endif %}{% if occurrence.comment %}<br>{{ occurrence.comment }}{% endif %}</div>{% endif %}
</div></div></div>
{% endblock %}
