File "audita.php"
Full Path: C:/wamp64/www/INVENTALMACEN/audita.php
File size: 11.55 KB
MIME-type: text/x-php
Charset: utf-8
<?PHP
session_start();
header("Cache-control: private");
include("conexion.php");
$conexion->set_charset("utf8");
$FECHA = date("Y-m-d");
$doc = $_SESSION['dcto'];
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Comparativo Inventario por Usuario</title>
<link rel="icon" type="image/png" href="img/icon.png">
<style>
body {
font-family: 'Segoe UI', Arial, sans-serif;
background: linear-gradient(135deg, #f4f4f4, #fdfdfd);
margin: 0;
padding: 0;
color: #333;
}
/* Contenedor principal */
.container {
width: 95%;
margin: auto;
padding: 15px;
}
/* Encabezado */
header {
background: linear-gradient(135deg, #800020, #5a0016);
color: white;
padding: 25px 0;
text-align: center;
box-shadow: 0 4px 10px rgba(0,0,0,0.2);
border-bottom: 4px solid #a88100;
}
/* Tablas */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}
th, td {
border: 1px solid #eee;
padding: 12px;
text-align: center;
transition: background 0.2s ease-in-out;
}
th {
background: #800020;
color: white;
text-transform: uppercase;
letter-spacing: 0.5px;
}
/* Filas alternas */
tr:nth-child(even) {
background-color: #fafafa;
}
tr:hover {
background-color: #ffe6eb;
transform: scale(1.01);
}
/* Clases para usuarios */
.user1 {
background-color: #e6f7ff;
}
.user2 {
background-color: #fff2e6;
}
/* Formularios */
form {
background: #ffffff;
padding: 25px;
margin-top: 20px;
border-radius: 12px;
box-shadow: 0 6px 18px rgba(0,0,0,0.1);
transition: all 0.3s ease-in-out;
}
form:hover {
transform: translateY(-2px);
}
/* Inputs y selects */
select, input[type="submit"] {
width: 100%;
padding: 12px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 8px;
transition: all 0.3s ease;
font-size: 15px;
}
select:focus {
border-color: #800020;
box-shadow: 0 0 6px rgba(128,0,32,0.5);
outline: none;
}
/* Botón */
input[type="submit"] {
background: linear-gradient(135deg, #a88100, #806200);
color: #ffffff;
border: none;
font-weight: bold;
cursor: pointer;
letter-spacing: 1px;
text-transform: uppercase;
transition: all 0.3s ease;
}
input[type="submit"]:hover {
background: linear-gradient(135deg, #2fa700, #1d6f00);
transform: scale(1.05);
}
.boton-dinamico {
background: linear-gradient(135deg, #006900ff, #2eb829ff); /* vinotinto degradado */
color: #fff;
padding: 12px 20px;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.boton-dinamico:hover {
background: linear-gradient(135deg, #a83279, #800020);
transform: scale(1.05);
box-shadow: 0 6px 10px rgba(0,0,0,0.3);
}
.boton-dinamico:active {
transform: scale(0.95);
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>Control de Registros Inventario General AVICAMPO PEREIRA</h1>
</header>
<form class="form-horizontal p-4 bg-light rounded shadow-sm" method="post">
<h5 class="text-vinotinto mb-4"><strong>Parámetros de Consulta</strong></h5>
<div class="row mb-3">
<label for="CON" class="col-sm-3 col-form-label"><strong>Consecutivo</strong></label>
<div class="col-sm-9">
<select name="CON" id="CON" class="form-control">
<?php
$tabla = $conexion->query("SELECT * FROM documento;");
while ($row_consulta_form = $tabla->fetch_array()) {
$NOMBREP = $row_consulta_form['dcto'];
echo '<option value="' . $NOMBREP . '">' . $NOMBREP . '</option>';
}
?>
</select>
</div>
</div>
<div class="row mb-3">
<label for="CON4" class="col-sm-3 col-form-label"><strong>Ubicación</strong></label>
<div class="col-sm-9">
<select name="CON4" id="CON4" class="form-control">
<option>Todas</option>
<?php
$tabla = $conexion->query("SELECT DISTINCT CODUBI FROM mvdcto WHERE TPDCTO='$doc';");
while ($row_consulta_form = $tabla->fetch_array()) {
$ubi = $row_consulta_form['CODUBI'];
echo '<option value="' . $ubi . '">' . $ubi . '</option>';
}
?>
</select>
</div>
</div>
<div class="row mb-4">
<label for="CON6" class="col-sm-3 col-form-label"><strong>Usuario</strong></label>
<div class="col-sm-9">
<select name="CON6" id="CON6" class="form-control">
<option>Todos</option>
<?php
$tabla = $conexion->query("SELECT DISTINCT USUARIO FROM mvdcto WHERE TPDCTO='$doc';");
while ($row_consulta_form = $tabla->fetch_array()) {
$USERT = $row_consulta_form['USUARIO'];
echo '<option value="' . $USERT . '">' . $USERT . '</option>';
}
?>
</select>
</div>
</div>
<div class="text-center">
<button type="submit" name="enviar" id="enviar" class="boton-dinamico">
<i class="fas fa-search"></i> CONSULTAR INFORMACIÓN
</button>
</div>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$CON = $_POST['CON'];
$UBI = $_POST['CON4'];
$PLAN = trim($_POST['CON6']);
$PLAN1 = $PLAN . "A";
if ($PLAN == "Todos") {
echo "<p style='color:red;'>Por favor seleccione un usuario específico.</p>";
exit;
}
$whereUbi = ($UBI == "Todas") ? "" : "AND CODUBI='$UBI'";
$tabla = $conexion->query("SELECT DISTINCT CODPROD, CODUBI, NPROD FROM mvdcto WHERE TPDCTO='$CON' $whereUbi ORDER BY CODUBI ASC;");
echo "<p>Comparando Usuario 1: <strong>$PLAN</strong> con Usuario 2: <strong>$PLAN1</strong></p>";
// Inicializar totales
$totals = array_fill_keys(['K1', 'U1', 'CN1', 'CJ1', 'B1', 'BS1', 'K2', 'U2', 'CN2', 'CJ2', 'B2', 'BS2'], 0);
$diferencias = [];
echo '<table>';
echo '<tr>
<th>Cod Ubicación</th><th>Producto</th><th>Descripción</th>
<th>Kilos ' . $PLAN . '</th><th>Unids ' . $PLAN . '</th><th>Canastas ' . $PLAN . '</th><th>Cajas ' . $PLAN . '</th><th>Bultos ' . $PLAN . '</th><th>Canastillas ' . $PLAN . '</th>
<th>Kilos ' . $PLAN1 . '</th><th>Unids ' . $PLAN1 . '</th><th>Canastas ' . $PLAN1 . '</th><th>Cajas ' . $PLAN1 . '</th><th>Bultos ' . $PLAN1 . '</th><th>Canastillas ' . $PLAN1 . '</th>
</tr>';
while ($row = $tabla->fetch_array()) {
$CODIGO = $row['CODPROD'];
$UBICACION = $row['CODUBI'];
$NOMBREP = $row['NPROD'];
$query1 = $conexion->query("SELECT
SUM(CANTIDAD) AS KILOS, SUM(CANTEMPAQ) AS UNDS, SUM(CNASTAPLL) AS CANASTAS,
SUM(CAJAS) AS CAJAS, SUM(BULTOS) AS BULTOS, SUM(CNASTILLAPLL) AS BASES
FROM mvdcto
WHERE TPDCTO='$CON' $whereUbi AND CODPROD='$CODIGO' AND USUARIO='$PLAN' AND ESTADO<>'PESO ELIMINADO';");
$res1 = $query1->fetch_array();
$query2 = $conexion->query("SELECT
SUM(CANTIDAD) AS KILOS, SUM(CANTEMPAQ) AS UNDS, SUM(CNASTAPLL) AS CANASTAS,
SUM(CAJAS) AS CAJAS, SUM(BULTOS) AS BULTOS, SUM(CNASTILLAPLL) AS BASES
FROM mvdcto
WHERE TPDCTO='$CON' $whereUbi AND CODPROD='$CODIGO' AND USUARIO='$PLAN1' AND ESTADO<>'PESO ELIMINADO';");
$res2 = $query2->fetch_array();
// Acumuladores
$totals['K1'] += $res1['KILOS'] ?? 0;
$totals['U1'] += $res1['UNDS'] ?? 0;
$totals['CN1'] += $res1['CANASTAS'] ?? 0;
$totals['CJ1'] += $res1['CAJAS'] ?? 0;
$totals['B1'] += $res1['BULTOS'] ?? 0;
$totals['BS1'] += $res1['BASES'] ?? 0;
$totals['K2'] += $res2['KILOS'] ?? 0;
$totals['U2'] += $res2['UNDS'] ?? 0;
$totals['CN2'] += $res2['CANASTAS'] ?? 0;
$totals['CJ2'] += $res2['CAJAS'] ?? 0;
$totals['B2'] += $res2['BULTOS'] ?? 0;
$totals['BS2'] += $res2['BASES'] ?? 0;
// Comparar diferencias
if (
($res1['KILOS'] ?? 0) != ($res2['KILOS'] ?? 0) ||
($res1['UNDS'] ?? 0) != ($res2['UNDS'] ?? 0) ||
($res1['CANASTAS'] ?? 0) != ($res2['CANASTAS'] ?? 0) ||
($res1['CAJAS'] ?? 0) != ($res2['CAJAS'] ?? 0) ||
($res1['BULTOS'] ?? 0) != ($res2['BULTOS'] ?? 0) ||
($res1['BASES'] ?? 0) != ($res2['BASES'] ?? 0)
) {
$diferencias[] = "Diferencia en producto $CODIGO ($NOMBREP) - Ubicación: $UBICACION";
}
echo "<tr>
<td>$UBICACION</td><td>$CODIGO</td><td>$NOMBREP</td>
<td class='user1'>" . number_format($res1['KILOS'] ?? 0, 2) . "</td>
<td class='user1'>" . ($res1['UNDS'] ?? 0) . "</td>
<td class='user1'>" . ($res1['CANASTAS'] ?? 0) . "</td>
<td class='user1'>" . ($res1['CAJAS'] ?? 0) . "</td>
<td class='user1'>" . ($res1['BULTOS'] ?? 0) . "</td>
<td class='user1'>" . ($res1['BASES'] ?? 0) . "</td>
<td class='user2'>" . number_format($res2['KILOS'] ?? 0, 2) . "</td>
<td class='user2'>" . ($res2['UNDS'] ?? 0) . "</td>
<td class='user2'>" . ($res2['CANASTAS'] ?? 0) . "</td>
<td class='user2'>" . ($res2['CAJAS'] ?? 0) . "</td>
<td class='user2'>" . ($res2['BULTOS'] ?? 0) . "</td>
<td class='user2'>" . ($res2['BASES'] ?? 0) . "</td>
</tr>";
}
// Mostrar totales
echo "<tr style='font-weight:bold; background-color:#dff0d8'>
<td colspan='3'>TOTAL</td>
<td class='user1'>" . number_format($totals['K1'], 2) . "</td>
<td class='user1'>" . $totals['U1'] . "</td>
<td class='user1'>" . $totals['CN1'] . "</td>
<td class='user1'>" . $totals['CJ1'] . "</td>
<td class='user1'>" . $totals['B1'] . "</td>
<td class='user1'>" . $totals['BS1'] . "</td>
<td class='user2'>" . number_format($totals['K2'], 2) . "</td>
<td class='user2'>" . $totals['U2'] . "</td>
<td class='user2'>" . $totals['CN2'] . "</td>
<td class='user2'>" . $totals['CJ2'] . "</td>
<td class='user2'>" . $totals['B2'] . "</td>
<td class='user2'>" . $totals['BS2'] . "</td>
</tr>";
echo '</table>';
// Mostrar diferencias
if (!empty($diferencias)) {
echo "<h3>Diferencias encontradas:</h3><ul>";
foreach ($diferencias as $dif) {
echo "<li>$dif</li>";
}
echo "</ul>";
} else {
echo "<p style='color:green;'>No se encontraron diferencias entre los usuarios.</p>";
}
}
?>
</div>
</body>
</html>