Actualizar automatizaciones.html

This commit is contained in:
2026-02-14 11:59:04 +00:00
parent 3455d10d69
commit ce9a102dbd

View File

@@ -15,9 +15,9 @@
.action-btn:hover:not(:disabled) { transform: translateY(-2px); } .action-btn:hover:not(:disabled) { transform: translateY(-2px); }
</style> </style>
</head> </head>
<body class="bg-gray-50 text-gray-800 font-sans antialiased overflow-hidden"> <body class="bg-gray-50 text-gray-800 font-sans antialiased overflow-hidden text-left">
<div class="flex h-screen overflow-hidden"> <div class="flex h-screen overflow-hidden text-left">
<div id="sidebar-container" class="h-full shrink-0"></div> <div id="sidebar-container" class="h-full shrink-0"></div>
<div class="flex-1 flex flex-col overflow-hidden relative"> <div class="flex-1 flex flex-col overflow-hidden relative">
@@ -31,9 +31,9 @@
<span class="bg-blue-600 p-2.5 rounded-xl text-white shadow-lg"><i data-lucide="bot"></i></span> <span class="bg-blue-600 p-2.5 rounded-xl text-white shadow-lg"><i data-lucide="bot"></i></span>
Buzón de Automatizaciones Buzón de Automatizaciones
</h2> </h2>
<p class="text-sm text-slate-500 mt-1 font-medium">Validación rápida y profesional de expedientes.</p> <p class="text-sm text-slate-500 mt-1 font-medium text-left">Expedientes capturados listos para procesar.</p>
</div> </div>
<button onclick="loadInbox()" class="bg-white border-2 border-slate-200 hover:border-blue-600 hover:text-blue-600 text-slate-600 px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 transition-all shadow-sm"> <button onclick="loadInbox()" class="bg-white border-2 border-slate-200 hover:border-blue-600 hover:text-blue-600 text-slate-600 px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 transition-all active:scale-95 shadow-sm">
<i data-lucide="refresh-cw" class="w-4 h-4"></i> Actualizar <i data-lucide="refresh-cw" class="w-4 h-4"></i> Actualizar
</button> </button>
</div> </div>
@@ -45,15 +45,15 @@
</div> </div>
<div id="importModal" class="fixed inset-0 bg-slate-900/70 hidden z-[100] flex items-center justify-center backdrop-blur-md p-2"> <div id="importModal" class="fixed inset-0 bg-slate-900/70 hidden z-[100] flex items-center justify-center backdrop-blur-md p-2">
<div class="bg-white rounded-[2.5rem] shadow-2xl w-full max-w-4xl flex flex-col max-h-[95vh] overflow-hidden border border-slate-200 fade-in text-left"> <div class="bg-white rounded-[2.5rem] shadow-2xl w-full max-w-4xl flex flex-col max-h-[95vh] overflow-hidden border border-slate-200 fade-in">
<div class="px-8 pt-6 pb-4 flex justify-between items-center border-b border-slate-50"> <div class="px-8 pt-6 pb-4 flex justify-between items-center border-b border-slate-50">
<div class="flex items-center gap-4"> <div class="flex items-center gap-4 text-left">
<div id="modalCompanyLogo" class="w-12 h-12 rounded-xl bg-slate-50 border border-slate-100 p-2 flex items-center justify-center shadow-sm overflow-hidden"></div> <div id="modalCompanyLogo" class="w-12 h-12 rounded-xl bg-slate-50 border border-slate-100 p-2 flex items-center justify-center shadow-sm overflow-hidden"></div>
<div> <div>
<h3 class="text-xl font-black text-slate-800 tracking-tight">Validación de Expediente</h3> <h3 class="text-xl font-black text-slate-800 tracking-tight">Validación de Expediente</h3>
<div class="flex items-center gap-2 mt-0.5"> <div class="flex items-center gap-2 mt-0.5">
<span id="displayRef" class="text-[10px] bg-slate-100 text-slate-500 px-2 py-0.5 rounded-lg font-bold border border-slate-200"># --</span> <span id="displayRef" class="text-[10px] bg-slate-100 text-slate-500 px-2 py-0.5 rounded-lg font-bold border border-slate-200 uppercase">REF: --</span>
<span id="displayCompany" class="text-[10px] bg-blue-50 text-blue-600 px-2 py-0.5 rounded-lg font-bold border border-blue-100 uppercase truncate max-w-[250px]">--</span> <span id="displayCompany" class="text-[10px] bg-blue-50 text-blue-600 px-2 py-0.5 rounded-lg font-bold border border-blue-100 uppercase truncate max-w-[250px]">--</span>
</div> </div>
</div> </div>
@@ -73,21 +73,21 @@
</div> </div>
</div> </div>
<form id="importForm" onsubmit="handleFinalImport(event)" class="px-8 py-6 space-y-5 overflow-y-auto no-scrollbar"> <form id="importForm" onsubmit="handleFinalImport(event)" class="px-8 py-6 space-y-5 overflow-y-auto no-scrollbar text-left">
<input type="hidden" id="impScrapedId"> <input type="hidden" id="impScrapedId">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-slate-50/50 p-3 rounded-2xl border border-slate-100 flex items-center gap-3"> <div class="bg-slate-50/50 p-3 rounded-2xl border border-slate-100 flex items-center gap-3">
<div class="bg-white p-2 rounded-xl shadow-sm text-slate-400"><i data-lucide="user" class="w-4 h-4"></i></div> <div class="bg-white p-2 rounded-xl shadow-sm text-slate-400"><i data-lucide="user"></i></div>
<div class="flex flex-col min-w-0 w-full"> <div class="flex flex-col min-w-0 w-full">
<span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Titular Asegurado</span> <span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Titular Asegurado</span>
<input type="text" id="impName" readonly class="bg-transparent border-none p-0 text-sm font-bold text-slate-700 outline-none focus:ring-0 truncate w-full"> <input type="text" id="impName" readonly class="bg-transparent border-none p-0 text-sm font-bold text-slate-700 outline-none focus:ring-0 truncate w-full">
</div> </div>
</div> </div>
<div class="bg-slate-50/50 p-3 rounded-2xl border border-slate-100 flex items-center gap-3"> <div class="bg-slate-50/50 p-3 rounded-2xl border border-slate-100 flex items-center gap-3">
<div class="bg-white p-2 rounded-xl shadow-sm text-emerald-500"><i data-lucide="phone" class="w-4 h-4"></i></div> <div class="bg-white p-2 rounded-xl shadow-sm text-emerald-500"><i data-lucide="phone"></i></div>
<div class="flex flex-col min-w-0 w-full"> <div class="flex flex-col min-w-0 w-full">
<span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Teléfono Movil</span> <span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Teléfono Móvil</span>
<input type="text" id="impPhone" readonly class="bg-transparent border-none p-0 text-sm font-black text-emerald-600 outline-none focus:ring-0 w-full"> <input type="text" id="impPhone" readonly class="bg-transparent border-none p-0 text-sm font-black text-emerald-600 outline-none focus:ring-0 w-full">
</div> </div>
</div> </div>
@@ -116,14 +116,14 @@
<div class="space-y-1"> <div class="space-y-1">
<label class="text-[9px] font-black text-slate-400 uppercase tracking-widest ml-2">Asignación Operario</label> <label class="text-[9px] font-black text-slate-400 uppercase tracking-widest ml-2">Asignación Operario</label>
<select id="impOperator" class="w-full border border-blue-100 bg-white px-3 py-2 rounded-xl text-sm font-bold shadow-sm outline-none focus:ring-2 focus:ring-blue-400"> <select id="impOperator" class="w-full border border-blue-100 bg-white px-3 py-2 rounded-xl text-sm font-bold shadow-sm outline-none focus:ring-2 focus:ring-blue-400">
<option value="">-- Automática (Futuro) --</option> <option value="">-- Automática --</option>
</select> </select>
</div> </div>
</div> </div>
<div class="space-y-3"> <div class="space-y-3 text-left">
<div class="space-y-1"> <div class="space-y-1">
<label class="text-[9px] font-black text-slate-400 uppercase tracking-widest ml-2">Descripción Limpia de la Avería</label> <label class="text-[9px] font-black text-slate-400 uppercase tracking-widest ml-2">Avería Detectada</label>
<textarea id="impDesc" rows="2" class="w-full border border-slate-200 bg-white px-4 py-2 rounded-2xl text-sm font-medium text-slate-600 outline-none focus:border-blue-400 resize-none shadow-sm"></textarea> <textarea id="impDesc" rows="2" class="w-full border border-slate-200 bg-white px-4 py-2 rounded-2xl text-sm font-medium text-slate-600 outline-none focus:border-blue-400 resize-none shadow-sm"></textarea>
</div> </div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
@@ -132,7 +132,7 @@
<textarea id="impNotesInt" rows="1" class="w-full border border-amber-100 bg-amber-50/30 px-3 py-2 rounded-xl text-xs outline-none focus:bg-white"></textarea> <textarea id="impNotesInt" rows="1" class="w-full border border-amber-100 bg-amber-50/30 px-3 py-2 rounded-xl text-xs outline-none focus:bg-white"></textarea>
</div> </div>
<div> <div>
<label class="text-[9px] font-black text-blue-500 uppercase ml-2 mb-1 block">Instrucciones Operario/Clte</label> <label class="text-[9px] font-black text-blue-500 uppercase ml-2 mb-1 block">Instrucciones Operario</label>
<textarea id="impNotesExt" rows="1" class="w-full border border-blue-100 bg-blue-50/30 px-3 py-2 rounded-xl text-xs outline-none focus:bg-white"></textarea> <textarea id="impNotesExt" rows="1" class="w-full border border-blue-100 bg-blue-50/30 px-3 py-2 rounded-xl text-xs outline-none focus:bg-white"></textarea>
</div> </div>
</div> </div>
@@ -146,10 +146,16 @@
</div> </div>
</form> </form>
</div> </div>
</div> </div>
<script> <div id="toast" class="fixed bottom-8 right-8 bg-slate-900 text-white px-8 py-4 rounded-2xl shadow-2xl hidden z-[200] border border-white/10"><span id="toastMsg" class="font-bold text-sm"></span></div>
// Diccionario de logos mejorado con SegurCaixa
<script src="js/layout.js"></script>
<script>
let allGuilds = [];
let scrapedData = [];
// DICCIONARIO DE LOGOS (Google Fetcher)
const companyLogos = { const companyLogos = {
'REPSOL': 'https://www.google.com/s2/favicons?domain=repsol.com&sz=128', 'REPSOL': 'https://www.google.com/s2/favicons?domain=repsol.com&sz=128',
'MUTUA': 'https://www.google.com/s2/favicons?domain=mutua.es&sz=128', 'MUTUA': 'https://www.google.com/s2/favicons?domain=mutua.es&sz=128',
@@ -164,49 +170,12 @@
'DEFAULT': 'https://cdn-icons-png.flaticon.com/512/2875/2875438.png' 'DEFAULT': 'https://cdn-icons-png.flaticon.com/512/2875/2875438.png'
}; };
function openEditor(id) { function getLogoUrl(companyName) {
const svc = scrapedData.find(s => s.id === id); if (!companyName) return companyLogos['DEFAULT'];
if(!svc) return; const name = companyName.toString().toUpperCase();
const raw = svc.raw_data; const keyFound = Object.keys(companyLogos).find(key => name.includes(key));
const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || ""; return keyFound ? companyLogos[keyFound] : companyLogos['DEFAULT'];
// PINTAR HEADER
document.getElementById('displayRef').innerText = `REF: ${svc.service_ref}`;
document.getElementById('displayCompany').innerText = companyName;
document.getElementById('modalCompanyLogo').innerHTML = `<img src="${getLogoUrl(companyName)}" class="max-w-full max-h-full object-contain">`;
// RELLENAR CAMPOS
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'] || "";
document.getElementById('impDesc').value = raw['Descripción'] || "";
// Sincronizar Urgencia en el nuevo selector
const isUrgent = raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true' || raw['URGENTE'] === 'SI';
document.getElementById('impUrgent').value = isUrgent.toString();
// Reset de Gremio y Notas
document.getElementById('impNotesInt').value = "";
document.getElementById('impNotesExt').value = "";
document.getElementById('impGuild').value = "";
document.getElementById('impOperator').innerHTML = '<option value="">-- Automática --</option>';
document.getElementById('importModal').classList.remove('hidden');
lucide.createIcons();
} }
</script>
// 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 = `... <img src="${logoUrl}" onerror="this.src='${companyLogos['DEFAULT']}'" ...`;
document.addEventListener("DOMContentLoaded", async () => { document.addEventListener("DOMContentLoaded", async () => {
if (!localStorage.getItem("token")) window.location.href = "index.html"; if (!localStorage.getItem("token")) window.location.href = "index.html";
@@ -214,21 +183,25 @@
}); });
async function loadGuilds() { async function loadGuilds() {
try {
const res = await fetch(`${API_URL}/guilds`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } }); const res = await fetch(`${API_URL}/guilds`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
const data = await res.json(); const data = await res.json();
allGuilds = data.guilds || []; allGuilds = data.guilds || [];
const sel = document.getElementById('impGuild'); const sel = document.getElementById('impGuild');
sel.innerHTML = '<option value="">-- Seleccionar Gremio --</option>'; sel.innerHTML = '<option value="">-- Seleccionar Gremio --</option>';
allGuilds.forEach(g => sel.innerHTML += `<option value="${g.id}">${g.name}</option>`); allGuilds.forEach(g => sel.innerHTML += `<option value="${g.id}">${g.name}</option>`);
} catch(e) {}
} }
async function loadOpsForGuild(guildId) { async function loadOpsForGuild(guildId) {
const sel = document.getElementById('impOperator'); const sel = document.getElementById('impOperator');
if(!guildId) { sel.innerHTML = '<option value="">-- Automática --</option>'; return; } if(!guildId) { sel.innerHTML = '<option value="">-- Automática --</option>'; return; }
try {
const res = await fetch(`${API_URL}/operators?guild_id=${guildId}`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } }); const res = await fetch(`${API_URL}/operators?guild_id=${guildId}`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
const data = await res.json(); const data = await res.json();
sel.innerHTML = '<option value="">-- Automática (Por defecto) --</option>'; sel.innerHTML = '<option value="">-- Automática --</option>';
data.operators.forEach(op => sel.innerHTML += `<option value="${op.id}">${op.full_name}</option>`); data.operators.forEach(op => sel.innerHTML += `<option value="${op.id}">${op.full_name}</option>`);
} catch(e) {}
} }
async function loadInbox() { async function loadInbox() {
@@ -253,19 +226,18 @@
const addr = raw['Dirección'] || raw['DOMICILIO'] || ""; const addr = raw['Dirección'] || raw['DOMICILIO'] || "";
const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || ""; const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || "";
const fullAddr = `${addr} ${pop}`.trim(); const fullAddr = `${addr} ${pop}`.trim();
const companyName = raw['Compañía'] || raw['COMPAÑIA'] || ""; const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "";
const logoUrl = getLogoUrl(companyName); //
const phone = (raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "").match(/[6789]\d{8}/)?.[0] || ""; const phone = (raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "").match(/[6789]\d{8}/)?.[0] || "";
const isBlocked = (!name || name.toUpperCase().includes('SIN NOMBRE') || !addr); const isBlocked = (!name || name.toUpperCase().includes('SIN NOMBRE') || !addr);
const card = document.createElement('div'); 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 = ` card.innerHTML = `
<div class="flex items-center gap-6 min-w-0"> <div class="flex items-center gap-6 min-w-0">
<div class="w-14 h-14 rounded-2xl bg-slate-50 border border-slate-100 p-2 flex items-center justify-center shrink-0 shadow-inner"> <div class="w-14 h-14 rounded-2xl bg-slate-50 border border-slate-100 p-2 flex items-center justify-center shrink-0 shadow-inner">
<img src="${logoUrl}" class="max-w-full max-h-full object-contain filter drop-shadow-sm"> <img src="${getLogoUrl(companyName)}" onerror="this.src='${companyLogos['DEFAULT']}'" class="max-w-full max-h-full object-contain">
</div> </div>
<div class="min-w-0"> <div class="min-w-0 text-left">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<h3 class="font-black text-slate-800 truncate uppercase text-lg">${isBlocked ? 'Bloqueado' : name}</h3> <h3 class="font-black text-slate-800 truncate uppercase text-lg">${isBlocked ? 'Bloqueado' : name}</h3>
<span class="text-[8px] font-black bg-slate-100 px-2 py-0.5 rounded-full border">${svc.provider === 'multiasistencia' ? 'MULTI' : 'HOME'}</span> <span class="text-[8px] font-black bg-slate-100 px-2 py-0.5 rounded-full border">${svc.provider === 'multiasistencia' ? 'MULTI' : 'HOME'}</span>
@@ -276,12 +248,12 @@
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
${!isBlocked ? ` ${!isBlocked ? `
<div class="hidden group-hover:flex items-center gap-1 pr-4 border-r mr-2 transition-all"> <div class="hidden group-hover:flex items-center gap-1 pr-4 border-r mr-2 transition-all">
<a href="https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(fullAddr)}" target="_blank" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-blue-600 shadow-sm"><i data-lucide="map" class="w-5 h-5"></i></a> <a href="https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(fullAddr)}" target="_blank" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-blue-600 shadow-sm"><i data-lucide="map"></i></a>
${phone ? ` ${phone ? `
<a href="https://wa.me/34${phone}" target="_blank" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-emerald-600 shadow-sm"><i data-lucide="message-square" class="w-5 h-5"></i></a> <a href="https://wa.me/34${phone}" target="_blank" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-emerald-600 shadow-sm"><i data-lucide="message-square"></i></a>
<a href="tel:${phone}" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-blue-600 shadow-sm"><i data-lucide="phone-call" class="w-5 h-5"></i></a> <a href="tel:${phone}" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-blue-600 shadow-sm"><i data-lucide="phone-call"></i></a>
` : ''} ` : ''}
<button onclick="openEditor(${svc.id})" class="bg-blue-600 text-white p-4 rounded-2xl shadow-lg active:scale-90 ml-2 transition-all"><i data-lucide="edit-3" class="w-6 h-6"></i></button> <button onclick="openEditor(${svc.id})" class="bg-blue-600 text-white p-4 rounded-2xl shadow-lg active:scale-90 transition-all ml-2"><i data-lucide="edit-3" class="w-6 h-6"></i></button>
</div>` : '<i data-lucide="shield-off" class="text-slate-300 mx-4"></i>'} </div>` : '<i data-lucide="shield-off" class="text-slate-300 mx-4"></i>'}
</div>`; </div>`;
container.appendChild(card); container.appendChild(card);
@@ -294,29 +266,30 @@
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'] || ""; const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "";
const logoUrl = getLogoUrl(companyName); //
// ACTUALIZACIÓN DE CABECERA
document.getElementById('displayRef').innerText = `REF: ${svc.service_ref}`; document.getElementById('displayRef').innerText = `REF: ${svc.service_ref}`;
document.getElementById('displayCompany').innerText = companyName || svc.provider.toUpperCase(); document.getElementById('displayCompany').innerText = companyName;
document.getElementById('modalCompanyLogo').innerHTML = `<img src="${logoUrl}" 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">`;
// RELLENAR FORMULARIO
document.getElementById('impScrapedId').value = id; 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'] || ""; const rawPhone = raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "";
document.getElementById('impPhone').value = rawPhone.match(/[6789]\d{8}/)?.[0] || ""; document.getElementById('impPhone').value = rawPhone.match(/[6789]\d{8}/)?.[0] || "";
const addr = raw['Dirección'] || raw['DOMICILIO'] || ""; const addr = raw['Dirección'] || raw['DOMICILIO'] || "";
const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || ""; const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || "";
document.getElementById('impAddress').value = `${addr} ${pop}`.trim(); 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('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('impNotesInt').value = "";
document.getElementById('impNotesExt').value = ""; document.getElementById('impNotesExt').value = "";
document.getElementById('impGuild').value = ""; document.getElementById('impGuild').value = "";
document.getElementById('impOperator').innerHTML = '<option value="">-- Automática --</option>';
document.getElementById('importModal').classList.remove('hidden'); document.getElementById('importModal').classList.remove('hidden');
lucide.createIcons(); lucide.createIcons();
} }
@@ -334,7 +307,7 @@
address: document.getElementById('impAddress').value, address: document.getElementById('impAddress').value,
cp: document.getElementById('impCP').value, cp: document.getElementById('impCP').value,
description: document.getElementById('impDesc').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, guild_id: document.getElementById('impGuild').value,
assigned_to: document.getElementById('impOperator').value || null, assigned_to: document.getElementById('impOperator').value || null,
internal_notes: document.getElementById('impNotesInt').value, internal_notes: document.getElementById('impNotesInt').value,
@@ -350,7 +323,7 @@
}); });
const result = await res.json(); const result = await res.json();
if(result.ok) { if(result.ok) {
showToast("✅ Expediente traspasado con éxito"); showToast("✅ Traspasado con éxito");
closeModal(); closeModal();
loadInbox(); loadInbox();
} else { showToast("❌ Error al importar", true); } } else { showToast("❌ Error al importar", true); }