-
-
-
Asignar a Mano:
-
-
+
+
+
+
@@ -318,7 +408,7 @@
setInterval(refreshPanel, 20000);
});
- // Helpers de Fechas para el filtro de semanas
+ // Helpers de Fechas
function getWeekNumber(d) {
d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay()||7));
@@ -335,7 +425,6 @@
return targetWeekStr === weekStr;
}
- // 1. CARGAMOS LOS ESTADOS DEL SISTEMA
async function loadStatuses() {
try {
const res = await fetch(`${API_URL}/statuses`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
@@ -353,7 +442,6 @@
} catch (e) { console.error("Error cargando estados:", e); }
}
- // 2. RENDERIZAR BOTONERA DE ESTADOS (CHIPS)
function renderStatusPills() {
const container = document.getElementById('statusPills');
let html = `
@@ -364,13 +452,9 @@
systemStatuses.forEach(st => {
const isActive = activeStatusFilter === String(st.id);
- // Usamos tu diccionario directamente para evitar fallos de Tailwind
const c = colorDict[st.color] || colorDict['gray'];
-
- // Extraemos el nombre del color base (ej: de 'bg-blue-100' sacamos 'blue')
const colorBase = c.bg.split('-')[1];
- // Clases seguras
const activeClasses = `bg-white border-${colorBase}-400 text-${colorBase}-700 shadow-md ring-2 ring-${colorBase}-100`;
const inactiveClasses = `bg-white border-slate-200 text-slate-500 hover:bg-slate-50`;
@@ -397,9 +481,7 @@
});
const data = await res.json();
if (data.ok) {
- // FILTRAR BLOQUEOS PARA QUE NO ENSUCIEN EL PANEL NI LAS ESTADÍSTICAS
localData = data.services.filter(s => s.provider !== 'SYSTEM_BLOCK');
-
updateOperatorFilter();
renderLists();
}
@@ -416,9 +498,6 @@
if (html.includes(`value="${currentValue}"`)) opSelect.value = currentValue;
}
- // ==========================================
- // 🚀 LÓGICA INTELIGENTE DE ENRUTAMIENTO (ESTADOS)
- // ==========================================
function getServiceStateInfo(s) {
const raw = s.raw_data || {};
const dbStat = raw.status_operativo;
@@ -484,7 +563,6 @@
const stateInfo = getServiceStateInfo(s);
s._stateInfo = stateInfo;
- // --- CÁLCULO DE KPIs (Solo para los bloques de colores superiores) ---
const stName = stateInfo.name.toLowerCase();
if (stateInfo.id === 'bolsa' || stName.includes('pendiente de asignar') || stName.includes('desasignado')) {
@@ -497,41 +575,27 @@
kpiWaiting++;
}
- // --- FILTROS DE BÚSQUEDA ---
const matchesSearch = searchTerm === "" || name.includes(searchTerm) || ref.includes(searchTerm) || addr.includes(searchTerm) || pop.includes(searchTerm) || phone.includes(searchTerm) || comp.includes(searchTerm);
const matchesOp = selectedOp === "ALL" || assigned === selectedOp;
- // --- FILTRO DE SEMANAS ---
let matchesWeek = true;
if (weekValue !== "") {
- if (dateRaw) {
- matchesWeek = isDateInWeekString(dateRaw, weekValue);
- } else {
- matchesWeek = false; // Si hay filtro de semana y no tiene fecha, lo ocultamos
- }
+ if (dateRaw) matchesWeek = isDateInWeekString(dateRaw, weekValue);
+ else matchesWeek = false;
}
- // --- FILTRO DE ESTADOS (El culpable arreglado) ---
let matchesStatus = false;
-
- if (activeStatusFilter === "ALL") {
- // MODO DIOS: Si estás en "TODOS", muestra TODO.
- matchesStatus = true;
- } else {
- // Si pinchas un filtro concreto, comprueba que el ID coincida
- matchesStatus = String(stateInfo.id) === activeStatusFilter;
- }
+ if (activeStatusFilter === "ALL") matchesStatus = true;
+ else matchesStatus = String(stateInfo.id) === activeStatusFilter;
return matchesSearch && matchesOp && matchesWeek && matchesStatus;
});
- // Pintar contadores
document.getElementById('kpi-unassigned').innerText = kpiUnassigned;
document.getElementById('kpi-scheduled').innerText = kpiScheduled;
document.getElementById('kpi-waiting').innerText = kpiWaiting;
document.getElementById('kpi-incident').innerText = kpiIncident;
- // Pintar Tarjetas
const grid = document.getElementById('servicesGrid');
grid.innerHTML = filteredData.length > 0
? filteredData.map(s => buildGridCard(s)).join('')
@@ -603,10 +667,6 @@
`;
}
- // ==========================================
- // FUNCIONES DE MODALES Y ACCIONES
- // ==========================================
-
function shakeCard(element, status) {
element.classList.add('shake');
setTimeout(() => element.classList.remove('shake'), 400);
@@ -810,9 +870,13 @@
e.preventDefault();
const action = e.submitter.value;
const data = {
- phone: document.getElementById('nPhone').value, name: document.getElementById('nName').value,
- address: document.getElementById('nAddr').value, description: document.getElementById('nDesc').value,
- guild_id: document.getElementById('nGuild').value, assigned_to: document.getElementById('nWorker').value || null
+ phone: document.getElementById('nPhone').value,
+ name: document.getElementById('nName').value,
+ address: document.getElementById('nAddr').value,
+ description: document.getElementById('nDesc').value,
+ guild_id: document.getElementById('nGuild').value,
+ assigned_to: document.getElementById('nWorker').value || null,
+ duration_minutes: document.getElementById('nDuration').value // <--- CAPTURA DE DURACIÓN
};
try {
const res = await fetch(`${API_URL}/services/manual-high`, {