panel admin: gestion de pedidos
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
$busqueda = mysqli_real_escape_string($conexion, $_GET['query'] ?? '');
|
||||
$modo = $_GET['modo'] ?? '';
|
||||
$usuario_id_fijo = (int)($_GET['usuario_id'] ?? 0);
|
||||
|
||||
if ($usuario_id_fijo > 0) {
|
||||
$query_u = "SELECT id_usuario, nombre FROM usuarios WHERE id_usuario = $usuario_id_fijo";
|
||||
$res_u = mysqli_query($conexion, $query_u);
|
||||
$usuario = mysqli_fetch_assoc($res_u);
|
||||
$coincidencias_usuarios = [$usuario];
|
||||
} else {
|
||||
$query_u = "SELECT id_usuario, nombre FROM usuarios WHERE id_usuario = '$busqueda' OR nombre LIKE '%$busqueda%'";
|
||||
$res_u = mysqli_query($conexion, $query_u);
|
||||
$coincidencias_usuarios = mysqli_fetch_all($res_u, MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
// Buscamos el pedido por ID
|
||||
$query_p = "SELECT id_pedido, id_usuario FROM pedidos WHERE id_pedido = '$busqueda'";
|
||||
$res_p = mysqli_query($conexion, $query_p);
|
||||
$pedido = mysqli_fetch_assoc($res_p);
|
||||
|
||||
$cantidad_usuarios = count($coincidencias_usuarios);
|
||||
|
||||
$mostrar_decision_bicefala = ($cantidad_usuarios === 1 && $pedido && empty($modo));
|
||||
|
||||
if ($pedido && $cantidad_usuarios === 0 && empty($modo)) {
|
||||
header("Location: ver_detalle.php?id=" . $pedido['id_pedido']);
|
||||
exit();
|
||||
}
|
||||
|
||||
// Si solo hubo una coincidencia de usuario y no hay conflicto con ID de pedido, lo marcamos para mostrar directo
|
||||
$usuario_unico = null;
|
||||
if ($cantidad_usuarios === 1 && !$mostrar_decision_bicefala) {
|
||||
$usuario_unico = $coincidencias_usuarios[0];
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Resultados de Búsqueda - La Pecosa</title>
|
||||
<link rel="stylesheet" href="../css/all.min.css">
|
||||
<link rel="stylesheet" href="admin_style.css">
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
body { font-family: 'Segoe UI', sans-serif; background: #f4f6f9; color: #1e293b; margin: 0; }
|
||||
|
||||
.main-content { padding: 40px; flex: 1; min-height: 100vh; }
|
||||
.page-title { font-size: 1.8rem; font-weight: 700; color: #0f172a; margin-bottom: 25px; margin-top: 0; }
|
||||
|
||||
.btn-action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 22px;
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
text-decoration: none;
|
||||
border-radius: 50px;
|
||||
transition: all 0.2s ease;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
}
|
||||
.btn-dark { background: #334155; color: white; margin-bottom: 25px; box-shadow: 0 4px 10px rgba(51,65,85,0.1); }
|
||||
.btn-dark:hover { background: #1e293b; transform: translateY(-1px); }
|
||||
|
||||
.card-bicefala {
|
||||
background: white;
|
||||
max-width: 680px;
|
||||
margin: 40px auto;
|
||||
padding: 40px 30px;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 10px 30px rgba(15,23,42,0.04);
|
||||
border-top: 4px solid #e02828;
|
||||
text-align: center;
|
||||
}
|
||||
.card-bicefala h2 { color: #0f172a; font-size: 1.5rem; font-weight: 700; margin-bottom: 10px; }
|
||||
.card-bicefala p { color: #64748b; font-size: 1rem; margin-bottom: 30px; }
|
||||
.bicefala-actions { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; }
|
||||
|
||||
.btn-choice-user { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
|
||||
.btn-choice-user:hover { background: #d1fae5; transform: translateY(-2px); }
|
||||
.btn-choice-order { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
|
||||
.btn-choice-order:hover { background: #dbeafe; transform: translateY(-2px); }
|
||||
|
||||
.panel-container { background: white; padding: 30px; border-radius: 20px; box-shadow: 0 4px 25px rgba(0,0,0,0.02); }
|
||||
.panel-subtitle { font-size: 1.2rem; font-weight: 600; color: #1e293b; margin-top: 0; margin-bottom: 15px; display: flex; align-items: center; gap: 8px; }
|
||||
|
||||
.coincidencias-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin-top: 20px; }
|
||||
.card-cliente { background: #f8fafc; padding: 20px; border-radius: 15px; border: 1px solid #e2e8f0; transition: all 0.2s; text-decoration: none; color: inherit; display: block; }
|
||||
.card-cliente:hover { border-color: #e02828; background: white; transform: translateY(-2px); box-shadow: 0 6px 15px rgba(224,40,40,0.06); }
|
||||
.card-cliente h3 { margin: 0 0 6px 0; color: #0f172a; font-size: 1.1rem; }
|
||||
|
||||
.cliente-info-box { background: white; padding: 25px; border-radius: 15px; box-shadow: 0 4px 20px rgba(0,0,0,0.02); margin-bottom: 25px; display: flex; align-items: center; justify-content: space-between; }
|
||||
.cliente-info-box h2 { margin: 0; color: #0f172a; font-size: 1.4rem; font-weight: 700; }
|
||||
.cliente-badge { background: #fff1f2; color: #e02828; padding: 6px 14px; border-radius: 50px; font-weight: 600; font-size: 0.85rem; }
|
||||
|
||||
.admin-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
|
||||
.admin-table th { background: #f8fafc; color: #64748b; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; padding: 14px; text-align: left; border-bottom: 2px solid #edf2f7; }
|
||||
.admin-table td { padding: 14px; border-bottom: 1px solid #f1f5f9; font-size: 0.9rem; color: #334155; vertical-align: middle; }
|
||||
.admin-table tr:hover td { background-color: #f8fafc; }
|
||||
.detalle-item { font-size: 0.8rem; color: #64748b; display: block; padding: 3px 0; }
|
||||
.status-badge { font-weight: 700; color: #e02828; font-size: 0.85rem; background: #fff1f2; padding: 4px 10px; border-radius: 50px; display: inline-block; }
|
||||
|
||||
.alert-error { padding: 20px; background: #fef2f2; border: 1px solid #fee2e2; color: #991b1b; border-radius: 15px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?php include("sidebar.php"); ?>
|
||||
|
||||
<div class="main-content">
|
||||
|
||||
<h1 class="page-title">Módulo de Búsqueda</h1>
|
||||
|
||||
<a href="pedidos.php" class="btn-action btn-dark"><i class="fa-solid fa-arrow-left"></i> Volver al panel</a>
|
||||
|
||||
<?php if ($mostrar_decision_bicefala): ?>
|
||||
<div class="card-bicefala">
|
||||
<div style="font-size: 2.5rem; color: #e02828; margin-bottom: 15px;"><i class="fa-solid fa-circle-question"></i></div>
|
||||
<h2>Coincidencia doble detectada</h2>
|
||||
<p>El número <strong>"<?php echo htmlspecialchars($busqueda); ?>"</strong> pertenece a un ID de Pedido y también al ID del usuario <strong><?php echo htmlspecialchars($coincidencias_usuarios[0]['nombre']); ?></strong>.</p>
|
||||
|
||||
<div class="bicefala-actions">
|
||||
<a href="buscar_clientes.php?query=<?php echo urlencode($busqueda); ?>&modo=usuario" class="btn-action btn-choice-user">
|
||||
<i class="fa-solid fa-user-clock"></i> Ver Historial del Usuario
|
||||
</a>
|
||||
<a href="ver_detalle.php?id=<?php echo $busqueda; ?>" class="btn-action btn-choice-order">
|
||||
<i class="fa-solid fa-receipt"></i> Ver Detalle del Pedido
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php elseif ($cantidad_usuarios > 1 && $usuario_id_fijo === 0): ?>
|
||||
<div class="panel-container">
|
||||
<h2 class="panel-subtitle"><i class="fa-solid fa-users" style="color: #e02828;"></i> Se encontraron <?php echo $cantidad_usuarios; ?> clientes</h2>
|
||||
<p style="color: #64748b; margin-top: 0; font-size: 0.95rem;">Seleccioná el cliente correcto para auditar su historial completo de comandas:</p>
|
||||
|
||||
<div class="coincidencias-container">
|
||||
<?php foreach ($coincidencias_usuarios as $u): ?>
|
||||
<a href="buscar_clientes.php?query=<?php echo urlencode($busqueda); ?>&usuario_id=<?php echo $u['id_usuario']; ?>" class="card-cliente">
|
||||
<h3><?php echo htmlspecialchars($u['nombre']); ?></h3>
|
||||
<span style="font-size: 0.8rem; color: #64748b; font-weight: 500;">
|
||||
<i class="fa-solid fa-id-card" style="color: #94a3b8;"></i> ID Cliente: #<?php echo $u['id_usuario']; ?>
|
||||
</span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php elseif ($usuario_unico || $usuario_id_fijo > 0):
|
||||
$u_actual = $usuario_unico ?? $coincidencias_usuarios[0];
|
||||
?>
|
||||
<div class="cliente-info-box">
|
||||
<div>
|
||||
<h2 style="color: #0f172a; font-weight: 700;"><?php echo htmlspecialchars($u_actual['nombre']); ?></h2>
|
||||
<p style="margin: 5px 0 0 0; font-size: 0.9rem; color: #64748b;"><i class="fa-solid fa-clock-rotate-left"></i> Historial completo de compras en el local</p>
|
||||
</div>
|
||||
<div class="cliente-badge">
|
||||
<i class="fa-solid fa-id-badge"></i> ID Usuario: #<?php echo $u_actual['id_usuario']; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-container" style="padding: 10px 20px 25px 20px;">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>NRO Pedido</th>
|
||||
<th>Fecha</th>
|
||||
<th>Detalle de Productos</th>
|
||||
<th>Monto Total</th>
|
||||
<th>Dirección de Envío</th>
|
||||
<th>Teléfono</th>
|
||||
<th>Estado Actual</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$pedidos_sql = "SELECT * FROM pedidos WHERE id_usuario = '{$u_actual['id_usuario']}' ORDER BY fecha DESC";
|
||||
$pedidos = mysqli_query($conexion, $pedidos_sql);
|
||||
|
||||
if(mysqli_num_rows($pedidos) > 0):
|
||||
while ($p = mysqli_fetch_assoc($pedidos)):
|
||||
?>
|
||||
<tr>
|
||||
<td><strong style="color: #0f172a;">#<?php echo $p['id_pedido']; ?></strong></td>
|
||||
<td style="color: #64748b; font-weight: 500;"><?php echo date('d/m H:i', strtotime($p['fecha'])); ?> hs</td>
|
||||
<td>
|
||||
<?php
|
||||
$det_sql = "SELECT p.nombre AS producto, d.cantidad
|
||||
FROM detalle_pedido d
|
||||
JOIN productos p ON d.producto_id = p.id
|
||||
WHERE d.pedido_id = '{$p['id_pedido']}'";
|
||||
$detalles = mysqli_query($conexion, $det_sql);
|
||||
while ($d = mysqli_fetch_assoc($detalles)):
|
||||
echo "<span class='detalle-item'><i class='fa-solid fa-circle-dot' style='font-size:0.5rem; color:#cbd5e1; margin-right:5px;'></i>{$d['producto']} (x{$d['cantidad']})</span>";
|
||||
endwhile;
|
||||
?>
|
||||
</td>
|
||||
<td><strong style="color: #0f172a; font-size: 1rem;">$<?php echo number_format($p['total'], 0, ',', '.'); ?></strong></td>
|
||||
<td style="color: #64748b;"><?php echo htmlspecialchars($p['direccion_envio'] ?? 'Retira en local'); ?></td>
|
||||
<td style="color: #64748b; font-weight: 500;"><?php echo htmlspecialchars($p['telefono_contacto'] ?? 'S/N'); ?></td>
|
||||
<td><span class="status-badge"><?php echo $p['estado']; ?></span></td>
|
||||
</tr>
|
||||
<?php
|
||||
endwhile;
|
||||
else:
|
||||
?>
|
||||
<tr><td colspan="7" style="text-align: center; color: #94a3b8; padding: 40px 0;"><i class="fa-solid fa-folder-open" style="font-size: 1.5rem; display:block; margin-bottom:10px;"></i> Este usuario no registra pedidos históricos en el sistema.</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
<div class="alert-error">
|
||||
<i class="fa-solid fa-circle-exclamation" style="font-size: 1.2rem;"></i>
|
||||
<span>No se encontraron clientes ni pedidos registrados asociados a la búsqueda: <strong>"<?php echo htmlspecialchars($busqueda); ?>"</strong></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
include '../db.php'; // Asegurá la ruta correcta hacia tu db.php raíz
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['nuevo_estado'])) {
|
||||
$nuevo_estado = $_POST['nuevo_estado'] === 'cerrado' ? 'cerrado' : 'abierto';
|
||||
|
||||
// Usamos la consulta correcta sobre tu nueva tabla 'ajustes'
|
||||
$stmt = $conexion->prepare("UPDATE ajustes SET valor = ? WHERE clave = 'estado_manual'");
|
||||
$stmt->bind_param("s", $nuevo_estado);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
// Volver de forma limpia al panel de administración
|
||||
header("Location: " . $_SERVER['HTTP_REFERER']);
|
||||
exit;
|
||||
} else {
|
||||
echo "Error al actualizar el estado: " . $conexion->error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
<?php
|
||||
include("../db.php");
|
||||
|
||||
// Consultamos el estado manual actual
|
||||
$query_estado = mysqli_query($conexion, "SELECT valor FROM ajustes WHERE clave = 'estado_manual'");
|
||||
$res_estado = mysqli_fetch_assoc($query_estado);
|
||||
$estado_actual = ($res_estado) ? $res_estado['valor'] : 'abierto';
|
||||
|
||||
date_default_timezone_set('America/Argentina/Buenos_Aires');
|
||||
$hoy = date('Y-m-d');
|
||||
|
||||
if (!isset($_SESSION['rol']) || $_SESSION['rol'] !== 'admin') {
|
||||
header("Location: ../login.php?error=acceso_denegado");
|
||||
exit();
|
||||
}
|
||||
|
||||
$query_ventas = "SELECT SUM(total) as total_dia FROM pedidos WHERE DATE(fecha) = '$hoy' AND estado != 'Cancelado'";
|
||||
$res_ventas = mysqli_query($conexion, $query_ventas);
|
||||
$data_ventas = mysqli_fetch_assoc($res_ventas);
|
||||
$total_dia = $data_ventas['total_dia'] ?? 0;
|
||||
|
||||
$query_activos = "SELECT COUNT(*) as cant FROM pedidos WHERE estado IN ('Pendiente', 'En Cocina')";
|
||||
$res_activos = mysqli_query($conexion, $query_activos);
|
||||
$data_activos = mysqli_fetch_assoc($res_activos);
|
||||
$cant_pedidos = $data_activos['cant'] ?? 0;
|
||||
|
||||
$nombres_grafico = [];
|
||||
$cantidades_grafico = [];
|
||||
$query_stats = "SELECT nombre_producto, cantidad_vendida FROM estadisticas_productos ORDER BY cantidad_vendida DESC LIMIT 5";
|
||||
$res_stats = mysqli_query($conexion, $query_stats);
|
||||
while($row = mysqli_fetch_assoc($res_stats)) {
|
||||
$nombres_grafico[] = $row['nombre_producto'];
|
||||
$cantidades_grafico[] = $row['cantidad_vendida'];
|
||||
}
|
||||
|
||||
$query_pedidos = "SELECT p.id_pedido, p.id_usuario, u.nombre as nombre_usuario, p.total, p.estado, p.fecha
|
||||
FROM pedidos p
|
||||
LEFT JOIN usuarios u ON p.id_usuario = u.id_usuario
|
||||
ORDER BY p.fecha DESC LIMIT 10";
|
||||
$res_pedidos = mysqli_query($conexion, $query_pedidos);
|
||||
|
||||
if ($res_pedidos) {
|
||||
$pedidos_reales = mysqli_fetch_all($res_pedidos, MYSQLI_ASSOC);
|
||||
} else {
|
||||
die("Error en la consulta: " . mysqli_error($conexion));
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Panel Admin - La Pecosa</title>
|
||||
<link rel="stylesheet" href="../css/all.min.css">
|
||||
<script src="chart.js"></script>
|
||||
<link rel="stylesheet" href="admin_style.css">
|
||||
<style>
|
||||
/* ── TOPBAR DE ACCIONES ── */
|
||||
.topbar-actions {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 260px;
|
||||
right: 0;
|
||||
height: 64px;
|
||||
background: #fff;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
padding: 0 40px;
|
||||
gap: 10px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.topbar-fecha {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
color: #4b5563;
|
||||
background: #f9fafb;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 7px;
|
||||
padding: 8px 14px;
|
||||
}
|
||||
.topbar-fecha i { color: #e02828; }
|
||||
|
||||
.btn-estado-abierto,
|
||||
.btn-estado-cerrado {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
border-radius: 7px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.15s, transform 0.15s;
|
||||
}
|
||||
.btn-estado-abierto:hover,
|
||||
.btn-estado-cerrado:hover { opacity: 0.88; transform: translateY(-1px); }
|
||||
|
||||
.btn-estado-abierto { background: #16a34a; color: #fff; }
|
||||
.btn-estado-cerrado { background: #e02828; color: #fff; }
|
||||
|
||||
/* Bajamos el main-content para que no quede debajo de la topbar */
|
||||
.main-content { padding-top: 84px; }
|
||||
|
||||
/* ── CARDS MEJORADAS ── */
|
||||
.dashboard-cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
||||
gap: 18px;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
.dash-card {
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
padding: 22px 24px;
|
||||
border: 1px solid #f0f0f0;
|
||||
box-shadow: 0 1px 4px rgba(0,0,0,0.04);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
.dash-card-label {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.6px;
|
||||
color: #9ca3af;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.dash-card-value {
|
||||
font-size: 2rem;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
}
|
||||
.dash-card-value.green { color: #16a34a; }
|
||||
.dash-card-value.red { color: #e02828; }
|
||||
|
||||
.dash-card-icon {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.3rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.dash-card-icon.green-bg { background: #dcfce7; color: #16a34a; }
|
||||
.dash-card-icon.red-bg { background: #fee2e2; color: #e02828; }
|
||||
|
||||
/* ── CONTENEDORES ── */
|
||||
.section-card {
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #f0f0f0;
|
||||
box-shadow: 0 1px 4px rgba(0,0,0,0.04);
|
||||
padding: 24px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.section-card-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
color: #111827;
|
||||
margin-bottom: 18px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.section-card-title i { color: #e02828; font-size: 0.95rem; }
|
||||
|
||||
/* ── TABLA ── */
|
||||
.admin-table td { font-size: 0.9rem; }
|
||||
.admin-table tr:last-child td { border-bottom: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- TOPBAR FIJA -->
|
||||
<div class="topbar-actions">
|
||||
|
||||
<div class="topbar-fecha">
|
||||
<i class="fa-solid fa-calendar-days"></i>
|
||||
<?php
|
||||
$dias = ["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"];
|
||||
echo $dias[date('w')] . " " . date('d/m/Y') . " · " . date('H:i') . " hs";
|
||||
?>
|
||||
</div>
|
||||
|
||||
<form action="cambiar_estado.php" method="POST" style="display:inline;">
|
||||
<?php if ($estado_actual === 'cerrado'): ?>
|
||||
<input type="hidden" name="nuevo_estado" value="abierto">
|
||||
<button type="submit" class="btn-estado-abierto">
|
||||
<i class="fa-solid fa-lock-open"></i> Abrir local
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<input type="hidden" name="nuevo_estado" value="cerrado">
|
||||
<button type="submit" class="btn-estado-cerrado">
|
||||
<i class="fa-solid fa-lock"></i> Cerrar página
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<?php include("sidebar.php"); ?>
|
||||
|
||||
<div class="main-content">
|
||||
|
||||
<div class="page-header">
|
||||
<h1><i class="fa-solid fa-chart-pie"></i> Panel de estadísticas generales</h1>
|
||||
</div>
|
||||
|
||||
<!-- CARDS -->
|
||||
<div class="dashboard-cards">
|
||||
<div class="dash-card">
|
||||
<div>
|
||||
<div class="dash-card-label">Ventas de hoy</div>
|
||||
<div class="dash-card-value green">$<?php echo number_format($total_dia, 0, ',', '.'); ?></div>
|
||||
</div>
|
||||
<div class="dash-card-icon green-bg">
|
||||
<i class="fa-solid fa-cash-register"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dash-card">
|
||||
<div>
|
||||
<div class="dash-card-label">Pedidos en espera / cocina</div>
|
||||
<div class="dash-card-value red"><?php echo $cant_pedidos; ?></div>
|
||||
</div>
|
||||
<div class="dash-card-icon red-bg">
|
||||
<i class="fa-solid fa-clock"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- GRÁFICO -->
|
||||
<div class="section-card">
|
||||
<div class="section-card-title">
|
||||
<i class="fa-solid fa-ranking-star"></i> Top 5 productos más vendidos
|
||||
</div>
|
||||
<div style="height: 260px; position: relative;">
|
||||
<canvas id="chartProductos"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TABLA -->
|
||||
<div class="section-card">
|
||||
<div class="section-card-title">
|
||||
<i class="fa-solid fa-clock-rotate-left"></i> Últimos 10 pedidos recibidos
|
||||
</div>
|
||||
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nº pedido</th>
|
||||
<th>Cliente</th>
|
||||
<th>Productos</th>
|
||||
<th>Total</th>
|
||||
<th>Estado</th>
|
||||
<th>Fecha / Hora</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($pedidos_reales as $p):
|
||||
$estado_normalizado = strtolower(trim($p['estado']));
|
||||
$clase_badge = 'badge-pendiente';
|
||||
switch ($estado_normalizado) {
|
||||
case 'pendiente': $clase_badge = 'badge-pendiente'; break;
|
||||
case 'en cocina': $clase_badge = 'badge-cocina'; break;
|
||||
case 'listo para retirar':
|
||||
case 'listo': $clase_badge = 'badge-listo'; break;
|
||||
case 'en camino': $clase_badge = 'badge-camino'; break;
|
||||
case 'entregado': $clase_badge = 'badge-entregado'; break;
|
||||
case 'cancelado': $clase_badge = 'badge-cancelado'; break;
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><strong>#<?php echo $p['id_pedido']; ?></strong></td>
|
||||
<td><?php echo htmlspecialchars($p['nombre_usuario'] ?? 'Invitado (S/R)'); ?></td>
|
||||
<td>
|
||||
<a href="ver_detalle.php?id=<?php echo $p['id_pedido']; ?>&desde=dashboard" style="color: #e02828; text-decoration: none; font-weight: 600;">
|
||||
<i class="fa-solid fa-eye"></i> Ver detalle
|
||||
</a>
|
||||
</td>
|
||||
<td><strong>$<?php echo number_format($p['total'], 0, ',', '.'); ?></strong></td>
|
||||
<td><span class="badge <?php echo $clase_badge; ?>"><?php echo htmlspecialchars($p['estado']); ?></span></td>
|
||||
<td style="color: #666;"><?php echo date('d/m H:i', strtotime($p['fecha'])); ?> hs</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const ctx = document.getElementById('chartProductos').getContext('2d');
|
||||
new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: <?php echo json_encode($nombres_grafico); ?>,
|
||||
datasets: [{
|
||||
label: 'Unidades vendidas',
|
||||
data: <?php echo json_encode($cantidades_grafico); ?>,
|
||||
backgroundColor: '#e02828',
|
||||
borderWidth: 0,
|
||||
borderRadius: 8
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
scales: {
|
||||
y: { beginAtZero: true, grid: { color: '#f3f4f6' }, ticks: { color: '#9ca3af', font: { size: 12 } } },
|
||||
x: { grid: { display: false }, ticks: { color: '#4b5563', font: { size: 12 } } }
|
||||
},
|
||||
plugins: { legend: { display: false } }
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
require_once("../db.php");
|
||||
|
||||
if (!isset($_SESSION['rol']) || $_SESSION['rol'] !== 'admin') {
|
||||
header("Location: ../login.php?error=acceso_denegado");
|
||||
exit();
|
||||
}
|
||||
|
||||
$archivo = basename($_GET['file'] ?? '');
|
||||
$ruta = 'comprobantes/' . $archivo;
|
||||
|
||||
if (empty($archivo) || !file_exists($ruta)) {
|
||||
die("
|
||||
<div style='font-family:\"Segoe UI\", sans-serif; text-align:center; padding:50px; background:#fffef8; height:100vh; box-sizing:border-box;'>
|
||||
<div style='max-width:450px; margin:0 auto; background:white; padding:30px; border-radius:20px; box-shadow:0 10px 30px rgba(0,0,0,0.05); border-top: 4px solid #e02828;'>
|
||||
<h3 style='color:#e02828; margin-bottom:10px;'>Error de Archivo</h3>
|
||||
<p style='color:#666; font-size:0.95rem; line-height:1.5;'>El comprobante no existe en el servidor o el nombre del archivo es inválido.</p>
|
||||
<button onclick='window.close()' style='margin-top:20px; background:#333; color:white; border:none; padding:10px 20px; border-radius:50px; cursor:pointer; font-weight:bold;'>Cerrar Ventana</button>
|
||||
</div>
|
||||
</div>");
|
||||
}
|
||||
|
||||
// Obtenemos la extensión para saber si es PDF o Imagen
|
||||
$extension = strtolower(pathinfo($ruta, PATHINFO_EXTENSION));
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Imprimir Comprobante - La Pecosa</title>
|
||||
<link rel="stylesheet" href="../css/all.min.css">
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { font-family: 'Segoe UI', sans-serif; background: #f4f6f9; color: #333; padding: 30px 20px; }
|
||||
|
||||
.no-print {
|
||||
max-width: 800px;
|
||||
margin: 0 auto 20px auto;
|
||||
background: white;
|
||||
padding: 12px 25px;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 4px 20px rgba(0,0,0,0.03);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.panel-info { font-size: 0.95rem; color: #64748b; font-weight: 500; }
|
||||
.panel-info i { color: #e02828; margin-right: 5px; }
|
||||
.button-group { display: flex; gap: 10px; }
|
||||
|
||||
.btn {
|
||||
padding: 10px 22px;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
border: none;
|
||||
border-radius: 50px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.btn-print { background: #e02828; color: white; box-shadow: 0 4px 10px rgba(224,40,40,0.15); }
|
||||
.btn-print:hover { background: #c02020; transform: translateY(-1px); }
|
||||
.btn-close { background: #f1f5f9; color: #475569; }
|
||||
.btn-close:hover { background: #e2e8f0; color: #1e293b; }
|
||||
|
||||
.view-container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 4px 25px rgba(0,0,0,0.04);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
img { max-width: 100%; height: auto; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.02); }
|
||||
iframe { width: 100%; height: 78vh; border: none; border-radius: 8px; }
|
||||
|
||||
@media print {
|
||||
.no-print { display: none !important; }
|
||||
body { background: white; padding: 0; }
|
||||
.view-container { box-shadow: none; padding: 0; max-width: 100%; }
|
||||
img { box-shadow: none; border-radius: 0; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="window.print()">
|
||||
|
||||
<div class="no-print">
|
||||
<div class="panel-info">
|
||||
<i class="fa-solid fa-file-invoice"></i> Vista de Comprobante
|
||||
</div>
|
||||
<div class="button-group">
|
||||
<button class="btn btn-close" onclick="window.close()">
|
||||
<i class="fa-solid fa-xmark"></i> Cerrar
|
||||
</button>
|
||||
<button class="btn btn-print" onclick="window.print()">
|
||||
<i class="fa-solid fa-print"></i> Imprimir Ticket
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="view-container">
|
||||
<?php if ($extension === 'pdf'): ?>
|
||||
<iframe src="<?php echo $ruta; ?>"></iframe>
|
||||
<?php else: ?>
|
||||
<img src="<?php echo $ruta; ?>" alt="Comprobante de Pago">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?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>
|
||||
@@ -0,0 +1,526 @@
|
||||
<?php
|
||||
include("../db.php");
|
||||
|
||||
if (!isset($_SESSION['rol']) || $_SESSION['rol'] !== 'admin') {
|
||||
header("Location: ../login.php?error=acceso_denegado");
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['cambiar_pago'])) {
|
||||
$id_p = (int)$_POST['id_pedido'];
|
||||
$nuevo_pago = mysqli_real_escape_string($conexion, $_POST['nuevo_pago']);
|
||||
$query_pago = "UPDATE pedidos SET pago_estado = '$nuevo_pago' WHERE id_pedido = $id_p";
|
||||
if (mysqli_query($conexion, $query_pago)) {
|
||||
$nombre_admin = $_SESSION['usuario'] ?? 'Admin ID: ' . ($_SESSION['id_usuario'] ?? 'Desconocido');
|
||||
escribir_log("[CAJA] Pedido #$id_p actualizó su estado de pago a '$nuevo_pago' por el Administrador: $nombre_admin");
|
||||
header("Location: pedidos.php?status=updated");
|
||||
} else {
|
||||
escribir_log("[ERROR SQL] Fallo al intentar cambiar pago del pedido #$id_p. Error: " . mysqli_error($conexion));
|
||||
header("Location: pedidos.php?status=error");
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['cambiar_estado'])) {
|
||||
$id_p = (int)$_POST['id_pedido'];
|
||||
$nuevo_est = mysqli_real_escape_string($conexion, $_POST['nuevo_estado']);
|
||||
$query_cliente = "SELECT p.telefono_contacto, u.nombre, p.total
|
||||
FROM pedidos p
|
||||
JOIN usuarios u ON p.id_usuario = u.id_usuario
|
||||
WHERE p.id_pedido = $id_p";
|
||||
$res_c = mysqli_query($conexion, $query_cliente);
|
||||
$data_c = mysqli_fetch_assoc($res_c);
|
||||
$query_update = "UPDATE pedidos SET estado = '$nuevo_est' WHERE id_pedido = $id_p";
|
||||
if (mysqli_query($conexion, $query_update)) {
|
||||
$nombre_admin = $_SESSION['usuario'] ?? 'Admin ID: ' . ($_SESSION['id_usuario'] ?? 'Desconocido');
|
||||
$nombre_cliente = $data_c['nombre'] ?? 'Desconocido';
|
||||
if ($nuevo_est === 'Cancelado') {
|
||||
$motivo = $_POST['motivo_cancelacion'] ?? 'No especificado o directo desde monitor';
|
||||
escribir_log("[🚨 CANCELACIÓN] Pedido ID #$id_p fue CANCELADO por Admin: $nombre_admin. Motivo: $motivo");
|
||||
} else {
|
||||
escribir_log("[CAJA/COCINA] Pedido #$id_p (Cliente: $nombre_cliente) cambio a estado '$nuevo_est' por el Administrador: $nombre_admin");
|
||||
}
|
||||
if ($nuevo_est !== 'Cancelado' && !empty($data_c['telefono_contacto']) && ($nuevo_est === 'En camino' || $nuevo_est === 'Listo para retirar')) {
|
||||
if ($nuevo_est === 'En camino') {
|
||||
$texto = "¡Hola " . $data_c['nombre'] . "! Tu pedido de *La Pecosa* ya está en camino. 🛵 ¡Prepárate para recibirlo! Total a pagar: $" . number_format($data_c['total'], 2, ',', '.');
|
||||
} else {
|
||||
$texto = "¡Hola " . $data_c['nombre'] . "! Tu pedido de *La Pecosa* ya está listo para ser retirado. 🛍️ ¡Te esperamos! Total: $" . number_format($data_c['total'], 2, ',', '.');
|
||||
}
|
||||
$mensaje_ws = urlencode($texto);
|
||||
$telefono_limpio = preg_replace('/[^0-9]/', '', $data_c['telefono_contacto']);
|
||||
if (substr($telefono_limpio, 0, 2) !== '54') {
|
||||
$telefono_limpio = '54' . $telefono_limpio;
|
||||
}
|
||||
$_SESSION['url_whatsapp'] = "https://api.whatsapp.com/send?phone=$telefono_limpio&text=$mensaje_ws";
|
||||
}
|
||||
header("Location: pedidos.php?status=updated");
|
||||
} else {
|
||||
escribir_log("[ERROR SQL] Fallo al intentar cambiar el estado del pedido #$id_p a '$nuevo_est'. Error: " . mysqli_error($conexion));
|
||||
header("Location: pedidos.php?status=error");
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
$query_activos = "SELECT p.id_pedido, p.fecha, p.total, p.estado, p.pago_estado, p.comprobante, u.nombre AS cliente
|
||||
FROM pedidos p
|
||||
JOIN usuarios u ON p.id_usuario = u.id_usuario
|
||||
WHERE p.estado IN ('Pendiente', 'En cocina', 'Listo para retirar', 'En camino')
|
||||
ORDER BY p.fecha DESC";
|
||||
$res_activos = mysqli_query($conexion, $query_activos);
|
||||
|
||||
$query_historial = "SELECT p.id_pedido, p.fecha, p.total, p.estado, p.pago_estado, p.comprobante, u.nombre AS cliente
|
||||
FROM pedidos p
|
||||
JOIN usuarios u ON p.id_usuario = u.id_usuario
|
||||
WHERE p.estado IN ('Entregado', 'Cancelado')
|
||||
ORDER BY p.fecha DESC
|
||||
LIMIT 50";
|
||||
$res_historial = mysqli_query($conexion, $query_historial);
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Pedidos Activos - La Pecosa</title>
|
||||
<link rel="stylesheet" href="../css/all.min.css">
|
||||
<link rel="stylesheet" href="admin_style.css">
|
||||
<style>
|
||||
/* ── TOAST ── */
|
||||
.toast-ok {
|
||||
background: #f0fdf4;
|
||||
border: 1px solid #bbf7d0;
|
||||
color: #166534;
|
||||
border-radius: 8px;
|
||||
padding: 12px 16px;
|
||||
margin-bottom: 20px;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* ── BUSCADOR ── */
|
||||
.search-bar {
|
||||
background: #fff;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 10px;
|
||||
padding: 16px 20px;
|
||||
margin-bottom: 24px;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
.search-bar .search-wrap {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
}
|
||||
.search-bar .search-wrap i {
|
||||
position: absolute;
|
||||
left: 14px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: #9ca3af;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.search-bar input {
|
||||
width: 100%;
|
||||
padding: 10px 12px 10px 40px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 7px;
|
||||
font-size: 0.9rem;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.search-bar input:focus { border-color: #e02828; }
|
||||
.search-bar .btn-buscar {
|
||||
background: #e02828;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 7px;
|
||||
font-weight: 700;
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
transition: opacity 0.15s;
|
||||
}
|
||||
.search-bar .btn-buscar:hover { opacity: 0.88; }
|
||||
|
||||
/* ── SECTION CARD ── */
|
||||
.section-card {
|
||||
background: #fff;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.section-card-header {
|
||||
padding: 16px 22px;
|
||||
border-bottom: 1px solid #f3f4f6;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.section-card-header h2 {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
color: #111827;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
}
|
||||
.section-card-body { overflow-x: auto; }
|
||||
|
||||
/* ── PULSO ── */
|
||||
@keyframes pulse {
|
||||
0% { opacity: 0.6; transform: scale(0.9); }
|
||||
50% { opacity: 1; transform: scale(1.1); }
|
||||
100% { opacity: 0.6; transform: scale(0.9); }
|
||||
}
|
||||
.dot-live {
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
border-radius: 50%;
|
||||
background: #e02828;
|
||||
display: inline-block;
|
||||
animation: pulse 1.6s infinite;
|
||||
}
|
||||
|
||||
/* ── TABLA ── */
|
||||
.admin-table td { font-size: 0.875rem; vertical-align: middle; }
|
||||
.admin-table tr:last-child td { border-bottom: none; }
|
||||
|
||||
/* ── CELDA ESTADO+PAGO (columna "Estado actual") ── */
|
||||
.estado-cell { display: flex; flex-direction: column; gap: 5px; }
|
||||
|
||||
/* ── PAGO ── */
|
||||
.pago-ok {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
color: #166534;
|
||||
}
|
||||
.pago-pendiente-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
color: #9d174d;
|
||||
background: #fdf2f8;
|
||||
border: 1px dashed #fbcfe8;
|
||||
border-radius: 5px;
|
||||
padding: 3px 8px;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.pago-pendiente-btn:hover { background: #fce7f3; }
|
||||
.pago-pendiente-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
color: #9d174d;
|
||||
background: #fdf2f8;
|
||||
border-radius: 5px;
|
||||
padding: 3px 8px;
|
||||
}
|
||||
|
||||
/* ── COMPROBANTE ── */
|
||||
.btn-comprobante {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
color: #475569;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 5px;
|
||||
padding: 3px 8px;
|
||||
text-decoration: none;
|
||||
transition: border-color 0.15s, color 0.15s;
|
||||
}
|
||||
.btn-comprobante:hover { border-color: #e02828; color: #e02828; }
|
||||
|
||||
/* ── VER DETALLE ── */
|
||||
.btn-detalle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: #475569;
|
||||
background: #f1f5f9;
|
||||
border-radius: 20px;
|
||||
padding: 6px 12px;
|
||||
text-decoration: none;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
.btn-detalle:hover { background: #e2e8f0; color: #111827; }
|
||||
|
||||
/* ── FORM ESTADO ── */
|
||||
.form-estado { display: flex; align-items: center; gap: 6px; }
|
||||
.btn-confirmar {
|
||||
background: #1f2937;
|
||||
color: #fff;
|
||||
border: none;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 0.75rem;
|
||||
flex-shrink: 0;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.btn-confirmar:hover { background: #e02828; }
|
||||
|
||||
/* ── HISTORIAL COLAPSABLE ── */
|
||||
.historial-toggle {
|
||||
width: 100%;
|
||||
background: #f9fafb;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 10px;
|
||||
padding: 14px 22px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
cursor: pointer;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 700;
|
||||
color: #374151;
|
||||
transition: background 0.15s;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.historial-toggle:hover { background: #f3f4f6; }
|
||||
.historial-toggle .toggle-left { display: flex; align-items: center; gap: 8px; }
|
||||
.historial-toggle .chevron {
|
||||
font-size: 0.8rem;
|
||||
color: #9ca3af;
|
||||
transition: transform 0.25s;
|
||||
}
|
||||
.historial-toggle.open .chevron { transform: rotate(180deg); }
|
||||
|
||||
.historial-body {
|
||||
display: none;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.historial-body.open { display: block; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php include("sidebar.php"); ?>
|
||||
|
||||
<div class="main-content">
|
||||
|
||||
<div class="page-header">
|
||||
<h1><i class="fa-solid fa-fire-burner"></i> Monitor operativo de pedidos</h1>
|
||||
</div>
|
||||
|
||||
<?php if (isset($_GET['status']) && $_GET['status'] === 'updated'): ?>
|
||||
<div class="toast-ok">
|
||||
<i class="fa-solid fa-circle-check"></i> Panel actualizado correctamente.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- BUSCADOR -->
|
||||
<div class="search-bar">
|
||||
<form action="buscar_clientes.php" method="GET" style="display:contents;">
|
||||
<div class="search-wrap">
|
||||
<i class="fa-solid fa-magnifying-glass"></i>
|
||||
<input type="text" name="query" required placeholder="Buscar por #ID de pedido, nombre de cliente o ID de usuario...">
|
||||
</div>
|
||||
<button type="submit" class="btn-buscar">
|
||||
<i class="fa-solid fa-filter"></i> Buscar
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- COMANDAS ACTIVAS -->
|
||||
<div class="section-card">
|
||||
<div class="section-card-header">
|
||||
<h2><span class="dot-live"></span> Comandas activas — cocina y despacho</h2>
|
||||
</div>
|
||||
<div class="section-card-body">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>N° Pedido</th>
|
||||
<th>Fecha / Hora</th>
|
||||
<th>Cliente</th>
|
||||
<th>Total</th>
|
||||
<th>Estado actual</th>
|
||||
<th>Ver detalle</th>
|
||||
<th>Cambiar estado</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (mysqli_num_rows($res_activos) == 0): ?>
|
||||
<tr>
|
||||
<td colspan="7" style="text-align:center; color:#9ca3af; padding:36px 14px;">
|
||||
<i class="fa-solid fa-mug-hot" style="font-size:1.4rem; display:block; margin-bottom:6px;"></i>
|
||||
No hay pedidos activos en este momento.
|
||||
</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php while ($ped = mysqli_fetch_assoc($res_activos)):
|
||||
$en = strtolower($ped['estado']);
|
||||
$badge = 'badge-pendiente';
|
||||
if ($en === 'en cocina') $badge = 'badge-cocina';
|
||||
if ($en === 'listo para retirar') $badge = 'badge-listo';
|
||||
if ($en === 'en camino') $badge = 'badge-camino';
|
||||
?>
|
||||
<tr>
|
||||
<td><strong>#<?php echo $ped['id_pedido']; ?></strong></td>
|
||||
<td style="color:#6b7280;"><?php echo date('d/m/Y H:i', strtotime($ped['fecha'])); ?> hs</td>
|
||||
<td><?php echo htmlspecialchars($ped['cliente']); ?></td>
|
||||
<td><strong>$<?php echo number_format($ped['total'], 2, ',', '.'); ?></strong></td>
|
||||
<td>
|
||||
<div class="estado-cell">
|
||||
<span class="badge <?php echo $badge; ?>"><?php echo htmlspecialchars($ped['estado']); ?></span>
|
||||
|
||||
<?php if ($ped['pago_estado'] === 'Aprobado'): ?>
|
||||
<span class="pago-ok"><i class="fa-solid fa-circle-dollar-to-slot"></i> Pago aprobado</span>
|
||||
<?php else: ?>
|
||||
<form action="pedidos.php" method="POST" style="display:inline;">
|
||||
<input type="hidden" name="id_pedido" value="<?php echo $ped['id_pedido']; ?>">
|
||||
<input type="hidden" name="nuevo_pago" value="Aprobado">
|
||||
<button type="submit" name="cambiar_pago" class="pago-pendiente-btn" title="Clic para registrar pago recibido">
|
||||
<i class="fa-solid fa-hand-holding-dollar"></i> Pago pendiente
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($ped['comprobante'])): ?>
|
||||
<a href="imprimir_ticket.php?file=<?php echo urlencode($ped['comprobante']); ?>" target="_blank" class="btn-comprobante">
|
||||
<i class="fa-solid fa-receipt"></i> Ver comprobante
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<a href="ver_detalle.php?id=<?php echo $ped['id_pedido']; ?>&desde=pedidos" class="btn-detalle">
|
||||
<i class="fa-solid fa-list-ul"></i> Ver detalle
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<form action="pedidos.php" method="POST" class="form-estado">
|
||||
<input type="hidden" name="id_pedido" value="<?php echo $ped['id_pedido']; ?>">
|
||||
<input type="hidden" name="cambiar_estado" value="1">
|
||||
<select name="nuevo_estado" class="select-status" required>
|
||||
<option value="Pendiente" <?php echo $ped['estado'] === 'Pendiente' ? 'selected' : ''; ?>>Pendiente</option>
|
||||
<option value="En cocina" <?php echo $ped['estado'] === 'En cocina' ? 'selected' : ''; ?>>En cocina</option>
|
||||
<option value="Listo para retirar" <?php echo $ped['estado'] === 'Listo para retirar' ? 'selected' : ''; ?>>Listo para retirar</option>
|
||||
<option value="En camino" <?php echo $ped['estado'] === 'En camino' ? 'selected' : ''; ?>>En camino</option>
|
||||
<option value="Entregado">Entregado (Finalizar)</option>
|
||||
<option value="Cancelado">Cancelado</option>
|
||||
</select>
|
||||
<button type="submit" class="btn-confirmar" title="Confirmar cambio">
|
||||
<i class="fa-solid fa-check"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- HISTORIAL COLAPSABLE -->
|
||||
<button class="historial-toggle" onclick="toggleHistorial(this)">
|
||||
<span class="toggle-left">
|
||||
<i class="fa-solid fa-clock-rotate-left" style="color:#6b7280;"></i>
|
||||
Historial de pedidos finalizados
|
||||
</span>
|
||||
<i class="fa-solid fa-chevron-down chevron"></i>
|
||||
</button>
|
||||
|
||||
<div class="historial-body" id="historialBody">
|
||||
<div class="section-card">
|
||||
<div class="section-card-body">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>N° Pedido</th>
|
||||
<th>Fecha / Hora</th>
|
||||
<th>Cliente</th>
|
||||
<th>Total cobrado</th>
|
||||
<th>Resolución</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (mysqli_num_rows($res_historial) == 0): ?>
|
||||
<tr>
|
||||
<td colspan="5" style="text-align:center; color:#9ca3af; padding:36px 14px;">
|
||||
<i class="fa-solid fa-box-open" style="font-size:1.4rem; display:block; margin-bottom:6px;"></i>
|
||||
Todavía no hay pedidos finalizados.
|
||||
</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php while ($hist = mysqli_fetch_assoc($res_historial)):
|
||||
$badge_h = ($hist['estado'] === 'Entregado') ? 'badge-entregado' : 'badge-cancelado';
|
||||
?>
|
||||
<tr>
|
||||
<td><strong>#<?php echo $hist['id_pedido']; ?></strong></td>
|
||||
<td style="color:#6b7280;"><?php echo date('d/m/Y H:i', strtotime($hist['fecha'])); ?> hs</td>
|
||||
<td><?php echo htmlspecialchars($hist['cliente']); ?></td>
|
||||
<td>$<?php echo number_format($hist['total'], 2, ',', '.'); ?></td>
|
||||
<td>
|
||||
<div class="estado-cell">
|
||||
<span class="badge <?php echo $badge_h; ?>"><?php echo htmlspecialchars($hist['estado']); ?></span>
|
||||
|
||||
<?php if ($hist['pago_estado'] === 'Aprobado'): ?>
|
||||
<span class="pago-ok"><i class="fa-solid fa-circle-dollar-to-slot"></i> Pago aprobado</span>
|
||||
<?php else: ?>
|
||||
<span class="pago-pendiente-tag"><i class="fa-solid fa-hand-holding-dollar"></i> Pago pendiente</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($hist['comprobante'])): ?>
|
||||
<a href="imprimir_ticket.php?file=<?php echo urlencode($hist['comprobante']); ?>" target="_blank" class="btn-comprobante">
|
||||
<i class="fa-solid fa-receipt"></i> Ver comprobante
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleHistorial(btn) {
|
||||
btn.classList.toggle('open');
|
||||
document.getElementById('historialBody').classList.toggle('open');
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php if (isset($_SESSION['url_whatsapp'])): ?>
|
||||
<script>
|
||||
window.open("<?php echo $_SESSION['url_whatsapp']; ?>", "_blank");
|
||||
</script>
|
||||
<?php unset($_SESSION['url_whatsapp']); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
include("../db.php");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$nombre = mysqli_real_escape_string($conexion, $_POST['nombre']);
|
||||
$categoria = mysqli_real_escape_string($conexion, $_POST['categoria']);
|
||||
$precio = (float)$_POST['precio'];
|
||||
$stock = (int)$_POST['stock'];
|
||||
$activo = 1;
|
||||
|
||||
$nombre_original_img = $_FILES['imagen']['name'];
|
||||
$origen_temporal = $_FILES['imagen']['tmp_name'];
|
||||
|
||||
$nombre_final_img = time() . "_" . basename($nombre_original_img);
|
||||
$carpeta_destino = "../img/" . $nombre_final_img;
|
||||
$ruta_para_bd = "img/" . $nombre_final_img;
|
||||
|
||||
if (move_uploaded_file($origen_temporal, $carpeta_destino)) {
|
||||
|
||||
$query_insertar = "INSERT INTO productos (nombre, precio, categoria, imagen, activo, stock)
|
||||
VALUES ('$nombre', $precio, '$categoria', '$ruta_para_bd', $activo, $stock)";
|
||||
|
||||
if (mysqli_query($conexion, $query_insertar)) {
|
||||
header("Location: inventario.php?status=ok_manual");
|
||||
} else {
|
||||
header("Location: inventario.php?status=error");
|
||||
}
|
||||
} else {
|
||||
header("Location: inventario.php?status=error");
|
||||
}
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
if (!isset($_SESSION['id_usuario']) || $_SESSION['rol'] !== 'admin') {
|
||||
header("Location: ../login.php?error=acceso_denegado");
|
||||
exit();
|
||||
}
|
||||
|
||||
$pagina_actual = basename($_SERVER['PHP_SELF']);
|
||||
?>
|
||||
<div class="sidebar">
|
||||
<div class="brand">
|
||||
<h3><i class="fa-solid fa-fire-burner"></i> LA PECOSA</h3>
|
||||
</div>
|
||||
<ul class="sidebar-menu">
|
||||
<li class="<?php echo ($pagina_actual == 'dashboard.php') ? 'active' : ''; ?>">
|
||||
<a href="dashboard.php"><i class="fa-solid fa-chart-line"></i> Estadísticas</a>
|
||||
</li>
|
||||
<li class="<?php echo ($pagina_actual == 'pedidos.php') ? 'active' : ''; ?>">
|
||||
<a href="pedidos.php"><i class="fa-solid fa-utensils"></i> Pedidos activos</a>
|
||||
</li>
|
||||
<li class="<?php echo ($pagina_actual == 'inventario.php') ? 'active' : ''; ?>">
|
||||
<a href="inventario.php"><i class="fa-solid fa-boxes-stacked"></i> Inventario</a>
|
||||
</li>
|
||||
<li class="<?php echo ($pagina_actual == 'promo.php') ? 'active' : ''; ?>">
|
||||
<a href="promo.php"><i class="fa-solid fa-bullhorn"></i> Promociones</a>
|
||||
</li>
|
||||
<li class="<?php echo ($pagina_actual == 'asistente.php') ? 'active' : ''; ?>">
|
||||
<a href="asistente.php"><i class="fa-solid fa-robot"></i> Asistente virtual </a>
|
||||
</li>
|
||||
<li class="<?php echo ($pagina_actual == 'backup.php') ? 'active' : ''; ?>">
|
||||
<a href="backup.php"><i class="fa-solid fa-database"></i> Copia de seguridad</a>
|
||||
</li>
|
||||
<li class="<?php echo ($pagina_actual == 'ayuda_admin.php') ? 'active' : ''; ?>">
|
||||
<a href="ayuda_admin.php"><i class="fa-solid fa-screwdriver-wrench"></i> Manual admin</a>
|
||||
</li>
|
||||
<li style="margin-top: auto;">
|
||||
<a href="../logout.php" style="color: #ff8888;"><i class="fa-solid fa-right-from-bracket"></i> Salir</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user