diff --git a/db/update11.2.sql b/db/update11.2.sql index 7939b8cfd6..83403f975a 100644 --- a/db/update11.2.sql +++ b/db/update11.2.sql @@ -1 +1,2 @@ update `zt_build` set `deleted`='1' where `project`='0' and `id` in (select `build` from `zt_release` where `deleted`='1'); +ALTER TABLE `zt_productplan` ADD `parent` mediumint(9) NOT NULL DEFAULT '0' AFTER `branch`; diff --git a/module/productplan/control.php b/module/productplan/control.php index 78c889cc6c..ee0817af09 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -42,7 +42,7 @@ class productplan extends control * @access public * @return void */ - public function create($product = '', $branch = 0) + public function create($product = '', $branch = 0, $parent = 0) { if(!empty($_POST)) { @@ -65,11 +65,15 @@ class productplan extends control $begin = date('Y-m-d', strtotime("+$delta days", $timestamp)); } $this->view->begin = $lastPlan ? $begin : ''; + if($parent) $this->view->parentPlan = $this->productplan->getById($parent); - $this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->productplan->create; - $this->view->lastPlan = $lastPlan; + $this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->productplan->create; $this->view->position[] = $this->lang->productplan->common; $this->view->position[] = $this->lang->productplan->create; + + $this->view->lastPlan = $lastPlan; + $this->view->branch = $branch; + $this->view->parent = $parent; $this->display(); } @@ -206,6 +210,7 @@ class productplan extends control $this->view->title = $products[$productID] . $this->lang->colon . $this->lang->productplan->browse; $this->view->position[] = $this->lang->productplan->browse; $this->view->productID = $productID; + $this->view->branch = $branch; $this->view->browseType = $browseType; $this->view->orderBy = $orderBy; $this->view->plans = $this->productplan->getList($productID, $branch, $browseType, $pager, $sort); diff --git a/module/productplan/css/browse.css b/module/productplan/css/browse.css index 966f3b4cd7..c650c25ecb 100644 --- a/module/productplan/css/browse.css +++ b/module/productplan/css/browse.css @@ -1 +1,13 @@ .table td.content { overflow:hidden; text-overflow:ellipsis; white-space:nowrap;} + +.table-children {border-left: 2px solid #cbd0db; border-right: 2px solid #cbd0db;} +.table tbody > tr.table-children.table-child-top {border-top: 2px solid #cbd0db;} +.table tbody > tr.table-children.table-child-bottom {border-bottom: 2px solid #cbd0db;} +.table td.has-child > a {max-width: 90%; max-width: calc(100% - 30px); display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;} +.table td.has-child > .task-toggle {color: #838a9d; position: relative; top: 1px;} +.table td.has-child > .task-toggle:hover {color: #006af1; cursor: pointer;} +.table td.has-child > .task-toggle > .icon {font-size: 16px; display: inline-block; transition: transform .2s; -ms-transform:rotate(-90deg); -moz-transform:rotate(-90deg); -o-transform:rotate(-90deg); -webkit-transform:rotate(-90deg); transform: rotate(-90deg);} +.table td.has-child > .task-toggle > .icon:before {text-align: left;} +.table td.has-child > .task-toggle.collapsed > .icon {-ms-transform:rotate(90deg); -moz-transform:rotate(90deg); -o-transform:rotate(90deg); -webkit-transform:rotate(90deg); transform: rotate(90deg);} +.main-table tbody > tr.table-children > td:first-child::before {width: 3px;} +@-moz-document url-prefix() {.main-table tbody > tr.table-children > td:first-child::before {width: 4px;}} diff --git a/module/productplan/lang/en.php b/module/productplan/lang/en.php index 024d866410..72c1a2bd4e 100644 --- a/module/productplan/lang/en.php +++ b/module/productplan/lang/en.php @@ -27,6 +27,7 @@ $lang->productplan->batchUnlinkStory = "Batch Unlink"; $lang->productplan->linkedStories = 'Linked Story'; $lang->productplan->unlinkedStories = 'Unlinked Story'; $lang->productplan->updateOrder = 'Sort'; +$lang->productplan->createChildren = "Create subplans"; $lang->productplan->linkBug = "Link Bug"; $lang->productplan->unlinkBug = "Unlink Bug"; @@ -54,6 +55,8 @@ $lang->productplan->stories = 'Stories'; $lang->productplan->bugs = 'Bugs'; $lang->productplan->hour = 'Hour'; $lang->productplan->project = $lang->projectCommon; +$lang->productplan->parent = "Father plan"; +$lang->productplan->children= "Sub plan"; $lang->productplan->endList[7] = '1 Week'; $lang->productplan->endList[14] = '2 Weeks'; diff --git a/module/productplan/lang/zh-cn.php b/module/productplan/lang/zh-cn.php index 37f4c71a20..61b6afdfba 100644 --- a/module/productplan/lang/zh-cn.php +++ b/module/productplan/lang/zh-cn.php @@ -27,6 +27,7 @@ $lang->productplan->batchUnlinkStory = "批量移除需求"; $lang->productplan->linkedStories = '需求'; $lang->productplan->unlinkedStories = '未关联需求'; $lang->productplan->updateOrder = '排序'; +$lang->productplan->createChildren = "创建子计划"; $lang->productplan->linkBug = "关联Bug"; $lang->productplan->unlinkBug = "移除Bug"; @@ -54,6 +55,8 @@ $lang->productplan->stories = '需求数'; $lang->productplan->bugs = 'Bug数'; $lang->productplan->hour = '工时'; $lang->productplan->project = $lang->projectCommon; +$lang->productplan->parent = "父计划"; +$lang->productplan->children= "子计划"; $lang->productplan->endList[7] = '一星期'; $lang->productplan->endList[14] = '两星期'; diff --git a/module/productplan/model.php b/module/productplan/model.php index 93918c6b51..b0c49a61e9 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -75,8 +75,8 @@ class productplanModel extends model */ public function getList($product = 0, $branch = 0, $browseType = 'all', $pager = null, $orderBy = 'begin_desc') { - $date = date('Y-m-d'); - $productPlans = $this->dao->select('t1.*,t2.project')->from(TABLE_PRODUCTPLAN)->alias('t1') + $date = date('Y-m-d'); + $plans = $this->dao->select('t1.*,t2.project')->from(TABLE_PRODUCTPLAN)->alias('t1') ->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')->on('t2.plan = t1.id and t2.product = ' . $product) ->where('t1.product')->eq($product) ->andWhere('t1.deleted')->eq(0) @@ -87,21 +87,49 @@ class productplanModel extends model ->page($pager) ->fetchAll('id'); - if(!empty($productPlans)) + $planIdList = array(); + $childrenPlans = array(); + foreach($plans as $plan) { - foreach($productPlans as $productPlan) + $planIdList[$plan->id] = $plan->id; + if($plan->parent > 0) { - $stories = $this->dao->select('id,estimate')->from(TABLE_STORY) - ->where("CONCAT(',', plan, ',')")->like("%,{$productPlan->id},%") - ->andWhere('deleted')->eq(0) - ->fetchPairs('id', 'estimate'); - $productPlan->stories = count($stories); - $productPlan->bugs = $this->dao->select()->from(TABLE_BUG)->where("plan")->eq($productPlan->id)->andWhere('deleted')->eq(0)->count(); - $productPlan->hour = array_sum($stories); - $productPlan->projectID = $productPlan->project; + $childrenPlans[$plan->parent][$plan->id] = $plan; + unset($plans[$plan->id]); } } - return $productPlans; + + if(!empty($childrenPlans)) + { + $processedPlans = array(); + foreach($plans as $plan) + { + $processedPlans[$plan->id] = $plan; + if(isset($childrenPlans[$plan->id])) + { + $plan->children = count($childrenPlans[$plan->id]); + foreach($childrenPlans[$plan->id] as $childrenPlan) $processedPlans[$childrenPlan->id] = $childrenPlan; + } + } + $plans = $processedPlans; + } + + if(!empty($plans)) + { + $bugs = $this->dao->select('*')->from(TABLE_BUG)->where("plan")->in($planIdList)->andWhere('deleted')->eq(0)->fetchGroup('plan', 'id'); + foreach($plans as $plan) + { + $stories = $this->dao->select('id,estimate')->from(TABLE_STORY) + ->where("CONCAT(',', plan, ',')")->like("%,{$plan->id},%") + ->andWhere('deleted')->eq(0) + ->fetchPairs('id', 'estimate'); + $plan->stories = count($stories); + $plan->bugs = isset($bugs[$plan->id]) ? count($bugs[$plan->id]) : 0; + $plan->hour = array_sum($stories); + $plan->projectID = $plan->project; + } + } + return $plans; } /** @@ -228,6 +256,7 @@ class productplanModel extends model $planID = $this->dao->lastInsertID(); $this->file->updateObjectID($this->post->uid, $planID, 'plan'); $this->loadModel('score')->create('productplan', 'create', $planID); + if($plan->parent) $this->dao->update(TABLE_PRODUCTPLAN)->set('parent')->eq('-1')->where('id')->eq($plan->parent)->andWhere('parent')->eq('0')->exec(); return $planID; } } diff --git a/module/productplan/view/browse.html.php b/module/productplan/view/browse.html.php index 006ce7b6f3..8b644412d0 100644 --- a/module/productplan/view/browse.html.php +++ b/module/productplan/view/browse.html.php @@ -63,14 +63,33 @@