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">
<div class="card">
<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
</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>
@ -2746,41 +2746,36 @@ $installersData = json_decode($config['installersDataWhatsApp'] ?? '{"instalador
const tableWrapper = document.getElementById('jobsTableWrapper');
const noResults = document.getElementById('jobsNoResults');
title.innerHTML = `📋 Tareas Activas: <strong>${installerName}</strong>`;
emptyState.style.display = 'none';
loading.style.display = 'block';
tableWrapper.style.display = 'none';
noResults.style.display = 'none';
// Scroll suave a la sección de jobs
title.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
if (title) title.innerHTML = `📋 Tareas Activas: <strong>${escapeHtml(installerName)}</strong>`;
if (emptyState) emptyState.style.display = 'none';
if (loading) loading.style.display = 'block';
if (tableWrapper) tableWrapper.style.display = 'none';
if (noResults) noResults.style.display = 'none';
try {
const resp = await fetch(`?action=get_installer_jobs&installerId=${installerId}`);
const jobs = await resp.json();
loading.style.display = 'none';
if (loading) loading.style.display = 'none';
if (!jobs.length) {
noResults.style.display = 'block';
if (!Array.isArray(jobs) || !jobs.length) {
if (noResults) noResults.style.display = 'block';
return;
}
const tbody = document.querySelector('#installerJobsTable tbody');
if (tbody) {
tbody.innerHTML = jobs.map(job => {
const dateFormatted = job.date ? new Date(job.date).toLocaleDateString('es-MX', {
day: '2-digit',
month: '2-digit',
year: 'numeric'
}) : 'S/F';
const titleClean = job.title.replace('[NOTIFICACION-PENDIENTE]', '').replace('[CLIENTE-SIN-WHATSAPP]', '').trim();
const titleClean = String(job.title || '').replace('[NOTIFICACION-PENDIENTE]', '').replace('[CLIENTE-SIN-WHATSAPP]', '').trim();
return `<tr>
<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>[${job.clientId}] ${job.clientName}</td>
<td>[${job.clientId || '-'}] ${escapeHtml(job.clientName)}</td>
<td>${dateFormatted}</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 style="max-width:200px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;" title="${escapeHtml(job.description)}">${escapeHtml(titleClean || job.description || 'Sin descripción')}</td>
<td>
<button class="btn btn-primary" style="padding:6px 14px; font-size:0.85em;" onclick="resendJobNotification(${job.id}, this)">
📨 Reenviar
@ -2788,10 +2783,11 @@ $installersData = json_decode($config['installersDataWhatsApp'] ?? '{"instalador
</td>
</tr>`;
}).join('');
tableWrapper.style.display = 'block';
}
if (tableWrapper) tableWrapper.style.display = 'block';
} catch (e) {
loading.style.display = 'none';
noResults.style.display = 'block';
if (loading) loading.style.display = 'none';
if (noResults) noResults.style.display = 'block';
console.error('Error loading installer jobs:', e);
}
}