up
This commit is contained in:
+30
-10
@@ -121,6 +121,14 @@ require_once __DIR__ . '/shared/components/sidebar.php';
|
||||
<option value="expirado">⏰ Expirado</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-6 col-sm-2">
|
||||
<label class="form-label form-label-sm mb-1 text-muted">Origen</label>
|
||||
<select id="env-f-origen" class="form-select form-select-sm" onchange="envios.filtrar()">
|
||||
<option value="">Todos</option>
|
||||
<option value="turnero">Turnero</option>
|
||||
<option value="otros">Otros</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-6 col-sm-3">
|
||||
<label class="form-label form-label-sm mb-1 text-muted">Paciente</label>
|
||||
<input type="text" id="env-f-paciente" class="form-control form-control-sm"
|
||||
@@ -151,14 +159,14 @@ require_once __DIR__ . '/shared/components/sidebar.php';
|
||||
<tr>
|
||||
<th>Formulario</th>
|
||||
<th>Paciente</th>
|
||||
<th>Origen</th>
|
||||
<th>Estado</th>
|
||||
<th>Enviado</th>
|
||||
<th>Expira</th>
|
||||
<th>Fecha</th>
|
||||
<th>Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody-envios">
|
||||
<tr><td colspan="6" class="text-center text-muted py-4">Cargando…</td></tr>
|
||||
<tr><td colspan="7" class="text-center text-muted py-4">Cargando…</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -496,6 +504,7 @@ const envios = {
|
||||
paciente: $('env-f-paciente').value.trim() || '',
|
||||
formulario_id: $('env-f-formulario').value || '',
|
||||
estado: $('env-f-estado').value || '',
|
||||
origen: $('env-f-origen').value || '',
|
||||
});
|
||||
},
|
||||
|
||||
@@ -514,7 +523,7 @@ const envios = {
|
||||
this._render();
|
||||
} catch(e) {
|
||||
const tb = $('tbody-envios');
|
||||
if (tb) tb.innerHTML = '<tr><td colspan="6" class="text-center text-danger py-4">Error al cargar envíos</td></tr>';
|
||||
if (tb) tb.innerHTML = '<tr><td colspan="7" class="text-center text-danger py-4">Error al cargar envíos</td></tr>';
|
||||
} finally {
|
||||
if (spinner) spinner.style.display = 'none';
|
||||
if (wrap) wrap.style.display = '';
|
||||
@@ -532,6 +541,7 @@ const envios = {
|
||||
$('env-f-paciente').value = '';
|
||||
$('env-f-formulario').value = '';
|
||||
$('env-f-estado').value = '';
|
||||
$('env-f-origen').value = '';
|
||||
this.cargar(1);
|
||||
},
|
||||
|
||||
@@ -595,29 +605,39 @@ const envios = {
|
||||
_render() {
|
||||
const tb = $('tbody-envios');
|
||||
if (!this._paginaData.length) {
|
||||
tb.innerHTML = '<tr><td colspan="6" class="text-center text-muted py-4">Sin envíos para los filtros seleccionados</td></tr>';
|
||||
tb.innerHTML = '<tr><td colspan="7" class="text-center text-muted py-4">Sin envíos para los filtros seleccionados</td></tr>';
|
||||
$('env-pag-info').textContent = '';
|
||||
$('env-paginacion').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
const inicio = (this._pagina - 1) * POR_PAGINA;
|
||||
tb.innerHTML = this._paginaData.map(e => {
|
||||
const info = ESTADO_ENV[e.estado] || {};
|
||||
const info = ESTADO_ENV[e.estado] || {};
|
||||
const esTurnero = e.origen === 'turnero';
|
||||
const origenBadge = esTurnero
|
||||
? `<span class="badge bg-info text-dark">Turnero${e.turno_codigo ? ' #'+esc(e.turno_codigo):''}</span>`
|
||||
: `<span class="badge bg-secondary">Otros</span>`;
|
||||
const viewHref = esTurnero
|
||||
? `ver_formulario_enviado.php?token=${esc(e.token)}`
|
||||
: `ver_formulario_enviado.php?id=${e.id}`;
|
||||
const fecha = (e.fecha||'').slice(0,16).replace('T',' ');
|
||||
return `<tr>
|
||||
<td><span class="fw-semibold">${esc(e.form_nombre)}</span>
|
||||
<br><small class="text-muted">${esc(e.categoria)}</small></td>
|
||||
<td>${esc(e.paciente_nombre || '—')}</td>
|
||||
<td>${origenBadge}</td>
|
||||
<td><span class="badge text-white ${info.cls}">${info.icon} ${e.estado}</span></td>
|
||||
<td><small>${esc((e.created_at||'').slice(0,16).replace('T',' '))}</small></td>
|
||||
<td><small class="text-muted">${esc((e.expira_en||'').slice(0,10))}</small></td>
|
||||
<td><small>${esc(fecha)}</small></td>
|
||||
<td>
|
||||
<button class="btn btn-xs btn-outline-secondary" title="Copiar link"
|
||||
onclick="envios.copiarTokenLink('${esc(e.token)}')">
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
${['completado','firmado'].includes(e.estado)
|
||||
? `<button class="btn btn-xs btn-outline-primary ms-1" onclick="verRespuesta.abrir(${e.id})"><i class="fas fa-eye"></i></button>
|
||||
<a class="btn btn-xs btn-outline-danger ms-1" href="ver_formulario_enviado.php?id=${e.id}" target="_blank"><i class="fas fa-file-pdf"></i></a>`
|
||||
? (esTurnero
|
||||
? `<a class="btn btn-xs btn-outline-danger ms-1" href="${viewHref}" target="_blank"><i class="fas fa-file-pdf"></i></a>`
|
||||
: `<button class="btn btn-xs btn-outline-primary ms-1" onclick="verRespuesta.abrir(${e.id})"><i class="fas fa-eye"></i></button>
|
||||
<a class="btn btn-xs btn-outline-danger ms-1" href="${viewHref}" target="_blank"><i class="fas fa-file-pdf"></i></a>`)
|
||||
: ''}
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
Reference in New Issue
Block a user