dkdk
This commit is contained in:
parent
883324698c
commit
ce9f0dfe67
65
admin.php
65
admin.php
@ -35,6 +35,13 @@ $stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$attendees = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Get data for the chart
|
||||
$chart_stmt = $pdo->query("SELECT DATE(created_at) as registration_day, COUNT(*) as user_count FROM attendees GROUP BY registration_day ORDER BY registration_day");
|
||||
$chart_data = $chart_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$chart_labels = json_encode(array_column($chart_data, 'registration_day'));
|
||||
$chart_values = json_encode(array_column($chart_data, 'user_count'));
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@ -42,6 +49,7 @@ $attendees = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
<meta charset="UTF-8">
|
||||
<title>Admin Dashboard</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-5">
|
||||
@ -54,6 +62,16 @@ $attendees = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="mt-4 p-4 border rounded shadow-sm bg-light">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h3 class="h5 mb-0">Daily Registrations</h3>
|
||||
<button id="downloadChartBtn" class="btn btn-sm btn-outline-primary">Save as Image</button>
|
||||
</div>
|
||||
<div style="max-width: 600px; margin: auto;">
|
||||
<canvas id="registrationsChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<h3 class="mt-4">Registered Attendees</h3>
|
||||
<a href="export_csv.php" class="btn btn-success">Download CSV</a>
|
||||
@ -119,5 +137,50 @@ $attendees = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const ctx = document.getElementById('registrationsChart');
|
||||
const registrationsChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: <?php echo $chart_labels; ?>,
|
||||
datasets: [{
|
||||
label: 'Daily Registrations',
|
||||
data: <?php echo $chart_values; ?>,
|
||||
backgroundColor: 'rgba(0, 123, 255, 0.1)',
|
||||
borderColor: 'rgba(0, 123, 255, 1)',
|
||||
borderWidth: 2,
|
||||
tension: 0.4,
|
||||
fill: true
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
ticks: {
|
||||
stepSize: 1
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'User Registrations per Day'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('downloadChartBtn').addEventListener('click', function() {
|
||||
const link = document.createElement('a');
|
||||
link.href = registrationsChart.toBase64Image();
|
||||
link.download = 'daily-registrations-chart.png';
|
||||
link.click();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
20812
mail/mail.log
20812
mail/mail.log
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user