-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
159 lines (158 loc) · 6.84 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/*
'Vertretungsplan' von 'Tom Aschmann' ist lizenziert
unter einer Creative Commons Namensnennung
Nicht kommerziell 4.0 International Lizenz
Um eine Kopie dieser Lizenz zu sehen, besuchen Sie
http://creativecommons.org/licenses/by-nc/4.0/
*/
if (!file_exists('./untis.inc.php')) {
die('Bitte folge der Installationsanleitung auf <a href="https://github.com/tomtactom/WebUntis-Vertretungsplan-App/blob/main/README.md#installation" target="_blank" title="WebUntis Vertretungsplan App Installationsanleitung">GitHub</a>');
}
// Der header wird eingefügt
require('header.inc.php');
// Der Vertretungsplan wird angezeigt
if ($show_site === true) {
?>
<table>
<tr><th>Stunde</th><th>Fach</th><th>Vertretung</th><th>Raum</th></tr>
<?php
$counter = 0; // Zählt alle einzelnen verfügbaren Stunden
$val_counter = 0; // Zählt alle Stunden die eine Änderung eingetragen haben
// Schleife in der alle einzelnen Stunden durchgegangen werden
foreach (timetableData(date("Ymd", strtotime('+'.$day_number.' days')))['data']['dayTimeTable'] as $lessondate_main) {
$counter = $counter + 1; //Counter (siehe oben)
// Überprüft den zur Stunde zugehörigen Lehrer und teilt diese auf, wenn zwei eingetragen sind
$lesson['teacher']['tmp'] = explode(',', $lessondate_main['teacher']);
if(empty($lesson['teacher']['tmp'][0])) {
$lesson['teacher'][0] = $lessondate_main['teacher'];
} else {
$lesson['teacher'][0] = $lesson['teacher']['tmp'][0];
$lesson['teacher'][1] = $lesson['teacher']['tmp'][1];
}
// Überprüft den zur Stunde zugehörigen Raum und teilt diese auf, wenn zwei eingetragen sind
$lesson['room']['tmp'] = explode(',', $lessondate_main['room']);
if(empty($lesson['room']['tmp'][0])) {
$lesson['room'][0] = $lessondate_main['room'];
} else {
$lesson['room'][0] = $lesson['room']['tmp'][0];
$lesson['room'][1] = $lesson['room']['tmp'][1];
}
// Speichert das zugehörige Fach, die zugehörige Stunde, den Code und die zugehörige ID ab
$lesson['subject'] = $lessondate_main['subject'];
$lesson['timeGridHour'] = $lessondate_main['timeGridHour'];
$lesson['id'] = $lessondate_main['periods'][0]['id'];
$lesson['code'] = $lessondate_main['periods'][0]['isCancelled'];
// Überprüft ob es eine änderung gibt und filtert Fächer mit Änderungen von Fächern ohne Änderungen
if ($lesson['code'] == 'cancelled') {
echo ' <style>.a'.$lesson['id'].' { background-color: #3498db; color: #fff; }</style>
';
$lesson['teacher'][0] = 'Entfall';
$anomaly0 = true;
} elseif ($lesson['code'] == 'irregular') {
echo ' <style>.a'.$lesson['id'].' { background-color: #d35400; color: #fff; }</style>
';
$lesson['teacher'][0] = '???';
$anomaly0 = true;
} elseif (strpos($lesson['teacher'][0], '.EVA.') !== false) {
echo ' <style>.a0_'.$lesson['id'].' { background-color: #2980b9; color: #fff; }</style>
';
$anomaly0 = true;
} elseif (strpos($lesson['teacher'][0], '.NN.') !== false) {
echo ' <style>.a0_'.$lesson['id'].' { background-color: #e74c3c; color: #fff; }</style>
';
$anomaly0 = true;
} elseif (strpos($lesson['room'][0], '(') !== false) {
$anomaly0 = true;
} elseif (strpos($lesson['teacher'][0], '(') !== false) {
$anomaly0 = true;
}
// Überprüft das gleiche, wenn ein zweiter Wert für die gleiche Stunde eingetragen ist
if ($lesson['code'] == 'cancelled') {
echo ' <style>.a'.$lesson['id'].' { background-color: #3498db; color: #fff; }</style>
';
$lesson['teacher'][1] = 'Entfall';
$anomaly1 = true;
} elseif ($lesson['code'] == 'irregular') {
echo ' <style>.a'.$lesson['id'].' { background-color: #d35400; color: #fff; }</style>
';
$lesson['teacher'][1] = '???';
$anomaly1 = true;
} elseif (strpos($lesson['teacher'][1], '.EVA.') !== false) {
echo ' <style>.a1_'.$lesson['id'].' { background-color: #2980b9; color: #fff; }</style>
';
$anomaly1 = true;
} elseif (strpos($lesson['teacher'][1], '.NN.') !== false) {
echo ' <style>.a1_'.$lesson['id'].' { background-color: #e74c3c; color: #fff; }</style>
';
$anomaly1 = true;
} elseif (strpos($lesson['room'][1], '(') !== false) {
$anomaly1 = true;
} elseif (strpos($lesson['teacher'][1], '(') !== false) {
$anomaly1 = true;
}
// Gibt die Stunde aus, wenn es eine Änderung gibt aus dem ersten Teil
if($anomaly0 === true) {
echo ' <tr class="a0_'.$lesson['id'].'"><td>'.$lesson['timeGridHour'].'</td><td>'.$lesson['subject'].'</td><td>'.str_replace('_GK', '', str_replace('NN', 'Abwesend', str_replace('.', '', $lesson['teacher'][0]))).'</td><td>'.$lesson['room'][0].'</td></tr>
';
$val_counter = $va_counter + 1; // Counter (siehe oben)
}
// Gibt die Stunde aus, wenn es eine Änderung gibt aus dem zweiten Teil
if($anomaly1 === true) {
if ($lesson['teacher'][1] == true && $lesson['room'][1] == true) {
echo ' <tr class="a1_'.$lesson['id'].'"><td>'.$lesson['timeGridHour'].'</td><td>'.$lesson['subject'].'</td><td>'.str_replace('_GK', '', str_replace('NN', 'Abwesend', str_replace('.', '', $lesson['teacher'][1]))).'</td><td>'.$lesson['room'][1].'</td></tr>
';
$val_counter = $va_counter + 1; // Counter (siehe oben)
}
}
// Sestzt alle Variablen auf false, damit beim ernseuten Schleifendurchgang es keine Probleme gibt
$lesson['id'] = false;
$lesson['timeGridHour'] = false;
$lesson['subject'] = false;
$lesson['teacher'][0] = false;
$lesson['teacher'][1] = false;
$lesson['room'][0] = false;
$lesson['room'][1] = false;
$anomaly0 = false;
$anomaly1 = false;
}
if(isset($_GET['analytics']) && $val_counter !== 0) {
$analytics_file = file_get_contents('analytics'.date('Y').'.inc.txt');
if(empty($analytics_file)) {
$analytics_file = 0;
}
$analytics_file = $analytics_file + $val_counter;
file_put_contents('analytics'.date('Y').'.inc.txt', $analytics_file);
}
?>
</table>
<br>
<?php if($val_counter === 0) { // Meldung, wenn es keine Änderungen gab ?>
<h1 id="noanomaly"><?php echo $status; ?> wird nichts Vertreten</h1>
<?php
}
if(!isset($_GET['authcode'])) { // Footer Bar zur navigierung, für Webseitennutzer ?>
<footer>
<form method="post">
<table>
<tbody>
<tr>
<?php if($_GET['day'] == '1' || $_GET['day'] == '2') { ?>
<th id="before"><button type="submit" name="before"></button></th>
<?php } ?>
<th id="status"><?php echo $status; ?></th>
<?php if($_GET['day'] == '0' || $_GET['day'] == '1' || !isset($_GET['day'])) { ?>
<th id="after"><button type="submit" name="after"></button></th>
<?php } ?>
</tr>
</tbody>
</table>
</form>
©Tom Aschmann
</footer>
<?php
}
}
?>
</body>
</html>