{% extends 'base.html' %}

{% block content %}
<div class="container-fluid mt-0">
    <h1>Edit Intervention</h1>
    <form method="POST" action="{{ url_for('edit_intervention', intervention_id=intervention.intervention_id) }}">
        <div class="form-group">
            <label for="maintenance_id">Maintenance:</label>
            <select id="maintenance_id" name="maintenance_id" class="form-control">
                {% for maintenance in maintenances %}
                <option value="{{ maintenance.maintenance_id }}" {% if maintenance.maintenance_id == intervention.maintenance_id %}selected{% endif %}>{{ maintenance.description }}</option>
                {% endfor %}
            </select>
        </div>
        <div class="form-group">
            <label for="machine_id">Machine:</label>
            <select id="machine_id" name="machine_id" class="form-control">
                {% for machine in machines %}
                <option value="{{ machine.machine_id }}" {% if machine.machine_id == intervention.machine_id %}selected{% endif %}>{{ machine.machine_name }}</option>
                {% endfor %}
            </select>
        </div>
        <div class="form-group">
            <label for="user_id">User:</label>
            <select id="user_id" name="user_id" class="form-control">
                {% for user in users %}
                <option value="{{ user.user_id }}" {% if user.user_id == intervention.user_id %}selected{% endif %}>{{ user.name }} {{ user.surname }}</option>
                {% endfor %}
            </select>
        </div>
        <div class="form-group">
            <label for="timestamp">Intervention Time:</label>
            <input type="datetime-local" id="timestamp" name="timestamp" class="form-control" value="{{ render_datetime(intervention.timestamp) }}" required>
        </div>
        <input type="submit" value="Update Intervention" class="btn btn-primary">
    </form>
</div>
{% endblock %}
