Actualizar proveedores.html

This commit is contained in:
2026-03-14 14:26:02 +00:00
parent 5c83e8dcfa
commit ac2c74c6af

View File

@@ -672,21 +672,31 @@
}
document.getElementById('impScrapedId').value = id;
document.getElementById('impName').value = raw['Nombre Cliente'] || raw['CLIENTE'] || "S/N";
// 1. LEER PRIMERO DE LA RAÍZ (DATOS EDITADOS), LUEGO DEL RAW (DATOS ORIGINALES)
document.getElementById('impName').value = svc.name || raw['Nombre Cliente'] || raw['CLIENTE'] || "S/N";
const rawPhone = raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "";
document.getElementById('impPhone').value = rawPhone.match(/[6789]\d{8}/)?.[0] || "";
document.getElementById('impPhone').value = svc.phone || (rawPhone.match(/[6789]\d{8}/)?.[0] || "");
const addr = raw['Dirección'] || raw['DOMICILIO'] || "";
// 2. REPARACIÓN DE LA DIRECCIÓN DUPLICADA
const baseAddr = svc.address || 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'] || raw['C.P.'] || "";
document.getElementById('impDesc').value = raw['Descripción'] || "";
let finalAddr = baseAddr;
// Solo añadimos la población si hay población Y la dirección actual no la contiene ya
if (pop && !finalAddr.toLowerCase().includes(pop.toLowerCase())) {
finalAddr = `${finalAddr} ${pop}`.trim();
}
document.getElementById('impAddress').value = finalAddr;
document.getElementById('impCP').value = svc.cp || raw['Código Postal'] || raw['C.P.'] || "";
document.getElementById('impDesc').value = svc.description || raw['Descripción'] || "";
const isUrgent = svc.is_urgent === true || raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true' || raw['URGENTE'] === 'SI';
document.getElementById('impUrgent').value = isUrgent.toString();
document.getElementById('impNotesInt').value = raw['internal_notes'] || "";
document.getElementById('impNotesExt').value = raw['client_notes'] || "";
document.getElementById('impNotesInt').value = svc.internal_notes || raw['internal_notes'] || "";
document.getElementById('impNotesExt').value = svc.client_notes || raw['client_notes'] || "";
const rawGuildId = svc.guild_id || raw['guild_id'] || raw.guild_id;
document.getElementById('impGuild').value = rawGuildId ? String(rawGuildId) : "";