fix: agregar id=jobsSectionTitle en h2 de section-installer-jobs y verificar referencias DOM en loadInstallerJobs

This commit is contained in:
DANYDHSV 2026-07-28 15:30:27 -06:00
parent d869499990
commit 17c7c2710a

View File

@ -2011,7 +2011,7 @@ $installersData = json_decode($config['installersDataWhatsApp'] ?? '{"instalador
<section id="section-installer-jobs" class="section-view"> <section id="section-installer-jobs" class="section-view">
<div class="card"> <div class="card">
<div style="margin-bottom: 1.5rem;"> <div style="margin-bottom: 1.5rem;">
<h2 style="margin: 0; display: flex; align-items: center; gap: 10px;"> <h2 id="jobsSectionTitle" style="margin: 0; display: flex; align-items: center; gap: 10px;">
📋 Tareas e Instalaciones Activas por Técnico 📋 Tareas e Instalaciones Activas por Técnico
</h2> </h2>
<p style="color: var(--text-muted); margin: 5px 0 0 0;">Selecciona un técnico instalador para consultar sus tareas "En curso" y reenviar notificaciones por WhatsApp</p> <p style="color: var(--text-muted); margin: 5px 0 0 0;">Selecciona un técnico instalador para consultar sus tareas "En curso" y reenviar notificaciones por WhatsApp</p>
@ -2746,52 +2746,48 @@ $installersData = json_decode($config['installersDataWhatsApp'] ?? '{"instalador
const tableWrapper = document.getElementById('jobsTableWrapper'); const tableWrapper = document.getElementById('jobsTableWrapper');
const noResults = document.getElementById('jobsNoResults'); const noResults = document.getElementById('jobsNoResults');
title.innerHTML = `📋 Tareas Activas: <strong>${installerName}</strong>`; if (title) title.innerHTML = `📋 Tareas Activas: <strong>${escapeHtml(installerName)}</strong>`;
emptyState.style.display = 'none'; if (emptyState) emptyState.style.display = 'none';
loading.style.display = 'block'; if (loading) loading.style.display = 'block';
tableWrapper.style.display = 'none'; if (tableWrapper) tableWrapper.style.display = 'none';
noResults.style.display = 'none'; if (noResults) noResults.style.display = 'none';
// Scroll suave a la sección de jobs
title.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
try { try {
const resp = await fetch(`?action=get_installer_jobs&installerId=${installerId}`); const resp = await fetch(`?action=get_installer_jobs&installerId=${installerId}`);
const jobs = await resp.json(); const jobs = await resp.json();
loading.style.display = 'none'; if (loading) loading.style.display = 'none';
if (!jobs.length) { if (!Array.isArray(jobs) || !jobs.length) {
noResults.style.display = 'block'; if (noResults) noResults.style.display = 'block';
return; return;
} }
const tbody = document.querySelector('#installerJobsTable tbody'); const tbody = document.querySelector('#installerJobsTable tbody');
tbody.innerHTML = jobs.map(job => { if (tbody) {
const dateFormatted = job.date ? new Date(job.date).toLocaleDateString('es-MX', { tbody.innerHTML = jobs.map(job => {
day: '2-digit', const dateFormatted = job.date ? new Date(job.date).toLocaleDateString('es-MX', {
month: '2-digit', day: '2-digit',
year: 'numeric' month: '2-digit',
}) : 'S/F'; year: 'numeric'
const titleClean = job.title.replace('[NOTIFICACION-PENDIENTE]', '').replace('[CLIENTE-SIN-WHATSAPP]', '').trim(); }) : 'S/F';
return `<tr> const titleClean = String(job.title || '').replace('[NOTIFICACION-PENDIENTE]', '').replace('[CLIENTE-SIN-WHATSAPP]', '').trim();
<td><strong><a href="${store.publicUrl}/scheduling/job/${job.id}" target="_blank" style="color: var(--primary); text-decoration: underline;">#${job.id}</a></strong></td> return `<tr>
<td>[${job.clientId}] ${job.clientName}</td> <td><strong><a href="${store.publicUrl}/scheduling/job/${job.id}" target="_blank" style="color: var(--primary); text-decoration: underline;">#${job.id}</a></strong></td>
<td>${dateFormatted}</td> <td>[${job.clientId || '-'}] ${escapeHtml(job.clientName)}</td>
<td style="max-width:200px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;" title="${job.description}">${titleClean || job.description || 'Sin descripción'}</td> <td>${dateFormatted}</td>
<td> <td style="max-width:200px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;" title="${escapeHtml(job.description)}">${escapeHtml(titleClean || job.description || 'Sin descripción')}</td>
<button class="btn btn-primary" style="padding:6px 14px; font-size:0.85em;" onclick="resendJobNotification(${job.id}, this)"> <td>
📨 Reenviar <button class="btn btn-primary" style="padding:6px 14px; font-size:0.85em;" onclick="resendJobNotification(${job.id}, this)">
</button> 📨 Reenviar
</td> </button>
</tr>`; </td>
}).join(''); </tr>`;
tableWrapper.style.display = 'block'; }).join('');
}
if (tableWrapper) tableWrapper.style.display = 'block';
} catch (e) { } catch (e) {
loading.style.display = 'none'; if (loading) loading.style.display = 'none';
noResults.style.display = 'block'; if (noResults) noResults.style.display = 'block';
console.error('Error loading installer jobs:', e); console.error('Error loading installer jobs:', e);
} }
} }