File "RegistrosA.php"
Full Path: C:/wamp64/www/INVENTAPP/RegistrosA.php
File size: 4.88 KB
MIME-type: text/html
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>
<style>
body { font-family: Arial; background-color: #f4f4f4; margin: 0; padding: 0; }
.container { width: 80%; margin: auto; }
header { background: #50b3a2; 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: #f2f2f2; }
.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: #50b3a2; color: #ffffff; border: none; cursor: pointer; }
input[type="submit"]:hover { background-color: #45a089; }
</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 = $_POST['CON6'];
$PLAN1 = $_POST['CON6']."A";
$tabla = $conexion->query("SELECT DISTINCT CODPROD, CODUBI, NPROD FROM mvdcto WHERE TPDCTO='$CON' AND CODUBI='$UBI' ORDER BY CODUBI ASC;");
echo '<table>';
echo '<tr>
<th>Cod Ubicación</th><th>Producto</th><th>Descripción</th>
<th>Kilos U1</th><th>Unids U1</th><th>Canastas U1</th><th>Cajas U1</th><th>Bultos U1</th><th>Bases U1</th>
<th>Kilos U2</th><th>Unids U2</th><th>Canastas U2</th><th>Cajas U2</th><th>Bultos U2</th><th>Bases U2</th>
</tr>';
while ($row = $tabla->fetch_array()) {
$CODIGO = $row['CODPROD'];
$UBICACION = $row['CODUBI'];
$NOMBREP = $row['NPROD'];
// Consulta para Usuario 1
$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(BASES) AS BASES
FROM mvdcto
WHERE TPDCTO='$CON' AND CODUBI='$UBI' AND CODPROD='$CODIGO' AND USUARIO='$PLAN';");
$res1 = $query1->fetch_array();
// Consulta para Usuario 2
$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(BASES) AS BASES
FROM mvdcto
WHERE TPDCTO='$CON' AND CODUBI='$UBI' AND CODPROD='$CODIGO' AND USUARIO='$PLAN1';");
$res2 = $query2->fetch_array();
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>";
}
echo '</table>';
}
?>
</div>
</body>
</html>