From 51dec7b73a244acf1bb2074f508fb266ff384694 Mon Sep 17 00:00:00 2001 From: marsalva Date: Sat, 14 Feb 2026 11:02:31 +0000 Subject: [PATCH] Actualizar automatizaciones.html --- automatizaciones.html | 57 ++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/automatizaciones.html b/automatizaciones.html index a6cd25e..d8c7889 100644 --- a/automatizaciones.html +++ b/automatizaciones.html @@ -210,31 +210,42 @@ } catch (e) { showToast("Error de conexión", true); } } - function openEditor(id) { - const svc = scrapedData.find(s => s.id === id); - if(!svc) return; - const raw = svc.raw_data; + function openEditor(id) { + const svc = scrapedData.find(s => s.id === id); + if(!svc) return; + const raw = svc.raw_data; - // SINCRONIZACIÓN DE TODOS LOS IDS DEL FORMULARIO - document.getElementById('impScrapedId').value = id; - document.getElementById('impName').value = raw['Nombre Cliente'] || ""; - document.getElementById('impPhone').value = (raw['Teléfono'] || "").match(/[6789]\d{8}/)?.[0] || ""; - document.getElementById('impAddress').value = `${raw['Dirección'] || ""} ${raw['Población'] || ""}`.trim(); - document.getElementById('impCP').value = raw['Código Postal'] || ""; - document.getElementById('impDesc').value = raw['Descripción'] || ""; - document.getElementById('impRef').value = svc.service_ref; - document.getElementById('impCompany').value = raw['Compañía'] || svc.provider.toUpperCase(); - document.getElementById('impUrgent').value = (raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true').toString(); - - // Campos adicionales vacíos por defecto - document.getElementById('impNotesInt').value = ""; - document.getElementById('impNotesExt').value = ""; - document.getElementById('impGuild').value = ""; - document.getElementById('impOperator').innerHTML = ''; + // SINCRONIZACIÓN DE TODOS LOS IDS DEL FORMULARIO + document.getElementById('impScrapedId').value = id; + document.getElementById('impName').value = raw['Nombre Cliente'] || raw['CLIENTE'] || ""; + + // CORRECCIÓN: Busca el teléfono en todas las variantes posibles (singular, plural, inglés) + const rawPhone = raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || raw['phone'] || ""; + document.getElementById('impPhone').value = rawPhone.match(/[6789]\d{8}/)?.[0] || ""; + + // Dirección y Población unificadas + const addr = raw['Dirección'] || raw['DOMICILIO'] || ""; + const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || ""; + document.getElementById('impAddress').value = `${addr} ${pop}`.trim(); + + document.getElementById('impCP').value = raw['Código Postal'] || ""; + document.getElementById('impDesc').value = raw['Descripción'] || ""; + document.getElementById('impRef').value = svc.service_ref; + + // Identificar compañía correctamente + document.getElementById('impCompany').value = raw['Compañía'] || raw['COMPAÑIA'] || svc.provider.toUpperCase(); + + document.getElementById('impUrgent').value = (raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true').toString(); + + // Campos adicionales vacíos por defecto + document.getElementById('impNotesInt').value = ""; + document.getElementById('impNotesExt').value = ""; + document.getElementById('impGuild').value = ""; + document.getElementById('impOperator').innerHTML = ''; - document.getElementById('importModal').classList.remove('hidden'); - lucide.createIcons(); - } + document.getElementById('importModal').classList.remove('hidden'); + lucide.createIcons(); +} function closeModal() { document.getElementById('importModal').classList.add('hidden'); }