From 9c5f045ca01ae35ebb089015b76af4c7db3a1eb1 Mon Sep 17 00:00:00 2001 From: marsalva Date: Sun, 27 Sep 2026 17:36:52 +0000 Subject: [PATCH] Filtro Citados + Con Retraso en servicios.html --- servicios.html | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/servicios.html b/servicios.html index 3b1043b..fe3a663 100644 --- a/servicios.html +++ b/servicios.html @@ -95,7 +95,7 @@ Cargando estados... -
+
@@ -113,10 +113,17 @@
-

Pte. Inicio

+

Citados

0

+
+
+
+

Con Retraso

+

0

+
+
@@ -726,6 +733,7 @@ let kpiPendingStart = 0; let kpiWorking = 0; let kpiFinished = 0; + let kpiLate = 0; const filteredData = localData.filter(s => { const raw = s.raw_data || {}; @@ -737,7 +745,20 @@ const hasDate = raw.scheduled_date && raw.scheduled_date.trim() !== ""; const isFinal = stateInfo.is_final || stName.includes('finaliza') || stName.includes('anulad') || stName.includes('terminad') || s.status === 'archived'; - let category = 'none'; + let isLate = false; + let daysLate = 0; + if (!isFinal && raw.scheduled_date && raw.scheduled_date.trim() !== "") { + const schedDate = new Date(raw.scheduled_date + 'T00:00:00'); + const today = new Date(); + today.setHours(0,0,0,0); + const diffDays = Math.floor((today - schedDate) / 86400000); + if (diffDays > 2) { isLate = true; daysLate = diffDays; } + } + s._isLate = isLate; + s._daysLate = daysLate; + if (isLate) kpiLate++; + + let category = 'none'; if (isFinal) { kpiFinished++; category = 'finished'; } else if (!s.assigned_to || stateInfo.id === 'bolsa' || stName.includes('asignar')) { kpiUnassigned++; category = 'unassigned'; } @@ -774,9 +795,11 @@ matchesKpi = true; // ๐Ÿ›‘ NUEVO: Si has tocado una pastilla, las cajas grandes ya no filtran } else if (activeKpiFilter === 'ACTIVE') { matchesKpi = category !== 'finished'; - } else { - matchesKpi = category === activeKpiFilter; - } + } else if (activeKpiFilter === 'late') { + matchesKpi = isLate; + } else { + matchesKpi = category === activeKpiFilter; + } return matchesSearch && matchesOp && matchesWeek && matchesStatus && matchesKpi; }); @@ -786,6 +809,7 @@ document.getElementById('kpi-pending-start').innerText = kpiPendingStart; document.getElementById('kpi-working').innerText = kpiWorking; document.getElementById('kpi-finished').innerText = kpiFinished; + document.getElementById('kpi-late').innerText = kpiLate; ['unassigned', 'unscheduled', 'pending_start', 'working', 'finished'].forEach(k => { const box = document.getElementById(`box-${k}`); @@ -795,7 +819,13 @@ } }); - const grid = document.getElementById('servicesGrid'); + +const lateBox = document.getElementById('box-late'); +if (lateBox) { + if (activeKpiFilter === 'late') lateBox.classList.add('ring-2', 'ring-red-500', 'bg-red-50'); + else lateBox.classList.remove('ring-2', 'ring-red-500', 'bg-red-50'); +} +const grid = document.getElementById('servicesGrid'); grid.innerHTML = filteredData.length > 0 ? filteredData.map(s => buildGridCard(s)).join('') : `
@@ -885,9 +915,9 @@
${s.assigned_name || 'Sin asignar'}
-
- - ${raw.scheduled_date ? cita.split('|')[0] : 'Pte. Cita'} +
+ + ${raw.scheduled_date ? cita.split('|')[0] : 'Pte. Cita'}${s._isLate ? ' ยท ' + s._daysLate + 'D RETRASO' : ''}
`;