Suivi consommables : compteur papier, ruban et photos avec diagnostic ratio
- Onglet Consommables dans General : barres de progression papier/ruban, compteur photos - Capacites configurables (feuilles par bobine / poses par bobine) - Reset individuel papier/ruban (quand on change la bobine) - Diagnostic ratio ruban/papier pour verifier que le rembobinage fonctionne - Tracking automatique a chaque impression (format-aware) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1401,6 +1401,67 @@ async function chargerDiagCamera() {
|
||||
}
|
||||
}
|
||||
|
||||
// === CONSOMMABLES ===
|
||||
|
||||
async function chargerConsommables() {
|
||||
try {
|
||||
const data = await apiGet('/api/consommables');
|
||||
document.getElementById('conso-papier-restant').textContent = data.papier_restant;
|
||||
document.getElementById('conso-papier-cap').textContent = data.papier_capacite;
|
||||
document.getElementById('conso-ruban-restant').textContent = data.ruban_restant;
|
||||
document.getElementById('conso-ruban-cap').textContent = data.ruban_capacite;
|
||||
document.getElementById('conso-photos').textContent = data.photos_imprimees;
|
||||
setValue('conso-cap-papier', data.papier_capacite);
|
||||
setValue('conso-cap-ruban', data.ruban_capacite);
|
||||
|
||||
const pctPapier = data.papier_capacite > 0 ? Math.max(0, (data.papier_restant / data.papier_capacite) * 100) : 0;
|
||||
const pctRuban = data.ruban_capacite > 0 ? Math.max(0, (data.ruban_restant / data.ruban_capacite) * 100) : 0;
|
||||
|
||||
const barrePapier = document.getElementById('conso-barre-papier');
|
||||
const barreRuban = document.getElementById('conso-barre-ruban');
|
||||
barrePapier.style.width = pctPapier + '%';
|
||||
barreRuban.style.width = pctRuban + '%';
|
||||
barrePapier.style.background = pctPapier < 10 ? '#f44336' : pctPapier < 25 ? '#fb8c00' : '#43a047';
|
||||
barreRuban.style.background = pctRuban < 10 ? '#f44336' : pctRuban < 25 ? '#fb8c00' : '#43a047';
|
||||
|
||||
const diag = document.getElementById('conso-diagnostic');
|
||||
const papierUsed = data.papier_utilise;
|
||||
const rubanUsed = data.ruban_utilise;
|
||||
let html = '<strong>Diagnostic</strong><br>';
|
||||
html += `Feuilles consommees : ${papierUsed}<br>`;
|
||||
html += `Poses ruban consommees : ${rubanUsed}<br>`;
|
||||
html += `Photos imprimees : ${data.photos_imprimees}<br>`;
|
||||
if (papierUsed > 0) {
|
||||
const ratio = (rubanUsed / papierUsed).toFixed(2);
|
||||
html += `<br>Ratio ruban/papier : <strong>${ratio}</strong>`;
|
||||
if (parseFloat(ratio) <= 0.75) {
|
||||
html += ' ✅ Rembobinage actif (economie ruban)';
|
||||
} else if (parseFloat(ratio) >= 0.95) {
|
||||
html += ' ⚠ Ratio 1:1 — pas d\'economie ruban';
|
||||
}
|
||||
}
|
||||
diag.innerHTML = html;
|
||||
} catch (e) {
|
||||
console.warn('Erreur chargement consommables:', e);
|
||||
}
|
||||
}
|
||||
|
||||
async function resetConsommable(quoi) {
|
||||
const labels = { papier: 'Reinitialiser le compteur papier ?', ruban: 'Reinitialiser le compteur ruban ?', tout: 'Reinitialiser tous les compteurs ?' };
|
||||
if (!confirm(labels[quoi] || 'Reinitialiser ?')) return;
|
||||
await apiPost('/api/consommables/reset', { quoi });
|
||||
chargerConsommables();
|
||||
afficherStatut('Consommable reinitialise', 'succes');
|
||||
}
|
||||
|
||||
async function sauvegarderCapacites() {
|
||||
const papier = parseInt(getValue('conso-cap-papier')) || 400;
|
||||
const ruban = parseInt(getValue('conso-cap-ruban')) || 400;
|
||||
await apiPost('/api/consommables/capacite', { papier_capacite: papier, ruban_capacite: ruban });
|
||||
chargerConsommables();
|
||||
afficherStatut('Capacites sauvegardees', 'succes');
|
||||
}
|
||||
|
||||
// === VIDEOS DE SITUATION ===
|
||||
|
||||
async function chargerVideosAdmin() {
|
||||
|
||||
Reference in New Issue
Block a user