diff --git a/module/testcase/control.php b/module/testcase/control.php index ea35a7644f..647fb1dcce 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -804,8 +804,9 @@ class testcase extends control $position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]); /* Set menu. */ + if($this->app->tab == 'project' or $this->app->tab == 'execution') $this->loadModel('execution'); if($this->app->tab == 'project') $this->loadModel('project')->setMenu($this->session->project); - if($this->app->tab == 'execution') $this->loadModel('execution')->setMenu($this->session->execution); + if($this->app->tab == 'execution') $this->execution->setMenu($this->session->execution); if($this->app->tab == 'qa') $this->testcase->setMenu($this->products, $productID, $case->branch); $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0, $case->branch); @@ -820,8 +821,22 @@ class testcase extends control } } + /* Get product and branches. */ + $product = $this->product->getById($productID); + if($this->app->tab == 'execution' or $this->app->tab == 'project') + { + $objectID = $this->app->tab == 'project' ? $this->session->project : $this->session->execution; + $productBranches = (isset($product->type) and $product->type != 'normal') ? $this->execution->getBranchByProduct($productID, $objectID) : array(); + $branches = isset($productBranches[$productID]) ? $productBranches[$productID] : array(); + } + else + { + $branches = (isset($product->type) and $product->type != 'normal') ? $this->loadModel('branch')->getPairs($productID) : array(); + } + $this->view->productID = $productID; - $this->view->branches = $this->session->currentProductType == 'normal' ? array() : $this->loadModel('branch')->getPairs($productID); + $this->view->product = $product; + $this->view->branches = $branches; $this->view->productName = $this->products[$productID]; $this->view->moduleOptionMenu = $moduleOptionMenu; $this->view->stories = $this->story->getProductStoryPairs($productID, $case->branch); diff --git a/module/testcase/model.php b/module/testcase/model.php index 0969f60781..3a0186770e 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -48,6 +48,7 @@ class testcaseModel extends model ->setDefault('openedBy', $this->app->user->account) ->setDefault('openedDate', $now) ->setIF($this->config->systemMode == 'new' and $this->app->tab == 'project', 'project', $this->session->project) + ->setIF($this->app->tab == 'execution', 'execution', $this->session->execution) ->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion((int)$this->post->story)) ->remove('steps,expects,files,labels,stepType,forceNotReview') ->setDefault('story', 0) @@ -364,6 +365,19 @@ class testcaseModel extends model $case = $this->dao->findById($caseID)->from(TABLE_CASE)->fetch(); if(!$case) return false; foreach($case as $key => $value) if(strpos($key, 'Date') !== false and !(int)substr($value, 0, 4)) $case->$key = ''; + + /* Get project and execution. */ + $objects = $this->dao->select('t1.*, t1.project as objectID, t2.type')->from(TABLE_PROJECTCASE)->alias('t1') + ->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.project=t2.id') + ->where('t1.case')->eq($caseID) + ->fetchAll('objectID'); + + foreach($objects as $objectID => $object) + { + if($object->type == 'project') $case->project = $objectID; + if(in_array($object->type, array('sprint', 'stage'))) $case->execution = $objectID; + } + if($case->story) { $story = $this->dao->findById($case->story)->from(TABLE_STORY)->fields('title, status, version')->fetch(); diff --git a/module/testcase/view/batchedit.html.php b/module/testcase/view/batchedit.html.php index ae088659cd..7377e5c5e8 100644 --- a/module/testcase/view/batchedit.html.php +++ b/module/testcase/view/batchedit.html.php @@ -65,6 +65,8 @@
+ loadModel('branch');?> + loadModel('execution');?> lib) or $app->tab != 'qa') { $product = $this->product->getByID($cases[$caseID]->product); - $branches = $product->type == 'normal' ? array('' => '') : $this->loadModel('branch')->getPairs($product->id); + $branches = array('' => ''); if($product->type != 'normal') { + if($this->app->tab == 'project') $productBranches = $this->execution->getBranchByProduct($product->id, $this->session->project); + $branches = isset($productBranches[$product->id]) ? $productBranches[$product->id] : $this->branch->getPairs($product->id); foreach($branches as $branchID => $branchName) $branches[$branchID] = '/' . $product->name . '/' . $branchName; } diff --git a/module/testcase/view/edit.html.php b/module/testcase/view/edit.html.php index 9764da5f59..72d273f5ec 100644 --- a/module/testcase/view/edit.html.php +++ b/module/testcase/view/edit.html.php @@ -17,6 +17,9 @@ testcase->insertAfter);?> id);?> execution);?> +app->tab);?> +app->tab == 'execution') js::set('objectID', $case->execution);?> +app->tab == 'project') js::set('objectID', $case->project);?>