fix: show multi-plate jobs in À planifier until all plateaux are scheduled
Deploy via Portainer / deploy (push) Successful in 0s

This commit is contained in:
Jo
2026-07-07 12:47:41 +02:00
parent b13d718d92
commit 1b740f9cee
2 changed files with 21 additions and 2 deletions
+11 -2
View File
@@ -1324,9 +1324,18 @@ def planning():
conn = get_db()
printers = [dict(r) for r in conn.execute('SELECT * FROM printers ORDER BY id').fetchall()]
unscheduled = conn.execute('''
SELECT j.*, c.name as client_name
SELECT j.*, c.name as client_name,
COALESCE((SELECT COUNT(*) FROM print_slots ps
WHERE ps.job_id=j.id
AND ps.status NOT IN ('cancelled','failed')), 0) as scheduled_plates,
(COALESCE(j.order_qty,1) + COALESCE(j.pieces_per_plate,1) - 1)
/ COALESCE(j.pieces_per_plate,1) as total_plates_needed
FROM jobs j LEFT JOIN clients c ON j.client_id=c.id
WHERE j.id NOT IN (SELECT DISTINCT job_id FROM print_slots WHERE status NOT IN ('cancelled','failed'))
WHERE (COALESCE(j.order_qty,1) + COALESCE(j.pieces_per_plate,1) - 1)
/ COALESCE(j.pieces_per_plate,1)
> COALESCE((SELECT COUNT(*) FROM print_slots ps
WHERE ps.job_id=j.id
AND ps.status NOT IN ('cancelled','failed')), 0)
ORDER BY j.created_at DESC LIMIT 20''').fetchall()
blocks = conn.execute(
"SELECT * FROM calendar_blocks"
+10
View File
@@ -49,6 +49,7 @@
{% if unscheduled %}
<div class="list-group list-group-flush">
{% for j in unscheduled %}
{% set missing = j.total_plates_needed - j.scheduled_plates %}
<div class="list-group-item py-2">
<div class="d-flex justify-content-between align-items-start">
<div>
@@ -58,6 +59,15 @@
{% if j.order_qty > 1 %} · ×{{ j.order_qty }} pièces{% endif %}
{% if j.client_name %} · {{ j.client_name }}{% endif %}
</div>
{% if j.total_plates_needed > 1 %}
<div class="mt-1">
<span class="badge bg-warning text-dark" style="font-size:.65rem">
<i class="bi bi-layers me-1"></i>
Plateau {{ j.scheduled_plates + 1 }}/{{ j.total_plates_needed }}
{% if missing > 1 %} · {{ missing }} restants{% endif %}
</span>
</div>
{% endif %}
</div>
<div class="d-flex gap-1">
<button class="btn btn-sm btn-outline-success py-0"