cambios
This commit is contained in:
+46
-2
@@ -633,14 +633,14 @@ const portal = {
|
||||
</button>`
|
||||
).join('');
|
||||
|
||||
const btnCancelar = !['completado','cancelado','reprogramado'].includes(est)
|
||||
const btnCancelar = !['completado','cancelado','reprogramado'].includes(est) && item.es_propio
|
||||
? `<button class="btn btn-outline-danger btn-accion"
|
||||
onclick="portal.abrirCancelar(${item.domicilio_id})">
|
||||
❌ Cancelar
|
||||
</button>`
|
||||
: '';
|
||||
|
||||
const btnReprogramar = !['completado','reprogramado'].includes(est)
|
||||
const btnReprogramar = !['completado','reprogramado'].includes(est) && item.es_propio
|
||||
? `<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
|
||||
@@ -1664,6 +1664,7 @@ const agendaNueva = {
|
||||
return;
|
||||
}
|
||||
if (!direccion) { this._mostrarError('La dirección es obligatoria.'); return; }
|
||||
if (direccion.length < 5) { this._mostrarError('La dirección es muy corta. Ej: Cra 15 # 32-10.'); return; }
|
||||
if (!fecha) { this._mostrarError('La fecha es obligatoria.'); return; }
|
||||
|
||||
const btn = document.getElementById('na-btn-guardar');
|
||||
@@ -1681,6 +1682,19 @@ const agendaNueva = {
|
||||
this._mostrarError('El nombre del nuevo paciente es obligatorio.');
|
||||
return;
|
||||
}
|
||||
// Validar formato del nombre
|
||||
if (!/^[\p{L}\s'\-\.]+$/u.test(nombre)) {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="fas fa-calendar-check me-1"></i>Agendar';
|
||||
this._mostrarError('El nombre solo debe contener letras y espacios (sin números ni símbolos).');
|
||||
return;
|
||||
}
|
||||
if (nombre.trim().split(/\s+/).length < 2) {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="fas fa-calendar-check me-1"></i>Agendar';
|
||||
this._mostrarError('Ingresa nombre y apellido completos (mínimo 2 palabras).');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const documento = document.getElementById('na-np-documento').value.trim();
|
||||
if (!documento) {
|
||||
@@ -1689,6 +1703,36 @@ const agendaNueva = {
|
||||
this._mostrarError('El número de documento del paciente es obligatorio.');
|
||||
return;
|
||||
}
|
||||
// Validar formato del documento
|
||||
const tipoDoc = document.getElementById('na-np-tipo-doc').value;
|
||||
if (['CC','TI','RC','CE'].includes(tipoDoc)) {
|
||||
const docDigits = documento.replace(/[^0-9]/g, '');
|
||||
if (docDigits.length < 4 || docDigits.length > 12) {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="fas fa-calendar-check me-1"></i>Agendar';
|
||||
this._mostrarError('La cédula/TI debe tener entre 4 y 12 dígitos.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Validar teléfono si fue ingresado
|
||||
const telRaw = document.getElementById('na-np-telefono').value.trim();
|
||||
if (telRaw) {
|
||||
const telDigits = telRaw.replace(/[^0-9]/g, '');
|
||||
if (!/^(57)?3\d{9}$/.test(telDigits)) {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="fas fa-calendar-check me-1"></i>Agendar';
|
||||
this._mostrarError('El celular debe comenzar por 3 y tener 10 dígitos. Ej: 3001234567.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Validar correo si fue ingresado
|
||||
const emailVal = document.getElementById('na-np-email').value.trim();
|
||||
if (emailVal && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(emailVal)) {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="fas fa-calendar-check me-1"></i>Agendar';
|
||||
this._mostrarError('El correo electrónico no es válido. Ej: nombre@dominio.com.');
|
||||
return;
|
||||
}
|
||||
const rPac = await fetch('api/lab/save_paciente.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
|
||||
Reference in New Issue
Block a user