#15 program > calendar, do not show previous month

This commit is contained in:
isUnknown 2024-11-04 16:11:36 +01:00
parent 6875193964
commit aaabf7638c

View file

@ -1,44 +1,37 @@
<?php
function sortByMonth($sessions) {
$currentMonth = date('F');
$frenchMonths = array(
'janvier', 'février', 'mars', 'avril', 'mai', 'juin',
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'
'janvier', 'février', 'mars', 'avril', 'mai', 'juin',
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'
);
$englishMonths = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$currentMonthIndex = date('n');
$frenchMonths = array_merge(
array_slice($frenchMonths, $currentMonthIndex - 1, 12),
array_slice($frenchMonths, 0, $currentMonthIndex - 1)
);
$englishMonths = array_merge(
array_slice($englishMonths, $currentMonthIndex - 1, 12),
array_slice($englishMonths, 0, $currentMonthIndex - 1)
$englishMonths = array(
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
);
$orderedSessions = array();
foreach ($frenchMonths as $month) {
$orderedSessions[$month] = array();
}
$currentMonthIndex = date('n') - 1;
$orderedSessions = [];
foreach ($sessions as $item) {
$month = date('F', strtotime($item['date']));
$month = str_replace(
$englishMonths,
$frenchMonths,
$month
);
$orderedSessions[$month][] = $item;
$monthIndex = date('n', strtotime($item['date'])) - 1;
if ($monthIndex >= $currentMonthIndex || $monthIndex < 8) {
$month = date('F', strtotime($item['date']));
$monthInFrench = str_replace($englishMonths, $frenchMonths, $month);
if (!isset($orderedSessions[$monthInFrench])) {
$orderedSessions[$monthInFrench] = [];
}
$orderedSessions[$monthInFrench][] = $item;
}
}
return $orderedSessions;
}
function createArraySession($event, $session) {
$isMapadoEvent = $event->isMapadoEvent() == 'true';
$arraySession = $session->toArray();