Frederico Falcao f2a6525224 init
2025-05-30 10:46:17 +01:00

107 lines
3.0 KiB
PHP

<?php
// 0.1 Include external libs
require_once __DIR__."/../vendor/autoload.php";
// 0.2 Require authentication
require_once __DIR__."/../_authenticate.php";
// 0.3 Enable SQL database connection
require_once __DIR__."/_database.php";
$metrics = [
'Total Sales' => '$25,300',
'New Customers' => '120',
'Active Subscriptions' => '350',
'Churn Rate' => '2.5%',
'Monthly Revenue' => '$7,400',
'Site Visitors Today' => '1,540',
];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Business Metrics Dashboard</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background-color: #f8f9fa;
}
.metric-card {
border-radius: 8px;
background-color: #fff;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
padding: 20px;
margin-bottom: 20px;
text-align: center;
height: 100%;
}
.metric-value {
font-size: 1.8rem;
font-weight: bold;
}
.metric-label {
font-size: 1rem;
color: #666;
}
</style>
</head>
<body>
<?php require __DIR__."/_navbar.php"; ?>
<!-- MAIN CONTENT -->
<div class="container mt-4">
<h1 class="mb-4">Key Metrics</h1>
<div class="row">
<?php foreach ($metrics as $label => $value): ?>
<div class="col-md-4">
<div class="metric-card">
<div class="metric-value"><?= htmlspecialchars($value) ?></div>
<div class="metric-label"><?= htmlspecialchars($label) ?></div>
</div>
</div>
<?php endforeach; ?>
</div>
<br/><br/>
<h1 class="mb-4">Cohort Analysis</h1>
<div class="row">
<?php
// Variables
$tblName = "Customers"; $cols = ["name", "email", "locale"];
// Fetch data
$rows = db_select($tblName, $cols);
?>
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead class="table-light">
<tr>
<?php foreach ($cols as $col): ?>
<th><?= htmlspecialchars(ucfirst($col)) ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($rows as $row): ?>
<tr>
<?php foreach ($cols as $col): ?>
<td><?= htmlspecialchars($row[$col]) ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<footer class="text-center mt-5 mb-3 text-muted">
&copy; <?= date("Y") ?> GrowFit Oy
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>