From d0e170871fe93007bcb159b1fd85ccb7b993b38c Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sat, 21 Sep 2024 01:48:26 +0300 Subject: [PATCH] fix: class is initialized outside each event scope, and in case of two events in the same time-frame we get duplicated classes --- src/phpCalendar/Calendar.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/phpCalendar/Calendar.php b/src/phpCalendar/Calendar.php index a9a689f..c96763a 100755 --- a/src/phpCalendar/Calendar.php +++ b/src/phpCalendar/Calendar.php @@ -992,11 +992,7 @@ public function asWeekView($date = false, $color = false) $datetime = $date->setTime(substr($time, 0, 2), substr($time, 3, 2)); - $events = $this->findEvents($datetime, 'week'); - - $class = ''; - - $event_summary = ''; + $events = $this->findEvents($datetime, 'week'); $today_class = ($date->format('Y-m-d H') == $today->format('Y-m-d H')) ? ' today' : ''; @@ -1006,6 +1002,11 @@ public function asWeekView($date = false, $color = false) if ($events) { foreach ($events as $index => $event) { + + $class = ''; + + $event_summary = ''; + if (in_array($event, $used_events)) { $event_summary = ' '; } else {