loko/streetup/contracts/templates/admin/contracts/contractpost/import_posts.html
2026-07-22 14:48:40 +02:00

94 lines
3.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends "admin/base_site.html" %}
{% load i18n %}
{% block title %}Importer des postes de contrat{% endblock %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans "Accueil" %}</a>
&rsaquo; <a href="{% url 'admin:app_list' app_label='contracts' %}">Contrats</a>
&rsaquo; <a href="{% url 'admin:contracts_contractpost_changelist' %}">Postes de contrat</a>
&rsaquo; Importer / mettre à jour (Excel)
</div>
{% endblock %}
{% block content %}
<h1>Importer / mettre à jour des postes de contrat depuis Excel</h1>
<p class="help">
Format attendu : colonnes <strong>Nr.&nbsp;Post&nbsp;(A)</strong>, Code&nbsp;(B),
Description&nbsp;NL&nbsp;(C), AO&nbsp;(D), Unité&nbsp;(E), Description&nbsp;FR&nbsp;(F),
NC&nbsp;(G), U&nbsp;(H), Quantité&nbsp;(I), Prix unitaire&nbsp;(J).<br>
Si <em>Mettre à jour les postes existants</em> est coché, les postes déjà présents
(identifiés par leur numéro de poste) seront mis à jour ; sinon ils sont ignorés.
</p>
{% if messages %}
<ul class="messagelist">
{% for message in messages %}
<li class="{{ message.tags }}">{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% if stats %}
<div class="results" style="margin-bottom:1.5em;">
<h2>Résultat de l'import{% if dry_run %} <em>(dry-run – rien n'a été enregistré)</em>{% endif %}</h2>
<table>
<tbody>
<tr><th>Lignes avec numéro de poste</th><td>{{ stats.total_rows }}</td></tr>
<tr style="color:green;"><th>Postes créés</th><td><strong>{{ stats.created }}</strong></td></tr>
<tr style="color:blue;"><th>Postes mis à jour</th><td><strong>{{ stats.updated }}</strong></td></tr>
<tr><th>Postes ignorés (déjà présents)</th><td>{{ stats.skipped_already_exists }}</td></tr>
<tr><th>Postes ignorés (prix manquant)</th><td>{{ stats.skipped_no_price }}</td></tr>
{% if stats.errors %}
<tr style="color:red;"><th>Erreurs</th><td><strong>{{ stats.errors }}</strong></td></tr>
{% endif %}
</tbody>
</table>
{% if log_lines %}
<details style="margin-top:1em;">
<summary>Journal détaillé ({{ log_lines|length }} lignes)</summary>
<pre style="max-height:400px; overflow:auto; font-size:0.8em; background:#f8f8f8; padding:1em; border:1px solid #ddd;">{{ log_lines|join:"\n" }}</pre>
</details>
{% endif %}
</div>
{% endif %}
<form method="post" enctype="multipart/form-data" style="max-width:600px;">
{% csrf_token %}
<fieldset class="module aligned">
<h2>Paramètres d'import</h2>
<div class="form-row">
<label for="{{ form.contract.id_for_label }}" class="required">{{ form.contract.label }}</label>
{{ form.contract }}
{% if form.contract.errors %}<ul class="errorlist">{% for e in form.contract.errors %}<li>{{ e }}</li>{% endfor %}</ul>{% endif %}
</div>
<div class="form-row">
<label for="{{ form.excel_file.id_for_label }}" class="required">{{ form.excel_file.label }}</label>
{{ form.excel_file }}
<p class="help">Fichiers acceptés : <code>.xlsx</code>, <code>.xlsm</code></p>
{% if form.excel_file.errors %}<ul class="errorlist">{% for e in form.excel_file.errors %}<li>{{ e }}</li>{% endfor %}</ul>{% endif %}
</div>
<div class="form-row">
<label for="{{ form.update_existing.id_for_label }}">{{ form.update_existing.label }}</label>
{{ form.update_existing }}
<p class="help">{{ form.update_existing.help_text }}</p>
</div>
<div class="form-row">
<label for="{{ form.dry_run.id_for_label }}">{{ form.dry_run.label }}</label>
{{ form.dry_run }}
<p class="help">{{ form.dry_run.help_text }}</p>
</div>
</fieldset>
<div class="submit-row">
<input type="submit" value="Lancer l'import" class="default">
<a href="{% url 'admin:contracts_contractpost_changelist' %}" class="closelink">Annuler</a>
</div>
</form>
{% endblock %}