diff --git a/module/project/model.php b/module/project/model.php index f7c4c8d808..1a789467dd 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -834,7 +834,7 @@ class projectModel extends model * Get execution pairs. * * @param int $projectID - * @param string $type all|execution|sprint|stage|kanban + * @param string $type all|sprint|stage|kanban * @param string $mode all|noclosed or empty * @access public * @return array @@ -850,8 +850,7 @@ class projectModel extends model $executions = $this->dao->select('*, IF(INSTR(" done,closed", status) < 2, 0, 1) AS isDone')->from(TABLE_EXECUTION) ->where('deleted')->eq(0) ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() - ->beginIF(!$projectID and $type == 'execution')->andWhere('project')->gt(0)->fi() - ->beginIF($type != 'all' and $type != 'execution')->andWhere('type')->eq($type)->fi() + ->beginIF($type != 'all')->andWhere('type')->eq($type)->fi() ->beginIF(strpos($mode, 'withdelete') === false)->andWhere('deleted')->eq(0)->fi() ->beginIF(!$this->app->user->admin and strpos($mode, 'all') === false)->andWhere('id')->in($this->app->user->view->sprints)->fi() ->orderBy($orderBy) diff --git a/module/todo/control.php b/module/todo/control.php index 0a64937f18..a6c06b7028 100644 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -369,15 +369,21 @@ class todo extends control $this->lang->set('menugroup.todo', $from); } - $this->view->title = $this->app->user->account == $todo->account ? "{$this->lang->todo->common} #$todo->id $todo->name" : $this->lang->todo->common ; - $this->view->position[] = $this->lang->todo->view; - $this->view->todo = $todo; - $this->view->times = date::buildTimeList($this->config->todo->times->begin, $this->config->todo->times->end, $this->config->todo->times->delta); - $this->view->users = $this->user->getPairs('noletter'); - $this->view->actions = $this->loadModel('action')->getList('todo', $todoID); - $this->view->from = $from; - $this->view->projects = $this->loadModel('project')->getExecutionPairs(0, 'execution'); - $this->view->products = $this->loadModel('product')->getPairs(); + $projects = $this->loadModel('program')->getPRJPairs(); + //$projectID = isset($this->session->PRJ) ? $this->session->PRJ : key($projects); + if(!isset($this->session->PRJ)) $this->session->set('PRJ', key($projects)); + + $this->view->title = $this->app->user->account == $todo->account ? "{$this->lang->todo->common} #$todo->id $todo->name" : $this->lang->todo->common ; + $this->view->position[] = $this->lang->todo->view; + $this->view->todo = $todo; + $this->view->times = date::buildTimeList($this->config->todo->times->begin, $this->config->todo->times->end, $this->config->todo->times->delta); + $this->view->users = $this->user->getPairs('noletter'); + $this->view->actions = $this->loadModel('action')->getList('todo', $todoID); + $this->view->from = $from; + $this->view->projects = $projects; + $this->view->executions = $this->loadModel('project')->getExecutionPairs($this->session->PRJ); + $this->view->products = $this->loadModel('product')->getPairs(); + $this->view->projectProducts = $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); $this->display(); } @@ -594,6 +600,36 @@ class todo extends control die($this->dao->select($field)->from($table)->where('id')->eq($objectID)->fetch($field)); } + /** + * AJAX: get execution pairs. + * + * @param int $projectID + * @access public + * @return void + */ + public function ajaxGetExecutionPairs($projectID) + { + $this->session->set('PRJ', $projectID); + + $executions = $this->loadModel('project')->getExecutionPairs($projectID); + die(html::select('execution', $executions, '', "class='form-control chosen'")); + } + + /** + * AJAX: get product pairs. + * + * @param int $projectID + * @access public + * @return void + */ + public function ajaxGetProductPairs($projectID) + { + $this->session->set('PRJ', $projectID); + + $products = $this->loadModel('product')->getProductPairsByProject($projectID); + die(html::select('product', $products, '', "class='form-control chosen'")); + } + /** * Create cycle. * diff --git a/module/todo/js/view.js b/module/todo/js/view.js index 703fba1cff..e39594d2d3 100644 --- a/module/todo/js/view.js +++ b/module/todo/js/view.js @@ -15,10 +15,10 @@ $(function() $('#toTaskButton').click(function() { var onlybody = config.onlybody; - var programID = $('#projectProgram').val(); + var projectID = $('#project').val(); - var projectID = $(this).closest('.input-group').find('#project').val(); - var link = createLink('task', 'create', 'projectID=' + projectID + '&storyID=0&moduleID=0&taskID=0&todoID=' + todoID, config.defaultView, 'no', programID); + var executionID = $(this).closest('.input-group').find('#execution').val(); + var link = createLink('task', 'create', 'projectID=' + executionID + '&storyID=0&moduleID=0&taskID=0&todoID=' + todoID, config.defaultView, 'no', projectID); parent.location.href = link; }) @@ -37,7 +37,7 @@ $(function() $('#toBugButton').click(function() { var onlybody = config.onlybody; - var programID = $('#productProgram').val(); + var programID = $('#project').val(); var productID = $(this).closest('.input-group').find('#product').val(); var link = createLink('bug', 'create', 'productID=' + productID + '&branch=0&extras=todoID=' + todoID, config.defaultView, 'no', programID); @@ -70,12 +70,19 @@ function createProject() parent.location.href = link; } -function getProgramByProject(projectID) +function getExecutionByProject(projectID) { - link = createLink('todo', 'ajaxGetProgramID', "projectID=" + projectID + '&type=project'); - $.post(link, function(data) - { - $('#projectProgram').val(data); + link = createLink('todo', 'ajaxGetExecutionPairs', "projectID=" + projectID); + $('#executionIdBox').load(link, function(){ + $(this).find('select').chosen(); + }) +} + +function getProductByProject(projectID) +{ + link = createLink('todo', 'ajaxGetProductPairs', "projectID=" + projectID); + $('#productIdBox').load(link, function(){ + $(this).find('select').chosen(); }) } diff --git a/module/todo/view/view.html.php b/module/todo/view/view.html.php index d374f344ab..1e8a2b7bce 100644 --- a/module/todo/view/view.html.php +++ b/module/todo/view/view.html.php @@ -78,7 +78,7 @@ echo "
"; if($isonlybody) $_GET['onlybody'] = 'yes'; } @@ -199,9 +199,13 @@