From 547355168de439bb30e9002e81fc79da7885bda2 Mon Sep 17 00:00:00 2001 From: pengjiangxiu Date: Mon, 21 Aug 2017 13:29:51 +0800 Subject: [PATCH] * Finish task #3195. --- module/bug/model.php | 4 ++-- module/story/control.php | 16 ++++++++-------- module/story/model.php | 35 +++++++++++++++++++++++++++------- module/task/control.php | 2 +- module/task/model.php | 5 +++-- module/task/view/edit.html.php | 4 ++-- module/tree/model.php | 25 +++++++++++++++++++----- 7 files changed, 64 insertions(+), 27 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index 6eecd56864..6a0114f9ed 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1467,7 +1467,7 @@ class bugModel extends model $i++; } } - + return array('title' => $title, 'steps' => $bugSteps, 'storyID' => $run->case->story, 'moduleID' => $run->case->module, 'version' => $run->case->version); } @@ -1538,7 +1538,7 @@ class bugModel extends model { $datas = $this->dao->select('module as name, count(module) as value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('module')->orderBy('value DESC')->fetchAll('name'); if(!$datas) return array(); - $modules = $this->loadModel('tree')->getModulesName(array_keys($datas)); + $modules = $this->loadModel('tree')->getModulesName(array_keys($datas),true,true); foreach($datas as $moduleID => $data) $data->name = isset($modules[$moduleID]) ? $modules[$moduleID] : '/'; return $datas; } diff --git a/module/story/control.php b/module/story/control.php index c0c6c0c174..9865defb61 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -1268,11 +1268,11 @@ class story extends control /** * The report page. - * - * @param int $productID - * @param string $browseType + * + * @param int $productID + * @param string $browseType * @param int $branchID - * @param int $moduleID + * @param int $moduleID * @access public * @return void */ @@ -1307,12 +1307,12 @@ class story extends control $this->view->checkedCharts = $this->post->charts ? join(',', $this->post->charts) : ''; $this->display(); } - + /** * get data to export - * - * @param int $productID - * @param string $orderBy + * + * @param int $productID + * @param string $orderBy * @access public * @return void */ diff --git a/module/story/model.php b/module/story/model.php index 1a23663c6e..43e514243a 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -193,7 +193,7 @@ class storyModel extends model ->set('version')->eq(1) ->exec(); } - + if($bugID > 0) { $bug = new stdclass(); @@ -1959,7 +1959,7 @@ class storyModel extends model /** * Get report data of storys per product - * + * * @access public * @return array */ @@ -1975,25 +1975,46 @@ class storyModel extends model } /** - * Get report data of storys per module - * + * Get report data of storys per module + * * @access public * @return array */ public function getDataOfStorysPerModule() { - $datas = $this->dao->select('module as name, count(module) as value')->from(TABLE_STORY) + $datas = $this->dao->select('module as name, count(module) as value, product, branch')->from(TABLE_STORY) ->where($this->reportCondition()) ->groupBy('module')->orderBy('value DESC')->fetchAll('name'); if(!$datas) return array(); + + $branchIDList = array(); + foreach($datas as $key => $project) + { + if(!$project->branch) continue; + $branchIDList[] = $project->branch; + } + + $branchIDList = array_unique($branchIDList); + $branchs = $this->dao->select('id, name')->from(TABLE_BRANCH)->where('id')->in($branchIDList)->andWhere('deleted')->eq(0)->fetchALL('id'); $modules = $this->loadModel('tree')->getModulesName(array_keys($datas)); - foreach($datas as $moduleID => $data) $data->name = isset($modules[$moduleID]) ? $modules[$moduleID] : '/'; + + foreach($datas as $moduleID => $data) + { + $branch = ''; + if(isset($branchs[$data->branch]->name)) + { + $branch = '/' . $branchs[$data->branch]->name; + } + + $data->name = $branch . (isset($modules[$moduleID]) ? $modules[$moduleID] : '/'); + } + return $datas; } /** * Get report data of storys per source - * + * * @access public * @return array */ diff --git a/module/task/control.php b/module/task/control.php index 0fc6c9e2f2..65385c923b 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -1087,7 +1087,7 @@ class task extends control */ public function report($projectID, $browseType = 'all') { - + $this->loadModel('report'); $this->view->charts = array(); diff --git a/module/task/model.php b/module/task/model.php index 8e2b667348..0ab27e780b 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -1356,7 +1356,8 @@ class taskModel extends model ->orderBy('value DESC') ->fetchAll('name'); if(!$datas) return array(); - $modules = $this->loadModel('tree')->getModulesName(array_keys($datas)); + + $modules = $this->loadModel('tree')->getModulesName(array_keys($datas),true,true); foreach($datas as $moduleID => $data) $data->name = isset($modules[$moduleID]) ? $modules[$moduleID] : '/'; return $datas; } @@ -1422,7 +1423,7 @@ class taskModel extends model return $priList; } - + /** * Get report data of tasks per deadline * diff --git a/module/task/view/edit.html.php b/module/task/view/edit.html.php index 59a1159c6e..124a0a7386 100644 --- a/module/task/view/edit.html.php +++ b/module/task/view/edit.html.php @@ -62,11 +62,11 @@
task->legendBasic;?> - +
- + diff --git a/module/tree/model.php b/module/tree/model.php index ae52f6108e..e2a34cfcd0 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -1103,18 +1103,21 @@ class treeModel extends model /** * Get modules name. - * - * @param array $moduleIdList - * @param bool $allPath + * + * @param array $moduleIdList + * @param bool $allPath + * @param bool $branchPath * @access public * @return array */ - public function getModulesName($moduleIdList, $allPath = true) + public function getModulesName($moduleIdList, $allPath = true, $branchPath = false) { if(!$allPath) return $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in($moduleIdList)->andWhere('deleted')->eq(0)->fetchPairs('id', 'name'); - $modules = $this->dao->select('id, name, path')->from(TABLE_MODULE)->where('id')->in($moduleIdList)->andWhere('deleted')->eq(0)->fetchAll('path'); + $modules = $this->dao->select('id, name, path, branch')->from(TABLE_MODULE)->where('id')->in($moduleIdList)->andWhere('deleted')->eq(0)->fetchAll('path'); $allModules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in(join(array_keys($modules)))->andWhere('deleted')->eq(0)->fetchPairs('id', 'name'); + + $branchIDList = array(); $modulePairs = array(); foreach($modules as $module) { @@ -1122,7 +1125,19 @@ class treeModel extends model $moduleName = ''; foreach($paths as $path) $moduleName .= '/' . $allModules[$path]; $modulePairs[$module->id] = $moduleName; + + if($module->branch) $branchIDList[] = $module->branch; } + + if(!$branchPath) return $modulePairs; + + $branchIDList = array_unique($branchIDList); + $branchs = $this->dao->select('id, name')->from(TABLE_BRANCH)->where('id')->in($branchIDList)->andWhere('deleted')->eq(0)->fetchALL('id'); + foreach($modules as $module) + { + if(isset($modulePairs[$module->id])) $modulePairs[$module->id] = '/' . $branchs[$module->branch]->name . $modulePairs[$module->id]; + } + return $modulePairs; }
task->project;?> project, 'class="form-control chosen" onchange="loadAll(this.value)"');?>
task->module;?> module, 'class="form-control chosen" onchange="loadModuleRelated()"');?>