2021-04-20 11:22:09 +02:00
|
|
|
<?php
|
2021-05-04 09:44:45 +02:00
|
|
|
|
|
|
|
|
2021-04-20 11:22:09 +02:00
|
|
|
require_once 'general.php';
|
2021-05-04 09:44:45 +02:00
|
|
|
require_once 'vendor/autoload.php';
|
2021-04-20 11:22:09 +02:00
|
|
|
|
2021-04-27 12:11:43 +02:00
|
|
|
session_start();
|
|
|
|
if(!isset($_SESSION['user'])) {
|
|
|
|
echo "Nicht angemeldet";
|
|
|
|
http_response_code(401);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$statement = getDatabase()->prepare("SELECT * from entries WHERE verify = 1");
|
2021-04-20 11:22:09 +02:00
|
|
|
|
2021-04-27 12:11:43 +02:00
|
|
|
if(!$statement->execute()) {
|
|
|
|
echo "database Error";
|
2021-04-20 11:22:09 +02:00
|
|
|
}
|
|
|
|
|
2021-04-27 12:11:43 +02:00
|
|
|
$entries = $statement->fetchAll(PDO::FETCH_ASSOC);
|
2021-04-21 10:17:02 +02:00
|
|
|
|
2021-05-04 09:44:45 +02:00
|
|
|
if($_GET['export'] != null) {
|
|
|
|
if($statement->rowCount() > 0){
|
|
|
|
$delimiter = ";";
|
|
|
|
$filename = "ehemalige_" . date('Y-m-d') . ".csv";
|
|
|
|
|
|
|
|
//create a file pointer
|
|
|
|
$f = fopen('php://memory', 'w');
|
|
|
|
|
|
|
|
//set column headers
|
|
|
|
$fields = array("ID", "Name", "E-Mail", "Abschlussjahrgang", "Geburtstag", "Email validiert", "Tätigkeit", "Eintragungsdatum");
|
|
|
|
fputcsv($f, $fields, $delimiter);
|
|
|
|
|
|
|
|
//output each row of the data, format line as csv and write to file pointer
|
|
|
|
foreach ($entries as $entry) {
|
|
|
|
$lineData = array($entry['id'], $entry['name'], $entry['mail'], $entry['year'], $entry['birthday'], $entry['verify'], $entry['vocation'], $entry['creation']);
|
|
|
|
fputcsv($f, $lineData, $delimiter);
|
|
|
|
}
|
|
|
|
|
|
|
|
//move back to beginning of file
|
|
|
|
fseek($f, 0);
|
|
|
|
|
|
|
|
//set headers to download file rather than displayed
|
|
|
|
header('Content-Type: text/csv');
|
|
|
|
header('Content-Disposition: attachment; filename="' . $filename . '";');
|
|
|
|
|
|
|
|
//output all remaining data on a file pointer
|
|
|
|
fpassthru($f);
|
|
|
|
}
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
returnHeader();
|
|
|
|
|
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">
|
2021-05-04 09:44:45 +02:00
|
|
|
<a href="overview.php?export=true" class="bg-blue-500 px-2 py-2 text-lg font-semibold tracking-wider text-white rounded hover:bg-blue-600">als CSV exportieren</a>
|
2021-04-30 10:16:33 +02:00
|
|
|
<a href="logout.php" class="bg-blue-500 px-4 py-2 text-lg font-semibold tracking-wider text-white rounded hover:bg-blue-600">ausloggen</a>
|
2021-04-20 11:22:09 +02:00
|
|
|
</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>
|
2021-05-04 09:44:45 +02:00
|
|
|
<th>Eintragung</th>
|
2021-04-20 11:22:09 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<?php
|
2021-04-21 10:17:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-04-20 11:22:09 +02:00
|
|
|
foreach ($entries as $entry) {
|
2021-04-27 12:11:43 +02:00
|
|
|
$age = date_diff(date_create($entry['birthday']), date_create('now'))->y;
|
2021-05-04 09:44:45 +02:00
|
|
|
$creationDate = date_create($entry["creation"]);
|
2021-04-20 11:22:09 +02:00
|
|
|
?>
|
|
|
|
<tr>
|
|
|
|
<td><?php echo $entry["name"] ?></td>
|
|
|
|
<td><?php echo $entry["vocation"] ?></td>
|
2021-04-27 12:11:43 +02:00
|
|
|
<td><?php echo $entry["mail"] ?></td>
|
2021-04-20 11:22:09 +02:00
|
|
|
<td><?php echo $entry["year"] ?></td>
|
2021-04-27 12:11:43 +02:00
|
|
|
<td><?php echo $age ?></td>
|
2021-05-04 09:44:45 +02:00
|
|
|
<td><?php echo date_format($creationDate, "d.m.Y") ?></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();
|