Actualizar automatizaciones.html
This commit is contained in:
@@ -285,38 +285,50 @@
|
||||
}
|
||||
|
||||
function openEditor(id) {
|
||||
const svc = scrapedData.find(s => s.id === id);
|
||||
if(!svc) return;
|
||||
const raw = svc.raw_data;
|
||||
const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "";
|
||||
const svc = scrapedData.find(s => s.id === id);
|
||||
if(!svc) return;
|
||||
const raw = svc.raw_data;
|
||||
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('displayRef').innerText = `REF: ${svc.service_ref}`;
|
||||
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('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('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('impScrapedId').value = id;
|
||||
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 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'] || raw['C.P.'] || "";
|
||||
document.getElementById('impDesc').value = raw['Descripción'] || "";
|
||||
document.getElementById('impScrapedId').value = id;
|
||||
document.getElementById('impName').value = raw['Nombre Cliente'] || raw['CLIENTE'] || "S/N";
|
||||
|
||||
const isUrgent = raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true' || raw['URGENTE'] === 'SI';
|
||||
document.getElementById('impUrgent').value = isUrgent.toString();
|
||||
const rawPhone = raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "";
|
||||
document.getElementById('impPhone').value = rawPhone.match(/[6789]\d{8}/)?.[0] || "";
|
||||
|
||||
document.getElementById('impNotesInt').value = "";
|
||||
document.getElementById('impNotesExt').value = "";
|
||||
document.getElementById('impGuild').value = "";
|
||||
document.getElementById('impOperator').innerHTML = '<option value="">-- Automática --</option>';
|
||||
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'] || raw['C.P.'] || "";
|
||||
document.getElementById('impDesc').value = raw['Descripción'] || "";
|
||||
|
||||
document.getElementById('importModal').classList.remove('hidden');
|
||||
lucide.createIcons();
|
||||
}
|
||||
const isUrgent = raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true' || raw['URGENTE'] === 'SI';
|
||||
document.getElementById('impUrgent').value = isUrgent.toString();
|
||||
|
||||
// RECUPERACIÓN DE DATOS GUARDADOS PREVIAMENTE
|
||||
document.getElementById('impNotesInt').value = raw['internal_notes'] || "";
|
||||
document.getElementById('impNotesExt').value = raw['client_notes'] || "";
|
||||
|
||||
// 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'); }
|
||||
|
||||
async function saveDraftChanges(e) {
|
||||
|
||||
Reference in New Issue
Block a user