34786-vm/handle_delete_column.php
2025-12-12 16:33:10 +00:00

22 lines
700 B
PHP

<?php
require_once 'db/config.php';
if (isset($_GET['id'])) {
$column_id = $_GET['id'];
$pdo = db();
// Set column_id to NULL for all cards in this column
$stmt_update = $pdo->prepare('UPDATE info_productos SET column_id = NULL WHERE column_id = :column_id');
$stmt_update->execute([':column_id' => $column_id]);
// Delete the column
$stmt_delete = $pdo->prepare('DELETE FROM kanban_columns WHERE id = :id');
$stmt_delete->execute([':id' => $column_id]);
$_SESSION['success_message'] = 'Columna eliminada. Las tarjetas han sido desasignadas.';
} else {
$_SESSION['error_message'] = 'ID de columna no especificado.';
}
header('Location: kanban.php');
exit;