DH_Alumni/overview.php

83 lines
2.8 KiB
PHP
Raw Normal View History

2021-04-20 11:22:09 +02:00
<?php
require_once 'general.php';
session_start();
if(!isset($_SESSION['user'])) {
echo "Nicht angemeldet";
http_response_code(401);
exit;
}
2021-04-20 11:22:09 +02:00
returnHeader();
$statement = getDatabase()->prepare("SELECT * from entries WHERE verify = 1");
2021-04-20 11:22:09 +02:00
if(!$statement->execute()) {
echo "database Error";
2021-04-20 11:22:09 +02:00
}
$entries = $statement->fetchAll(PDO::FETCH_ASSOC);
2021-04-21 10:17:02 +02:00
2021-04-20 11:22:09 +02:00
?>
<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
2021-04-21 10:17:02 +02:00
2021-04-20 11:22:09 +02:00
foreach ($entries as $entry) {
$age = date_diff(date_create($entry['birthday']), date_create('now'))->y;
2021-04-20 11:22:09 +02:00
?>
<tr>
<td><?php echo $entry["name"] ?></td>
<td><?php echo $entry["vocation"] ?></td>
<td><?php echo $entry["mail"] ?></td>
2021-04-20 11:22:09 +02:00
<td><?php echo $entry["year"] ?></td>
<td><?php echo $age ?></td>
2021-04-20 11:22:09 +02:00
</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();