Update enfermero_portal.php
This commit is contained in:
+83
-2
@@ -451,10 +451,12 @@ const portal = {
|
||||
_agenda: [],
|
||||
_cancelModal: null,
|
||||
_seModal: null,
|
||||
_reprModal: null,
|
||||
|
||||
init() {
|
||||
this._cancelModal = new bootstrap.Modal('#modalCancelar');
|
||||
this._seModal = new bootstrap.Modal('#modalServicioExtra');
|
||||
this._reprModal = new bootstrap.Modal('#modalReprogramar');
|
||||
document.getElementById('se-pago').addEventListener('change', e => {
|
||||
document.getElementById('se-valor-cont').style.display = e.target.checked ? '' : 'none';
|
||||
});
|
||||
@@ -593,13 +595,20 @@ const portal = {
|
||||
</button>`
|
||||
).join('');
|
||||
|
||||
const btnCancelar = !['completado','cancelado'].includes(est)
|
||||
const btnCancelar = !['completado','cancelado','reprogramado'].includes(est)
|
||||
? `<button class="btn btn-outline-danger btn-accion"
|
||||
onclick="portal.abrirCancelar(${item.domicilio_id})">
|
||||
❌ Cancelar
|
||||
</button>`
|
||||
: '';
|
||||
|
||||
const btnReprogramar = !['completado','reprogramado'].includes(est)
|
||||
? `<button class="btn btn-accion text-white" style="background:#6f42c1"
|
||||
onclick="portal.abrirReprogramar(${item.domicilio_id}, '${(item.hora_programada||'').slice(0,5)}')">
|
||||
<i class="fas fa-calendar-alt me-1"></i>Reprogramar
|
||||
</button>`
|
||||
: '';
|
||||
|
||||
return `<div class="domcard estado-${est} mb-3 p-3" id="card-${item.domicilio_id}">
|
||||
<div class="domcard-header" onclick="toggleDomCard(this)">
|
||||
<div class="d-flex align-items-center gap-2 flex-wrap" style="max-width:calc(100% - 22px)">
|
||||
@@ -704,6 +713,7 @@ const portal = {
|
||||
<div class="d-flex flex-wrap gap-2 mt-2">
|
||||
${btnsAccion}
|
||||
${btnCancelar}
|
||||
${btnReprogramar}
|
||||
${!['completado','cancelado'].includes(est)
|
||||
? `<button class="btn btn-outline-secondary btn-accion"
|
||||
onclick="portal.abrirServicioExtra(${item.domicilio_id})">
|
||||
@@ -835,6 +845,39 @@ const portal = {
|
||||
await this.actualizarEstado(domId, 'cancelado', notas);
|
||||
},
|
||||
|
||||
// ── Modal reprogramar ─────────────────────────────────────────────────
|
||||
abrirReprogramar(domId, horaActual) {
|
||||
document.getElementById('repr-dom-id').value = domId;
|
||||
document.getElementById('repr-fecha').value = '';
|
||||
document.getElementById('repr-hora').value = horaActual || '';
|
||||
document.getElementById('repr-motivo').value = '';
|
||||
document.getElementById('repr-error').classList.add('d-none');
|
||||
this._reprModal.show();
|
||||
},
|
||||
async confirmarReprogramar() {
|
||||
const id = +document.getElementById('repr-dom-id').value;
|
||||
const fecha = document.getElementById('repr-fecha').value;
|
||||
const hora = document.getElementById('repr-hora').value;
|
||||
const motivo = document.getElementById('repr-motivo').value.trim();
|
||||
if (!fecha) { document.getElementById('repr-error').classList.remove('d-none'); return; }
|
||||
this._reprModal.hide();
|
||||
try {
|
||||
const r = await fetch('api/lab/save_domicilio.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ id, reprogramar: true, nueva_fecha: fecha, nueva_hora: hora, motivo }),
|
||||
});
|
||||
const d = await r.json();
|
||||
if (d.success) {
|
||||
this.cargar();
|
||||
} else {
|
||||
alert(d.error || 'Error al reprogramar');
|
||||
}
|
||||
} catch (e) {
|
||||
alert('Error al reprogramar: ' + e.message);
|
||||
}
|
||||
},
|
||||
|
||||
// ── Modal servicio extra ──────────────────────────────────────────────
|
||||
abrirServicioExtra(domId) {
|
||||
document.getElementById('se-dom-id').value = domId;
|
||||
@@ -1194,6 +1237,29 @@ const formVer = {
|
||||
placeholder="Casa azul, portón negro…">
|
||||
</div>
|
||||
|
||||
<!-- Tipo cliente -->
|
||||
<div class="mb-3 p-2 rounded border bg-light">
|
||||
<label class="form-label small fw-semibold mb-2 d-block">
|
||||
<i class="fas fa-id-card me-1"></i>Tipo de cliente
|
||||
</label>
|
||||
<div class="d-flex gap-2">
|
||||
<input type="radio" class="btn-check" name="na-tipo-cliente" id="na-tc-particular"
|
||||
value="particular" checked onchange="agendaNueva._toggleSeguro()">
|
||||
<label class="btn btn-sm btn-outline-secondary" for="na-tc-particular">
|
||||
<i class="fas fa-wallet me-1"></i>Particular
|
||||
</label>
|
||||
<input type="radio" class="btn-check" name="na-tipo-cliente" id="na-tc-seguro"
|
||||
value="seguro" onchange="agendaNueva._toggleSeguro()">
|
||||
<label class="btn btn-sm btn-outline-info" for="na-tc-seguro">
|
||||
<i class="fas fa-shield-alt me-1"></i>Seguro
|
||||
</label>
|
||||
</div>
|
||||
<div id="na-seguro-row" class="mt-2 d-none">
|
||||
<input type="text" id="na-seguro-nombre" class="form-control form-control-sm"
|
||||
placeholder="Nombre del seguro: Sura, Colsanitas…">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Fecha y hora -->
|
||||
<div class="row g-2 mb-3">
|
||||
<div class="col-7">
|
||||
@@ -1344,6 +1410,12 @@ const agendaNueva = {
|
||||
document.getElementById('na-valor-dom').value = '';
|
||||
document.getElementById('na-valor-cop').value = '';
|
||||
document.getElementById('na-fecha').value = document.getElementById('portal-fecha').value;
|
||||
// Reset tipo cliente a particular
|
||||
const tcPart = document.getElementById('na-tc-particular');
|
||||
if (tcPart) { tcPart.checked = true; }
|
||||
document.getElementById('na-seguro-row')?.classList.add('d-none');
|
||||
const snEl = document.getElementById('na-seguro-nombre');
|
||||
if (snEl) snEl.value = '';
|
||||
// Reset archivo adjunto
|
||||
document.getElementById('na-orden-file').value = '';
|
||||
document.getElementById('na-orden-preview').innerHTML = '';
|
||||
@@ -1472,6 +1544,12 @@ const agendaNueva = {
|
||||
}
|
||||
},
|
||||
|
||||
_toggleSeguro() {
|
||||
const esSeguro = document.querySelector('input[name="na-tipo-cliente"]:checked')?.value === 'seguro';
|
||||
document.getElementById('na-seguro-row').classList.toggle('d-none', !esSeguro);
|
||||
if (!esSeguro) document.getElementById('na-seguro-nombre').value = '';
|
||||
},
|
||||
|
||||
limpiarPaciente() {
|
||||
document.getElementById('na-paciente-id').value = '';
|
||||
document.getElementById('na-paciente-buscar').value = '';
|
||||
@@ -1576,7 +1654,10 @@ const agendaNueva = {
|
||||
fecha_programada: fecha,
|
||||
hora_programada: document.getElementById('na-hora').value || null,
|
||||
tipo_servicio: 'domicilio',
|
||||
tipo_cliente: 'particular',
|
||||
tipo_cliente: document.querySelector('input[name="na-tipo-cliente"]:checked')?.value || 'particular',
|
||||
seguro_nombre: (document.querySelector('input[name="na-tipo-cliente"]:checked')?.value === 'seguro')
|
||||
? (document.getElementById('na-seguro-nombre').value.trim() || null)
|
||||
: null,
|
||||
valor_domicilio: parseFloat(document.getElementById('na-valor-dom').value) || null,
|
||||
valor_copago: parseFloat(document.getElementById('na-valor-cop').value) || null,
|
||||
notas_admin: document.getElementById('na-notas').value.trim() || null,
|
||||
|
||||
Reference in New Issue
Block a user