File "VERNOEN.PHP-20260419143005.bak"
Full Path: C:/wamp64/www/APPSST/inventario/VERNOEN.PHP-20260419143005.bak
File size: 11.14 KB
MIME-type: text/x-php
Charset: utf-8
<?php
session_start();
header("Cache-control: private");
include("../bd/conexion.php");
// ★★★ DEPURACIÓN DE SESIÓN ★★★
$usuario_sesion = isset($_SESSION['DIGITA']) ? $_SESSION['DIGITA'] : 'Usuario no identificado';
error_log("Usuario en sesión en VERNOEN.PHP: " . $usuario_sesion);
// Función para limpiar datos
function limpiarDato($dato) {
global $conexion;
$dato = trim($dato);
$dato = stripslashes($dato);
$dato = htmlspecialchars($dato);
if ($conexion) {
$dato = $conexion->real_escape_string($dato);
}
return $dato;
}
// Procesar confirmación de entrega
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['CONFIRMA'])) {
header("Location: insertInventario.php");
exit();
}
// Procesar eliminación de elemento
if (isset($_GET['eliminar'])) {
if (isset($_SESSION['elementos_seleccionados'])) {
foreach ($_SESSION['elementos_seleccionados'] as $key => $elemento) {
if ($elemento['codigo'] == $_GET['eliminar']) {
unset($_SESSION['elementos_seleccionados'][$key]);
$_SESSION['mensaje_exito'] = 'Elemento eliminado correctamente';
break;
}
}
$_SESSION['elementos_seleccionados'] = array_values($_SESSION['elementos_seleccionados']);
}
header("Location: VERNOEN.PHP");
exit();
}
// Obtener elementos para mostrar y sus cantidades actuales
$elementos_mostrar = [];
if (isset($_SESSION['elementos_seleccionados'])) {
foreach ($_SESSION['elementos_seleccionados'] as $elemento) {
$codigo = limpiarDato($elemento['codigo']);
$consulta = "SELECT CANTIDAD FROM inventario WHERE CODIGO = '$codigo' AND estado = 0 LIMIT 1";
$resultado = $conexion->query($consulta);
$cantidad_actual = 0;
if ($resultado && $resultado->num_rows > 0) {
$fila = $resultado->fetch_assoc();
$cantidad_actual = $fila['CANTIDAD'];
}
$elementos_mostrar[] = [
'codigo' => $elemento['codigo'],
'descripcion' => $elemento['descripcion'],
'cantidad' => $elemento['cantidad'],
'cantidad_actual' => $cantidad_actual,
'cantidad_total' => $cantidad_actual + $elemento['cantidad']
];
}
}
$mensaje_error = isset($_SESSION['mensaje_error']) ? $_SESSION['mensaje_error'] : '';
$mensaje_exito = isset($_SESSION['mensaje_exito']) ? $_SESSION['mensaje_exito'] : '';
unset($_SESSION['mensaje_error']);
unset($_SESSION['mensaje_exito']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
td {
text-align: center;
}
td th {
text-align: center;
}
.tbl {
margin: 5px;
border-radius: 5px;
}
.mensaje-error {
background-color: #f8d7da;
color: #721c24;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #f5c6cb;
border-radius: 5px;
}
.mensaje-exito {
background-color: #d4edda;
color: #155724;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #c3e6cb;
border-radius: 5px;
}
/* Estilo general */
body {
height: 100vh;
background-image: linear-gradient(225deg, #d0101d, #752b2a);
margin: 0;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
/* Wrapper para centrar el contenido */
.wrapper {
background: linear-gradient(to right, #e2e2e2, #ffe5c9);
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 100%;
padding: 20px;
background-repeat: no-repeat;
background-position: top center;
}
/* Estilo del formulario */
form {
background: white;
border-radius: 25px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.35);
width: 90%;
max-width: 900px;
padding: 20px;
}
/* Estilo del título */
.tituloReg {
margin: 0;
font-size: 1.5em;
text-align: center;
}
/* Estilo de las tablas */
table {
width: 100%;
border-collapse: collapse;
}
table td, table th {
padding: 10px;
text-align: center;
}
.table-hover tbody tr:hover {
background-color: #f5f5f5;
}
.fondoTituloVer {
background-color: #ff8a37;
}
.fondoTituloVer td {
color: #ffffff;
}
/* Estilos responsivos */
@media (max-width: 768px) {
form {
width: 100%;
}
.tituloReg {
font-size: 1.2em;
}
table td, table th {
padding: 8px;
}
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Entrega de Dotacion</title>
<link rel="icon" type="image/png" href="../img/icono.png">
<link rel="shortcut icon" href="./overol.png" />
<link rel="stylesheet" type="text/css" href="../css/menup.css">
<link rel="stylesheet" type="text/css" href="../css/eppdotmanu.css">
<link rel="stylesheet" type="text/css" href="../css/registro.css">
<link rel="stylesheet" type="text/css" href="../css/vernoe.css">
</head>
<div class="user-info">
<strong><i class="fas fa-user"></i> Usuario logueado:</strong> <?php echo $_SESSION['DIGITA']; ?>
</div>
<body style="height: 100vh;background-image: linear-gradient(225deg, #d0101d, #752b2a);">
<div class="wrapper" style="background: linear-gradient(to right, #e2e2e2,#ffe5c9); display: flex;align-items: center;flex-direction: column;justify-content: center;width: 100%;min-height: 100%;padding: 20px;background-repeat: no-repeat;background-position: top center;">
<form class="form-horizontal" method="post" style="background: white;border-radius: 25px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.35);">
<strong>
<CENTER>
<table width="902" height="179" cellspacing="0">
<tr>
<td height="177">
<CENTER>
<hr />
<h3 class="tituloReg">VISUALIZACION INVENTARIO DOTACION</h3>
<hr />
<?php if (!empty($mensaje_error)): ?>
<div class="mensaje-error">
<i class="fa-solid fa-circle-exclamation"></i> <?php echo $mensaje_error; ?>
</div>
<?php endif; ?>
<?php if (!empty($mensaje_exito)): ?>
<div class="mensaje-exito">
<i class="fa-solid fa-circle-check"></i> <?php echo $mensaje_exito; ?>
</div>
<?php endif; ?>
<p>Recuerde que si ya se agregó el item anteriormente, la cantidad se sumará a la existente.</p>
<hr />
<table class="table table-hover" style="width: 90%;" border="1" cellspacing="0" bordercolor="#CCCCCC">
<thead>
<tr class="fondoTituloVer">
<td width="88"><CENTER><font color="#FFFFFF">CODIGO</font></CENTER></td>
<td width="300"><CENTER><font color="#FFFFFF">DESCRIPCIÓN EPP</font></CENTER></td>
<td width="85"><CENTER><font color="#FFFFFF">CANT. ACTUAL</font></CENTER></td>
<td width="85"><CENTER><font color="#FFFFFF">CANT. AÑADIR</font></CENTER></td>
<td width="85"><CENTER><font color="#FFFFFF">TOTAL</font></CENTER></td>
<td width="50"><CENTER></CENTER></td>
</tr>
</thead>
<tbody>
<?php if (!empty($elementos_mostrar)): ?>
<?php foreach ($elementos_mostrar as $elemento): ?>
<tr bordercolor="#800000">
<th height="33"><center><?= $elemento['codigo'] ?></center></th>
<td><center><?= $elemento['descripcion'] ?></center></td>
<td><CENTER><?= $elemento['cantidad_actual'] ?></CENTER></td>
<td><CENTER><?= $elemento['cantidad'] ?></CENTER></td>
<td><CENTER><strong><?= $elemento['cantidad_total'] ?></strong></CENTER></td>
<td style="vertical-align: middle;">
<CENTER>
<a href="VERNOEN.PHP?eliminar=<?= $elemento['codigo'] ?>" class="btn btn-outline-secondary delete-button">
<i class="fa-solid fa-trash-can"></i>
</a>
</CENTER>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr><td colspan="6"><center>No hay elementos seleccionados</center></td></tr>
<?php endif; ?>
</tbody>
</table>
<p>
<a class="btn btn-red btn-lg" href="DOTIN.PHP"><i class="fa-solid fa-circle-arrow-left"></i></a>
<?php if (!empty($elementos_mostrar)): ?>
<button type="submit" name="CONFIRMA" id="CONFIRMA" class="btn btn-orange" title="Entrega de Dotacion">CONFIRMAR</button>
<?php endif; ?>
</p>
</CENTER>
</td>
</tr>
</table>
</CENTER>
</strong>
</form>
</div>
<script src="https://unpkg.com/sweetalert2@7.19.3/dist/sweetalert2.all.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.4/umd/popper.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script>
</script>
</body>
</html>