From c00704a2aabaa06681de05435d266d31f9451bce Mon Sep 17 00:00:00 2001 From: Jo Date: Thu, 16 Jul 2026 19:25:25 +0200 Subject: [PATCH] feat: jobs page filters/sort/summary + poids piece in detail --- app.py | 7 +- templates/job_detail.html | 1 + templates/jobs.html | 235 +++++++++++++++++++++++++++++++++----- 3 files changed, 213 insertions(+), 30 deletions(-) diff --git a/app.py b/app.py index d0b9d9a..c808d61 100644 --- a/app.py +++ b/app.py @@ -1252,14 +1252,13 @@ def jobs(): conn = get_db() jobs = conn.execute(''' SELECT j.*, c.name as client_name, m.name as material_name, - ps.status as slot_status, ps.planned_start + COALESCE(j.cout_fixe, 0) + COALESCE(j.total_marge, 0) as prix_ht_piece FROM jobs j LEFT JOIN clients c ON j.client_id=c.id LEFT JOIN materials m ON j.material_id=m.id - LEFT JOIN print_slots ps ON ps.job_id=j.id AND ps.id=( - SELECT id FROM print_slots WHERE job_id=j.id ORDER BY planned_start LIMIT 1) ORDER BY j.created_at DESC''').fetchall() + clients = conn.execute('SELECT id, name FROM clients ORDER BY name').fetchall() conn.close() - return render_template('jobs.html', jobs=jobs) + return render_template('jobs.html', jobs=jobs, clients=clients) @app.route('/jobs/new', methods=['GET','POST']) def new_job(): diff --git a/templates/job_detail.html b/templates/job_detail.html index e52d15a..fb300ad 100644 --- a/templates/job_detail.html +++ b/templates/job_detail.html @@ -82,6 +82,7 @@ {% endif %} Date{{ job.created_at[:10] }} Poids plateau{{ job.weight_g }} g + Poids / pièce{{ '%.2f'|format(job.weight_g / (job.pieces_per_plate or 1)) }} g Pieces / plateau{{ job.pieces_per_plate or 1 }} Quantite commandee{{ qty }} pièce{{ 's' if qty > 1 else '' }} Duree plateau{{ job.print_time_s | fmt_time }} diff --git a/templates/jobs.html b/templates/jobs.html index 425f5ac..08378ba 100644 --- a/templates/jobs.html +++ b/templates/jobs.html @@ -14,46 +14,153 @@ + +
+
+
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+
+
+ + +
+
+
+
Commandes
+
{{ jobs|length }}
+
+
+
+
+
Total HT commandes
+
--
+
+
+
+
+
Total prix final
+
--
+
+
+
+
+
Poids total
+
--
+
+
+
+ +
{% if jobs %}
- +
- - - + + + + + + + + + - + {% for j in jobs %} - - - - - - - - - - - + + - - + + + + + +
DateNomClientRéf. plateauPoidsDuréeDesignMarge bruteTotal margeRemisePrix finalDateNomClientMatierePoidsDureePrix HTPrix final
{{ j.created_at[:10] }}{{ j.name }}{{ j.client_name or '—' }}{{ j.plate_name or '—' }}{{ j.weight_g }} g{{ j.print_time_s | fmt_time }}×{{ j.design_multiplier }}{{ j.gross_margin_pct }}%{% if j.total_marge %}{{ '%.2f'|format(j.total_marge) }} €
{% if j.marge_pct_on_ht %}{{ j.marge_pct_on_ht }}% du HT{% endif %}{% else %}—{% endif %}
- {% if j.discount_pct > 0 %} - -{{ j.discount_pct }}% - {% else %}—{% endif %} + {% set pieces = j.pieces_per_plate or 1 %} + {% set qty = j.order_qty or 1 %} + {% set prix_ht = j.prix_ht_piece or 0 %} + {% set poids_piece = j.weight_g / pieces %} +
{{ j.created_at[:10] }} + {{ j.name }} + {% if j.plate_name %}
{{ j.plate_name }}{% endif %}
{{ j.final_price }} € + {{ j.client_name or '--' }} + {% if j.material_name %}{{ j.material_name }}{% else %}--{% endif %} + + {{ j.weight_g }} g + {% if pieces > 1 %} +
{{ '%.1f'|format(poids_piece) }} g/pce x{{ pieces }} + {% else %} +
{{ '%.1f'|format(poids_piece) }} g/pce + {% endif %} +
{{ j.print_time_s | fmt_time }} + {% if prix_ht > 0 %} + {{ '%.2f'|format(prix_ht) }} € /pce + {% if qty > 1 %} +
{{ '%.2f'|format(prix_ht * qty) }} € x{{ qty }} + {% endif %} + {% else %}--{% endif %} +
+ {{ '%.2f'|format(j.final_price or 0) }} € + {% if j.discount_pct and j.discount_pct > 0 %} + -{{ j.discount_pct }}% + {% endif %} + {% if qty > 1 %} +
{{ '%.2f'|format((j.final_price or 0) * qty) }} € tot. + {% endif %} +
{% if j.client_token %} + class="btn btn-sm btn-outline-success py-0" title="Portail client"> {% endif %} - +
@@ -65,13 +172,89 @@
+
+ +

Aucune commande ne correspond aux filtres.

+
{% else %}
-

Aucune commande enregistrée.

- Créer le premier calcul +

Aucune commande enregistree.

+ Creer le premier calcul
{% endif %}
+ + {% endblock %}