<?php
require_once 'db/config.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $column_id = $_POST['column_id'] ?? null;
    $column_name = trim($_POST['column_name']);

    if ($column_id && !empty($column_name)) {
        $pdo = db();
        $stmt = $pdo->prepare('UPDATE kanban_columns SET nombre = :nombre WHERE id = :id');
        $stmt->execute([':nombre' => $column_name, ':id' => $column_id]);
        $_SESSION['success_message'] = 'Columna renombrada exitosamente.';
    } else {
        $_SESSION['error_message'] = 'Faltan datos para renombrar la columna.';
    }
}

header('Location: kanban.php');
exit;