fix clear and copy week

This commit is contained in:
2019-11-05 16:58:25 +01:00
committed by Roland Schneider
parent 9c0e2a56ee
commit 2c5db234ce
19 changed files with 692 additions and 142 deletions

View File

@@ -22,7 +22,6 @@ use customerapi\models\available\EventInterval;
class TimeTableMonthWeek
{
public $monday;
public $tuesday;
public $wednesday;
@@ -47,4 +46,43 @@ class TimeTableMonthWeek
return $this->$objectAttribute;
}
public function getAllDays(){
$result = [];
foreach (EventInterval::weekdays as $weekday ){
$result[] = $this->$weekday;
}
return $result;
}
/**
* @return \DateTime
* @throws \Exception
*/
public function getWeekStart()
{
$firstDayOfWeek = clone $this->monday->date ;
$firstDayOfWeek->modify('this week');
$firstDayOfWeek->setTime(0,0);
return $firstDayOfWeek;
}
public function getWeekNumber(){
return $this->getWeekStart()->format('W');
}
public function getWeekYear(){
return $this->getWeekStart()->format('Y');
}
public function getWeekString(){
return $this->getWeekYear() . " - " . $this->getWeekNumber();
}
public function getAllEvents(){
$events = [];
foreach ($this->getAllDays() as $day){
$events = array_merge($events,$day->events);
}
return $events;
}
}