This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.max.dynamic.php
340 lines (253 loc) · 10.1 KB
/
index.max.dynamic.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
require_once __DIR__ . '/src/config.php';
require_once __DIR__ . '/src/session.php';
if (!$AUTHORIZED) {
logout();
redirect('/login/');
exit;
}
get_person();
?>
<!DOCTYPE html>
<html lang="ru"<?php if (!$UI_ERROR && isset($_COOKIE['dark']) && $_COOKIE['dark']) echo ' class="dark"'?>>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="build/home.min.css">
<?php include_once __DIR__ . '/src/favicon.html' ?>
<title>NetSchool PTHS</title>
</head>
<body>
<?php require_once __DIR__ . '/src/header.php' ?>
<main>
<?php
include_once __DIR__ . '/src/message_alerts.php';
require_once __DIR__ . '/src/menu.html';
$diary = json_decode($person['diary'], true);
$tasks = [];
if ($diary) {
// Expired tasks:
foreach ($diary as $date => $day_tasks) {
$lessons_task_index = [];
foreach ($day_tasks as $task_data) {
$lesson = $task_data[0];
$task = $task_data[2];
$task_expired = $task_data[5];
$day = new DateTime($date);
if (!isset($lessons_task_index[$lesson])) $lessons_task_index[$lesson] = 0;
if ($task_expired && $day >= class_to_diary_period($db, $person['class'])[0]) $tasks[] = [
'day' => $day,
'lesson' => $lesson,
'task_name' => $task,
'task_index' => $lessons_task_index[$lesson]++,
'task_expired' => true
];
}
}
// Tasks tomorrow:
if (isset($diary[$SCHOOL_DAY->format('Y-m-d')])) {
$lessons_task_index = [];
foreach ($diary[$SCHOOL_DAY->format('Y-m-d')] as $task_data) {
$lesson = $task_data[0];
$task = $task_data[2];
if (!isset($lessons_task_index[$lesson])) $lessons_task_index[$lesson] = 0;
$tasks[] = [
'day' => $SCHOOL_DAY,
'lesson' => $lesson,
'task_name' => $task,
'task_index' => $lessons_task_index[$lesson]++,
'task_expired' => false
];
}
}
}
if (!empty($tasks)) {
?>
<div class="tasks" title="Просроченные задания и задания текущего дня">
<h2>Задания</h2>
<ul>
<?php
foreach ($tasks as $task) {
extract($task);
?>
<li
<?php
if ($task_expired) echo ' class="expired"';
echo ' title="' . ($NOW > $day ? 'Было задано' : 'Необходимо сдать') . ' ' . format_days_diff(date_diff($TODAY, $day)->format('%r%a')) . '"';
?>
>
<?php echo $lesson . ': ' ?>
<span>
<a href="/diary/#<?php echo $day->format('Y-m-d') . '-' . $lesson . '-' . $task_index ?>"><?php echo $task_name ?></a>
</span>
<div><?php echo format_days_diff(date_diff($TODAY, $day)->format('%r%a')) ?></div>
</li>
<?php
}
?>
</ul>
</div>
<?php
}
?>
<div class="timetable">
<button id="goto_today" title="Перейти к текущей неделе">Сегодня →</button>
<svg id="timetable_previous" viewBox="0 0 40 70" xmlns="http://www.w3.org/2000/svg">
<title>Предыдущая неделя</title>
<?php include __DIR__ . '/files/icons/arrow_thick.path.svg' ?>
</svg>
<?php
$timetable = json_decode($person['timetable'], true);
$week_period = new DatePeriod($TRUE_SCHOOL_YEAR_BEGIN, DateInterval::createFromDateString('1 week'), $TRUE_SCHOOL_YEAR_END);
foreach ($week_period as $monday) {
$sunday = new DateTime($monday->format('Y-m-d') . ' Sunday this week');
$school_week_start = new DateTime($monday->format('Y-m-d') . ' Saturday last week ' . $SCHOOL_DAY_BORDER->format('H:i'));
$school_week_end = new DateTime($monday->format('Y-m-d') . ' Saturday this week ' . $SCHOOL_DAY_BORDER->format('H:i'));
?>
<div class="<?php
echo $monday->format('Y-m-d');
if ($school_week_start <= $NOW && $NOW < $school_week_end) echo ' shown displayed';
if ($monday == $MONDAY) echo ' cur_week';
?>">
<h3 title="<?php echo 'Неделя с ' . $monday->format('d') . ' ' . $months_genetive[$monday->format('m') - 1] . ' ' . $monday->format('Y') . ' по ' . $sunday->format('d') . ' ' . $months_genetive[$sunday->format('m') - 1] . ' ' . $sunday->format('Y') ?>">
<?php
echo ltrim($monday->format('d'), '0') . ' ' . $months_genetive[$monday->format('m') - 1] . ' - ' . ltrim($sunday->format('d'), '0') . ' ' . $months_genetive[$sunday->format('m') - 1]
?>
</h3>
<div>
<?php
$day_period = new DatePeriod($monday, DateInterval::createFromDateString('1 day'), $sunday);
foreach ($day_period as $day) {
?>
<div class="<?php echo $day->format('Y-m-d'); if ($day == $TODAY) echo ' today' ?>" title="<?php echo $weekdays[get_weekday($day)] . ', ' . ltrim($day->format('d'), '0') . ' ' . $months_genetive[$day->format('m') - 1] ?>">
<?php
if (isset($timetable[$day->format('Y-m-d')]) && !is_null($timetable[$day->format('Y-m-d')])) {
$lessons = [];
$vacations = [];
$has_any_lesson = false;
$has_any_cabinet = false;
foreach ($timetable[$day->format('Y-m-d')] as $item) {
if (!is_null($item)) {
$type = $item[0];
$name = $item[1];
if (!is_null($name) && ($type == 'lesson')) {
$has_any_lesson = true;
preg_match_all('/(.*)\[(\d+)\]/', $name, $match, PREG_PATTERN_ORDER);
if (isset($match[2][0]) && trim($match[2][0])) {
$has_any_cabinet = true;
break;
}
}
}
}
$zoom_day = ($has_any_lesson && !$has_any_cabinet);
?>
<h4><?php echo $weekdays[get_weekday($day)] ?></h4>
<div class="day_info<?php if ($zoom_day) echo ' zoom_day' ?>">
<?php
echo ltrim($day->format('d'), '0') . ' ' . $months_genetive[$day->format('m') - 1];
if ($zoom_day) {
echo ', ';
?>
<img class="zoom-icon" src="/files/icons/zoom_blue.svg" alt="zoom" title="Этот день ПРЕДПОЛОЖИТЕЛЬНО проходит дистанционно на платформе https://zoom.us">
<?php
}
?>
</div>
<ul>
<?php
$lesson_index = 0;
foreach ($timetable[$day->format('Y-m-d')] as $item) {
if (!is_null($item)) {
$type = $item[0];
$name = $item[1];
$start_time = $item[2];
$end_time = $item[3];
if (is_null($name)) {
++$lesson_index;
?>
<li class="no_lesson" title="<?php echo $weekdays[get_weekday($day)] . ', ' . ltrim($day->format('d'), '0') . ' ' . $months_genetive[$day->format('m') - 1] . ': нет ' . $lesson_index . '-го урока' ?>"></li>
<?php
} else if ($type == 'lesson' || $type == 'vacation') {
++$lesson_index;
preg_match_all('/(.*)\[(\d+)\]/', $name, $match, PREG_PATTERN_ORDER);
if (isset($match[1][0]) && trim($match[1][0])) {
$name = trim($match[1][0]);
}
$cabinet = (isset($match[2][0]) ? trim($match[2][0]) : '');
$start_time = new DateTime($start_time);
$end_time = new DateTime($end_time);
?>
<li
<?php
$classes = array();
if ($type == 'vacation') {
$classes[] = 'vacation';
}
if ($type == 'lesson' && $start_time <= $NOW && $NOW <= $end_time) {
$classes[] = 'cur_lesson';
}
if (!empty($classes)) echo ' class="' . implode(' ', $classes) . '"';
?>
title="<?php echo $weekdays[get_weekday($day)] . ', ' . ltrim($day->format('d'), '0') . ' ' . $months_genetive[$day->format('m') - 1] . ': ' . $lesson_index . ' урок' ?>"
>
<a><?php echo handle_lesson_name($name) ?></a>
<div>
<h5<?php if (!is_null($start_time) || !is_null($end_time) || $cabinet) echo ' style="margin-bottom: 7px"' ?>>
<?php echo handle_lesson_name($name) ?>
</h5>
<?php
$details = [];
// if ($start_time) $details[] = 'Тип: ' . $type;
$info_wrap = '<span class="info">';
if ($start_time) $details[] = 'Начало: '. $info_wrap . $start_time->format('H:i'). '</span>';
if ($end_time) $details[] = 'Конец: '. $info_wrap . $end_time->format('H:i'). '</span>';
if ($cabinet) $details[] = 'Кабинет: '.$info_wrap . $cabinet . '</span>';
echo implode('<br>', $details);
?>
</div>
</li>
<?php
}
} else {
++$lesson_index;
?>
<li class="no_lesson" title="<?php echo $weekdays[get_weekday($day)] . ', ' . ltrim($day->format('d'), '0') . ' ' . $months_genetive[$day->format('m') - 1] . ': нет ' . $lesson_index . '-го урока' ?>"></li>
<?php
}
}
?>
</ul>
<?php
} else {
?>
<div class="pending">
Раписание на этот день не загружено
</div>
<?php
}
?>
</div>
<?php
}
?>
</div>
</div>
<?php
}
?>
<svg id="timetable_next" viewBox="0 0 40 70" xmlns="http://www.w3.org/2000/svg">
<title>Следующая неделя</title>
<?php include __DIR__ . '/files/icons/arrow_thick.path.svg' ?>
</svg>
</div>
</main>
<div class="details"></div>
<?php include_once __DIR__ . '/src/online_media/online_media.php' ?>
<script type="text/javascript" src="/src/lib/event.js" defer></script>
<script type="text/javascript" src="/src/build/ajax.min.js" defer></script>
<script type="text/javascript" src="/src/build/common.min.js" defer></script>
<script type="text/javascript" src="build/home.min.js" defer></script>
<script type="text/javascript" src="/src/online_media/build/online_media.min.js" defer></script>
</body>
</html>