diff --git a/module/execution/control.php b/module/execution/control.php index f819837e60..dea9973497 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1825,27 +1825,44 @@ class execution extends control * Kanban. * * @param int $executionID - * @param string $objectType - * @param string $groupBy + * @param string $orderBy + * @param string $type * @access public * @return void */ - public function kanban($executionID, $objectType = 'all', $groupBy = 'id_desc') + public function kanban($executionID, $orderBy = 'all', $type = 'id_desc') { /* Save to session. */ $uri = $this->app->getURI(true); $this->app->session->set('taskList', $uri, 'execution'); $this->app->session->set('bugList', $uri, 'qa'); - /* Compatibility IE8*/ + /* Compatibility IE8. */ if(strpos($this->server->http_user_agent, 'MSIE 8.0') !== false) header("X-UA-Compatible: IE=EmulateIE7"); - $lanes = $this->loadModel('kanban')->getLanesByExecution($executionID, $objectType); + $kanbanLanes = $this->loadModel('kanban')->getLanesByExecution($executionID); + $kanbanColumns = $this->kanban->getColumnsByLane(array_keys($kanbanLanes)); + $kanban = array(); + + foreach($kanbanLanes as $laneID => $lane) + { + $kanban[$lane->type] = $lane; + $kanban[$lane->type]->columns = array(); + foreach($kanbanColumns as $columnID => $column) + { + if($column->lane == $laneID) + { + $kanban[$lane->type]->columns[$columnID] = $column; + unset($kanbanColumns[$columnID]); + } + } + } + $this->execution->setMenu($executionID); $execution = $this->loadModel('execution')->getById($executionID); $tasks = $this->execution->getKanbanTasks($executionID, "id"); $bugs = $this->loadModel('bug')->getExecutionBugs($executionID); - $stories = $this->loadModel('story')->getExecutionStories($executionID, 0, 0, $orderBy); + $stories = $this->loadModel('story')->getExecutionStories($executionID); /* Determines whether an object is editable. */ $canBeChanged = common::canModify('execution', $execution); diff --git a/module/kanban/model.php b/module/kanban/model.php index d709f69563..9825ac6c45 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -30,6 +30,25 @@ class kanbanModel extends model ->fetchAll('id'); } + /** + * Get Kanban columns by lane ID. + * + * @param int|array $lanes + * @param string $type + * @access public + * @return void + */ + public function getColumnsByLane($lanes, $type = 'all') + { + if(empty($lanes)) return array(); + return $this->dao->select('t2.id as id, t2.*')->from(TABLE_KANBANLANE)->alias('t1') + ->leftJoin(TABLE_KANBANCOLUMN)->alias('t2')->on('t1.id=t2.lane') + ->where('t2.deleted')->eq(0) + ->andWhere('t2.lane')->in($lanes) + ->beginIF($type !== 'all')->andWhere('t1.type')->eq($type)->fi() + ->fetchAll('id'); + } + /** * Add execution Kanban lanes. *