feat: módulo lab_examenes — CRUD catálogo de exámenes, items y tarifas
- Nuevo módulo lab_examenes con lista paginada, buscador y filtro por categoría - Vista de detalle/edición con campos completos de exam_tipos (CUPS, protocolo, tipo muestra, nivel, abreviatura, seremite, ayuno, instrucciones) - Sub-tabla inline de items de resultado (lab_items_resultado) con edición por fila - Sub-tabla de precios por tarifa (lab_tarifas) con modal de edición - APIs: list, get, save, save_item, save_tarifa, get_tarifas - Script ETL Firebird→MySQL (scripts/etl_examenes.php) para la migración inicial Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
229977785b
commit
fb0e77523c
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
ob_start();
|
||||
require_once __DIR__ . '/../../../config/config.php';
|
||||
error_reporting(E_ERROR | E_PARSE);
|
||||
ini_set('display_errors', '0');
|
||||
ini_set('html_errors', '0');
|
||||
|
||||
register_shutdown_function(function () {
|
||||
$err = error_get_last();
|
||||
if ($err && in_array($err['type'], [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR])) {
|
||||
ob_clean();
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode(['ok' => false, 'error' => 'Error interno: ' . $err['message']]);
|
||||
}
|
||||
});
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(204); exit; }
|
||||
|
||||
function jsonOk(array $data = [], string $msg = ''): never {
|
||||
ob_clean();
|
||||
$r = ['ok' => true];
|
||||
if ($msg) $r['message'] = $msg;
|
||||
if ($data) $r = array_merge($r, $data);
|
||||
echo json_encode($r);
|
||||
exit;
|
||||
}
|
||||
|
||||
function jsonError(string $msg, int $code = 400): never {
|
||||
ob_clean();
|
||||
http_response_code($code);
|
||||
echo json_encode(['ok' => false, 'error' => $msg]);
|
||||
exit;
|
||||
}
|
||||
|
||||
function requireAdmin(): void {
|
||||
if (!isUserLoggedIn()) jsonError('No autorizado', 401);
|
||||
$role = $_SESSION['admin_user']['role'] ?? '';
|
||||
if (!in_array($role, ['superadmin', 'admin', 'supervisor'], true)) jsonError('Sin permiso', 403);
|
||||
}
|
||||
|
||||
function requireLogin(): void {
|
||||
if (!isUserLoggedIn()) jsonError('No autorizado', 401);
|
||||
}
|
||||
|
||||
function inputJson(): array {
|
||||
return json_decode(file_get_contents('php://input'), true) ?? [];
|
||||
}
|
||||
|
||||
function db(): PDO {
|
||||
$pdo = Database::getInstance()->getConnection();
|
||||
$pdo->exec("SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci");
|
||||
return $pdo;
|
||||
}
|
||||
Reference in New Issue
Block a user