actividades
This commit is contained in:
+18
-11
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user