From 836ce16b033802e5f1e492667efc13c252e83613 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 14 Feb 2023 13:29:36 +0800 Subject: [PATCH] * Code for finish task #84575. --- module/programplan/control.php | 2 +- module/programplan/model.php | 20 ++++++++++++++++++-- module/programplan/view/create.html.php | 17 ++++++++++++++++- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/module/programplan/control.php b/module/programplan/control.php index a4705f6ee2..bf2d7d215e 100644 --- a/module/programplan/control.php +++ b/module/programplan/control.php @@ -188,7 +188,7 @@ class programplan extends control $this->view->productID = $productID ? $productID : key($productList); $this->view->stages = empty($planID) ? $this->loadModel('stage')->getStages('id_asc') : array(); $this->view->programPlan = $programPlan; - $this->view->plans = $this->programplan->getStage($planID ? $planID : $projectID, $this->productID, 'parent'); + $this->view->plans = $this->programplan->getStage($planID ? $planID : $projectID, $this->productID, 'parent', 'order_asc'); $this->view->planID = $planID; $this->view->type = 'lists'; $this->view->PMUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst', $project->PM); diff --git a/module/programplan/model.php b/module/programplan/model.php index f46c09526e..58612680e3 100755 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -751,7 +751,6 @@ class programplanModel extends model $datas[] = $plan; } - $totalPercent = 0; $totalDevType = 0; $milestone = 0; @@ -834,6 +833,20 @@ class programplanModel extends model $this->app->loadLang('doc'); $account = $this->app->user->account; $now = helper::now(); + + if(!isset($orders)) $orders = array(); + asort($orders); + if(count($orders) < count($datas)) + { + $orderIndex = empty($orders) ? 0 : count($orders); + $lastID = $this->dao->select('id')->from(TABLE_EXECUTION)->orderBy('id_desc')->fetch('id'); + for($i = $orderIndex; $i < count($datas); $i ++) + { + $lastID ++; + $orders[$i] = $lastID * 5; + } + } + foreach($datas as $data) { /* Set planDuration and realDuration. */ @@ -845,6 +858,8 @@ class programplanModel extends model $projectChanged = false; $data->days = helper::diffDate($data->end, $data->begin) + 1; + $data->order = current($orders); + if($data->id) { $stageID = $data->id; @@ -922,7 +937,6 @@ class programplanModel extends model $stageID = $this->dao->lastInsertID(); if($data->acl != 'open') $this->user->updateUserView($stageID, 'sprint'); - $this->dao->update(TABLE_PROJECT)->set('`order`')->eq($stageID * 5)->where('id')->eq($stageID)->exec(); /* Create doc lib. */ $lib = new stdclass(); @@ -1002,6 +1016,8 @@ class programplanModel extends model if($parentID and $milestone) $this->dao->update(TABLE_PROJECT)->set('milestone')->eq(0)->where('id')->eq($parentID)->exec(); if(dao::isError()) return print(js::error(dao::getError())); + + next($orders); } } diff --git a/module/programplan/view/create.html.php b/module/programplan/view/create.html.php index d32f7cb922..e652f7e983 100644 --- a/module/programplan/view/create.html.php +++ b/module/programplan/view/create.html.php @@ -11,6 +11,7 @@ */ ?> +