{% extends "base.html" %}
{% block title %}Nouvelle règle de relevé{% endblock %}
{% block content %}
<div class="container py-3"><h1 class="h3">Nouvelle règle de relevé</h1>
<form method="post" class="row g-3">
  <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
  <div class="col-md-6"><label class="form-label" for="meter_id">Compteur</label><select class="form-select" id="meter_id" name="meter_id" required>{% for meter in meters %}<option value="{{ meter.id }}">{{ meter.name }} — {{ meter.unit }}</option>{% endfor %}</select></div>
  <div class="col-md-6"><label class="form-label" for="frequency">Fréquence</label><select class="form-select" id="frequency" name="frequency" required>{% for frequency in frequencies %}<option value="{{ frequency }}">{{ frequency }}</option>{% endfor %}</select></div>
  <div class="col-md-4"><label class="form-label" for="reference_date">Date de début/référence</label><input class="form-control" type="date" id="reference_date" name="reference_date" required></div>
  <div class="col-md-4"><label class="form-label" for="target_time">Heure cible facultative</label><input class="form-control" type="time" id="target_time" name="target_time"></div>
  <div class="col-md-4"><label class="form-label" for="duration_minutes">Durée estimée (minutes)</label><input class="form-control" type="number" min="1" id="duration_minutes" name="duration_minutes" value="5" required></div>
  <div class="col-md-4"><label class="form-label" for="assigned_to_id">Responsable</label><select class="form-select" id="assigned_to_id" name="assigned_to_id"><option value="">Non attribué</option>{% for user in users %}<option value="{{ user.id }}">{{ user.full_name or user.username }}</option>{% endfor %}</select></div>
  <div class="col-md-4"><label class="form-label" for="calendar_scope">Calendrier</label><select class="form-select" id="calendar_scope" name="calendar_scope"><option value="school">Collège</option><option value="housing">Logement de fonction</option></select></div>
  <div class="col-md-4"><label class="form-label" for="fixed_month">Date annuelle fixe (mois/jour)</label><div class="input-group"><input class="form-control" type="number" min="1" max="12" id="fixed_month" name="fixed_month" placeholder="Mois"><input class="form-control" type="number" min="1" max="31" name="fixed_day" placeholder="Jour"></div></div>
  <div class="col-12"><button class="btn btn-primary">Enregistrer</button> <a class="btn btn-outline-secondary" href="{{ url_for('planning.meter_schedules') }}">Annuler</a></div>
</form></div>
{% endblock %}
