From b8fa0246803dab40cf57d40b45984c53046f2d55 Mon Sep 17 00:00:00 2001 From: "Dzial Techniczny WMW Projekt s.c" Date: Tue, 10 Dec 2019 11:34:53 +0100 Subject: Plugins directory and local modifications --- .../Model/GroupAssignCalendarModel.php | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 plugins/Group_assign/Model/GroupAssignCalendarModel.php (limited to 'plugins/Group_assign/Model/GroupAssignCalendarModel.php') diff --git a/plugins/Group_assign/Model/GroupAssignCalendarModel.php b/plugins/Group_assign/Model/GroupAssignCalendarModel.php new file mode 100644 index 00000000..5b45ca09 --- /dev/null +++ b/plugins/Group_assign/Model/GroupAssignCalendarModel.php @@ -0,0 +1,89 @@ +db->table(MultiselectMemberModel::TABLE) + ->eq('user_id', $user_id) + ->findAllByColumn('group_id'); + + $getGr_Ids = $this->db->table(GroupMemberModel::TABLE) + ->eq('user_id', $user_id) + ->findAllByColumn('group_id'); + + $tasks = $this->db->table(self::TABLE) + ->beginOr() + ->eq('owner_id', $user_id) + ->in('owner_gp', $getGr_Ids) + ->in('owner_ms', $getMS_Ids) + ->closeOr() + ->gte('date_due', strtotime($start)) + ->lte('date_due', strtotime($end)) + ->neq('is_active', 0); + + $tasks = $tasks->findAll(); + + $events = array(); + + foreach ($tasks as $task) { + + $startDate = new DateTime(); + $startDate->setTimestamp($task['date_started']); + + $endDate = new DateTime(); + $endDate->setTimestamp($task['date_due']); + + if ($startDate->getTimestamp() == 0) { $startDate = $endDate; } + + $allDay = $startDate == $endDate && $endDate->format('Hi') == '0000'; + $format = $allDay ? 'Y-m-d' : 'Y-m-d\TH:i:s'; + + $events[] = array( + 'timezoneParam' => $this->timezoneModel->getCurrentTimezone(), + 'id' => $task['id'], + 'title' => t('#%d', $task['id']).' '.$task['title'], + 'backgroundColor' => $this->colorModel->getBackgroundColor('dark_grey'), + 'borderColor' => $this->colorModel->getBorderColor($task['color_id']), + 'textColor' => 'white', + 'url' => $this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), + 'start' => $startDate->format($format), + 'end' => $endDate->format($format), + 'editable' => $allDay, + 'allday' => $allDay, + ); + } + + return $events; + } + +} -- cgit v1.2.3