feat(audit): registrar en lab_actividad_admin quien edita formularios de lugar
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
* POST {id, _delete: true} → eliminar
|
* POST {id, _delete: true} → eliminar
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/_helpers.php';
|
require_once __DIR__ . '/_helpers.php';
|
||||||
|
require_once __DIR__ . '/../../../classes/lab/ActividadAdmin.php';
|
||||||
|
|
||||||
requireTurnero();
|
requireTurnero();
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ if ($delete) {
|
|||||||
}
|
}
|
||||||
$stmt = db()->prepare('DELETE FROM turnero_lugares WHERE id = ?');
|
$stmt = db()->prepare('DELETE FROM turnero_lugares WHERE id = ?');
|
||||||
$stmt->execute([$id]);
|
$stmt->execute([$id]);
|
||||||
|
(new ActividadAdmin())->registrar(adminId(), 'turnero_config', 'eliminar_lugar', $id, ['lugar_id' => $id]);
|
||||||
jsonOk([], 'Lugar eliminado');
|
jsonOk([], 'Lugar eliminado');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +92,25 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$pdo->commit();
|
$pdo->commit();
|
||||||
|
|
||||||
|
// Auditoría: registrar quién guardó el lugar y con qué formularios
|
||||||
|
try {
|
||||||
|
$fNombres = [];
|
||||||
|
if (!empty($formularioIds)) {
|
||||||
|
$ph = implode(',', array_fill(0, count($formularioIds), '?'));
|
||||||
|
$fNombres = db()->prepare("SELECT id, nombre FROM lab_formularios WHERE id IN ($ph)");
|
||||||
|
$fNombres->execute(array_values($formularioIds));
|
||||||
|
$fNombres = $fNombres->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||||
|
}
|
||||||
|
(new ActividadAdmin())->registrar(
|
||||||
|
adminId(),
|
||||||
|
'turnero_config',
|
||||||
|
$id ? 'editar_lugar' : 'crear_lugar',
|
||||||
|
$lugarId,
|
||||||
|
['nombre' => $nombre, 'tipo' => $tipo, 'activo' => $activo, 'formularios' => $fNombres]
|
||||||
|
);
|
||||||
|
} catch (\Throwable $_) {}
|
||||||
|
|
||||||
jsonOk(['id' => $lugarId], $id ? 'Lugar actualizado' : 'Lugar creado');
|
jsonOk(['id' => $lugarId], $id ? 'Lugar actualizado' : 'Lugar creado');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$pdo->rollBack();
|
$pdo->rollBack();
|
||||||
|
|||||||
Reference in New Issue
Block a user