68 lines
2.1 KiB
PHP
68 lines
2.1 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
session_start();
|
|
if (!isset($_SESSION['username'])) {
|
|
header("Location: login.php");
|
|
exit();
|
|
}
|
|
|
|
include 'layout_header.php';
|
|
|
|
$sql = "
|
|
SELECT
|
|
u.nombre_asesor,
|
|
COUNT(p.id) AS total_pedidos
|
|
FROM pedidos p
|
|
JOIN users u ON p.asesor_id = u.id
|
|
WHERE DATE(p.created_at) = CURDATE()
|
|
GROUP BY u.nombre_asesor
|
|
ORDER BY total_pedidos DESC;
|
|
";
|
|
|
|
$stmt = db()->prepare($sql);
|
|
$stmt->execute();
|
|
$pedidos_por_asesor = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
?>
|
|
|
|
<div class="container-fluid px-4">
|
|
<h1 class="mt-4">Pedidos del Día Cargados Correctamente</h1>
|
|
<ol class="breadcrumb mb-4">
|
|
<li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
|
|
<li class="breadcrumb-item active">Pedidos del Día</li>
|
|
</ol>
|
|
|
|
<div class="card mb-4">
|
|
<div class="card-header">
|
|
<i class="fas fa-table me-1"></i>
|
|
Resumen de Pedidos por Asesor para Hoy (<?php echo date('d/m/Y'); ?>)
|
|
</div>
|
|
<div class="card-body">
|
|
<table class="table table-bordered table-striped">
|
|
<thead class="thead-dark">
|
|
<tr>
|
|
<th>Nombre del Asesor</th>
|
|
<th>Cantidad de Pedidos Cargados</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (count($pedidos_por_asesor) > 0): ?>
|
|
<?php foreach ($pedidos_por_asesor as $row): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($row['nombre_asesor']); ?></td>
|
|
<td><?php echo htmlspecialchars($row['total_pedidos']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<tr>
|
|
<td colspan="2" class="text-center">No se han cargado pedidos el día de hoy.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include 'layout_footer.php'; ?>
|