From 83ea052cc79f592c67354e078d5601d7ab26064c Mon Sep 17 00:00:00 2001 From: L_DA Date: Thu, 24 Sep 2020 19:45:03 +0200 Subject: [PATCH] changes --- classes/timetable.php | 102 +++++++++++++++++++++++++++++------------- 1 file changed, 71 insertions(+), 31 deletions(-) diff --git a/classes/timetable.php b/classes/timetable.php index 67598e8..fb5217d 100755 --- a/classes/timetable.php +++ b/classes/timetable.php @@ -95,6 +95,7 @@ class timetable { foreach ($result as $substitution) { $this->data[$i+1][$substitution->period]['substitution'][] = $substitution; if ($this->periodmax < $lesson->period) $this->periodmax = $lesson->period; + //echo var_dump($substitution); } } $day->add(new \DateInterval("P1D")); @@ -251,8 +252,8 @@ class timetable { $days = array(); for ($day=0; $day<$numdayweek; $day++) { $days[$day] = array(); - $days[$day]['substitution'] = ""; - $days[$day]['lessons'] = array(); + $days[$day]['substitution'] = ""; + $days[$day]['lessons'] = array(); if (array_key_exists($period+1,$this->data[$day+1]) && array_key_exists('lesson',$this->data[$day+1][$period+1])) { foreach ($this->data[$day+1][$period+1]['lesson'] as $lesson) { @@ -261,43 +262,82 @@ class timetable { $mylesson['teacher'] = $lesson->teacher; $mylesson['room'] = $lesson->room; $mylesson['subject'] = $lesson->subject; - $mylesson['status'] = ""; - if ($lesson->week[$this->week-1] == 'x') $mylesson['status'] = 1; - $mylesson['flag'] = ""; - if ($lesson->flag) $mylesson['flag'] = $lesson->flag; - - /* - if ($this->type == 'class') $mylesson['class'] = ""; - if ($this->type == 'teacher') $mylesson['teacher'] = ""; - if ($this->type == 'room') $mylesson['room'] = ""; - */ - if ($lesson->week[$this->week-1] != '0') $days[$day]['lessons'][] = $mylesson; - /* - - für diese Woche wurden keine Daten ausgegeben - 0 in dieser Woche findet der Unterricht nicht statt - 1 in dieser Woche findet der Unterricht statt - x in dieser Woche entfällt der Unterricht - - if ($lesson->week[$this->week-1] == 'x') - */ + $mylesson['status'] = ""; + if ($lesson->week[$this->week-1] == 'x') { + $mylesson['status'] = 1; + /* + if (array_key_exists('substitution', $this->data[$day+1][$period+1])) { + foreach ($this->data[$day+1][$period+1]['substitution'] as $substitution) { + if ($lesson->class == $substitution->classa && + $lesson->teacher == $substitution->teachera && + $lesson->subject == $substitution->subjecta && + $lesson->room == $substitution->rooma) { + $mylesson['class'] = $substitution->classb; + $mylesson['teacher'] = $substitution->teacherb; + $mylesson['room'] = $substitution->roomb; + $mylesson['subject'] = $substitution->subjectb; + $mylesson['status'] = ''; } + } } - if (array_key_exists($period+1,$this->data[$day+1]) - && array_key_exists('substitution', $this->data[$day+1][$period+1])) { - foreach ($this->data[$day+1][$period+1]['substitution'] as $substitution) { - //echo "In substitution loop".$substitution->text; - $days[$day]['substitution'] .= $substitution->text; - } - } + */ + } + $mylesson['flag'] = ""; + if ($lesson->flag) $mylesson['flag'] = $lesson->flag; + + /* + if ($this->type == 'class') $mylesson['class'] = ""; + if ($this->type == 'teacher') $mylesson['teacher'] = ""; + if ($this->type == 'room') $mylesson['room'] = ""; + */ + if ($lesson->week[$this->week-1] != '0') $days[$day]['lessons'][] = $mylesson; + /* + - für diese Woche wurden keine Daten ausgegeben + 0 in dieser Woche findet der Unterricht nicht statt + 1 in dieser Woche findet der Unterricht statt + x in dieser Woche entfällt der Unterricht + + if ($lesson->week[$this->week-1] == 'x') + */ + } + } + if (array_key_exists($period+1,$this->data[$day+1]) + && array_key_exists('substitution', $this->data[$day+1][$period+1])) { + foreach ($this->data[$day+1][$period+1]['substitution'] as $substitution) { + //echo "In substitution loop".$substitution->text; + $days[$day]['substitution'] .= $substitution->text; + + if ($substitution->subjectb && + (($this->type == 'teacher' && $this->name == $substitution->teacherb) || + ($this->type == 'class' && $this->name == $substitution->classb) || + ($this->type == 'room' && $this->name == $substitution->roomb)) + ) { + + $mylesson = array(); + $mylesson['class'] = $substitution->classb; + $mylesson['teacher'] = $substitution->teacherb; + $mylesson['room'] = $substitution->roomb; + $mylesson['subject'] = $substitution->subjectb; + $mylesson['status'] = ""; + $mylesson['flag'] = 1; + + $days[$day]['lessons'][] = $mylesson; + //if ($lesson->week[$this->week-1] != '0') $days[$day]['lessons'][] = $mylesson; + + + } + + } + } } $periods[$period] = array(); $periods[$period]['days'] = $days; - $periods[$period]['number'] = $period+1; + $periods[$period]['number'] = $period+1; } $resultdata['periods'] = $periods; //echo var_dump($data); - return $resultdata; - } + return $resultdata; + } }