diff --git a/module/product/model.php b/module/product/model.php index 24002521e5..4f05e02c3f 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -957,29 +957,30 @@ class productModel extends model * @param int $productID * @param int $branch * @param string $orderBy + * @param int $projectID * @access public * @return array */ - public function getExecutionPairsByProduct($productID, $branch = 0, $orderBy = 'id_asc') + public function getExecutionPairsByProduct($productID, $branch = 0, $orderBy = 'id_asc', $projectID = 0) { - if(!$this->session->PRJ || !$productID) return array(); + if($productID) return array(); + if(empty($projectID)) return $this->getAllExecutionPairsByProduct($productID, $branch); - $project = $this->loadModel('program')->getPRJByID($this->session->PRJ); + $project = $this->loadModel('program')->getPRJByID($projectID); $orderBy = $project->model == 'waterfall' ? 'begin_asc,id_asc' : 'begin_desc,id_desc'; $executions = $this->dao->select('t2.id,t2.name,t2.grade,t2.parent')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') ->where('t1.product')->eq($productID) - ->andWhere('t2.project')->eq($this->session->PRJ) + ->andWhere('t2.project')->eq($projectID) ->beginIF($branch)->andWhere('t1.branch')->in($branch)->fi() ->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->sprints)->fi() ->andWhere('t2.deleted')->eq('0') ->orderBy($orderBy) ->fetchAll('id'); - $executionList = array('0' => ''); - /* The waterfall project needs to show the hierarchy and remove the parent stage. */ + $executionList = array('0' => ''); if($project->model == 'waterfall') { foreach($executions as $id => $execution) @@ -1010,6 +1011,54 @@ class productModel extends model return $executionList; } + /** + * Get execution pairs by product. + * + * @param int $productID + * @param int $branch + * @access public + * @return array + */ + public function getAllExecutionPairsByProduct($productID, $branch = 0) + { + if(empty($productID)) return array(); + $executions = $this->dao->select('t2.id,t2.project,t2.name,t2.grade,t2.parent')->from(TABLE_PROJECTPRODUCT)->alias('t1') + ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') + ->where('t1.product')->eq($productID) + ->andWhere('t2.type')->in('stage,sprint') + ->beginIF($branch)->andWhere('t1.branch')->in($branch)->fi() + ->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->sprints)->fi() + ->andWhere('t2.deleted')->eq('0') + ->fetchAll('id'); + + $projectIdList = array(); + foreach($executions as $id => $execution) $projectIdList[$execution->project] = $execution->project; + + $executionPairs = array(); + $projectPairs = $this->loadModel('program')->getPRJPairsByIdList($projectIdList); + foreach($executions as $id => $execution) + { + if($execution->grade == 2 && isset($executions[$execution->parent])) + { + $execution->name = $projectPairs[$execution->project] . '/' . $executions[$execution->parent]->name . '/' . $execution->name; + $executions[$execution->parent]->children[$id] = $execution->name; + unset($executions[$id]); + } + } + + foreach($executions as $execution) + { + if(isset($execution->children)) + { + $executionPairs = $executionPairs + $execution->children; + continue; + } + $executionPairs[$execution->id] = $projectPairs[$execution->project] . '/' . $execution->name; + } + + return $executionPairs; + } + /** * Get roadmap of a proejct. * diff --git a/module/program/model.php b/module/program/model.php index 9f6f7a52bf..53036f9182 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1745,7 +1745,7 @@ class programModel extends model { foreach($_POST['products'] as $productID => $product) { - $this->dao->update(TABLE_PRODUCT)->set('program')->eq($newTopPGM)->where('id')->eq((int)$productID)->exec(); + $this->dao->update(TABLE_PRODUCT)->set('program')->eq((int)$newTopPGM)->where('id')->eq((int)$productID)->exec(); } } diff --git a/module/testreport/model.php b/module/testreport/model.php index ab67c5ef5a..15bc4f4b8d 100644 --- a/module/testreport/model.php +++ b/module/testreport/model.php @@ -57,7 +57,7 @@ class testreportModel extends model { $data = fixer::input('post') ->stripTags($this->config->testreport->editor->create['id'], $this->config->allowedTags) - ->add('PRJ', $this->session->PRJ) + ->setIF($this->lang->navGroup->testreport != 'qa', 'PRJ', $this->session->PRJ) ->add('createdBy', $this->app->user->account) ->add('createdDate', helper::now()) ->join('stories', ',') @@ -149,7 +149,7 @@ class testreportModel extends model { $objectID = (int)$objectID; return $this->dao->select('*')->from(TABLE_TESTREPORT)->where('deleted')->eq(0) - ->andWhere('PRJ')->eq($this->session->PRJ) + ->beginIF($this->lang->navGroup->testreport != 'qa')->andWhere('PRJ')->eq($this->session->PRJ)->fi() ->beginIF($objectType == 'project')->andWhere('objectID')->eq($objectID)->andWhere('objectType')->eq('project')->fi() ->beginIF($objectType == 'product' and $extra)->andWhere('objectID')->eq((int)$extra)->andWhere('objectType')->eq('testtask')->fi() ->beginIF($objectType == 'product' and empty($extra))->andWhere('product')->eq($objectID)->fi() diff --git a/module/testsuite/model.php b/module/testsuite/model.php index b98f13c1b5..a09c797328 100644 --- a/module/testsuite/model.php +++ b/module/testsuite/model.php @@ -101,7 +101,7 @@ class testsuiteModel extends model { $suite = fixer::input('post') ->stripTags($this->config->testsuite->editor->create['id'], $this->config->allowedTags) - ->add('PRJ', $this->session->PRJ) + ->setIF($this->lang->navGroup->testsuite != 'qa', 'PRJ', $this->session->PRJ) ->add('product', (int)$productID) ->add('addedBy', $this->app->user->account) ->add('addedDate', helper::now()) @@ -133,7 +133,7 @@ class testsuiteModel extends model { return $this->dao->select("*")->from(TABLE_TESTSUITE) ->where('product')->eq((int)$productID) - ->andWhere('PRJ')->eq($this->session->PRJ) + ->beginIF($this->lang->navGroup->testsuite != 'qa')->andWhere('PRJ')->eq($this->session->PRJ)->fi() ->andWhere('deleted')->eq(0) ->andWhere("(`type` = 'public' OR (`type` = 'private' and addedBy = '{$this->app->user->account}'))") ->orderBy($orderBy) diff --git a/module/upgrade/control.php b/module/upgrade/control.php index 42a01a1822..b98140138c 100644 --- a/module/upgrade/control.php +++ b/module/upgrade/control.php @@ -305,7 +305,9 @@ class upgrade extends control $hourPoint = $this->loadModel('setting')->getItem('owner=system&module=custom&key=hourPoint'); if(empty($hourPoint)) $this->setting->setItem('system.custom.hourPoint', 0); - $this->dao->update(TABLE_ACTION)->set('objectType')->eq('execution')->where('objectType')->eq('project')->exec(); + /* Update sprints history. */ + $sprints = $this->dao->select('id')->from(TABLE_PROJECT)->where('type')->eq('sprint')->fetchAll('id'); + $this->dao->update(TABLE_ACTION)->set('objectType')->eq('execution')->where('objectID')->in(array_keys($sprints))->andWhere('objectType')->eq('project')->exec(); die(js::locate($this->createLink('upgrade', 'mergeRepo'))); } diff --git a/module/upgrade/js/mergeprogram.js b/module/upgrade/js/mergeprogram.js index b1194e1ba5..621a31c5c7 100644 --- a/module/upgrade/js/mergeprogram.js +++ b/module/upgrade/js/mergeprogram.js @@ -60,7 +60,10 @@ $(function() $('.lineBox').addClass('hidden'); $(target).removeClass('hidden'); $('#source').find('.lineBox :checkBox').prop('checked', false); - $(target).find(":checkbox").prop('checked', true); + + /* The first group of products is selected by default. */ + var firstProduct = $(target).find(":checkbox:first").prop('checked', true); + $('[data-product=' + firstProduct.val() + ']').prop('checked', true); /* Replace program name. */ $('#PGMName').val($(this).text()); diff --git a/module/upgrade/view/mergebyline.html.php b/module/upgrade/view/mergebyline.html.php index 85235cd073..d61b16ea7f 100644 --- a/module/upgrade/view/mergebyline.html.php +++ b/module/upgrade/view/mergebyline.html.php @@ -51,9 +51,9 @@ + -