35690-vm/friends.php
Flatlogic Bot 9c72d549df final v1
2025-11-13 13:51:54 +00:00

172 lines
7.8 KiB
PHP

<?php
require_once __DIR__ . '/db/config.php';
// Fetch attendees
$attendees = [];
$company_type_data = [];
$relation_data = [];
try {
$pdo = db();
$stmt = $pdo->query("SELECT name, company, occupation, relation, company_type, linkedin_url, created_at FROM attendees ORDER BY created_at DESC");
$attendees = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Fetch data for charts
$company_type_stmt = $pdo->query("SELECT company_type, COUNT(*) as count FROM attendees WHERE company_type IS NOT NULL AND company_type != '' GROUP BY company_type");
$company_type_data = $company_type_stmt->fetchAll(PDO::FETCH_ASSOC);
$relation_stmt = $pdo->query("SELECT relation, COUNT(*) as count FROM attendees WHERE relation IS NOT NULL AND relation != '' GROUP BY relation");
$relation_data = $relation_stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
// Silently fail for now, or log error
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Friends List - Belarusians Worldwide</title>
<meta name="description" content="A friends list for the Belarusian Pavilion at Web Summit.">
<meta name="keywords" content="Belarusian Pavilion, Web Summit, Belarusians Worldwide, tech community, startups, networking, Belarusian founders, tech diaspora, Built with Flatlogic Generator">
<meta property="og:title" content="Belarusians Worldwide Friends">
<meta property="og:description" content="A friends list for the Belarusian Pavilion at Web Summit.">
<meta property="og:image" content="">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@700&family=Montserrat:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<div class="container my-5">
<header class="hero text-center mb-5">
<h1>Our Friends & Associates</h1>
<p class="lead">A directory of the amazing people in the Belarusian tech community.</p>
<a href="index.php" class="btn btn-secondary">Back to Join the List</a>
</header>
<main>
<section class="charts-section mb-5">
<h2 class="text-center">Community Insights</h2>
<div class="row">
<div class="col-md-6">
<canvas id="companyTypeChart"></canvas>
</div>
<div class="col-md-6">
<canvas id="relationChart"></canvas>
</div>
</div>
</section>
<section class="list-section">
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead class="table-dark">
<tr>
<th>Name</th>
<th>Company / Startup</th>
<th>Occupation</th>
<th>Company Type</th>
<th>LinkedIn</th>
<th>Relation</th>
<th>Date Joined</th>
</tr>
</thead>
<tbody>
<?php if (empty($attendees)): ?>
<tr>
<td colspan="7" class="text-center">No friends yet. Be the first to join!</td>
</tr>
<?php else: ?>
<?php foreach ($attendees as $attendee): ?>
<tr>
<td><?php echo htmlspecialchars($attendee['name']); ?></td>
<td><?php echo htmlspecialchars($attendee['company']); ?></td>
<td><?php echo htmlspecialchars($attendee['occupation']); ?></td>
<td><?php echo htmlspecialchars($attendee['company_type']); ?></td>
<td><a href="<?php echo htmlspecialchars($attendee['linkedin_url']); ?>" target="_blank">View Profile</a></td>
<td><?php echo htmlspecialchars($attendee['relation']); ?></td>
<td><?php echo date('M d, Y', strtotime($attendee['created_at'])); ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</section>
</main>
<footer class="text-center text-muted mt-5">
<p>Built with ❤️ by the Belarusian Worldwide community.</p>
</footer>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
const companyTypeData = <?php echo json_encode($company_type_data); ?>;
const relationData = <?php echo json_encode($relation_data); ?>;
const generateChart = (ctx, label, data, dataLabel, chartType) => {
const labels = data.map(item => item[dataLabel]);
const values = data.map(item => item.count);
new Chart(ctx, {
type: chartType,
data: {
labels: labels,
datasets: [{
label: label,
data: values,
backgroundColor: [
'rgba(255, 99, 132, 0.7)',
'rgba(54, 162, 235, 0.7)',
'rgba(255, 206, 86, 0.7)',
'rgba(75, 192, 192, 0.7)',
'rgba(153, 102, 255, 0.7)',
'rgba(255, 159, 64, 0.7)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: label
}
}
}
});
};
const companyTypeCtx = document.getElementById('companyTypeChart').getContext('2d');
generateChart(companyTypeCtx, 'Users by Company Type', companyTypeData, 'company_type', 'pie');
const relationCtx = document.getElementById('relationChart').getContext('2d');
generateChart(relationCtx, 'Users by Relation', relationData, 'relation', 'pie');
});
</script>
</body>
</html>