Actualizar automatizaciones.html

This commit is contained in:
2026-02-14 22:48:23 +00:00
parent 7d9bd8faf7
commit 282d1e2a77

View File

@@ -285,38 +285,50 @@
} }
function openEditor(id) { function openEditor(id) {
const svc = scrapedData.find(s => s.id === id); const svc = scrapedData.find(s => s.id === id);
if(!svc) return; if(!svc) return;
const raw = svc.raw_data; const raw = svc.raw_data;
const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || ""; const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "";
document.getElementById('modalCompanyLogo').innerHTML = `<img src="${getLogoUrl(companyName)}" class="max-w-full max-h-full object-contain">`; document.getElementById('modalCompanyLogo').innerHTML = `<img src="${getLogoUrl(companyName)}" class="max-w-full max-h-full object-contain">`;
document.getElementById('displayRef').innerText = `REF: ${svc.service_ref}`; document.getElementById('displayRef').innerText = `REF: ${svc.service_ref}`;
document.getElementById('displayCompany').innerText = companyName; document.getElementById('displayCompany').innerText = companyName;
document.getElementById('modalStatusBadge').innerHTML = `<span class="text-[9px] bg-emerald-50 text-emerald-600 px-3 py-1 rounded-full font-black border border-emerald-100">SERVICIO ACTIVO</span>`; document.getElementById('modalStatusBadge').innerHTML = `<span class="text-[9px] bg-emerald-50 text-emerald-600 px-3 py-1 rounded-full font-black border border-emerald-100">SERVICIO ACTIVO</span>`;
document.getElementById('impScrapedId').value = id; document.getElementById('impScrapedId').value = id;
document.getElementById('impName').value = raw['Nombre Cliente'] || raw['CLIENTE'] || "S/N"; document.getElementById('impName').value = 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] || ""; const rawPhone = raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "";
const addr = raw['Dirección'] || raw['DOMICILIO'] || ""; document.getElementById('impPhone').value = rawPhone.match(/[6789]\d{8}/)?.[0] || "";
const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || "";
document.getElementById('impAddress').value = `${addr} ${pop}`.trim(); const addr = raw['Dirección'] || raw['DOMICILIO'] || "";
document.getElementById('impCP').value = raw['Código Postal'] || raw['C.P.'] || ""; const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || "";
document.getElementById('impDesc').value = raw['Descripción'] || ""; document.getElementById('impAddress').value = `${addr} ${pop}`.trim();
document.getElementById('impCP').value = raw['Código Postal'] || raw['C.P.'] || "";
const isUrgent = raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true' || raw['URGENTE'] === 'SI'; document.getElementById('impDesc').value = raw['Descripción'] || "";
document.getElementById('impUrgent').value = isUrgent.toString();
const isUrgent = raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true' || raw['URGENTE'] === 'SI';
document.getElementById('impNotesInt').value = ""; document.getElementById('impUrgent').value = isUrgent.toString();
document.getElementById('impNotesExt').value = "";
document.getElementById('impGuild').value = ""; // RECUPERACIÓN DE DATOS GUARDADOS PREVIAMENTE
document.getElementById('impOperator').innerHTML = '<option value="">-- Automática --</option>'; document.getElementById('impNotesInt').value = raw['internal_notes'] || "";
document.getElementById('impNotesExt').value = raw['client_notes'] || "";
document.getElementById('importModal').classList.remove('hidden');
lucide.createIcons(); // Cargar Gremio y disparar carga de operarios si ya existía
} const savedGuild = raw['guild_id'] || "";
document.getElementById('impGuild').value = savedGuild;
if(savedGuild) {
loadOpsForGuild(savedGuild).then(() => {
document.getElementById('impOperator').value = raw['assigned_to'] || "";
});
} else {
document.getElementById('impOperator').innerHTML = '<option value="">-- Automática --</option>';
}
document.getElementById('importModal').classList.remove('hidden');
lucide.createIcons();
}
function closeModal() { document.getElementById('importModal').classList.add('hidden'); } function closeModal() { document.getElementById('importModal').classList.add('hidden'); }
async function saveDraftChanges(e) { async function saveDraftChanges(e) {