Dialog: Auswahl des Schuljahres angepasst
This commit is contained in:
parent
e515fd8ca2
commit
c11737df71
@ -39,10 +39,30 @@ class StartType extends AbstractType
|
|||||||
'label' => 'Schuljahr',
|
'label' => 'Schuljahr',
|
||||||
'placeholder' => 'Auswählen...',
|
'placeholder' => 'Auswählen...',
|
||||||
'choices' => [
|
'choices' => [
|
||||||
'für das kommende Schuljahr (ab 01.08.' . (intval(date("m")) < 8 ? date("Y") : (date("Y")+1)) . ')' => (intval(date("m")) < 8 ? date("Y") . "_" . (date("Y")+1) : (date("Y")+1) . "_" . (date("Y")+2)),
|
'für das laufende Schuljahr (' . (intval(date("m")) < 8 ? (date("Y") - 1) . "/" . date("Y") : date("Y") . "/" . (date("Y") + 1)) . ')' => (intval(date("m")) < 8 ? (date("Y") - 1) . "_" . date("Y") : date("Y") . "_" . (date("Y")+1)),
|
||||||
'für das laufende Schuljahr (bis 31.07.' . (intval(date("m")) < 8 ? date("Y") : (date("Y")+1)) . ')' => (intval(date("m")) < 8 ? (date("Y") - 1) . "_" . date("Y") : date("Y") . "_" . (date("Y")+1))
|
'für das kommende Schuljahr (' . (intval(date("m")) < 8 ? date("Y") . "/" . (date("Y") + 1) : (date("Y") + 1) . "/" . (date("Y") + 2)) . ')' => (intval(date("m")) < 8 ? date("Y") . "_" . (date("Y") + 1) : (date("Y") + 1) . "_" . (date("Y") + 2)),
|
||||||
],
|
],
|
||||||
'expanded' => true
|
'expanded' => true,
|
||||||
|
'choice_attr' => function($choice, $key, $value) {
|
||||||
|
$currentDate = new \DateTime();
|
||||||
|
$currentYear = (int)$currentDate->format('Y');
|
||||||
|
$currentMonth = (int)$currentDate->format('m');
|
||||||
|
$currentDay = (int)$currentDate->format('d');
|
||||||
|
|
||||||
|
// Determine the start year of the upcoming school year
|
||||||
|
$startYear = $currentMonth < 8 ? $currentYear : $currentYear + 1;
|
||||||
|
$upcomingStartYear = $startYear + 1;
|
||||||
|
|
||||||
|
// Check if the current date is before 1st February of the start year
|
||||||
|
if ($value === $startYear . "_" . $upcomingStartYear) {
|
||||||
|
$februaryFirst = new \DateTime("$startYear-02-01");
|
||||||
|
if ($currentDate < $februaryFirst) {
|
||||||
|
return ['disabled' => 'disabled'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user