Show events in the past
This commit is contained in:
parent
ec166854cb
commit
c60b5f653e
@ -28,8 +28,8 @@ final class CalendarController extends AbstractController
|
|||||||
return new Response('Kein Zugriff', Response::HTTP_FORBIDDEN);
|
return new Response('Kein Zugriff', Response::HTTP_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
$startDate = (new DateTime())->format('Y-m-d');
|
$startDate = (new DateTime('-1 day'))->format('Y-m-d');
|
||||||
$endDate = (new DateTime('+90 days'))->format('Y-m-d');
|
$endDate = (new DateTime('+180 days'))->format('Y-m-d');
|
||||||
|
|
||||||
$absences = $this->absenceManager->getAbsencesForUser('tim.lappe@check24.de', new DateTime('-1 day'));
|
$absences = $this->absenceManager->getAbsencesForUser('tim.lappe@check24.de', new DateTime('-1 day'));
|
||||||
|
|
||||||
@ -50,10 +50,10 @@ final class CalendarController extends AbstractController
|
|||||||
return new Response('Kein Zugriff', Response::HTTP_FORBIDDEN);
|
return new Response('Kein Zugriff', Response::HTTP_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
$startDate = (new DateTime())->format('Y-m-d');
|
$startDate = (new DateTime('-1 year'))->format('Y-m-d');
|
||||||
$endDate = (new DateTime('+180 days'))->format('Y-m-d');
|
$endDate = (new DateTime('+180 days'))->format('Y-m-d');
|
||||||
|
|
||||||
$absences = $this->absenceManager->getAbsencesForUser('tim.lappe@check24.de', new DateTime('-1 day'));
|
$absences = $this->absenceManager->getAbsencesForUser('tim.lappe@check24.de', new DateTime('-1 year'));
|
||||||
|
|
||||||
$days = $this->calendarService->getAllDays($startDate, $endDate);
|
$days = $this->calendarService->getAllDays($startDate, $endDate);
|
||||||
$days = $this->calendarService->processAbsences($days, $absences);
|
$days = $this->calendarService->processAbsences($days, $absences);
|
||||||
|
|||||||
@ -25,7 +25,7 @@ final class AbsenceManager
|
|||||||
|
|
||||||
$response = $this->absenceClient->getAbsences([
|
$response = $this->absenceClient->getAbsences([
|
||||||
'skip' => 0,
|
'skip' => 0,
|
||||||
'limit' => 50,
|
'limit' => 500,
|
||||||
'filter' => [
|
'filter' => [
|
||||||
'start' => ['$gte' => $startDate->format('Y-m-d\TH:i:s.u\Z')],
|
'start' => ['$gte' => $startDate->format('Y-m-d\TH:i:s.u\Z')],
|
||||||
'assignedTo:user._id' => [
|
'assignedTo:user._id' => [
|
||||||
|
|||||||
@ -53,34 +53,58 @@
|
|||||||
<div class="calendar-header">So</div>
|
<div class="calendar-header">So</div>
|
||||||
|
|
||||||
{% set currentMonth = null %}
|
{% set currentMonth = null %}
|
||||||
{% set firstDay = days|first %}
|
{% set currentWeek = null %}
|
||||||
{% if firstDay.weekday > 1 %}
|
|
||||||
{% if currentMonth != firstDay.date|date('F') %}
|
|
||||||
{% set currentMonth = firstDay.date|date('F') %}
|
|
||||||
<div class="calendar-week" style="background-color: #e9ecef;">{{ firstDay.date|date('F Y') }}</div>
|
|
||||||
{% endif %}
|
|
||||||
{% for i in 1..firstDay.weekday - 1 %}
|
|
||||||
<div class="calendar-day"></div>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% for day in days %}
|
{% for day in days %}
|
||||||
{% if currentMonth != day.date|date('F') %}
|
{# Check if month changed #}
|
||||||
{% set currentMonth = day.date|date('F') %}
|
{% if currentMonth != day.date|date('F Y') %}
|
||||||
|
{% set currentMonth = day.date|date('F Y') %}
|
||||||
<div class="calendar-week" style="background-color: #e9ecef;">{{ day.date|date('F Y') }}</div>
|
<div class="calendar-week" style="background-color: #e9ecef;">{{ day.date|date('F Y') }}</div>
|
||||||
|
|
||||||
|
{# Add empty cells for first row of month #}
|
||||||
|
{% set dayWeekday = day.weekday %}
|
||||||
|
{% if dayWeekday > 1 %}
|
||||||
|
{% for i in 1..dayWeekday-1 %}
|
||||||
|
<div class="calendar-day"></div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{# Check if week changed #}
|
||||||
|
{% if currentWeek != day.weekNumber %}
|
||||||
|
{% set currentWeek = day.weekNumber %}
|
||||||
|
{% if day.weekday > 1 and not loop.first and currentMonth == day.date|date('F Y') %}
|
||||||
|
{# If it's not the first day overall and not the first day of a month, but it's the first day of a week #}
|
||||||
|
{% for i in 1..day.weekday-1 %}
|
||||||
|
<div class="calendar-day"></div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# Render the day #}
|
||||||
<div class="calendar-day {{ day.class }}">
|
<div class="calendar-day {{ day.class }}">
|
||||||
<div>{{ day.date|date('d.m.Y') }}</div>
|
<div>{{ day.date|date('d.m.Y') }}</div>
|
||||||
{% if day.isFtk %}<div>FTK</div>{% endif %}
|
{% if day.isFtk %}<div>FTK</div>{% endif %}
|
||||||
{% if day.isUrlaub %}<div>Urlaub</div>{% endif %}
|
{% if day.isUrlaub %}<div>Urlaub</div>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% if days|last.weekday < 7 %}
|
{# After the last day of a month, fill remaining days in the week #}
|
||||||
{% for i in days|last.weekday + 1..7 %}
|
{% set nextDay = days[loop.index] is defined ? days[loop.index] : null %}
|
||||||
<div class="calendar-day"></div>
|
{% if nextDay and nextDay.date|date('F Y') != day.date|date('F Y') %}
|
||||||
{% endfor %}
|
{% if day.weekday < 7 %}
|
||||||
{% endif %}
|
{% for i in day.weekday+1..7 %}
|
||||||
|
<div class="calendar-day"></div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# After the very last day, fill remaining days in the week #}
|
||||||
|
{% if loop.last and day.weekday < 7 %}
|
||||||
|
{% for i in day.weekday+1..7 %}
|
||||||
|
<div class="calendar-day"></div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user