29 lines
732 B
PHP
29 lines
732 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
require_once 'database/database.php';
|
|
|
|
$startDate = $_GET['startDate'] ?? null;
|
|
$endDate = $_GET['endDate'] ?? null;
|
|
|
|
$data = [
|
|
'fechas_rango' => []
|
|
];
|
|
|
|
if ($startDate && $endDate) {
|
|
$query = "SELECT DATE(fecha) AS dia, COUNT(*) AS count FROM entrada
|
|
WHERE fecha BETWEEN ? AND ? GROUP BY DATE(fecha) ORDER BY DATE(fecha) ASC";
|
|
|
|
$stmt = $conexion->prepare($query);
|
|
$stmt->bind_param("ss", $startDate, $endDate);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
while ($row = $result->fetch_assoc()) {
|
|
$data['fechas_rango'][$row['dia']] = (int)$row['count'];
|
|
}
|
|
$stmt->close();
|
|
}
|
|
|
|
echo json_encode($data);
|
|
$conexion->close();
|
|
?>
|