File "process_form.php"
Full Path: C:/wamp64/www/INVENTALMACEN/process_form.php
File size: 7.33 KB
MIME-type: text/x-php
Charset: utf-8
<?php
session_start();
header("Cache-control: private"); // Arregla IE 6
include("conexion.php");
$FECHA = date("Y-m-d");
$USUARIO = $_SESSION['nomUser'];
$UBICACION = $_SESSION['ubicacion'];
$DCTO = $_SESSION['dcto'];
$ESTADO = $_SESSION['ESTADO'];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$nombre_planillador = $_POST['nombre_planillador'];
$nombre_auditor = $_POST['nombre_auditor'];
$nombre_pesador = $_POST['nombre_pesador'];
$signature_planillador = $_POST['signaturePlanillador'];
$signature_auditor = $_POST['signatureAuditor'];
$signature_pesador = $_POST['signaturePesador'];
// Consulta para insertar los datos en la base de datos
$sql = "INSERT INTO ACTAS (FECHA, CONSECUTIVO, CUARTO, PESADOR, AUDITOR, PLANILLADOR, FPESADOR, FAUDITOR, FPLANILLADOR, USUARIO)
VALUES ('$FECHA', '$DCTO', '$UBICACION', '$nombre_pesador', '$nombre_auditor', '$nombre_planillador', '$signature_pesador', '$signature_auditor', '$signature_planillador', '$USUARIO')";
if (mysqli_query($conexion, $sql)) {
// Consulta SQL para obtener los datos agregados
$sql = "SELECT SUM(CANTIDAD) AS CANTIDAD, SUM(CANTEMPAQ) AS UNIDADES, SUM(CNASTAPLL) AS CANASTAS, SUM(CAJAS) AS CAJAS, SUM(BULTOS) AS BULTOS, SUM(BASES) AS BASES FROM mvdcto WHERE USUARIO='$USUARIO' AND TPDCTO='$DCTO' AND CODUBI='$UBICACION'";
$result = mysqli_query($conexion, $sql);
if ($result) {
$row = mysqli_fetch_assoc($result);
$cantidad = $row['CANTIDAD'];
$unidades = $row['UNIDADES'];
$canastas = $row['CANASTAS'];
$cajas = $row['CAJAS'];
$bultos = $row['BULTOS'];
$bases = $row['BASES'];
} else {
echo "Error en la consulta: " . mysqli_error($conexion);
}
// Segunda consulta SQL (aunque es la misma, se imprime para claridad)
$sql1 = "SELECT SUM(CANTIDAD) AS CANTIDAD, SUM(CANTEMPAQ) AS UNIDADES, SUM(CNASTAPLL) AS CANASTAS, SUM(CAJAS) AS CAJAS, SUM(BULTOS) AS BULTOS, SUM(BASES) AS BASES FROM mvdcto WHERE USUARIO='$USUARIO' AND TPDCTO='$DCTO' AND CODUBI='$UBICACION'";
$result1 = mysqli_query($conexion, $sql1);
if ($result1) {
$row1 = mysqli_fetch_assoc($result1);
$cantidad1 = $row1['CANTIDAD'];
$unidades1 = $row1['UNIDADES'];
$canastas1 = $row1['CANASTAS'];
$cajas1 = $row1['CAJAS'];
$bultos1 = $row1['BULTOS'];
$bases1 = $row1['BASES'];
} else {
$cantidad1 = 0;
$unidades1 = 0;
$canastas1 = 0;
$cajas1 = 0;
$bultos1 = 0;
$bases1 = 0;
}
// Diseño del acta
echo "<div style='font-family: Arial, sans-serif; margin: 20px; width: 8.5in; height: 11in; border: 1px solid #000; padding: 1in; background: #f9f9f9; color: #333;'>";
// Header con logo y título
echo "<div style='text-align: center;'>";
echo "<img src='logo.png' alt='Logo' style='width: 100px; height: auto;'><br>";
echo "<h2 style='color: #4CAF50;'>Acta de Registro</h2>"; // Color del título
echo "</div>";
// Información general
echo "<p><strong>Fecha:</strong> " . $FECHA . "</p>";
echo "<p><strong>Usuario:</strong> " . $USUARIO . "</p>";
echo "<p><strong>Ubicación:</strong> " . $UBICACION . "</p>";
echo "<p><strong>Documento:</strong> " . $DCTO . "</p>";
echo "<p><strong>Estado:</strong> " . $ESTADO . "</p>";
// Detalles del Registro
echo "<div style='background-color: #eaf2f8; padding: 15px; border-radius: 8px; margin-top: 20px;'>";
echo "<h3 style='color: #2980b9;'>Detalles del Registro:</h3>";
echo "<p><strong>Planillador:</strong> " . $nombre_planillador . "</p>";
echo "<p><strong>Auditor:</strong> " . $nombre_auditor . "</p>";
echo "<p><strong>Pesador:</strong> " . $nombre_pesador . "</p>";
echo "</div>";
// Resultados de Consultas SQL
echo "<div style='background-color: #f2f2f2; padding: 15px; border-radius: 8px; margin-top: 20px;'>";
echo "<h3 style='color: #8e44ad;'>Detalle de los Registros:</h3>";
echo "<table style='width: 100%; border-collapse: collapse; border: 1px solid #ddd;'>";
echo "<tr><th style='border: 1px solid #000; padding: 8px; background-color: #f2f2f2;'>Consulta SQL</th><th style='border: 1px solid #000; padding: 8px;'>Cantidad</th><th style='border: 1px solid #000; padding: 8px;'>Unidades</th><th style='border: 1px solid #000; padding: 8px;'>Canastas</th><th style='border: 1px solid #000; padding: 8px;'>Cajas</th><th style='border: 1px solid #000; padding: 8px;'>Bultos</th><th style='border: 1px solid #000; padding: 8px;'>Bases</th></tr>";
// Imprimir ambas consultas
echo "<tr style='background-color: #f9f9f9;'><td style='border: 1px solid #000; padding: 8px;'>Usuario Digitador</td><td style='border: 1px solid #000; padding: 8px;'>" . $cantidad . "</td><td style='border: 1px solid #000; padding: 8px;'>" . $unidades . "</td><td style='border: 1px solid #000; padding: 8px;'>" . $canastas . "</td><td style='border: 1px solid #000; padding: 8px;'>" . $cajas . "</td><td style='border: 1px solid #000; padding: 8px;'>" . $bultos . "</td><td style='border: 1px solid #000; padding: 8px;'>" . $bases . "</td></tr>";
echo "<tr><td style='border: 1px solid #000; padding: 8px;'>Usuario Auditor</td><td style='border: 1px solid #000; padding: 8px;'>" . $cantidad1 . "</td><td style='border: 1px solid #000; padding: 8px;'>" . $unidades1 . "</td><td style='border: 1px solid #000; padding: 8px;'>" . $canastas1 . "</td><td style='border: 1px solid #000; padding: 8px;'>" . $cajas1 . "</td><td style='border: 1px solid #000; padding: 8px;'>" . $bultos1 . "</td><td style='border: 1px solid #000; padding: 8px;'>" . $bases1 . "</td></tr>";
echo "</table>";
echo "</div>";
// Firmas
echo "<div style='background-color: #fefefe; padding: 15px; border-radius: 8px; margin-top: 20px;'>";
echo "<h3 style='color: #2c3e50;'>Firmas:</h3>";
echo "<div style='display: flex; justify-content: space-between;'>";
echo "<div style='text-align: center;'><strong>Planillador:</strong><br>" . $nombre_planillador . "<br><img src='" . $signature_planillador . "' alt='Firma Planillador' style='width: 150px; height: auto;'></div>";
echo "<div style='text-align: center;'><strong>Auditor:</strong><br>" . $nombre_auditor . "<br><img src='" . $signature_auditor . "' alt='Firma Auditor' style='width: 150px; height: auto;'></div>";
echo "<div style='text-align: center;'><strong>Pesador:</strong><br>" . $nombre_pesador . "<br><img src='" . $signature_pesador . "' alt='Firma Pesador' style='width: 150px; height: auto;'></div>";
echo "</div>";
echo "</div>";
echo "</div>";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conexion);
}
mysqli_close($conexion);
}
?>
<style>
@media print {
body {
width: 100%;
margin: 0;
padding: 0;
}
div {
width: 8.5in;
height: 11in;
}
table {
page-break-inside: avoid;
}
h2 {
font-size: 24px;
}
}
</style>