From d6c53479cf4e8517048118500caecd16c16c7067 Mon Sep 17 00:00:00 2001 From: Jo Date: Mon, 6 Jul 2026 23:36:21 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20dupliquer=20un=20job=20+=20enregistrer?= =?UTF-8?q?=20et=20cr=C3=A9er=20un=20autre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 17 +++++++- templates/job_detail.html | 13 ++++-- templates/new_job.html | 84 ++++++++++++++++++++++++++++----------- 3 files changed, 84 insertions(+), 30 deletions(-) diff --git a/app.py b/app.py index 082adc9..c4e68d0 100644 --- a/app.py +++ b/app.py @@ -956,8 +956,19 @@ def new_job(): handling_profiles = conn.execute('SELECT * FROM handling_profiles ORDER BY name').fetchall() material_profiles = conn.execute('SELECT * FROM material_profiles ORDER BY name').fetchall() pricing_profiles = conn.execute('SELECT * FROM pricing_profiles ORDER BY name').fetchall() + projects = conn.execute('SELECT id,name FROM projects ORDER BY name').fetchall() settings = get_settings() + # Pré-remplissage depuis un job existant + prefill = None + clone_from = request.args.get('clone_from') + if clone_from: + prefill = conn.execute('SELECT * FROM jobs WHERE id=?', (clone_from,)).fetchone() + if prefill: + prefill = dict(prefill) + prefill['hours'] = prefill['print_time_s'] // 3600 + prefill['minutes'] = (prefill['print_time_s'] % 3600) // 60 + if request.method == 'POST': weight_g = float(request.form['weight_g']) hours = int(request.form.get('hours',0)) @@ -1026,17 +1037,19 @@ def new_job(): r['cotisations_amount'],r['vfl_amount'],r['tva_amount'],r['other_taxes_amount'], r['tax_amount'],r['final_price'],round(r['final_price'],2), request.form.get('notes',''))) + new_id = conn.execute('SELECT last_insert_rowid()').fetchone()[0] if material_id: conn.execute('UPDATE materials SET stock_g=MAX(0,stock_g-?) WHERE id=?', (weight_g, material_id)) conn.commit(); conn.close() + if request.form.get('action') == 'save_and_new': + return redirect(url_for('new_job', clone_from=new_id)) return redirect(url_for('jobs')) - projects = conn.execute('SELECT id,name FROM projects ORDER BY name').fetchall() conn.close() return render_template('new_job.html', clients=clients, materials=mats, settings=settings, machine_profiles=machine_profiles, handling_profiles=handling_profiles, material_profiles=material_profiles, pricing_profiles=pricing_profiles, - projects=projects) + projects=projects, prefill=prefill) @app.route('/jobs/') def job_detail(id): diff --git a/templates/job_detail.html b/templates/job_detail.html index 0c7069d..75e5c46 100644 --- a/templates/job_detail.html +++ b/templates/job_detail.html @@ -9,10 +9,15 @@

{{ job.name }}

-
- -
+
+ + Dupliquer + +
+ +
+
{% set qty = job.order_qty or 1 %} diff --git a/templates/new_job.html b/templates/new_job.html index 6bcf857..7c3a71e 100644 --- a/templates/new_job.html +++ b/templates/new_job.html @@ -34,15 +34,25 @@
Donnees impression
+ {% if prefill %} +
+
+ + Dupliqué depuis {{ prefill.name }} — modifiez les champs souhaités. +
+
+ {% endif %}
+ placeholder="ex: Marqueurs competition salle X" + value="{% if prefill %}Copie — {{ prefill.name }}{% endif %}">
+ placeholder="nom_fichier.3mf" + value="{{ prefill.source_file if prefill else '' }}">
@@ -51,7 +61,10 @@
@@ -61,7 +74,7 @@ {% for p in projects %} {% endfor %} @@ -74,7 +87,8 @@ {% for m in materials %} @@ -87,16 +101,19 @@
+ step="0.01" min="0.1" required placeholder="423.97" + value="{{ prefill.weight_g if prefill else '' }}">
Poids total du plateau Bambu (toutes pièces)
- +
- +
Temps total Bambu
@@ -104,13 +121,13 @@
+ min="1" step="1" value="{{ prefill.pieces_per_plate if prefill else 1 }}">
Combien de pièces tiennent sur un plateau.
+ min="1" step="1" value="{{ prefill.order_qty if prefill else 1 }}">
Nombre total de pièces à produire.
@@ -134,7 +151,10 @@ @@ -145,7 +165,10 @@ @@ -156,7 +179,8 @@ + class="form-control form-control-sm" step="0.05" min="0" + value="{{ prefill.design_multiplier if prefill else 1.80 }}">
+ min="0" max="100" step="0.5" + value="{{ prefill.gross_margin_pct if prefill else 27.5 }}">
0%100%
@@ -219,18 +246,24 @@
+ min="0" max="100" step="0.5" + value="{{ prefill.discount_pct if prefill else 0 }}">
- +
- +
+ + +
@@ -556,8 +589,11 @@ function renderBreakdown(d, body) { ` + capBlock; } -// Init -updateDMLabel(1.80); -updateMarginDisplay(27.5); +// Init — utiliser les valeurs du champ (prefill ou défaut) +const _initDM = parseFloat(document.getElementById('design_multiplier').value) || 1.80; +const _initMargin = parseFloat(document.getElementById('gross_margin_pct').value) ?? 27.5; +updateDMLabel(_initDM); +updateMarginDisplay(_initMargin); +if (document.getElementById('weight_g').value) recalc(); {% endblock %}