diff --git a/panel.html b/panel.html index c840131..79b23e1 100644 --- a/panel.html +++ b/panel.html @@ -25,7 +25,7 @@
-
+
@@ -40,42 +40,51 @@
-
+
-
+

Activos Totales

-

-

-

Expedientes en marcha

+

-

+

Expedientes en marcha

-
+
-

Buscando Operario

+

Sin Asignar

+
+
+

-

+

Muertos en bandeja

+
+ +
+
+

En Rueda

-

-

-

En rueda de WhatsApp

+

-

+

Buscando Operario

-
+
-

Pendiente Cita

+

Sin Agendar

-

-

-

Asignados sin agendar

+

-

+

Asignados sin cita

-
+
-

Visitas de Hoy

+

Citas de Hoy

-

-

-

Programadas para hoy

+

-

+

Programadas para hoy

@@ -117,7 +126,7 @@ const resActive = await fetch(`${API_URL}/services/active`, { headers: { "Authorization": `Bearer ${token}` } }); const dataActive = await resActive.json(); - // 2. Pedimos los datos de Proveedores (para saber cuántos están en cola buscando) + // 2. Pedimos los datos de Proveedores (para saber cuántos están en bandeja y en cola) const resScraped = await fetch(`${API_URL}/providers/scraped`, { headers: { "Authorization": `Bearer ${token}` } }); const dataScraped = await resScraped.json(); @@ -136,20 +145,24 @@ // --- CÁLCULO DE KPIs --- - // Expedientes en rueda automatizada (in_progress) - const queueCount = scrapedServices.filter(s => s.automation_status === 'in_progress' && s.status !== 'archived').length; + // 1. SIN ASIGNAR (En bandeja de entrada, status pending, sin mandar a la rueda automatizada) + const unassignedCount = scrapedServices.filter(s => s.status === 'pending' && s.automation_status !== 'in_progress').length; + + // 2. EN RUEDA (Buscando operario en automático) + const queueCount = scrapedServices.filter(s => s.status === 'pending' && s.automation_status === 'in_progress').length; - // Asignados a operario pero que aún no han puesto fecha de cita + // 3. ASIGNADOS PERO SIN FECHA (En el Panel Operativo, columna izquierda) const pendingCount = activeServices.filter(s => s.estado_operativo === 'asignado_operario').length; - // Visitas programadas exactamente para hoy + // 4. CITAS DE HOY (Tienen programada la visita para la fecha de hoy) const todayVisits = activeServices.filter(s => s.raw_data && s.raw_data.scheduled_date === todayStr); - // Total general (Activos operativos + En cola) - const totalActive = activeServices.length + queueCount; + // 5. TOTAL GENERAL (Todo lo que no está archivado ni terminado de forma permanente) + const totalActive = activeServices.length + queueCount + unassignedCount; - // Pintar los números + // Pintar los números con animación animateValue("kpiTotal", totalActive); + animateValue("kpiUnassigned", unassignedCount); animateValue("kpiQueue", queueCount); animateValue("kpiPending", pendingCount); animateValue("kpiToday", todayVisits.length); @@ -179,12 +192,13 @@ const time = raw.scheduled_time ? raw.scheduled_time.substring(0,5) : "--:--"; const op = s.assigned_name || "Sin Asignar"; const name = raw['Nombre Cliente'] || raw['CLIENTE'] || "Asegurado"; - const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || "Dirección"; + const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || "Dirección no especificada"; const ref = s.service_ref; // Color según estado (por si está trabajando o ya terminó el de hoy) let statusColor = "bg-blue-50 text-blue-600"; if(raw.status_operativo === 'trabajando') statusColor = "bg-amber-50 text-amber-600"; + if(raw.status_operativo === 'incidencia') statusColor = "bg-red-50 text-red-600"; if(raw.status_operativo === 'terminado') statusColor = "bg-emerald-50 text-emerald-600"; return ` @@ -194,7 +208,10 @@ ${time}
-

${name}

+
+

${name}

+ #${ref} +

${pop}