feat(pacientes): verificar WhatsApp al ingresar teléfono, vincular user_id al guardar
fix(recepcion): mostrar nombre_completo en resultados de búsqueda de paciente Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
018d445846
commit
af584bcc26
+25
-1
@@ -283,8 +283,11 @@ require_once __DIR__ . '/shared/components/sidebar.php';
|
||||
<option value="1">🇺🇸 1</option>
|
||||
</select>
|
||||
<input type="tel" class="form-control" name="telefono" id="pac-tel"
|
||||
placeholder="3001234567" tabindex="5" style="border-radius:0 .45rem .45rem 0">
|
||||
placeholder="3001234567" tabindex="5" style="border-radius:0 .45rem .45rem 0"
|
||||
onblur="verificarWhatsapp()">
|
||||
</div>
|
||||
<div id="wa-badge" class="mt-1" style="font-size:.78rem;min-height:18px"></div>
|
||||
<input type="hidden" id="pac-user-id" name="user_id">
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="form-floating">
|
||||
@@ -517,6 +520,27 @@ async function editarPaciente(id) {
|
||||
if (d.data?.[0]) abrirFormulario(d.data[0]);
|
||||
}
|
||||
|
||||
async function verificarWhatsapp() {
|
||||
const prefijo = document.getElementById('pac-tel-prefijo').value || '57';
|
||||
let tel = (document.getElementById('pac-tel').value || '').replace(/[^0-9]/g, '');
|
||||
if (tel.length === 10) tel = prefijo + tel;
|
||||
const badge = document.getElementById('wa-badge');
|
||||
const hiddenUid = document.getElementById('pac-user-id');
|
||||
if (!tel || tel.length < 10) { badge.innerHTML = ''; hiddenUid.value = ''; return; }
|
||||
badge.innerHTML = '<span class="text-muted"><i class="fas fa-spinner fa-spin me-1"></i>Verificando WhatsApp…</span>';
|
||||
try {
|
||||
const r = await fetch(`api/lab/check_whatsapp.php?phone=${encodeURIComponent(tel)}`);
|
||||
const d = await r.json();
|
||||
if (d.ok && d.data.found) {
|
||||
badge.innerHTML = '<span class="text-success"><i class="fab fa-whatsapp me-1"></i>Registrado en WhatsApp</span>';
|
||||
hiddenUid.value = d.data.user_id;
|
||||
} else {
|
||||
badge.innerHTML = '<span class="text-muted"><i class="fas fa-times-circle me-1"></i>Sin WhatsApp registrado</span>';
|
||||
hiddenUid.value = '';
|
||||
}
|
||||
} catch(_) { badge.innerHTML = ''; hiddenUid.value = ''; }
|
||||
}
|
||||
|
||||
async function guardarPaciente() {
|
||||
const form = document.getElementById('form-paciente');
|
||||
if (!form.checkValidity()) { form.reportValidity(); return; }
|
||||
|
||||
Reference in New Issue
Block a user