{% extends "base.html" %}
{% block title %}Individualiser une unité — GMAO{% endblock %}

{% block content %}
<div class="container-fluid">
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{{ url_for('equipments.index') }}">Équipements</a></li>
            <li class="breadcrumb-item"><a href="{{ url_for('equipments.detail', id=equipment.id) }}">{{ equipment.name }}</a></li>
            <li class="breadcrumb-item active">Individualiser une unité</li>
        </ol>
    </nav>
    <div class="row"><div class="col-lg-7">
        <div class="card mb-3">
            <div class="card-header"><i class="bi bi-box-seam me-1"></i> Groupe d’origine</div>
            <div class="card-body">
                <h1 class="h4">{{ equipment.name }}</h1>
                <div class="row g-2">
                    <div class="col-sm-4"><strong>Total physique</strong><br>{{ equipment.quantity }}</div>
                    <div class="col-sm-4"><strong>Déjà individualisées</strong><br>{{ equipment.individualized_quantity }}</div>
                    <div class="col-sm-4"><strong>Restantes après l’action</strong><br>{{ equipment.unindividualized_quantity - 1 }}</div>
                </div>
                {% if equipment.effective_lot %}
                <p class="mt-3 mb-0 text-muted">Lot hérité : <strong>{{ equipment.effective_lot.name }}</strong></p>
                {% endif %}
            </div>
        </div>
        <form method="POST" class="card">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            <div class="card-header">Nouvelle fiche individuelle #{{ next_number }}</div>
            <div class="card-body">
                <div class="mb-3">
                    <label for="name" class="form-label">Nom</label>
                    <input id="name" name="name" class="form-control" placeholder="{{ equipment.name }} #{{ next_number }}">
                </div>
                <div class="mb-3">
                    <label for="code" class="form-label">Code, repère ou numéro de série</label>
                    <input id="code" name="code" class="form-control" placeholder="Ex. A01-LUM-{{ '%02d'|format(next_number) }}">
                </div>
                <div class="mb-3">
                    <label for="position" class="form-label">Position précise</label>
                    <input id="position" name="position" class="form-control" placeholder="Ex. milieu, côté fenêtres">
                    <div class="form-text">Facultatif pour le mobilier, recommandé pour un luminaire, une prise ou une fenêtre.</div>
                </div>
            </div>
            <div class="card-footer d-flex gap-2">
                <button type="submit" class="btn btn-primary"><i class="bi bi-box-arrow-up-right me-1"></i> Individualiser une unité</button>
                <a href="{{ url_for('equipments.detail', id=equipment.id) }}" class="btn btn-secondary">Annuler</a>
            </div>
        </form>
    </div></div>
</div>
{% endblock %}
