+
+
+
+
Validación de Expediente
+
+ REF: --
+ --
+
-
-
-
-
Teléfono Movil
-
+
+
+
+ Prioridad del Aviso
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-// CORRECCIÓN EN EL RENDERIZADO DEL LISTADO
-// Asegúrate de que en loadInbox() la imagen tenga un onError para evitar el cuadro blanco
-// card.innerHTML = `...

name.includes(key));
+ return keyFound ? companyLogos[keyFound] : companyLogos['DEFAULT'];
+ }
document.addEventListener("DOMContentLoaded", async () => {
if (!localStorage.getItem("token")) window.location.href = "index.html";
@@ -214,21 +183,25 @@
});
async function loadGuilds() {
- const res = await fetch(`${API_URL}/guilds`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
- const data = await res.json();
- allGuilds = data.guilds || [];
- const sel = document.getElementById('impGuild');
- sel.innerHTML = '
';
- allGuilds.forEach(g => sel.innerHTML += `
`);
+ try {
+ const res = await fetch(`${API_URL}/guilds`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
+ const data = await res.json();
+ allGuilds = data.guilds || [];
+ const sel = document.getElementById('impGuild');
+ sel.innerHTML = '
';
+ allGuilds.forEach(g => sel.innerHTML += `
`);
+ } catch(e) {}
}
async function loadOpsForGuild(guildId) {
const sel = document.getElementById('impOperator');
if(!guildId) { sel.innerHTML = '
'; return; }
- const res = await fetch(`${API_URL}/operators?guild_id=${guildId}`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
- const data = await res.json();
- sel.innerHTML = '
';
- data.operators.forEach(op => sel.innerHTML += `
`);
+ try {
+ const res = await fetch(`${API_URL}/operators?guild_id=${guildId}`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
+ const data = await res.json();
+ sel.innerHTML = '
';
+ data.operators.forEach(op => sel.innerHTML += `
`);
+ } catch(e) {}
}
async function loadInbox() {
@@ -253,19 +226,18 @@
const addr = raw['Dirección'] || raw['DOMICILIO'] || "";
const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || "";
const fullAddr = `${addr} ${pop}`.trim();
- const companyName = raw['Compañía'] || raw['COMPAÑIA'] || "";
- const logoUrl = getLogoUrl(companyName); //
+ const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "";
const phone = (raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "").match(/[6789]\d{8}/)?.[0] || "";
const isBlocked = (!name || name.toUpperCase().includes('SIN NOMBRE') || !addr);
const card = document.createElement('div');
- card.className = `bg-white p-5 rounded-2xl border ${isBlocked ? 'opacity-50' : 'shadow-sm hover:border-blue-300'} flex items-center justify-between transition-all group fade-in`;
+ card.className = `bg-white p-5 rounded-2xl border ${isBlocked ? 'opacity-50' : 'shadow-sm hover:border-blue-300'} flex items-center justify-between transition-all group fade-in text-left`;
card.innerHTML = `
-

+
-
+
${isBlocked ? 'Bloqueado' : name}
${svc.provider === 'multiasistencia' ? 'MULTI' : 'HOME'}
@@ -276,12 +248,12 @@
${!isBlocked ? `
-
+
${phone ? `
-
-
+
+
` : ''}
-
+
` : '
'}
`;
container.appendChild(card);
@@ -294,29 +266,30 @@
const svc = scrapedData.find(s => s.id === id);
if(!svc) return;
const raw = svc.raw_data;
- const companyName = raw['Compañía'] || raw['COMPAÑIA'] || "";
- const logoUrl = getLogoUrl(companyName); //
-
- // ACTUALIZACIÓN DE CABECERA
+ const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "";
+
document.getElementById('displayRef').innerText = `REF: ${svc.service_ref}`;
- document.getElementById('displayCompany').innerText = companyName || svc.provider.toUpperCase();
- document.getElementById('modalCompanyLogo').innerHTML = `

`;
+ document.getElementById('displayCompany').innerText = companyName;
+ document.getElementById('modalCompanyLogo').innerHTML = `
})
`;
- // RELLENAR FORMULARIO
document.getElementById('impScrapedId').value = id;
- document.getElementById('impName').value = raw['Nombre Cliente'] || raw['CLIENTE'] || "";
+ 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'] || "";
+ document.getElementById('impCP').value = raw['Código Postal'] || raw['C.P.'] || "";
document.getElementById('impDesc').value = raw['Descripción'] || "";
- document.getElementById('impUrgent').value = (raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true').toString();
+
+ const isUrgent = raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true' || raw['URGENTE'] === 'SI';
+ document.getElementById('impUrgent').value = isUrgent.toString();
document.getElementById('impNotesInt').value = "";
document.getElementById('impNotesExt').value = "";
document.getElementById('impGuild').value = "";
+ document.getElementById('impOperator').innerHTML = '
';
+
document.getElementById('importModal').classList.remove('hidden');
lucide.createIcons();
}
@@ -334,7 +307,7 @@
address: document.getElementById('impAddress').value,
cp: document.getElementById('impCP').value,
description: document.getElementById('impDesc').value,
- company_ref: document.getElementById('displayRef').innerText.replace('REF: ', ''),
+ company_ref: document.getElementById('displayRef').innerText.replace('REF: ', '').replace('# ', ''),
guild_id: document.getElementById('impGuild').value,
assigned_to: document.getElementById('impOperator').value || null,
internal_notes: document.getElementById('impNotesInt').value,
@@ -350,7 +323,7 @@
});
const result = await res.json();
if(result.ok) {
- showToast("✅ Expediente traspasado con éxito");
+ showToast("✅ Traspasado con éxito");
closeModal();
loadInbox();
} else { showToast("❌ Error al importar", true); }