File "audita.php.bak"
Full Path: C:/wamp64/www/INVENTAPP/audita.php.bak
File size: 11.41 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: Arial;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.container {
width: 100%;
margin: auto;
}
header {
background: #f8a41b;
color: white;
padding: 20px 0;
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th,
td {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
}
th {
background-color: #f8a41b;
color: white;
}
.user1 {
background-color: #e6f7ff;
}
.user2 {
background-color: #fff2e6;
}
form {
background: #ffffff;
padding: 20px;
margin-top: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
select,
input[type="submit"] {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #dddddd;
border-radius: 5px;
}
input[type="submit"] {
background-color: #f8a41b;
color: #ffffff;
border: none;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #d29531;
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>Control de Registros Inventario General AVICAMPO PEREIRA</h1>
</header>
<form class="form-horizontal" method="post">
<p><strong>Parametros de Consulta</strong></p>
<table>
<tr>
<td>
<table>
<tr>
<td><strong>Consecutivo</strong></td>
<td>
<label for="CON"></label>
<select name="CON" id="CON">
<?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>
</td>
</tr>
</table>
<table>
<tr>
<td><strong>Ubicación</strong></td>
<td>
<label for="CON4"></label>
<select name="CON4" id="CON4">
<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>
</td>
</tr>
</table>
<table>
<tr>
<td><strong>Usuario</strong></td>
<td>
<label for="CON6"></label>
<select name="CON6" id="CON6">
<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>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>
<input type="submit" name="enviar" id="enviar" value="***CONSULTAR INFORMACIÓN***" formmethod="post" formaction="" />
</p>
</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';");
$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>