1ra Versión

This commit is contained in:
MarcosFlorSalcedo
2026-07-14 18:24:27 -03:00
commit 8ec55e40fc
86 changed files with 15839 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
<?php
require_once 'conexion.php';
header('Content-Type: application/json');
try {
$data = json_decode(file_get_contents('php://input'), true);
if (!isset($data['columna'])) {
throw new Exception("Columna no especificada");
}
$columna = trim($data['columna']);
// Validar que sea un nombre válido
if (empty($columna)) {
throw new Exception("Columna inválida");
}
// Convertir nombre a formato de columna
$nombre_columna = strtolower(str_replace(' ', '_', $columna));
// Verificar que la columna existe
$sql_check = "SHOW COLUMNS FROM gastos LIKE '" . $conexion->real_escape_string($nombre_columna) . "'";
$result_check = $conexion->query($sql_check);
if ($result_check === false || $result_check->num_rows === 0) {
throw new Exception("La columna de gasto no existe:");
}
// Eliminar la columna
$sql_drop = "ALTER TABLE gastos DROP COLUMN `$nombre_columna`";
if (!$conexion->query($sql_drop)) {
throw new Exception("Error al eliminar columna: " . $conexion->error);
}
echo json_encode([
'success' => true,
'message' => 'Gasto eliminado correctamente'
]);
} catch (Exception $e) {
echo json_encode([
'success' => false,
'message' => $e->getMessage()
]);
}
?>