<?php
$ruta = "../";
require_once "../class/c_login.php";

// check if the session is started
if (!isset($_SESSION['user']))
    die(json_encode(['error' => 'No se ha iniciado sesión']));

$user = unserialize($_SESSION['user']);
$ruta = "../";
require_once "../include/bd_pdo.php";
$old = query("SELECT * FROM FS_CARRERA WHERE ID = :id", [':id' => $_POST['id']]);
$sql = "SELECT fu_updatecarrera(:idcarrera, :nombre, :activa, :idnivel)";
print_r($_POST);
$params = [':idcarrera' => $_POST['id'], ':nombre' => mb_strtoupper($_POST['nombre']), ':activa' => $_POST['estado'], ':idnivel' => $_POST['nivel']];
query($sql, $params, true);
$user->print_to_log("Actualiza carrera.", old: $old, new: $params);
header("Location: ../carreras.php?facultad=" . $_POST['facultad']);
exit();