fix clear and copy week
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user