Files
garagemanager/templates/intervention_detail.html

204 lines
9.8 KiB
HTML

{% extends "base.html" %}
{% block title %}Intervention — GarageManager{% endblock %}
{% block content %}
<a href="/vehicules/{{ intervention.vid }}" class="back-link"><i class="fas fa-arrow-left"></i> Retour au véhicule</a>
<!-- Header -->
<div class="flex justify-between items-start mb-8">
<div>
<h1 class="page-title" style="max-width:600px">{{ intervention.description }}</h1>
<p class="page-subtitle" style="margin-top:0.4rem">
<a href="/vehicules/{{ intervention.vid }}" class="mono" style="color:var(--accent-electric);text-decoration:none;font-size:0.95rem">{{ intervention.immatriculation }}</a>
<span class="text-muted"> — {{ intervention.marque }} {{ intervention.modele }}</span>
</p>
<div class="flex gap-4 mt-2" style="flex-wrap:wrap">
{% if intervention.date_intervention %}
<span class="text-xs text-secondary"><i class="fas fa-calendar mr-1"></i>{{ intervention.date_intervention }}</span>
{% endif %}
{% if intervention.kilometrage_intervention %}
<span class="text-xs text-secondary mono"><i class="fas fa-tachometer-alt mr-1"></i>{{ intervention.kilometrage_intervention }} km</span>
{% endif %}
{% if intervention.technicien %}
<span class="text-xs text-secondary"><i class="fas fa-user-cog mr-1"></i>{{ intervention.technicien }}</span>
{% endif %}
</div>
</div>
<div class="flex gap-2">
<a href="/interventions/{{ intervention.id }}/edit" class="btn-secondary btn-sm">
<i class="fas fa-edit"></i> Modifier
</a>
<form method="post" action="/interventions/{{ intervention.id }}/delete" onsubmit="return confirm('Supprimer cette intervention ?')">
<button class="btn-danger btn-sm">
<i class="fas fa-trash"></i> Supprimer
</button>
</form>
</div>
</div>
<!-- Résumé coûts -->
<div class="grid grid-3 mb-6">
<div class="card" style="cursor:default">
<div class="stat-label mb-2">Main d'œuvre</div>
<div class="stat-value" style="color:var(--accent-electric)">{{ "%.2f"|format(intervention.cout_main_oeuvre) }} €</div>
</div>
<div class="card" style="cursor:default">
<div class="stat-label mb-2">Pièces</div>
<div class="stat-value" style="color:var(--text-secondary)">{{ "%.2f"|format(intervention.cout_pieces) }} €</div>
</div>
<div class="card" style="cursor:default;border-color:rgba(250,204,21,0.25)">
<div class="stat-label mb-2" style="color:var(--accent-volt)">Total</div>
<div class="stat-value" style="color:var(--accent-volt)">{{ "%.2f"|format(intervention.cout_main_oeuvre + intervention.cout_pieces) }} €</div>
</div>
</div>
{% if intervention.notes %}
<div class="card mb-6">
<h3 class="card-title mb-3"><i class="fas fa-clipboard-list text-secondary" style="margin-right:0.4rem"></i>Notes</h3>
<p class="text-sm" style="white-space:pre-wrap;color:var(--text-secondary)">{{ intervention.notes }}</p>
</div>
{% endif %}
<!-- ── Pièces utilisées ── -->
<div class="card" style="padding:0">
<div class="card-header">
<span class="card-title">
<i class="fas fa-cog text-volt" style="margin-right:0.4rem"></i>
Pièces utilisées
<span class="badge badge-warning ml-2">{{ pieces_utilisees|length }}</span>
</span>
<button onclick="toggleAddPiece()" class="btn-primary btn-sm">
<i class="fas fa-plus"></i> Ajouter une pièce
</button>
</div>
<!-- Form ajout pièce -->
<div id="add-piece-form" style="display:none;background:var(--bg-secondary);border-bottom:1px solid var(--border);padding:1.25rem 1.5rem">
<form method="post" action="/interventions/{{ intervention.id }}/pieces/add" enctype="multipart/form-data">
{% if pieces_connues %}
<div class="mb-4">
<p class="text-xs font-semibold uppercase" style="color:var(--text-muted);letter-spacing:0.06em;margin-bottom:0.5rem">
🔄 Réutiliser une pièce connue sur ce véhicule
</p>
<div class="scroll-list">
{% for p in pieces_connues %}
<label class="scroll-list-item">
<input type="radio" name="_prefill" value="{{ loop.index0 }}"
data-nom="{{ p.nom }}" data-ref="{{ p.reference or '' }}" data-marque="{{ p.marque or '' }}" data-prix="{{ p.prix }}"
onchange="prefillPiece(this)"
style="width:auto;background:none;border:none;padding:0">
<span class="font-medium text-sm" style="flex:1">{{ p.nom }}</span>
{% if p.reference %}<span class="mono text-xs text-muted">{{ p.reference }}</span>{% endif %}
{% if p.marque %}<span class="text-xs text-secondary">{{ p.marque }}</span>{% endif %}
<span class="font-semibold text-sm text-electric mono">{{ "%.2f"|format(p.prix) }} €</span>
</label>
{% endfor %}
</div>
<p class="text-xs text-muted mt-1">Les infos se pré-remplissent automatiquement, tu peux les modifier.</p>
</div>
{% endif %}
<div class="grid grid-2 mb-3">
<div>
<label>Nom *</label>
<input id="p-nom" name="nom" required placeholder="Nom de la pièce">
</div>
<div>
<label>Référence</label>
<input id="p-ref" name="reference" placeholder="Ex: 06A115561B…" style="font-family:'JetBrains Mono',monospace">
</div>
</div>
<div class="grid grid-3 mb-3">
<div>
<label>Marque</label>
<input id="p-marque" name="marque" placeholder="Bosch, NGK…">
</div>
<div>
<label>Prix unitaire (€)</label>
<input id="p-prix" name="prix" type="number" step="0.01" min="0" value="0" class="mono">
</div>
<div>
<label>Quantité</label>
<input name="quantite" type="number" min="1" value="1" class="mono">
</div>
</div>
<div class="mb-3">
<label>Photo (optionnel)</label>
<input type="file" name="photo" accept="image/*" style="background:none;border:none;padding:0.25rem 0;color:var(--text-secondary)">
</div>
<button type="submit" class="btn-primary btn-sm">
<i class="fas fa-plus"></i> Ajouter la pièce
</button>
</form>
</div>
{% if pieces_utilisees %}
<div class="overflow-x-auto">
<table>
<thead>
<tr>
<th>Photo</th>
<th>Pièce</th>
<th>Référence</th>
<th>Marque</th>
<th class="text-center">Qté</th>
<th class="text-right">Prix unit.</th>
<th class="text-right">Total</th>
<th></th>
</tr>
</thead>
<tbody>
{% for p in pieces_utilisees %}
<tr>
<td>
{% if p.photo %}
<img src="{{ p.photo }}" class="photo-thumb" style="width:48px;height:48px" onclick="window.open('{{ p.photo }}','_blank')">
{% else %}
<div class="photo-placeholder" style="width:48px;height:48px"><i class="fas fa-cog"></i></div>
{% endif %}
</td>
<td class="font-medium">{{ p.nom }}</td>
<td class="mono text-xs text-muted">{{ p.reference or '—' }}</td>
<td class="text-secondary text-sm">{{ p.marque or '—' }}</td>
<td class="text-center text-secondary mono">{{ p.quantite }}</td>
<td class="text-right mono text-sm">{{ "%.2f"|format(p.prix) }} €</td>
<td class="text-right font-semibold mono" style="color:var(--accent-volt)">{{ "%.2f"|format(p.prix * p.quantite) }} €</td>
<td>
<form method="post" action="/interventions/{{ intervention.id }}/pieces/{{ p.id }}/delete" onsubmit="return confirm('Supprimer cette pièce ?')">
<button class="link-danger"></button>
</form>
</td>
</tr>
{% endfor %}
<tr style="background:var(--bg-secondary)">
<td colspan="6" class="text-right font-semibold text-secondary text-sm">Total pièces</td>
<td class="text-right font-bold mono" style="color:var(--accent-volt)">{{ "%.2f"|format(intervention.cout_pieces) }} €</td>
<td></td>
</tr>
</tbody>
</table>
</div>
{% else %}
<div class="empty-state">
<i class="fas fa-cog"></i>
<p>Aucune pièce pour cette intervention</p>
<button onclick="toggleAddPiece()" class="link-action">Ajouter →</button>
</div>
{% endif %}
</div>
<script>
function toggleAddPiece() {
const f = document.getElementById('add-piece-form');
f.style.display = f.style.display === 'none' ? 'block' : 'none';
}
function prefillPiece(radio) {
document.getElementById('p-nom').value = radio.dataset.nom;
document.getElementById('p-ref').value = radio.dataset.ref;
document.getElementById('p-marque').value = radio.dataset.marque;
document.getElementById('p-prix').value = radio.dataset.prix;
}
</script>
{% endblock %}