33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?php
|
|
/** GET /api/lab/get_actividad.php — Log de trazabilidad del módulo */
|
|
require_once __DIR__ . '/_helpers.php';
|
|
requireMethod('GET');
|
|
|
|
try {
|
|
$log = new ActividadAdmin();
|
|
|
|
// Caso especial: historial de una entidad concreta
|
|
$entidad = (int)($_GET['entidad_id'] ?? 0);
|
|
$modulo = $_GET['modulo'] ?? '';
|
|
if ($entidad && $modulo) {
|
|
$data = $log->porEntidad($modulo, $entidad);
|
|
jsonOk(['data' => $data, 'total' => count($data), 'paginas' => 1, 'pagina' => 1]);
|
|
exit;
|
|
}
|
|
|
|
$result = $log->filtrar([
|
|
'desde' => $_GET['desde'] ?? '',
|
|
'hasta' => $_GET['hasta'] ?? '',
|
|
'modulo' => $modulo,
|
|
'accion' => $_GET['accion'] ?? '',
|
|
'admin_id' => (int)($_GET['admin_id'] ?? 0) ?: null,
|
|
'buscar' => $_GET['buscar'] ?? '',
|
|
'page' => max(1, (int)($_GET['page'] ?? 1)),
|
|
'per_page' => max(1, min(200, (int)($_GET['limit'] ?? 50))),
|
|
]);
|
|
|
|
jsonOk($result);
|
|
} catch (Exception $e) {
|
|
jsonError($e->getMessage(), 500);
|
|
}
|