feat(medicos): módulo CRUD de médicos con tabla, búsqueda y modal edición
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
665fee99a9
commit
1574f12275
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../../config/config.php';
|
||||
if (!isUserLoggedIn()) { http_response_code(401); echo json_encode(['ok'=>false,'error'=>'No autorizado']); exit; }
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['ok'=>false,'error'=>'Método no permitido']); exit;
|
||||
}
|
||||
|
||||
$datos = json_decode(file_get_contents('php://input'), true) ?? [];
|
||||
$id = !empty($datos['id']) ? (int)$datos['id'] : 0;
|
||||
|
||||
if (!$id) { echo json_encode(['ok'=>false,'error'=>'ID inválido.']); exit; }
|
||||
|
||||
$pdo = Database::getInstance()->getConnection();
|
||||
$stmt = $pdo->prepare("DELETE FROM medicos WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
|
||||
if ($stmt->rowCount()) {
|
||||
echo json_encode(['ok'=>true,'mensaje'=>'Médico eliminado.']);
|
||||
} else {
|
||||
echo json_encode(['ok'=>false,'error'=>'Médico no encontrado.']);
|
||||
}
|
||||
Reference in New Issue
Block a user