Actualizar automatizaciones.html

This commit is contained in:
2026-02-15 14:52:25 +00:00
parent d1b08f671e
commit e4ba74522a

View File

@@ -39,8 +39,8 @@
</button> </button>
</div> </div>
<div class="bg-white p-4 rounded-2xl border border-slate-200 shadow-sm mb-6 flex flex-wrap gap-4 items-center"> <div class="bg-white p-4 rounded-2xl border border-slate-200 shadow-sm mb-4 flex flex-wrap gap-4 items-center">
<div class="flex-1 min-w-[280px] relative"> <div class="flex-1 min-w-[280px] relative text-left">
<i data-lucide="search" class="w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"></i> <i data-lucide="search" class="w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"></i>
<input type="text" id="searchBox" oninput="renderFilteredInbox()" placeholder="Buscar por Nombre, REF, Dirección, Teléfono..." class="w-full pl-11 pr-4 py-2.5 bg-slate-50 border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-blue-500 outline-none transition-all"> <input type="text" id="searchBox" oninput="renderFilteredInbox()" placeholder="Buscar por Nombre, REF, Dirección, Teléfono..." class="w-full pl-11 pr-4 py-2.5 bg-slate-50 border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-blue-500 outline-none transition-all">
</div> </div>
@@ -61,6 +61,21 @@
</div> </div>
</div> </div>
<div class="flex gap-4 mb-6 text-left">
<div class="bg-emerald-50 border border-emerald-100 px-4 py-2 rounded-xl flex items-center gap-2">
<span class="text-[10px] font-black text-emerald-600 uppercase tracking-widest">Activos:</span>
<span id="countActive" class="text-sm font-black text-emerald-700">0</span>
</div>
<div class="bg-slate-100 border border-slate-200 px-4 py-2 rounded-xl flex items-center gap-2 text-left">
<span class="text-[10px] font-black text-slate-500 uppercase tracking-widest">Archivados:</span>
<span id="countArchived" class="text-sm font-black text-slate-700">0</span>
</div>
<div class="bg-blue-50 border border-blue-100 px-4 py-2 rounded-xl flex items-center gap-2 text-left">
<span class="text-[10px] font-black text-blue-600 uppercase tracking-widest">Total:</span>
<span id="countTotal" class="text-sm font-black text-blue-700">0</span>
</div>
</div>
<div id="inboxContainer" class="space-y-4 text-left"></div> <div id="inboxContainer" class="space-y-4 text-left"></div>
</div> </div>
</main> </main>
@@ -73,7 +88,7 @@
<div class="flex items-center gap-4 text-left"> <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>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2 text-left">
<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 id="modalStatusBadge"></div> <div id="modalStatusBadge"></div>
</div> </div>
@@ -99,15 +114,15 @@
<form id="importForm" onsubmit="handleFinalImport(event)" class="px-8 py-6 space-y-5 overflow-y-auto no-scrollbar text-left"> <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 text-left">
<div class="bg-white p-2 rounded-xl shadow-sm text-slate-400"><i data-lucide="user"></i></div> <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="flex flex-col min-w-0 w-full text-left"> <div class="flex flex-col min-w-0 w-full text-left">
<span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Asegurado</span> <span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Asegurado</span>
<input type="text" id="impName" readonly class="bg-transparent border-none p-0 text-sm font-bold text-slate-700 outline-none w-full"> <input type="text" id="impName" readonly class="bg-transparent border-none p-0 text-sm font-bold text-slate-700 outline-none 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 text-left"> <div class="bg-slate-50/50 p-3 rounded-2xl border border-slate-100 flex items-center gap-3 text-left">
<div class="bg-white p-2 rounded-xl shadow-sm text-emerald-500"><i data-lucide="phone"></i></div> <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="flex flex-col min-w-0 w-full text-left"> <div class="flex flex-col min-w-0 w-full text-left">
<span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Teléfono</span> <span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Teléfono</span>
<input type="text" id="impPhone" readonly class="bg-transparent border-none p-0 text-sm font-black text-emerald-600 outline-none w-full"> <input type="text" id="impPhone" readonly class="bg-transparent border-none p-0 text-sm font-black text-emerald-600 outline-none w-full">
@@ -116,7 +131,7 @@
</div> </div>
<div class="grid grid-cols-1 md:grid-cols-5 gap-3 text-left"> <div class="grid grid-cols-1 md:grid-cols-5 gap-3 text-left">
<div class="md:col-span-4 space-y-1 text-left"> <div class="md:col-span-4 space-y-1 text-left">
<label class="text-[9px] font-black text-blue-600 uppercase tracking-widest ml-2 flex items-center gap-1"><i data-lucide="map-pin"></i> Dirección</label> <label class="text-[9px] font-black text-blue-600 uppercase tracking-widest ml-2 flex items-center gap-1 text-left"><i data-lucide="map-pin" class="w-3 h-3"></i> Dirección</label>
<input type="text" id="impAddress" required class="w-full border-2 border-slate-100 bg-white px-4 py-2.5 rounded-2xl text-sm font-medium outline-none focus:border-blue-500 shadow-sm"> <input type="text" id="impAddress" required class="w-full border-2 border-slate-100 bg-white px-4 py-2.5 rounded-2xl text-sm font-medium outline-none focus:border-blue-500 shadow-sm">
</div> </div>
<div class="space-y-1 text-center"> <div class="space-y-1 text-center">
@@ -127,13 +142,13 @@
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 p-5 rounded-[1.8rem] border-2 border-blue-50 bg-blue-50/30 text-left"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4 p-5 rounded-[1.8rem] border-2 border-blue-50 bg-blue-50/30 text-left">
<div class="space-y-1 text-left"> <div class="space-y-1 text-left">
<label class="text-[9px] font-black text-blue-600 uppercase tracking-widest ml-2">Gremio Especialista *</label> <label class="text-[9px] font-black text-blue-600 uppercase tracking-widest ml-2">Gremio Especialista *</label>
<select id="impGuild" required onchange="loadOpsForGuild(this.value)" 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="impGuild" required onchange="loadOpsForGuild(this.value)" 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 text-left">
<option value="">-- Seleccionar Gremio --</option> <option value="">-- Seleccionar Gremio --</option>
</select> </select>
</div> </div>
<div class="space-y-1 text-left"> <div class="space-y-1 text-left">
<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 text-left">
<option value="">-- Automática --</option> <option value="">-- Automática --</option>
</select> </select>
</div> </div>
@@ -141,25 +156,25 @@
<div class="space-y-3 text-left"> <div class="space-y-3 text-left">
<div class="space-y-1 text-left"> <div class="space-y-1 text-left">
<label class="text-[9px] font-black text-slate-400 uppercase tracking-widest ml-2">Avería Detectada</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 text-left"></textarea>
</div> </div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-left"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-left">
<div class="text-left"> <div class="text-left">
<label class="text-[9px] font-black text-amber-600 uppercase ml-2 mb-1 block">Notas Oficina</label> <label class="text-[9px] font-black text-amber-600 uppercase ml-2 mb-1 block">Notas Oficina</label>
<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 text-left"></textarea>
</div> </div>
<div class="text-left"> <div class="text-left">
<label class="text-[9px] font-black text-blue-500 uppercase ml-2 mb-1 block">Instrucciones Operario</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 text-left"></textarea>
</div> </div>
</div> </div>
</div> </div>
<div class="flex items-center gap-3 pt-4 border-t text-left"> <div class="flex items-center gap-3 pt-4 border-t text-left">
<button type="button" onclick="saveDraftChanges(event)" class="bg-slate-100 hover:bg-slate-200 text-slate-600 font-black px-6 py-5 rounded-[1.8rem] transition-all flex items-center justify-center gap-2 active:scale-95 text-xs uppercase tracking-widest"> <button type="button" onclick="saveDraftChanges(event)" class="bg-slate-100 hover:bg-slate-200 text-slate-600 font-black px-6 py-5 rounded-[1.8rem] transition-all flex items-center justify-center gap-2 active:scale-95 text-xs uppercase tracking-widest">
<i data-lucide="save"></i> <span>Guardar Borrador</span> <i data-lucide="save" class="w-4 h-4"></i> <span>Guardar Borrador</span>
</button> </button>
<button type="submit" class="flex-1 bg-slate-900 hover:bg-emerald-600 text-white font-black py-5 rounded-[1.8rem] shadow-xl transition-all flex items-center justify-center gap-3 active:scale-95 text-sm uppercase tracking-[0.2em]"> <button type="submit" class="flex-1 bg-slate-900 hover:bg-emerald-600 text-white font-black py-5 rounded-[1.8rem] shadow-xl transition-all flex items-center justify-center gap-3 active:scale-95 text-sm uppercase tracking-[0.2em]">
<span>TRASPASAR A CRM</span> <i data-lucide="send"></i> <span>TRASPASAR A CRM</span> <i data-lucide="send" class="w-5 h-5"></i>
</button> </button>
</div> </div>
</form> </form>
@@ -242,6 +257,13 @@
compSelect.innerHTML = '<option value="ALL">COMPAÑÍAS</option>'; compSelect.innerHTML = '<option value="ALL">COMPAÑÍAS</option>';
uniqueCompanies.forEach(c => compSelect.innerHTML += `<option value="${c}">${c}</option>`); uniqueCompanies.forEach(c => compSelect.innerHTML += `<option value="${c}">${c}</option>`);
// ACTUALIZAR ESTADÍSTICAS
const active = scrapedData.filter(s => s.status === 'pending').length;
const archived = scrapedData.filter(s => s.status === 'archived').length;
document.getElementById('countActive').innerText = active;
document.getElementById('countArchived').innerText = archived;
document.getElementById('countTotal').innerText = scrapedData.length;
renderFilteredInbox(); renderFilteredInbox();
} catch (e) { showToast("Error de conexión", true); } } catch (e) { showToast("Error de conexión", true); }
} }
@@ -251,7 +273,7 @@
const search = document.getElementById('searchBox').value.toUpperCase(); const search = document.getElementById('searchBox').value.toUpperCase();
const provider = document.getElementById('filterProvider').value; const provider = document.getElementById('filterProvider').value;
const company = document.getElementById('filterCompany').value; const company = document.getElementById('filterCompany').value;
const status = document.getElementById('filterStatus').value; // NUEVO FILTRO const status = document.getElementById('filterStatus').value;
const filtered = scrapedData.filter(svc => { const filtered = scrapedData.filter(svc => {
const raw = svc.raw_data || {}; const raw = svc.raw_data || {};
@@ -264,14 +286,14 @@
const matchesSearch = name.includes(search) || ref.includes(search) || addr.includes(search) || phone.includes(search); const matchesSearch = name.includes(search) || ref.includes(search) || addr.includes(search) || phone.includes(search);
const matchesProvider = provider === 'ALL' || svc.provider === provider; const matchesProvider = provider === 'ALL' || svc.provider === provider;
const matchesCompany = company === 'ALL' || comp === company; const matchesCompany = company === 'ALL' || comp === company;
const matchesStatus = status === 'ALL' || svc.status === status; // const matchesStatus = status === 'ALL' || svc.status === status;
return matchesSearch && matchesProvider && matchesCompany && matchesStatus; return matchesSearch && matchesProvider && matchesCompany && matchesStatus;
}); });
container.innerHTML = ""; container.innerHTML = "";
if(filtered.length === 0) { if(filtered.length === 0) {
container.innerHTML = '<div class="p-12 text-center text-slate-400 bg-white rounded-3xl border-2 border-dashed">No se encontraron expedientes con estos filtros.</div>'; container.innerHTML = '<div class="p-12 text-center text-slate-400 bg-white rounded-3xl border-2 border-dashed text-left">No se encontraron expedientes con estos filtros.</div>';
return; return;
} }
@@ -305,29 +327,28 @@
<span class="text-[9px] font-black uppercase tracking-tighter">${svc.provider === 'multiasistencia' ? 'MULTI' : 'HOME'}</span> <span class="text-[9px] font-black uppercase tracking-tighter">${svc.provider === 'multiasistencia' ? 'MULTI' : 'HOME'}</span>
<i data-lucide="${isArchived ? 'lock' : 'file-text'}" class="w-5 h-5 mt-0.5"></i> <i data-lucide="${isArchived ? 'lock' : 'file-text'}" class="w-5 h-5 mt-0.5"></i>
</div> </div>
<div class="w-12 h-12 rounded-xl bg-white border border-slate-100 p-2 flex items-center justify-center shrink-0 shadow-inner"> <div class="w-12 h-12 rounded-xl bg-white border border-slate-100 p-2 flex items-center justify-center shrink-0 shadow-inner text-left">
<img src="${getLogoUrl(raw['Compañía'] || raw['COMPAÑIA'])}" onerror="this.src='${companyLogos['DEFAULT']}'" class="max-w-full max-h-full object-contain"> <img src="${getLogoUrl(raw['Compañía'] || raw['COMPAÑIA'])}" onerror="this.src='${companyLogos['DEFAULT']}'" class="max-w-full max-h-full object-contain">
</div> </div>
<div class="min-w-0 text-left"> <div class="min-w-0 text-left">
<div class="flex items-center gap-2 text-left"> <div class="flex items-center gap-2 text-left">
<h3 class="font-black text-slate-800 truncate uppercase text-lg leading-tight">${name}</h3> <h3 class="font-black text-slate-800 truncate uppercase text-lg leading-tight text-left">${name}</h3>
<span class="text-[8px] font-black px-2 py-0.5 rounded-full border ${statusClass}">${statusLabel}</span> <span class="text-[8px] font-black px-2 py-0.5 rounded-full border ${statusClass} text-left">${statusLabel}</span>
</div> </div>
<p class="text-xs text-slate-400 truncate italic mt-0.5">${fullAddr}</p> <p class="text-xs text-slate-400 truncate italic mt-0.5 text-left">${fullAddr}</p>
<div class="flex flex-wrap gap-2 mt-2"> <div class="flex flex-wrap gap-2 mt-2 text-left">
<span class="text-[10px] bg-slate-100 text-slate-500 px-2 py-0.5 rounded-lg font-bold border">#${svc.service_ref}</span> <span class="text-[10px] bg-slate-100 text-slate-500 px-2 py-0.5 rounded-lg font-bold border text-left">#${svc.service_ref}</span>
${guildName ? `<span class="text-[10px] bg-blue-50 text-blue-600 px-2 py-0.5 rounded-lg font-bold border border-blue-100"><i data-lucide="hammer" class="w-2.5 h-2.5 inline mr-1"></i>${guildName}</span>` : ''} ${guildName ? `<span class="text-[10px] bg-blue-50 text-blue-600 px-2 py-0.5 rounded-lg font-bold border border-blue-100 text-left"><i data-lucide="hammer" class="w-2.5 h-2.5 inline mr-1"></i>${guildName}</span>` : ''}
${opName ? `<span class="text-[10px] bg-purple-50 text-purple-600 px-2 py-0.5 rounded-lg font-bold border border-purple-100"><i data-lucide="user" class="w-2.5 h-2.5 inline mr-1"></i>${opName}</span>` : ''} ${opName ? `<span class="text-[10px] bg-purple-50 text-purple-600 px-2 py-0.5 rounded-lg font-bold border border-purple-100 text-left"><i data-lucide="user" class="w-2.5 h-2.5 inline mr-1"></i>${opName}</span>` : ''}
</div> </div>
</div> </div>
</div> </div>
<div class="flex items-center gap-2 text-left"> <div class="flex items-center gap-2 text-left">
${!isArchived ? ` ${!isArchived ? `
<div class="hidden group-hover:flex items-center gap-2 pr-4 transition-all"> <div class="hidden group-hover:flex items-center gap-2 pr-4 transition-all text-left">
<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> <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 text-left"><i data-lucide="map" class="w-5 h-5 text-left"></i></a>
${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"></i></a>` : ''} ${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 text-left"><i data-lucide="message-square" class="w-5 h-5 text-left"></i></a>` : ''}
</div> </div>` : ''}
<div class="bg-blue-600 text-white p-4 rounded-2xl shadow-lg group-hover:scale-105 transition-all"><i data-lucide="chevron-right" class="w-6 h-6"></i></div>` : ''}
</div>`; </div>`;
container.appendChild(card); container.appendChild(card);
}); });
@@ -444,7 +465,7 @@
function showToast(msg, isError = false) { function showToast(msg, isError = false) {
const t = document.getElementById('toast'), m = document.getElementById('toastMsg'); const t = document.getElementById('toast'), m = document.getElementById('toastMsg');
t.className = `fixed bottom-8 right-8 px-8 py-4 rounded-2xl shadow-2xl z-[200] flex items-center gap-3 transition-all ${isError ? 'bg-red-600' : 'bg-slate-900'} text-white`; t.className = `fixed bottom-8 right-8 px-8 py-4 rounded-2xl shadow-2xl z-[200] flex items-center gap-3 transition-all ${isError ? 'bg-red-600' : 'bg-slate-900'} text-white text-left`;
m.innerText = msg; t.classList.remove('hidden'); m.innerText = msg; t.classList.remove('hidden');
setTimeout(() => t.classList.add('hidden'), 4000); setTimeout(() => t.classList.add('hidden'), 4000);
} }