fix: agregar id=jobsSectionTitle en h2 de section-installer-jobs y verificar referencias DOM en loadInstallerJobs
This commit is contained in:
parent
d869499990
commit
17c7c2710a
38
public.php
38
public.php
@ -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,41 +2746,36 @@ $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');
|
||||||
|
if (tbody) {
|
||||||
tbody.innerHTML = jobs.map(job => {
|
tbody.innerHTML = jobs.map(job => {
|
||||||
const dateFormatted = job.date ? new Date(job.date).toLocaleDateString('es-MX', {
|
const dateFormatted = job.date ? new Date(job.date).toLocaleDateString('es-MX', {
|
||||||
day: '2-digit',
|
day: '2-digit',
|
||||||
month: '2-digit',
|
month: '2-digit',
|
||||||
year: 'numeric'
|
year: 'numeric'
|
||||||
}) : 'S/F';
|
}) : '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>
|
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><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>${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>
|
<td>
|
||||||
<button class="btn btn-primary" style="padding:6px 14px; font-size:0.85em;" onclick="resendJobNotification(${job.id}, this)">
|
<button class="btn btn-primary" style="padding:6px 14px; font-size:0.85em;" onclick="resendJobNotification(${job.id}, this)">
|
||||||
📨 Reenviar
|
📨 Reenviar
|
||||||
@ -2788,10 +2783,11 @@ $installersData = json_decode($config['installersDataWhatsApp'] ?? '{"instalador
|
|||||||
</td>
|
</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
tableWrapper.style.display = 'block';
|
}
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user