From c0f84b7f290a8c87399402d621ddee7eba9d1749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E8=BE=B0=E8=BD=A9?= Date: Fri, 23 Dec 2022 10:49:21 +0800 Subject: [PATCH] * Modify burn chart . --- module/execution/control.php | 4 +++- module/execution/model.php | 16 +++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 6c75eb573b..ecbd08396b 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1413,7 +1413,9 @@ class execution extends control $deadline = strpos('closed,suspended', $execution->status) === false ? helper::today() : $deadline; $endDate = strpos($type, 'withdelay') !== false ? $deadline : $execution->end; list($dateList, $interval) = $this->execution->getDateList($execution->begin, $endDate, $type, $interval, 'Y-m-d', $execution->end); - $chartData = $this->execution->buildBurnData($executionID, $dateList, $type, $burnBy); + + $executionEnd = strpos($type, 'withdelay') !== false ? $execution->end : ''; + $chartData = $this->execution->buildBurnData($executionID, $dateList, $type, $burnBy, $executionEnd); $dayList = array_fill(1, floor((int)$execution->days / $this->config->execution->maxBurnDay) + 5, ''); foreach($dayList as $key => $val) $dayList[$key] = $this->lang->execution->interval . ($key + 1) . $this->lang->day; diff --git a/module/execution/model.php b/module/execution/model.php index 03e57902cd..8b261dbe19 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -3170,12 +3170,12 @@ class executionModel extends model { dao::$errors['message'][] = sprintf($this->lang->execution->daysGreaterProject, $execution->days); return false; - } + } if((float)$hours[$key] > 24) { dao::$errors['message'][] = $this->lang->execution->errorHours; return false; - } + } } $this->dao->delete()->from(TABLE_TEAM)->where('root')->eq($executionID)->andWhere('type')->eq($executionType)->exec(); @@ -4354,10 +4354,11 @@ class executionModel extends model * @param array $dateList * @param string $type * @param string $burnBy + * @param string $executionEnd * @access public * @return array */ - public function buildBurnData($executionID, $dateList, $type, $burnBy = 'left') + public function buildBurnData($executionID, $dateList, $type, $burnBy = 'left', $executionEnd = '') { $this->loadModel('report'); $burnBy = $burnBy ? $burnBy : 'left'; @@ -4369,10 +4370,15 @@ class executionModel extends model $firstBurn = empty($sets) ? 0 : reset($sets); $firstTime = !empty($firstBurn->$burnBy) ? $firstBurn->$burnBy : (!empty($firstBurn->value) ? $firstBurn->value : 0); $firstTime = $firstTime == 'null' ? 0 : $firstTime; - $days = count($dateList) - 1; + /* If the $executionEnd is passed, the guide should end of execution. */ + $days = $executionEnd ? array_search($executionEnd, $dateList) : count($dateList) - 1; $rate = $days ? $firstTime / $days : ''; $baselineJSON = '['; - foreach($dateList as $i => $date) $baselineJSON .= round(($days - $i) * (float)$rate, 3) . ','; + foreach($dateList as $i => $date) + { + $value = ($i > $days ? 0 : round(($days - $i) * (float)$rate, 3)) . ','; + $baselineJSON .= $value; + } $baselineJSON = rtrim($baselineJSON, ',') . ']'; $chartData['labels'] = $this->report->convertFormat($dateList, DT_DATE5);