Files
Sistema-Web-Rotiseria/admin/obtener_detalle.php
T
2026-06-30 14:59:19 -03:00

70 lines
3.6 KiB
PHP

<?php
session_start();
include("../db.php");
if (!isset($_SESSION['rol']) || $_SESSION['rol'] !== 'admin') {
die("Acceso denegado.");
}
$id_pedido = intval($_GET['id'] ?? 0);
if ($id_pedido <= 0) {
die("ID de pedido inválido.");
}
$query_pedido = "SELECT p.*, u.nombre
FROM pedidos p
LEFT JOIN usuarios u ON p.id_usuario = u.id_usuario
WHERE p.id_pedido = '$id_pedido'";
$res_pedido = mysqli_query($conexion, $query_pedido);
$pedido = mysqli_fetch_assoc($res_pedido);
if (!$pedido) {
die("Pedido no encontrado.");
}
$query_detalle = "SELECT d.*, p.nombre as nombre_prod
FROM detalle_pedido d
JOIN productos p ON d.producto_id = p.id
WHERE d.pedido_id = '$id_pedido'";
$res_detalle = mysqli_query($conexion, $query_detalle);
?>
<div class="ticket-interior">
<h3 style="color: #e02828; text-transform: uppercase; border-bottom: 2px dashed #e2e8f0; padding-bottom: 8px; margin-bottom: 12px; font-size: 1.2rem;">
<i class="fa-solid fa-receipt"></i> Pedido #<?php echo $id_pedido; ?>
</h3>
<div style="font-size: 0.85rem; line-height: 1.6; color: #475569; margin-bottom: 15px; background: #fffef8; padding: 10px; border-radius: 8px; border: 1px solid #f1f5f9;">
<p><strong><i class="fa-solid fa-user" style="width: 15px;"></i> Cliente:</strong> <?php echo htmlspecialchars($pedido['nombre'] ?? 'Invitado'); ?></p>
<p><strong><i class="fa-solid fa-phone" style="width: 15px;"></i> Teléfono:</strong> <?php echo htmlspecialchars($pedido['telefono_contacto'] ?? 'No registrado'); ?></p>
<p><strong><i class="fa-solid fa-clock" style="width: 15px;"></i> Fecha:</strong> <?php echo date('d/m/Y H:i', strtotime($pedido['fecha'])); ?></p>
<p><strong><i class="fa-solid fa-truck" style="width: 15px;"></i> Entrega:</strong> <span style="text-transform: capitalize; font-weight: 600;"><?php echo htmlspecialchars($pedido['tipo_entrega']); ?></span></p>
<p><strong><i class="fa-solid fa-location-dot" style="width: 15px;"></i> Dirección:</strong> <?php echo htmlspecialchars($pedido['direccion_envio']); ?></p>
</div>
<table style="width: 100%; border-collapse: collapse; font-size: 0.9rem;">
<thead>
<tr style="border-bottom: 2px solid #edf2f7; text-align: left; color: #94a3b8; font-size: 0.75rem;">
<th style="padding-bottom: 8px;">PRODUCTO</th>
<th style="padding-bottom: 8px; text-align: center;">CANT.</th>
<th style="padding-bottom: 8px; text-align: right;">SUBTOTAL</th>
</tr>
</thead>
<tbody>
<?php while($item = mysqli_fetch_assoc($res_detalle)): ?>
<tr style="border-bottom: 1px solid #f8fafc;">
<td style="padding: 10px 0; font-weight: 500; color: #1e293b;"><?php echo htmlspecialchars($item['nombre_prod']); ?></td>
<td style="padding: 10px 0; text-align: center; color: #64748b;">x<?php echo $item['cantidad']; ?></td>
<td style="padding: 10px 0; text-align: right; font-weight: 600; color: #334155;">$<?php echo number_format($item['precio_unitario'] * $item['cantidad'], 2, ',', '.'); ?></td>
</tr>
<?php endwhile; ?>
<tr style="font-size: 1.1rem; font-weight: bold; color: #e02828;">
<td colspan="2" style="padding-top: 15px; border-top: 2px dashed #e2e8f0;">TOTAL</td>
<td style="padding-top: 15px; text-align: right; border-top: 2px dashed #e2e8f0;">$<?php echo number_format($pedido['total'], 2, ',', '.'); ?></td>
</tr>
</tbody>
</table>
</div>