DH_Alumni/overview.php

83 lines
2.8 KiB
PHP

<?php
require_once 'general.php';
session_start();
if(!isset($_SESSION['user'])) {
echo "Nicht angemeldet";
http_response_code(401);
exit;
}
returnHeader();
$statement = getDatabase()->prepare("SELECT * from entries WHERE verify = 1");
if(!$statement->execute()) {
echo "database Error";
}
$entries = $statement->fetchAll(PDO::FETCH_ASSOC);
?>
<div class="flex flex-col">
<div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
<div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
<div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg relative space-y-32">
<div class="md:mt-6 top-0 right-0 absolute">
<button class="bg-blue-500 px-2 py-2 text-lg font-semibold tracking-wider text-white rounded hover:bg-blue-600">als CSV exportieren</button>
<button class="bg-blue-500 px-4 py-2 text-lg font-semibold tracking-wider text-white rounded hover:bg-blue-600">ausloggen</button>
</div>
<table id="overviewTable" class="display">
<thead>
<tr>
<th>Name</th>
<th>Tätigkeit</th>
<th>E-Mail Adresse</th>
<th>Jahrgang</th>
<th>Alter</th>
</tr>
</thead>
<tbody>
<?php
foreach ($entries as $entry) {
$age = date_diff(date_create($entry['birthday']), date_create('now'))->y;
?>
<tr>
<td><?php echo $entry["name"] ?></td>
<td><?php echo $entry["vocation"] ?></td>
<td><?php echo $entry["mail"] ?></td>
<td><?php echo $entry["year"] ?></td>
<td><?php echo $age ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function () {
$('#overviewTable').DataTable({
language: {
url: 'https://cdn.datatables.net/plug-ins/1.10.24/i18n/German.json'
}
});
});
</script>
<?php
returnFooter();