147 lines
4.5 KiB
PHP
147 lines
4.5 KiB
PHP
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Arbeitstage FTK - Tim Lappe</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<style>
|
|
.type-urlaub {
|
|
background-color: rgb(166, 199, 203);
|
|
}
|
|
.type-ftk {
|
|
background-color: rgb(0, 124, 0);
|
|
color: white;
|
|
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.5);
|
|
z-index: 10;
|
|
position: relative;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<?php
|
|
|
|
if (!isset($_GET['key']) || $_GET['key'] !== "74857389798572903480209489024") {
|
|
echo "Kein Zugriff";
|
|
return;
|
|
}
|
|
|
|
ini_set('display_errors', 1);
|
|
|
|
use App\App;
|
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
Locale::setDefault('de_DE');
|
|
setlocale(LC_ALL, "de_DE"); //only necessary if the locale isn't already set
|
|
|
|
$formatter = new IntlDateFormatter(
|
|
'de_DE',
|
|
IntlDateFormatter::FULL,
|
|
IntlDateFormatter::FULL,
|
|
'Europe/Berlin',
|
|
IntlDateFormatter::GREGORIAN,
|
|
'EEEE'
|
|
);
|
|
|
|
$app = new App();
|
|
$app->init();
|
|
|
|
$data = ($app->getAbsenceClient())->getAbsences([
|
|
'skip' => 0,
|
|
'limit' => 50,
|
|
'filter' => [
|
|
'start' => ['$gte' => (new DateTime('-1 day'))->format('Y-m-d\TH:i:s.u\Z')],
|
|
'assignedTo:user._id' => [
|
|
'email' => 'tim.lappe@check24.de'
|
|
]
|
|
],
|
|
'sortBy' => [
|
|
'start' => 1
|
|
],
|
|
'relations' => ['assignedToId', 'reasonId', 'approverId']
|
|
]);
|
|
|
|
$data = $data['data'];
|
|
|
|
// Funktion zum Erstellen einer Liste aller Tage in einem bestimmten Zeitraum
|
|
function getAllDays($startDate, $endDate) {
|
|
$period = new DatePeriod(
|
|
new DateTime($startDate),
|
|
new DateInterval('P1D'),
|
|
(new DateTime($endDate))->modify('+1 day')
|
|
);
|
|
|
|
$days = [];
|
|
foreach ($period as $date) {
|
|
$days[] = $date->format('Y-m-d');
|
|
}
|
|
return $days;
|
|
}
|
|
|
|
// Beispiel: Zeitraum eines Monats (kann angepasst werden)
|
|
$startDate = (new DateTime())->format('Y-m-d');
|
|
$endDate = (new DateTime('+90 days'))->format('Y-m-d');
|
|
$allDays = getAllDays($startDate, $endDate);
|
|
|
|
?>
|
|
|
|
<div class="container mt-5">
|
|
<h1>Arbeitstage FTK - Tim Lappe</h1>
|
|
<p>Zeitraum: <?= $startDate; ?> - <?= $endDate; ?></p>
|
|
<table class="table table-borderless" style="table-layout: fixed">
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 100px">Datum</th>
|
|
<th>Wochentag</th>
|
|
<th>Typ</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($allDays as $day): ?>
|
|
<?php
|
|
$reason = '';
|
|
$isFtk = false;
|
|
$isUrlaub = false;
|
|
$class = 'bg-light text-dark';
|
|
|
|
// Prüfen, ob es für diesen Tag eine Abwesenheit gibt
|
|
foreach ($data as $absence) {
|
|
foreach ($absence['days'] as $absenceDay) {
|
|
if ((new DateTime($absenceDay['date']))->format('Y-m-d') === $day) {
|
|
$reason = $absence['reason']['name'];
|
|
$isFtk = str_contains($reason, 'mobile Arbeit');
|
|
$isUrlaub = str_contains($reason, 'Urlaub') || str_contains($reason, 'Sonderurlaub');
|
|
$class = $isFtk ? 'type-ftk' : '';
|
|
$class = $isUrlaub ? 'type-urlaub' : $class;
|
|
break 2;
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<?php if (DateTimeImmutable::createFromFormat('Y-m-d', $day)->format('N') == 6): ?>
|
|
<tr>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
<?php continue; ?>
|
|
<?php endif; ?>
|
|
<?php if (DateTimeImmutable::createFromFormat('Y-m-d', $day)->format('N') == 7): ?>
|
|
<tr class="bg-white text-secondary">
|
|
<td colspan="2">KW <?php echo ((int) (new DateTime($day))->format('W')) + 1; ?></td>
|
|
</tr>
|
|
<?php continue; ?>
|
|
<?php endif; ?>
|
|
<tr class="<?= $class ?>">
|
|
<td><?= (new DateTime($day))->format('d.m.Y'); ?></td>
|
|
<td><?= $formatter->format((new DateTime($day))) ?></td>
|
|
<td><?php if ($isFtk): ?>FTK<?php endif; ?> <?php if($isUrlaub): ?>Urlaub<?php endif; ?></td>
|
|
</tr>
|
|
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|