panel admin: gestion de pedidos

This commit is contained in:
Brisa
2026-06-30 14:59:19 -03:00
parent 47ef868129
commit c0af5c08ae
9 changed files with 1496 additions and 0 deletions
+126
View File
@@ -0,0 +1,126 @@
<?php
include("../db.php");
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
if (!isset($_SESSION['rol']) || $_SESSION['rol'] !== 'admin') {
header("Location: ../login.php?error=acceso_denegado");
exit();
}
$id_pedido = intval($_GET['id'] ?? 0);
if ($id_pedido <= 0) {
header("Location: pedidos.php");
exit();
}
$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) {
header("Location: pedidos.php");
exit();
}
$query_detalle = "SELECT d.*, pr.nombre as nombre_prod
FROM detalle_pedido d
JOIN productos pr ON d.producto_id = pr.id
WHERE d.pedido_id = '$id_pedido'";
$res_detalle = mysqli_query($conexion, $query_detalle);
// ─── CONTROL DINÁMICO DE RETORNO ───
$desde = $_GET['desde'] ?? 'pedidos';
$url_volver = "pedidos.php";
if ($desde === 'dashboard') {
$url_volver = "dashboard.php";
}
// ────────────────────────────────────
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Detalle de Pedido #<?php echo $id_pedido; ?> - La Pecosa</title>
<link rel="stylesheet" href="../css/all.min.css">
<link rel="stylesheet" href="admin_style.css">
<style>
body { font-family: 'Segoe UI', sans-serif; background: #f4f6f9; color: #1e293b; margin: 0; }
.main-content { padding: 40px; flex: 1; min-height: 100vh; }
.btn-volver {
display: inline-flex; align-items: center; gap: 8px;
padding: 10px 22px; font-weight: 600; font-size: 0.9rem;
text-decoration: none; border-radius: 50px; background: #334155; color: white;
transition: all 0.2s; box-shadow: 0 4px 10px rgba(51,65,85,0.1); margin-bottom: 25px;
}
.btn-volver:hover { background: #1e293b; transform: translateY(-1px); }
.ticket-card {
background: white; max-width: 550px; margin: 0 auto;
padding: 35px; border-radius: 20px; box-shadow: 0 10px 30px rgba(15,23,42,0.04);
border-top: 5px solid #e02828;
}
.ticket-card h2 { color: #0f172a; font-size: 1.5rem; font-weight: 700; margin-top: 0; text-transform: uppercase; border-bottom: 2px dashed #edf2f7; padding-bottom: 12px; margin-bottom: 20px; }
.info-cliente-box { font-size: 0.9rem; line-height: 1.6; color: #475569; margin-bottom: 25px; background: #fffef8; padding: 15px; border-radius: 12px; border: 1px solid #f1f5f9; }
.info-cliente-box p { margin: 6px 0; display: flex; align-items: center; gap: 8px; }
.info-cliente-box i { color: #e02828; width: 16px; text-align: center; }
.ticket-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
.ticket-table th { text-align: left; border-bottom: 2px solid #edf2f7; padding-bottom: 10px; color: #94a3b8; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.ticket-table td { padding: 12px 0; border-bottom: 1px solid #f8fafc; font-size: 0.95rem; color: #334155; }
.total-row { font-size: 1.2rem; font-weight: bold; color: #e02828; }
.total-row td { padding-top: 20px; border-top: 2px dashed #edf2f7; border-bottom: none; }
</style>
</head>
<body>
<?php include("sidebar.php"); ?>
<div class="main-content">
<a href="<?php echo $url_volver; ?>" class="btn-volver"><i class="fa-solid fa-arrow-left"></i> Volver atrás</a>
<div class="ticket-card">
<h2><i class="fa-solid fa-receipt"></i> Pedido #<?php echo $id_pedido; ?></h2>
<div class="info-cliente-box">
<p><strong><i class="fa-solid fa-user"></i> Cliente:</strong> <?php echo htmlspecialchars($pedido['nombre'] ?? 'Invitado'); ?></p>
<p><strong><i class="fa-solid fa-phone"></i> Teléfono:</strong> <?php echo htmlspecialchars($pedido['telefono_contacto'] ?? 'S/N'); ?></p>
<p><strong><i class="fa-solid fa-clock"></i> Fecha:</strong> <?php echo date('d/m/Y H:i', strtotime($pedido['fecha'])); ?> hs</p>
<p><strong><i class="fa-solid fa-truck"></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"></i> Dirección:</strong> <?php echo htmlspecialchars($pedido['direccion_envio'] ?? 'Retira en local'); ?></p>
</div>
<table class="ticket-table">
<thead>
<tr>
<th>Producto</th>
<th style="text-align: center;">Cant.</th>
<th style="text-align: right;">Subtotal</th>
</tr>
</thead>
<tbody>
<?php while($item = mysqli_fetch_assoc($res_detalle)): ?>
<tr>
<td style="font-weight: 500;"><?php echo htmlspecialchars($item['nombre_prod']); ?></td>
<td style="text-align: center; color: #64748b;">x<?php echo $item['cantidad']; ?></td>
<td style="text-align: right; font-weight: 600;">$<?php echo number_format($item['precio_unitario'] * $item['cantidad'], 2, ',', '.'); ?></td>
</tr>
<?php endwhile; ?>
<tr class="total-row">
<td colspan="2">TOTAL</td>
<td style="text-align: right;">$<?php echo number_format($pedido['total'], 2, ',', '.'); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>