Newer
Older
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
<?php
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
// +--------------------------------------------------------------------------+
// This file is part of Stud.IP
// MetaDate.class.php
//
// Repräsentiert die Zeit- und Turnusdaten einer Veranstaltung
//
// +--------------------------------------------------------------------------+
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or any later version.
// +--------------------------------------------------------------------------+
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// +--------------------------------------------------------------------------+
/**
* MetaDate.class.php
*
*
* @author Till Glöggler <tgloeggl@uos.de>
* @version 28. Juni 2007
* @access protected
* @package raumzeit
*/
class MetaDate
{
var $seminar_id = '';
var $seminarStartTime = 0;
var $seminarDurationTime = 0;
var $cycles = [];
var $hasDatesTmp = [];
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
/**
* Constructor
* @param string $seminar_id
*/
function __construct($seminar_id = '')
{
if ($seminar_id != '') {
$this->seminar_id = $seminar_id;
$this->restore();
}
}
/**
* returns start week (Semesterwoche) for a cycledate
* for compatibility the first cycledate is chosen if no one is specified
*
* @deprecated
* @param string id of cycledate
* @return int
*/
function getStartWoche($metadate_id = null)
{
if ($metadate_id) {
return $this->cycles[$metadate_id]->week_offset;
} else {
$first_metadate = $this->getFirstMetadate();
return $first_metadate ? $first_metadate->week_offset : null;
}
}
/**
* sets start week (Semesterwoche) for a cycledate
* for compatibility the first cycledate is chosen if no one is specified
*
* @deprecated
* @param int $start_woche
* @param string $metadate_id
* @return null|Ambigous <NULL, unknown>
*/
function setStartWoche($start_woche, $metadate_id = null)
{
if ($metadate_id) {
return $this->cycles[$metadate_id]->week_offset = $start_woche;
} else {
$first_metadate = $this->getFirstMetadate();
return $first_metadate ? $first_metadate->week_offset = $start_woche : null;
}
}
/**
* returns first cycledate
*
* @return CycleData
*/
function getFirstMetadate()
{
$cycles = array_keys($this->cycles);
$first_metadate_id = array_shift($cycles);
return $first_metadate_id ? $this->cycles[$first_metadate_id] : null;
}
/**
* returns the cycle for a cycledate
* for compatibility the first cycledate is chosen if no one is specified
*
* @deprecated
* @param string $metadate_id
* @return int 0,1,2 for weekly, biweekly ...
*/
function getTurnus($metadate_id = null)
{
if ($metadate_id) {
return $this->cycles[$metadate_id]->cycle;
} else {
$first_metadate = $this->getFirstMetadate();
return $first_metadate ? $first_metadate->cycle : null;
}
}
/**
* set the cycle for a cycledate
* for compatibility the first cycledate is chosen if no one is specified
*
* @deprecated
* @param int 0,1,2 for weekly, biweekly ...
* @param string $metadate_id
* @return int
*/
function setTurnus($turnus, $metadate_id = null)
{
if ($metadate_id) {
return $this->cycles[$metadate_id]->cycle = $turnus;
} else {
$first_metadate = $this->getFirstMetadate();
return $first_metadate ? $first_metadate->cycle = $turnus : null;
}
}
function setSeminarStartTime($start)
{
$this->seminarStartTime = $start;
}
function setSeminarDurationTime($duration)
{
$this->seminarDurationTime = $duration;
}
function getSeminarID()
{
return $this->seminar_id;
}
/**
* internal method to apply cycledate data from assoc array to a given
* CycleData object. checks the start and endtime and retruns false if wrong
*
* @deprecated
* @param array assoc, see CycleData, metadate_id must be in $data['cycle_id']
* @param CycleData $cycle
* @return boolean
*/
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
{
$cycle->seminar_id = $this->getSeminarId();
$cycles = array_keys($this->cycles);
if ($last_one = array_pop($cycles)) {
$cycle->sorter = $this->cycles[$last_one]->sorter > 0 ? $this->cycles[$last_one]->sorter + 1 : 0;
}
if ($cycle->getDescription() != $data['description']) {
$cycle->setDescription($data['description']);
}
if (isset($data['weekday'])) $cycle->weekday = (int)$data['weekday'];
if (isset($data['week_offset'])) $cycle->week_offset = (int)$data['week_offset'];
if (isset($data['cycle'])) $cycle->cycle = (int)$data['cycle'];
if (isset($data['sws'])) $cycle->sws = $data['sws'];
if (isset($data['endWeek'])) $cycle->end_offset = (int)$data['endWeek'];
if (isset($data['day']) && isset($data['start_stunde']) && isset($data['start_minute']) && isset($data['end_stunde']) && isset($data['end_minute'])) {
if (
($data['start_stunde'] > 23) || ($data['start_stunde'] < 0) ||
($data['end_stunde'] > 23) || ($data['end_stunde'] < 0) ||
($data['start_minute'] > 59) || ($data['start_minute'] < 0) ||
($data['end_minute'] > 59) || ($data['end_minute'] < 0)
) {
return FALSE;
}
if (mktime((int)$data['start_stunde'], (int)$data['start_minute']) < mktime((int)$data['end_stunde'], (int)$data['end_minute'])) {
$cycle->setDay($data['day']);
$cycle->setStart($data['start_stunde'], $data['start_minute']);
$cycle->setEnd($data['end_stunde'], $data['end_minute']);
return TRUE;
}
}
return FALSE;
}
/**
* adds a new cycledate, single dates are created if second param is true
*
* @param array assoc, see CycleData, metadate_id must be in $data['cycle_id']
* @param bool $create_single_dates
* @return string|boolean metadate_id of created cycle
*/
function addCycle($data = [], $create_single_dates = true)
{
$data['day'] = (int)$data['day'];
$data['start_stunde'] = (int)$data['start_stunde'];
$data['start_minute'] = (int)$data['start_minute'];
$data['end_stunde'] = (int)$data['end_stunde'];
$data['end_minute'] = (int)$data['end_minute'];
$cycle = new CycleData();
if ($this->setCycleData($data, $cycle)) {
$this->cycles[$cycle->getMetadateID()] = $cycle;
$this->sortCycleData();
if ($create_single_dates) $this->createSingleDates($cycle->getMetadateID());
return $cycle->getMetadateID();
}
return FALSE;
}
/**
* change existing cycledate, changes also corresponding single dates
*
* @param array assoc, see CycleData, metadate_id must be in $data['cycle_id']
* @return number|boolean
*/
function editCycle($data = [])
{
$cycle = $this->cycles[$data['cycle_id']];
$new_start = mktime((int)$data['start_stunde'], (int)$data['start_minute']);
$new_end = mktime((int)$data['end_stunde'], (int)$data['end_minute']);
$old_start = mktime($cycle->getStartStunde(), $cycle->getStartMinute());
$old_end = mktime($cycle->getEndStunde(), $cycle->getEndMinute());
if (($new_start >= $old_start) && ($new_end <= $old_end) && ($data['day'] == $cycle->day) && ($data['endWeek'] == $cycle->end_offset)) {
// Zeitraum wurde verkuerzt, Raumbuchungen bleiben erhalten...
if ($this->setCycleData($data, $cycle)) {
$termine = $cycle->getSingleDates();
foreach ($termine as $key => $val) {
$tos = $val->getStartTime();
$toe = $val->getEndTime();
if ($toe > time()) {
$t_start = mktime((int)$data['start_stunde'], (int)$data['start_minute'], 0, date('m', $tos), date('d', $tos), date('Y', $tos));
$t_end = mktime((int)$data['end_stunde'], (int)$data['end_minute'], 0, date('m', $toe), date('d', $toe), date('Y', $toe));
$termine[$key]->setTime($t_start, $t_end);
$termine[$key]->store();
} else {
unset($termine[$key]);
}
}
$this->sortCycleData();
}
return sizeof($termine);
} else {
if ($this->setCycleData($data, $cycle)) {
// collect all existing themes (issues) for this cycle:
$issues = [];
$issue_objects = [];
$singledate_count = 0;
// loop through the single dates and look for themes (issues)
$termine = $cycle->getSingleDates();
foreach ($termine as $key => $termin) {
// get all isues of this date ( zero, one, or more, if the expert view is activated)
// and store them at the relative position of this single date
$issues[$singledate_count] = $termin->getIssueIDs();
$singledate_count++;
}
// remove all SingleDates in the future for this CycleData
$count = CycleDataDB::deleteNewerSingleDates($data['cycle_id'], time());
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
// create new SingleDates
$this->createSingleDates(['metadate_id' => $cycle->getMetaDateId(),
'startAfterTimeStamp' => time()
]);
// clear all loaded SingleDates so no odd ones remain. The Seminar-Class will load them fresh when needed
$cycle->termine = NULL;
// read all new single dates
$termine = $cycle->getSingleDates();
// new dates counter
$new_singledate_count = 0;
// loop through the single dates and add the themes (issues)
foreach ($termine as $key => $termin) {
// check, if there are issues for this single date
if ($issues[$new_singledate_count] != NULL) {
// add all issues:
foreach ($issues[$new_singledate_count] as $issue_key => $issue_id) {
$termin->addIssueID($issue_id);
$termin->store();
}
}
unset($issues[$new_singledate_count]);
$new_singledate_count++;
}
// delete issues, that are not assigned to a single date because of to few dates
// (only if the schedule expert view is off)
if (!Config::get()->RESOURCES_ENABLES_EXPERT_SCHEDULE_VIEW) {
if ($new_singledate_count < $singledate_count) {
for ($i = $new_singledate_count; $i < $singledate_count; $i++) {
if ($issues[$i] != NULL) {
foreach ($issues[$i] as $issue_id) {
// delete this issue
IssueDB::deleteIssue($issue_id);
}
}
}
}
}
$this->sortCycleData();
return $count;
}
}
return FALSE;
}
/**
* completey remove cycledate
* @see CycleData::delete()
* @param string $cycle_id
* @return boolean
*/
function deleteCycle($cycle_id)
{
$this->cycles[$cycle_id]->delete();
unset ($this->cycles[$cycle_id]);
return TRUE;
}
function deleteSingleDate($cycle_id, $date_id, $filterStart, $filterEnd)
{
$this->cycles[$cycle_id]->deleteSingleDate($date_id, $filterStart, $filterEnd);
}
function unDeleteSingleDate($cycle_id, $date_id, $filterStart, $filterEnd)
{
return $this->cycles[$cycle_id]->unDeleteSingleDate($date_id, $filterStart, $filterEnd);
}
/**
* store all changes to cycledates for the course, removed cycles are deleted from database
* @return int > 0 if changes where made
*/
function store()
{
$old_cycle_dates = [];
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
foreach (SeminarCycleDate::findBySeminar($this->seminar_id) as $c) {
$old_cycle_dates[$c->getId()] = $c;
}
$removed = array_diff(array_keys($old_cycle_dates), array_keys($this->cycles));
foreach ($removed as $one) {
$changed += $old_cycle_dates[$one]->delete();
}
foreach ($this->cycles as $one) {
$changed += $one->storeCycleDate();
}
$this->sortCycleData();
return $changed;
}
/**
* load all cycledates from database
*/
function restore()
{
$this->cycles = [];
foreach (SeminarCycleDate::findBySeminar($this->seminar_id) as $c) {
$this->cycles[$c->getId()] = new CycleData($c);
}
$this->sortCycleData();
}
function delete($removeSingleDates = TRUE)
{
//TODO: Löschen eines MetaDate-Eintrages (CycleData);
}
/**
* sort cycledates by sorter column and date
*/
function sortCycleData()
{
uasort($this->cycles, function ($a, $b) {
return $a->sorter - $b->sorter
?: $a->weekday - $b->weekday
?: $a->start_hour - $b->start_hour;
});
}
/**
* returns cycledates as arrays
*
* @param bool $show_invisibles if cycles without dates should
* be in the array, defaults to false
* @return array assoc of cycledate data arrays
*/
function getCycleData($show_invisibles = false)
{
$ret = [];
foreach ($this->cycles as $val) {
if ($val->is_visible || $show_invisibles) {
$ret[$val->getMetaDateID()] = $val->toArray();
}
}
return $ret;
}
/**
* returns the cycledate objects
* @return array of CycleData objects
*/
function getCycles()
{
return $this->cycles;
}
/**
* returns an array of SingleDate objects corresponding to the given cycle id
* use the optional params to specify a timerange
*
* @param string a cycle id
* @param int unix timestamp
* @param int unix timestamp
* @return array of SingleDate objects
*/
function getSingleDates($metadate_id, $filterStart = 0, $filterEnd = 0)
{
if (!$this->cycles[$metadate_id]->termine) {
$this->readSingleDates($metadate_id, $filterStart, $filterEnd);
}
return $this->cycles[$metadate_id]->termine;
}
/**
* reload SingleDate objects for a given cycle id
*
* @param string $metadate_id
* @param int $start
* @param int $end
* @return bool
*/
function readSingleDates($metadate_id, $start = 0, $end = 0)
{
return $this->cycles[$metadate_id]->readSingleDates($start, $end);
}
/**
* returns true if a given cycle has at least one date at all or in the given time range
*
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
* @param int $filterStart
* @param int $filterEnd
* @return bool
*/
function hasDates($metadate_id, $filterStart = 0, $filterEnd = 0)
{
if (!isset($this->hasDatesTmp[$metadate_id])) {
$this->hasDatesTmp[$metadate_id] = MetaDateDB::has_dates($metadate_id, $this->getSeminarID(), $filterStart, $filterEnd);
}
return $this->hasDatesTmp[$metadate_id];
}
/**
* create single dates for one cycle and all semester and store them in database, deleting obsolete ones
*
* @param mixed cycle id (string) or array with 'metadate_id' => string cycle id, 'startAfterTimeStamp' => int timestamp to override semester start
*/
function createSingleDates($data)
{
foreach ($this->getVirtualSingleDates($data) as $semester_id => $dates_for_semester) {
list($dates, $dates_to_delete) = array_values($dates_for_semester);
foreach ($dates_to_delete as $d) $d->delete();
foreach ($dates as $d) {
if ($d->isUpdate()) continue; //vorhandene Termine nicht speichern wg. chdate
$d->store();
}
}
//das sollte nicht nötig sein, muss aber erst genauer untersucht werden
$this->store();
$this->restore();
}
/**
* generate single date objects for one cycle and all semester, existing dates are merged in
*
* @param mixed cycle id (string) or array with 'metadate_id' => string cycle id, 'startAfterTimeStamp' => int timestamp to override semester start
* @return array array of arrays, for each semester id an array of two arrays of SingleDate objects: 'dates' => all new and surviving dates, 'dates_to_delete' => obsolete dates
*/
function getVirtualSingleDates($data)
{
if (is_array($data)) {
$metadate_id = $data['metadate_id'];
$startAfterTimeStamp = $data['startAfterTimeStamp'];
} else {
$metadate_id = $data;
$startAfterTimeStamp = 0;
}
$ret = [];
$all_semester = Semester::findAllVisible(false);
$sem_begin = null;
$sem_end = null;
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
// get the starting-point for creating singleDates for the choosen cycleData
foreach ($all_semester as $val) {
if (($this->seminarStartTime >= $val["beginn"]) && ($this->seminarStartTime <= $val["ende"])) {
$sem_begin = mktime(0, 0, 0, date("n", $val["vorles_beginn"]), date("j", $val["vorles_beginn"]), date("Y", $val["vorles_beginn"]));
}
}
// get the end-point
if ($this->seminarDurationTime == -1) {
foreach ($all_semester as $val) {
$sem_end = $val['vorles_ende'];
}
} else {
$i = 0;
foreach ($all_semester as $val) {
$i++;
$timestamp = $this->seminarDurationTime + $this->seminarStartTime;
if (($timestamp >= $val['beginn']) && ($timestamp <= $val['ende'])) {
$sem_end = $val["vorles_ende"];
}
}
}
$passed = false;
foreach ($all_semester as $val) {
if ($sem_begin <= $val['vorles_beginn']) {
$passed = true;
}
if ($passed && ($sem_end >= $val['vorles_ende']) && ($startAfterTimeStamp <= $val['ende'])) {
// correction calculation, if the semester does not start on monday
$dow = date("w", $val['vorles_beginn']);
if ($dow <= 5)
$corr = ($dow - 1) * -1;
elseif ($dow == 6)
$corr = 2;
elseif ($dow == 0)
$corr = 1;
else
$corr = 0;
$ret[$val['semester_id']] = $this->getVirtualSingleDatesForSemester($metadate_id, $val['vorles_beginn'], $val['vorles_ende'], $startAfterTimeStamp, $corr);
}
}
return $ret;
}
/**
* generate single date objects for one cycle and one semester, existing dates are merged in
*
* @param string cycle id
* @param int timestamp of semester start
* @param int timestamp of semester end
* @param int alternative timestamp to start from
* @param int correction calculation, if the semester does not start on monday (number of days?)
* @return array returns an array of two arrays of SingleDate objects: 'dates' => all new and surviving dates, 'dates_to_delete' => obsolete dates
*/
function getVirtualSingleDatesForSemester($metadate_id, $sem_begin, $sem_end, $startAfterTimeStamp, $corr)
{
$dates = [];
$dates_to_delete = [];
// loads the singledates of the by metadate_id denoted regular time-entry into the object
$this->readSingleDates($metadate_id);
// The currently existing singledates for the by metadate_id denoted regular time-entry
$existingSingleDates =& $this->cycles[$metadate_id]->getSingleDates();
$start_woche = $this->cycles[$metadate_id]->week_offset;
$end_woche = $this->cycles[$metadate_id]->end_offset;
$turnus = $this->cycles[$metadate_id]->cycle;
// This variable is used to check if a given singledate shall be created in a bi-weekly seminar.
if ($start_woche == -1) $start_woche = 0;
$week = 0;
// get the first presence date after sem_begin
$day_of_week = date('l', strtotime('Sunday + ' . $this->cycles[$metadate_id]->day . ' days'));
$stamp = strtotime('this week ' . $day_of_week, $sem_begin);
$start_time = mktime(
(int)$this->cycles[$metadate_id]->start_stunde, // Hour
(int)$this->cycles[$metadate_id]->start_minute, // Minute
0, // Second
date("n", $stamp), // Month
date("j", $stamp), // Day
date("Y", $stamp)); // Year
$end_time = mktime(
(int)$this->cycles[$metadate_id]->end_stunde, // Hour
(int)$this->cycles[$metadate_id]->end_minute, // Minute
0, // Second
date("n", $stamp), // Month
date("j", $stamp), // Day
date("Y", $stamp)); // Year
// loop through all possible singledates for this regular time-entry
do {
// if dateExists is true, the singledate will not be created. Default is of course to create the singledate
$dateExists = false;
// do not create singledates if they are earlier than the semester start
if ($end_time < $sem_begin) $dateExists = true;
// do not create singledates, if they are earlier then the chosen start-week
if ($start_woche > $week || (isset($end_woche) && $week > $end_woche)) $dateExists = true;
// bi-weekly check
if ($turnus > 0 && ($week - $start_woche) > 0 && (($week - $start_woche) % ($turnus + 1))) {
$dateExists = true;
}
/*
* We only create dates, which do not already exist, so we do not overwrite existing dates.
*
* Additionally, we delete singledates which are not needed any more (bi-weekly, changed start-week, etc.)
*/
foreach ($existingSingleDates as $key => $val) {
// take only the singledate into account, that maps the current timepoint
if ($start_time > $startAfterTimeStamp && ($val->date == $start_time) && ($val->end_time == $end_time)) {
// bi-weekly check
if ($turnus > 0 && ($week - $start_woche) > 0 && (($week - $start_woche) % ($turnus + 1))) {
$dates_to_delete[$key] = $val;
unset($existingSingleDates[$key]);
}
// delete singledates if they are earlier than the chosen start-week
if ($start_woche > $week || (isset($end_woche) && $week > $end_woche)) {
$dates_to_delete[$key] = $val;
unset($existingSingleDates[$key]);
}
$dateExists = true;
if (isset($existingSingleDates[$key])) {
$dates[$key] = $val;
}
}
}
if ($start_time < $startAfterTimeStamp) {
$dateExists = true;
}
if (!$dateExists) {
$termin = new SingleDate(['seminar_id' => $this->seminar_id]);
$all_holiday = SemesterHoliday::getAll(); // fetch all Holidays
foreach ($all_holiday as $val2) {
if (($val2["beginn"] <= $start_time) && ($start_time <= $val2["ende"])) {
$termin->setExTermin(true);
}
}
//check for calculatable holidays
if (!$termin->isExTermin()) {
$holy_type = holiday($start_time);
if ($holy_type["col"] == 3) {
$termin->setExTermin(true);
}
}
// fill the singleDate-Object with data
$termin->setMetaDateID($metadate_id);
$termin->setTime($start_time, $end_time);
$termin->setDateType(1); //best guess
$dates[$termin->getTerminID()] = $termin;
}
//inc the week, create timestamps for the next singledate
$start_time = strtotime('+1 week', $start_time);
$end_time = strtotime('+1 week', $end_time);
$week++;
} while ($end_time < $sem_end);
return ['dates' => $dates, 'dates_to_delete' => $dates_to_delete];
}
}