actividades

This commit is contained in:
Lizandro Guarnizo
2026-04-08 09:02:32 -05:00
parent 3d252efbdd
commit d38b5936ca
12 changed files with 427 additions and 11 deletions
+18 -11
View File
@@ -6,20 +6,27 @@ requireMethod('GET');
try {
$log = new ActividadAdmin();
$modulo = $_GET['modulo'] ?? '';
$adminFilt = (int)($_GET['admin_id'] ?? 0);
$entidad = (int)($_GET['entidad_id'] ?? 0);
$limit = max(1, min(200, (int)($_GET['limit'] ?? 50)));
if ($adminFilt) {
$data = $log->porAdmin($adminFilt, $limit);
} elseif ($entidad && $modulo) {
// Caso especial: historial de una entidad concreta
$entidad = (int)($_GET['entidad_id'] ?? 0);
$modulo = $_GET['modulo'] ?? '';
if ($entidad && $modulo) {
$data = $log->porEntidad($modulo, $entidad);
} else {
$data = $log->reciente($limit, $modulo);
jsonOk(['data' => $data, 'total' => count($data), 'paginas' => 1, 'pagina' => 1]);
exit;
}
jsonOk(['data' => $data, 'total' => count($data)]);
$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);
}