/** * Method to get a list of project items: * Milestones, task lists and tasks * * @return array */ protected static function getProjectDetails() { $params = self::$params; $pid = self::$project; $default = array('1', '0', '2'); $show_lists = $params->get('show_lists', $default); // Fix "Show Task Lists" setting from older module versions if (!is_array($show_lists)) { if ($show_lists == '1') { $show_lists = array('1', '0', '2'); } else { $show_lists = array('-1'); } } $milestones = modPFganttHelperMilestones::getItems($pid); $lists = !in_array('-1', $show_lists) ? modPFganttHelperLists::getItems($pid) : array(); $tasks = modPFganttHelperTasks::getItems($pid); // Sort data by hierarchy $items = self::sortByHierarchy($milestones, $lists, $tasks); return $items; }
public function getEndDate($id, $ms = 0, $ms_date = null) { $db = JFactory::getDbo(); $nd = $db->getNullDate(); $query = $db->getQuery(true); // Get the end date from the task $query->select('a.id, a.end_date, a.milestone_id')->select('m.end_date AS m_end')->from('#__pf_tasks AS a')->join('left', '#__pf_milestones AS m ON m.id = a.milestone_id')->where('a.list_id = ' . (int) $id)->where('a.state != -2')->order('a.end_date DESC, a.id ASC'); $db->setQuery($query, 0, 1); $task = $db->loadObject(); if (empty($task)) { if (!empty($ms_date) && $ms_date != $nd) { $date = $ms_date; } elseif ($ms) { $mhelper = modPFganttHelperMilestones($this->pid); $date = $mhelper->getEndDate($ms); } else { $dates = $this->getDateRange($id); $date = $dates[1]; } } elseif ($task->end_date == $nd) { $thelper = new modPFganttHelperTasks($this->pid); $date = $thelper->getEndDate($task->id, $task->milestone_id, $task->m_end); } else { $date = $task->end_date; } return $date; }
/** * Method to get the end date of a task list * based on the latest task assigned to it. * Falls back to milestone and then to the project. * * @param integer $id The task list id * @param integer $ms The parent milestone id * @param string $ms_date The parent milestone end date * * @return string The end date */ public static function getEndDate($id, $ms = 0, $ms_date = null) { static $cache = array(); // Check the cache if (isset($cache[$id])) { return $cache[$id]; } $db = JFactory::getDbo(); $nd = $db->getNullDate(); $query = $db->getQuery(true); // Get the end date from the task $query->select('a.id, a.end_date, a.milestone_id')->select('m.end_date AS m_end')->from('#__pf_tasks AS a')->join('left', '#__pf_milestones AS m ON m.id = a.milestone_id')->where('a.list_id = ' . (int) $id)->where('a.state != -2')->order('a.end_date DESC, a.id ASC'); $db->setQuery($query, 0, 1); $task = $db->loadObject(); if (empty($task)) { if (!empty($ms_date) && $ms_date != $nd) { $date = $ms_date; } elseif ($ms) { $date = modPFganttHelperMilestones::getEndDate($ms); } else { $date = modPFganttHelper::$project_end; } } elseif ($task->end_date == $nd) { $date = modPFganttHelperTasks::getEndDate($task->id, $task->milestone_id, $task->m_end); } else { $date = $task->end_date; } $cache[$id] = $date; return $cache[$id]; }