From fa38ced902ed35fa0a1277bd1e1d9653d4de1929 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 20 Sep 2018 13:17:27 +0800 Subject: [PATCH] * finish task #4897. --- module/product/control.php | 2 +- module/product/css/view.css | 4 +-- module/product/model.php | 45 ++++++++++++++++++++++++++++++- module/product/view/view.html.php | 18 +++++++++---- 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index fea42a7013..71254d6941 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -396,7 +396,7 @@ class product extends control $this->view->lines = array('') + $this->loadModel('tree')->getLinePairs(); $this->view->branches = $this->loadModel('branch')->getPairs($productID); $this->view->dynamics = $this->loadModel('action')->getDynamic('all', 'all', 'date_desc', $pager, $productID); - $this->view->plans = $this->loadModel('productplan')->getList($productID, 0, 'unexpired', null, 'begin'); + $this->view->roadmap = $this->product->getRoadmap($productID, 0, 6); $this->display(); } diff --git a/module/product/css/view.css b/module/product/css/view.css index 66f90deafe..b318347e90 100644 --- a/module/product/css/view.css +++ b/module/product/css/view.css @@ -1,6 +1,6 @@ .branch-list {padding-left: 0; margin: 0;} .branch-list > li {float: left; list-style: none; width: 50%; margin: 5px 0;} .data-basic.table-data tbody > tr > th {width: 80px;} -.block-release .panel-body, .block-dynamic .panel-body {height: 240px; overflow: auto; position: relative;} +.block-release .panel-body, .block-dynamic .panel-body {height: 240px; overflow-x: hidden; overflow-y: auto; position: relative;} .block-release .panel-body {padding-bottom: 50px;} -.block-release .panel-body > .btn.pull-right {position: absolute; right: 20px; bottom: 20px;} \ No newline at end of file +.block-release .panel-body > .btn.pull-right {position: absolute; right: 20px; bottom: 20px;} diff --git a/module/product/model.php b/module/product/model.php index 1252e7558c..acab00edec 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -607,29 +607,44 @@ class productModel extends model * Get roadmap of a proejct * * @param int $productID + * @param int $branch + * @param int $num * @access public * @return array */ - public function getRoadmap($productID, $branch = 0) + public function getRoadmap($productID, $branch = 0, $num = 0) { $plans = $this->loadModel('productplan')->getList($productID, $branch); $releases = $this->loadModel('release')->getList($productID, $branch); $roadmap = array(); + $total = 0; foreach($plans as $plan) { if(($plan->end != '0000-00-00' and strtotime($plan->end) - time() <= 0) or $plan->end == '2030-01-01') continue; $year = substr($plan->end, 0, 4); $roadmap[$year][$plan->branch][] = $plan; + + $total++; + } + + if($num > 0 and $total >= $num) + { + krsort($roadmap); + return $this->limitRoadmap($roadmap, $num); } foreach($releases as $release) { $year = substr($release->date, 0, 4); $roadmap[$year][$release->branch][] = $release; + + $total++; + if($num > 0 and $total >= $num) break; } krsort($roadmap); + if($num > 0) return $this->limitRoadmap($roadmap, $num); $groupRoadmap = array(); foreach($roadmap as $year => $branchRoadmaps) @@ -666,6 +681,34 @@ class productModel extends model return $lastRoadmap; } + /** + * Limit roadmap. + * + * @param string $roadmap + * @param int $num + * @access public + * @return array + */ + public function limitRoadmap($roadmap, $num) + { + $i = 0; + $newRoadmap = array(); + foreach($roadmap as $year => $branches) + { + foreach($branches as $branch => $plans) + { + krsort($plans); + foreach($plans as $plan) + { + $newRoadmap[$year][$branch][] = $plan; + $i++; + if($i >= $num) break; + } + } + } + return $newRoadmap; + } + /** * Get team members of a product from projects. * diff --git a/module/product/view/view.html.php b/module/product/view/view.html.php index a5ea3c294b..6a5f0262d5 100644 --- a/module/product/view/view.html.php +++ b/module/product/view/view.html.php @@ -17,22 +17,30 @@
-
productplan->unexpired;?> product->iterationInfo, count($plans));?>
+
product->roadmap;?>