diff --git a/automatizaciones.html b/automatizaciones.html index 8b01e69..077c9ef 100644 --- a/automatizaciones.html +++ b/automatizaciones.html @@ -24,17 +24,16 @@
-

- + Buzón de Automatizaciones

-

Validación y limpieza quirúrgica de expedientes externos.

+

Gestión inteligente de expedientes externos.

- - + +
- +
@@ -101,14 +100,14 @@
-
- @@ -140,10 +139,10 @@ scrapedData = dataSvc.services || []; if(scrapedData.length === 0) { - container.innerHTML = `
+ container.innerHTML = `
-

Buzón al día

-

No hay nuevos expedientes para validar.

+

Todo al día

+

No hay expedientes para validar.

`; lucide.createIcons(); return; @@ -154,48 +153,32 @@ const raw = svc.raw_data || {}; const myMap = mappings.filter(m => m.provider === svc.provider); - // --- LÓGICA DE EXTRACCIÓN Y LIMPIEZA --- const rawName = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || ""; const rawAddr = raw[myMap.find(m => m.target_key === 'address')?.original_key] || ""; - - // Extraer CP y Población del campo CP capturado const rawCPField = raw[myMap.find(m => m.target_key === 'cp')?.original_key] || raw['Población_CP'] || ""; + const cpMatch = rawCPField.match(/\b\d{5}\b/); const cpOnly = cpMatch ? cpMatch[0] : ""; const popOnly = rawCPField.replace(cpOnly, '').replace('-', '').trim(); - // Dirección final: Calle + Población const fullAddr = `${rawAddr} ${popOnly}`.trim(); - - const rawPhone = raw[myMap.find(m => m.target_key === 'phone')?.original_key] || raw['Teléfono'] || ""; - const cleanPhone = rawPhone.match(/[6789]\d{8}/) ? rawPhone.match(/[6789]\d{8}/)[0] : ""; - - // Lógica de Bloqueo (Candado) const isBlocked = (!rawName || rawName.toLowerCase().includes('expediente sin nombre') || !rawAddr); const shortProv = svc.provider === 'multiasistencia' ? 'MULTI' : 'HOME'; const card = document.createElement('div'); - card.className = `bg-white p-5 rounded-2xl border ${isBlocked ? 'border-slate-200 bg-slate-50/50' : 'border-slate-100 shadow-sm'} flex items-center justify-between hover:shadow-md transition-all fade-in group relative overflow-hidden`; + card.className = `bg-white p-5 rounded-2xl border ${isBlocked ? 'border-slate-200 opacity-60' : 'border-slate-100 shadow-sm'} flex items-center justify-between hover:shadow-md transition-all fade-in group relative overflow-hidden`; card.innerHTML = ` - ${isBlocked ? '
' : `
`} - -
-
+
+
${shortProv}

${isBlocked ? 'Expediente Bloqueado' : (rawName || 'S/N')}

-

- ${isBlocked ? 'Pendiente de liberación' : (fullAddr || 'Sin dirección')} +

+ ${isBlocked ? 'Pendiente de liberación' : (fullAddr || 'Sin dirección')}

- ${!isBlocked ? ` -
- #${svc.service_ref} - ${cleanPhone ? `${cleanPhone}` : ''} - ${cpOnly ? `${cpOnly}` : ''} -
` : ''}
@@ -203,14 +186,9 @@ ${!isBlocked ? ` - ` : ` + ` : `
`} @@ -232,9 +210,9 @@ const phoneVal = raw[myMap.find(m => m.target_key === 'phone')?.original_key] || raw['Teléfono'] || ""; const phoneMatch = phoneVal.match(/[6789]\d{8}/); document.getElementById('imp_phone').value = phoneMatch ? phoneMatch[0] : ""; - document.getElementById('imp_phone_extra').innerText = phoneVal !== (phoneMatch ? phoneMatch[0] : "") ? `Dato original capturado: ${phoneVal}` : ""; + document.getElementById('imp_phone_extra').innerText = phoneVal !== (phoneMatch ? phoneMatch[0] : "") ? `Capturado: ${phoneVal}` : ""; - // 2. SEPARAR CP Y POBLACIÓN DEL CAMPO CP + // 2. SEPARAR CP Y POBLACIÓN const rawAddr = raw[myMap.find(m => m.target_key === 'address')?.original_key] || ""; const rawCPField = raw[myMap.find(m => m.target_key === 'cp')?.original_key] || raw['Población_CP'] || ""; const cpMatch = rawCPField.match(/\b\d{5}\b/); @@ -244,15 +222,17 @@ document.getElementById('imp_address').value = `${rawAddr} ${popOnly}`.trim(); document.getElementById('imp_cp').value = cpOnly; - // 3. PROVEEDOR ACORTADO EN COMPAÑÍA - const cia = raw[myMap.find(m => m.target_key === 'compania')?.original_key] || raw['Compañía'] || ""; - const shortProv = svc.provider.toUpperCase() === 'MULTIASISTENCIA' ? 'MULTI' : 'HOME'; - document.getElementById('imp_company').value = `${shortProv} - ${cia}`; + // 3. DESCRIPCIÓN TÉCNICA (LIMPIEZA DE HISTORIAL) + let rawDesc = raw[myMap.find(m => m.target_key === 'descripcion')?.original_key] || raw['Descripción'] || ""; + // Cortamos el texto justo antes de la primera fecha de registro (formato 00/00/0000) + const idxDate = rawDesc.search(/\b\d{2}\/\d{2}\/\d{4}\b/); + const cleanDesc = idxDate !== -1 ? rawDesc.substring(0, idxDate).trim() : rawDesc; + document.getElementById('imp_desc').value = cleanDesc; + document.getElementById('imp_company').value = `${svc.provider === 'multiasistencia' ? 'MULTI' : 'HOME'} - ${raw[myMap.find(m => m.target_key === 'compania')?.original_key] || raw['Compañía'] || ""}`; document.getElementById('scrapedId').value = scrapedId; document.getElementById('imp_name').value = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || ""; document.getElementById('imp_ref').value = svc.service_ref; - document.getElementById('imp_desc').value = raw[myMap.find(m => m.target_key === 'descripcion')?.original_key] || raw['Descripción'] || ""; document.getElementById('imp_urgent').value = (raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true').toString(); document.getElementById('importModal').classList.remove('hidden');