36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
require_once __DIR__.'/auth_guard.php';
|
||
|
|
require_once __DIR__.'/audit.php';
|
||
|
|
|
||
|
|
require_once "../config.php";
|
||
|
|
|
||
|
|
$idcat = isset($_POST['idcat']) ? (int)$_POST['idcat'] : 0;
|
||
|
|
$urlimgcat = isset($_POST['urlimgcat']) ? $_POST['urlimgcat'] : '';
|
||
|
|
$nombre = isset($_POST['nombre']) ? $_POST['nombre'] : '';
|
||
|
|
$desc = isset($_POST['desc']) ? $_POST['desc'] : '';
|
||
|
|
$habilitado = isset($_POST['habilitado']) ? (int)$_POST['habilitado'] : 0;
|
||
|
|
$order = isset($_POST['order']) ? (int)$_POST['order'] : 0;
|
||
|
|
$clave = isset($_POST['clave']) ? $_POST['clave'] : '';
|
||
|
|
$catsuperior = isset($_POST['catsuperior']) ? (int)$_POST['catsuperior'] : 0;
|
||
|
|
|
||
|
|
global $link;
|
||
|
|
dbConnect();
|
||
|
|
|
||
|
|
$sql = "UPDATE categoria SET padre=?, imagen=?, nombre=?, clave=?, descripcion=?, habilitado=?, order_desc=? WHERE id=?";
|
||
|
|
$stmt = mysqli_prepare($link, $sql);
|
||
|
|
if ($stmt) {
|
||
|
|
mysqli_stmt_bind_param($stmt, 'issssiii', $catsuperior, $urlimgcat, $nombre, $clave, $desc, $habilitado, $order, $idcat);
|
||
|
|
if (mysqli_stmt_execute($stmt)) {
|
||
|
|
audit_log('categoria_update', 'id=' . $idcat . ' nombre=' . $nombre . ' padre=' . $catsuperior);
|
||
|
|
echo "Actualización correcta";
|
||
|
|
} else {
|
||
|
|
http_response_code(500);
|
||
|
|
echo "Error al actualizar categoría";
|
||
|
|
}
|
||
|
|
mysqli_stmt_close($stmt);
|
||
|
|
} else {
|
||
|
|
http_response_code(500);
|
||
|
|
echo "Error al preparar la consulta";
|
||
|
|
}
|
||
|
|
?>
|