@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $lessons = $this->lessonRepository->findAllByDate($today); |
| 36 | 36 | $io->text(sprintf('Anzahl der Unterrichtsstunden am Tag: %d', count($lessons))); |
| 37 | 37 | |
| 38 | - foreach($freeTimespans as $timespan) { |
|
| 38 | + foreach ($freeTimespans as $timespan) { |
|
| 39 | 39 | $io->section(sprintf('Markiere %d.-%d. Stunde als Entfall: %s', $timespan->getLessonStart(), $timespan->getLessonEnd(), $timespan->getReason())); |
| 40 | 40 | |
| 41 | 41 | /** @var TimetableLesson[] $affectedLessons */ |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | $io->text(sprintf('Betroffene Stunden: %d', count($affectedLessons))); |
| 45 | 45 | $count = 0; |
| 46 | 46 | |
| 47 | - foreach($affectedLessons as $affectedLesson) { |
|
| 48 | - if($affectedLesson->getEntries()->count() === 0) { |
|
| 47 | + foreach ($affectedLessons as $affectedLesson) { |
|
| 48 | + if ($affectedLesson->getEntries()->count() === 0) { |
|
| 49 | 49 | $this->cancelHelper->cancelLesson($affectedLesson, $timespan->getReason()); |
| 50 | 50 | $count++; |
| 51 | 51 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $entries = $this->entryRepository->findAllByTuition($tuition, $start, $end); |
| 38 | 38 | $comments = $this->commentRepository->findAllByDateAndTuition($tuition, $start, $end); |
| 39 | 39 | |
| 40 | - return $this->computeOverview([$tuition], $entries, $comments, [ ], $start, $end); |
|
| 40 | + return $this->computeOverview([$tuition], $entries, $comments, [], $start, $end); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param Substitution[] $substitutions |
| 48 | 48 | */ |
| 49 | 49 | private function computeOverview(array $tuitions, array $entries, array $comments, array $substitutions, DateTime $start, DateTime $end): EntryOverview { |
| 50 | - if($start > $end) { |
|
| 50 | + if ($start > $end) { |
|
| 51 | 51 | $tmp = $start; |
| 52 | 52 | $start = $end; |
| 53 | 53 | $end = $tmp; |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $tuitions = array_filter($tuitions, fn(Tuition $tuition) => $tuition->isBookEnabled()); |
| 57 | 57 | |
| 58 | - $lessons = [ ]; |
|
| 58 | + $lessons = []; |
|
| 59 | 59 | |
| 60 | - foreach($entries as $entry) { |
|
| 61 | - if($entry->getTuition() === null) { |
|
| 60 | + foreach ($entries as $entry) { |
|
| 61 | + if ($entry->getTuition() === null) { |
|
| 62 | 62 | // discard entries without tuition |
| 63 | 63 | continue; |
| 64 | 64 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $absentCount = $this->attendanceRepository->countAbsent($entry); |
| 68 | 68 | $lateCount = $this->attendanceRepository->countLate($entry); |
| 69 | 69 | |
| 70 | - for($lessonNumber = $entry->getLessonStart(); $lessonNumber <= $entry->getLessonEnd(); $lessonNumber++) { |
|
| 70 | + for ($lessonNumber = $entry->getLessonStart(); $lessonNumber <= $entry->getLessonEnd(); $lessonNumber++) { |
|
| 71 | 71 | $key = sprintf('%s-%d-%s', $entry->getLesson()->getDate()->format('Y-m-d'), $lessonNumber, $entry->getTuition()->getUuid()->toString()); |
| 72 | 72 | |
| 73 | 73 | $lesson = new Lesson(clone $entry->getLesson()->getDate(), $lessonNumber, null, $entry); |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $weekNumbers = [ ]; |
|
| 82 | + $weekNumbers = []; |
|
| 83 | 83 | $currentWeek = clone $start; |
| 84 | - while($currentWeek < $end) { |
|
| 85 | - $weekNumber = (int)$currentWeek->format('W'); |
|
| 84 | + while ($currentWeek < $end) { |
|
| 85 | + $weekNumber = (int) $currentWeek->format('W'); |
|
| 86 | 86 | |
| 87 | - if(!in_array($weekNumber, $weekNumbers)) { |
|
| 87 | + if (!in_array($weekNumber, $weekNumbers)) { |
|
| 88 | 88 | $weekNumbers[] = $weekNumber; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | $timetableLessons = $this->lessonRepository->findAllByTuitions($start, $end, $tuitions); |
| 95 | 95 | |
| 96 | 96 | $current = clone $start; |
| 97 | - while($current <= $end) { |
|
| 97 | + while ($current <= $end) { |
|
| 98 | 98 | $dailyLessons = array_filter($timetableLessons, fn(TimetableLesson $lesson) => $lesson->getDate() == $current); |
| 99 | 99 | |
| 100 | - foreach($dailyLessons as $dailyLesson) { |
|
| 101 | - for($lessonNumber = $dailyLesson->getLessonStart(); $lessonNumber <= $dailyLesson->getLessonEnd(); $lessonNumber++) { |
|
| 100 | + foreach ($dailyLessons as $dailyLesson) { |
|
| 101 | + for ($lessonNumber = $dailyLesson->getLessonStart(); $lessonNumber <= $dailyLesson->getLessonEnd(); $lessonNumber++) { |
|
| 102 | 102 | $key = sprintf('%s-%d-%s', $current->format('Y-m-d'), $lessonNumber, $dailyLesson->getTuition()->getUuid()->toString()); |
| 103 | 103 | |
| 104 | 104 | if (!array_key_exists($key, $lessons)) { |
@@ -112,19 +112,19 @@ discard block |
||
| 112 | 112 | $current = $current->modify('+1 day'); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - foreach($substitutions as $substitution) { |
|
| 115 | + foreach ($substitutions as $substitution) { |
|
| 116 | 116 | $tuition = $this->tuitionRepository->findOneBySubstitution($substitution, $this->sectionResolver->getSectionForDate($substitution->getDate())); |
| 117 | 117 | |
| 118 | - if($tuition === null) { |
|
| 118 | + if ($tuition === null) { |
|
| 119 | 119 | continue; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $timetableLessons = $this->lessonRepository->findAllByTuitions($substitution->getDate(), $substitution->getDate(), [$tuition]); |
| 123 | 123 | |
| 124 | 124 | // Filter correct lesson |
| 125 | - foreach($timetableLessons as $dailyLesson) { |
|
| 126 | - for($lessonNumber = $dailyLesson->getLessonStart(); $lessonNumber <= $dailyLesson->getLessonEnd(); $lessonNumber++) { |
|
| 127 | - if($substitution->getLessonStart() <= $lessonNumber && $lessonNumber <= $substitution->getLessonEnd()) { |
|
| 125 | + foreach ($timetableLessons as $dailyLesson) { |
|
| 126 | + for ($lessonNumber = $dailyLesson->getLessonStart(); $lessonNumber <= $dailyLesson->getLessonEnd(); $lessonNumber++) { |
|
| 127 | + if ($substitution->getLessonStart() <= $lessonNumber && $lessonNumber <= $substitution->getLessonEnd()) { |
|
| 128 | 128 | $key = sprintf('%s-%d-%s', $substitution->getDate()->format('Y-m-d'), $lessonNumber, $dailyLesson->getTuition()->getUuid()->toString()); |
| 129 | 129 | |
| 130 | 130 | if (!array_key_exists($key, $lessons)) { |
@@ -133,14 +133,14 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | // Set correct entry |
| 135 | 135 | /** @var LessonEntry $lessonEntry */ |
| 136 | - foreach($dailyLesson->getEntries() as $lessonEntry) { |
|
| 137 | - if($lessonEntry->getLessonStart() <= $lessonNumber && $lessonNumber <= $lessonEntry->getLessonEnd()) { |
|
| 136 | + foreach ($dailyLesson->getEntries() as $lessonEntry) { |
|
| 137 | + if ($lessonEntry->getLessonStart() <= $lessonNumber && $lessonNumber <= $lessonEntry->getLessonEnd()) { |
|
| 138 | 138 | $lessons[$key]->setEntry($lessonEntry); |
| 139 | 139 | break; |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if($lessons[$key]->getLesson() === null) { |
|
| 143 | + if ($lessons[$key]->getLesson() === null) { |
|
| 144 | 144 | $lessons[$key]->setLesson($dailyLesson); |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -159,15 +159,15 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | public function computeOverviewForTeacher(Teacher $teacher, DateTime $start, DateTime $end): EntryOverview { |
| 161 | 161 | $section = $this->sectionResolver->getSectionForDate($start); |
| 162 | - $entries = [ ]; |
|
| 163 | - $tuitions = [ ]; |
|
| 164 | - $comments = [ ]; |
|
| 162 | + $entries = []; |
|
| 163 | + $tuitions = []; |
|
| 164 | + $comments = []; |
|
| 165 | 165 | |
| 166 | - if($section !== null) { |
|
| 166 | + if ($section !== null) { |
|
| 167 | 167 | $entries = $this->entryRepository->findAllBySubstituteTeacher($teacher, $start, $end); |
| 168 | 168 | $tuitions = $this->tuitionRepository->findAllByTeacher($teacher, $section); |
| 169 | 169 | |
| 170 | - foreach($tuitions as $tuition) { |
|
| 170 | + foreach ($tuitions as $tuition) { |
|
| 171 | 171 | $entries = array_merge($entries, $this->entryRepository->findAllByTuition($tuition, $start, $end)); |
| 172 | 172 | $comments = array_merge($comments, $this->commentRepository->findAllByDateAndTuition($tuition, $start, $end)); |
| 173 | 173 | } |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | $comments = ArrayUtils::unique($comments); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $substitutions = [ ]; |
|
| 178 | + $substitutions = []; |
|
| 179 | 179 | |
| 180 | 180 | $current = clone $start; |
| 181 | - while($current <= $end) { |
|
| 181 | + while ($current <= $end) { |
|
| 182 | 182 | $substitutions = array_merge( |
| 183 | 183 | $substitutions, |
| 184 | 184 | $this->substitutionRepository->findAllForTeacher($teacher, $current) |
@@ -194,41 +194,41 @@ discard block |
||
| 194 | 194 | public function computeOverviewForGrade(Grade $grade, DateTime $start, DateTime $end): EntryOverview { |
| 195 | 195 | $section = $this->sectionResolver->getSectionForDate($start); |
| 196 | 196 | |
| 197 | - if($section === null) { |
|
| 198 | - return new EntryOverview($start, $end, [ ], [ ], [ ]); |
|
| 197 | + if ($section === null) { |
|
| 198 | + return new EntryOverview($start, $end, [], [], []); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if($end > $section->getEnd()) { |
|
| 201 | + if ($end > $section->getEnd()) { |
|
| 202 | 202 | $end = $section->getEnd(); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | $entries = $this->entryRepository->findAllByGrade($grade, $start, $end); |
| 206 | 206 | $tuitions = $this->tuitionRepository->findAllByGrades([$grade], $section); |
| 207 | 207 | |
| 208 | - $comments = [ ]; |
|
| 208 | + $comments = []; |
|
| 209 | 209 | $section = $this->sectionResolver->getSectionForDate($start); |
| 210 | 210 | |
| 211 | - if($section !== null) { |
|
| 211 | + if ($section !== null) { |
|
| 212 | 212 | $comments = $this->commentRepository->findAllByDateAndGrade($grade, $section, $start, $end); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - return $this->computeOverview($tuitions, $entries, $comments, [ ], $start, $end); |
|
| 215 | + return $this->computeOverview($tuitions, $entries, $comments, [], $start, $end); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
| 219 | 219 | * @return FreeTimespan[] |
| 220 | 220 | */ |
| 221 | 221 | public function computeFreeTimespans(DateTime $start, DateTime $end): array { |
| 222 | - $result = [ ]; |
|
| 222 | + $result = []; |
|
| 223 | 223 | |
| 224 | 224 | $categories = array_map(fn(int $id) => $this->appointmentCategoryRepository->findOneById($id), $this->timetableSettings->getCategoryIds()); |
| 225 | 225 | |
| 226 | - if(count($categories) > 0) { |
|
| 226 | + if (count($categories) > 0) { |
|
| 227 | 227 | $appointments = $this->appointmentRepository->findAllStartEnd($start, $end, $categories); |
| 228 | 228 | |
| 229 | - foreach($appointments as $appointment) { |
|
| 229 | + foreach ($appointments as $appointment) { |
|
| 230 | 230 | $current = clone $appointment->getStart(); |
| 231 | - while($current < $appointment->getEnd()) { |
|
| 231 | + while ($current < $appointment->getEnd()) { |
|
| 232 | 232 | $result[] = new FreeTimespan(clone $current, 1, $this->timetableSettings->getMaxLessons(), $appointment->getTitle()); |
| 233 | 233 | $current = $current->modify('+1 day'); |
| 234 | 234 | } |
@@ -236,10 +236,10 @@ discard block |
||
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | $current = clone $start; |
| 239 | - while($current <= $end) { |
|
| 239 | + while ($current <= $end) { |
|
| 240 | 240 | $freeTimespans = $this->freeTimespanRepository->findAllByDate($current); |
| 241 | 241 | |
| 242 | - foreach($freeTimespans as $timespan) { |
|
| 242 | + foreach ($freeTimespans as $timespan) { |
|
| 243 | 243 | $result[] = new FreeTimespan(clone $timespan->getDate(), $timespan->getStart(), $timespan->getEnd(), 'Vertretungsplan'); |
| 244 | 244 | } |
| 245 | 245 | |