From 9cccd7ec3bbfa9d85a92130055b8cd84106ab4d0 Mon Sep 17 00:00:00 2001 From: sunjun Date: Fri, 1 Apr 2022 15:10:54 +0800 Subject: [PATCH 1/3] *Fixbug #20719 --- module/project/model.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/module/project/model.php b/module/project/model.php index eecff42064..00e9e383ca 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -2169,6 +2169,14 @@ class projectModel extends model ->andWhere('deleted')->eq(0) ->fetchGroup('execution', 'id'); + $parentStage = array(); + foreach($executions as $executionID => $execution) + { + if($execution->grade != 2) continue; + if(!isset($parentStage[$execution->parent])) $parentStage[$execution->parent] = array(); + $parentStage[$execution->parent][$executionID] = $executionID; + } + /* Compute totalEstimate, totalConsumed, totalLeft. */ foreach($tasks as $executionID => $executionTasks) { @@ -2182,6 +2190,21 @@ class projectModel extends model $hours[$executionID] = $hour; } + foreach($parentStage as $executionID => $subExecutionID) + { + $hours[$executionID] = (object)$emptyHour; + foreach($subExecutionID as $subExe) + { + if(isset($hours[$subExe])) + { + $hours[$executionID]->totalEstimate += $hours[$subExe]->totalEstimate; + $hours[$executionID]->totalConsumed += $hours[$subExe]->totalConsumed; + $hours[$executionID]->totalLeft += $hours[$subExe]->totalLeft; + $hours[$executionID]->progress += $hours[$subExe]->progress; + } + } + } + /* Compute totalReal and progress. */ foreach($hours as $hour) { @@ -2191,7 +2214,6 @@ class projectModel extends model $hour->totalReal = $hour->totalConsumed + $hour->totalLeft; $hour->progress = $hour->totalReal ? round($hour->totalConsumed / $hour->totalReal * 100, 2) : 0; } - return $hours; } From 979fb8b587708f0b1a5577f89873c08b5323c1a9 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Sat, 2 Apr 2022 09:54:43 +0800 Subject: [PATCH 2/3] * Fix bug#20719. --- module/project/model.php | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/module/project/model.php b/module/project/model.php index 00e9e383ca..ad39c8ebcc 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -2169,14 +2169,6 @@ class projectModel extends model ->andWhere('deleted')->eq(0) ->fetchGroup('execution', 'id'); - $parentStage = array(); - foreach($executions as $executionID => $execution) - { - if($execution->grade != 2) continue; - if(!isset($parentStage[$execution->parent])) $parentStage[$execution->parent] = array(); - $parentStage[$execution->parent][$executionID] = $executionID; - } - /* Compute totalEstimate, totalConsumed, totalLeft. */ foreach($tasks as $executionID => $executionTasks) { @@ -2188,20 +2180,19 @@ class projectModel extends model if($task->status != 'cancel' and $task->status != 'closed') $hour->totalLeft += $task->left; } $hours[$executionID] = $hour; - } - foreach($parentStage as $executionID => $subExecutionID) - { - $hours[$executionID] = (object)$emptyHour; - foreach($subExecutionID as $subExe) + if($executions[$executionID]->type == 'stage' and $executions[$executionID]->grade == 2) { - if(isset($hours[$subExe])) + $stageParent = $executions[$executionID]->parent; + if(!isset($hours[$stageParent])) { - $hours[$executionID]->totalEstimate += $hours[$subExe]->totalEstimate; - $hours[$executionID]->totalConsumed += $hours[$subExe]->totalConsumed; - $hours[$executionID]->totalLeft += $hours[$subExe]->totalLeft; - $hours[$executionID]->progress += $hours[$subExe]->progress; + $hours[$stageParent] = clone $hour; + continue; } + + $hours[$stageParent]->totalEstimate += $hour->totalEstimate; + $hours[$stageParent]->totalConsumed += $hour->totalConsumed; + $hours[$stageParent]->totalLeft += $hour->totalLeft; } } From cdd7396261858cd83ccb955441e206278b1a6c94 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Sat, 2 Apr 2022 09:56:31 +0800 Subject: [PATCH 3/3] * Add space line. --- module/project/model.php | 1 + 1 file changed, 1 insertion(+) diff --git a/module/project/model.php b/module/project/model.php index ad39c8ebcc..b510fb91e4 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -2205,6 +2205,7 @@ class projectModel extends model $hour->totalReal = $hour->totalConsumed + $hour->totalLeft; $hour->progress = $hour->totalReal ? round($hour->totalConsumed / $hour->totalReal * 100, 2) : 0; } + return $hours; }