From 9dac5358e393208b8842ce3a1a23f62edce7cde3 Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Fri, 26 Nov 2021 15:20:17 +0800 Subject: [PATCH] *Finish task #45148. --- module/execution/lang/en.php | 4 ++++ module/execution/lang/zh-cn.php | 5 +++++ module/execution/model.php | 31 ++++++++++++++++++++++++++-- module/execution/view/close.html.php | 2 +- module/execution/view/start.html.php | 2 +- module/project/lang/en.php | 3 +++ module/project/lang/zh-cn.php | 3 +++ module/project/model.php | 13 ++++++++++++ module/project/view/close.html.php | 2 +- 9 files changed, 60 insertions(+), 5 deletions(-) diff --git a/module/execution/lang/en.php b/module/execution/lang/en.php index 5ff823d2c8..357248ea13 100644 --- a/module/execution/lang/en.php +++ b/module/execution/lang/en.php @@ -351,6 +351,10 @@ $lang->execution->unfinishedExecution = "This {$lang->executionCommon} h $lang->execution->unfinishedTask = "[%s] unfinished tasks. "; $lang->execution->unresolvedBug = "[%s] unresolved bugs. "; $lang->execution->projectNotEmpty = 'Project cannot be empty.'; +$lang->execution->realBeganNotEmpty = 'Real Began should not be empty.'; +$lang->execution->realBeganNotFuture = 'Real Began should not be a feture date.'; +$lang->execution->realEndNotEmpty = 'Real End should not be empty.'; +$lang->execution->realEndNotFuture = 'Real End should not be a feture date.'; /* Statistics. */ $lang->execution->charts = new stdclass(); diff --git a/module/execution/lang/zh-cn.php b/module/execution/lang/zh-cn.php index 6213a08bf4..99132abcdb 100644 --- a/module/execution/lang/zh-cn.php +++ b/module/execution/lang/zh-cn.php @@ -351,6 +351,11 @@ $lang->execution->unfinishedExecution = "该{$lang->executionCommon}下 $lang->execution->unfinishedTask = "[%s]个未完成的任务,"; $lang->execution->unresolvedBug = "[%s]个未解决的bug,"; $lang->execution->projectNotEmpty = '所属项目不能为空。'; +$lang->execution->realBeganNotEmpty = "实际开始不能为空。"; +$lang->execution->realBeganNotFuture = "实际开始不能为未来日期。"; +$lang->execution->realEndNotEmpty = "实际完成不能为空。"; +$lang->execution->realEndNotFuture = "实际完成不能为未来日期。"; + /* 统计。*/ $lang->execution->charts = new stdclass(); diff --git a/module/execution/model.php b/module/execution/model.php index 9bd30cb925..f58916ea63 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -706,8 +706,23 @@ class executionModel extends model ->remove('comment')->get(); $this->dao->update(TABLE_EXECUTION)->data($execution)->autoCheck()->where('id')->eq((int)$executionID)->exec(); + + if(!dao::isError()) + { + if($execution->realBegan == '') + { + dao::$errors['realBegan'] = $this->lang->execution->realBeganNotEmpty; + return false; + } - if(!dao::isError()) return common::createChanges($oldExecution, $execution); + if($execution->realBegan > $now) + { + dao::$errors['realBegan'] = $this->lang->execution->realBeganNotFuture; + return false; + } + + return common::createChanges($oldExecution, $execution); + } } /** @@ -778,6 +793,7 @@ class executionModel extends model $now = helper::now(); $execution = fixer::input('post') + ->setDefault('realEnd','') ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) @@ -847,7 +863,6 @@ class executionModel extends model $execution = fixer::input('post') ->setDefault('status', 'closed') - ->setDefault('realEnd', helper::today()) ->setDefault('closedBy', $this->app->user->account) ->setDefault('closedDate', $now) ->setDefault('lastEditedBy', $this->app->user->account) @@ -861,6 +876,18 @@ class executionModel extends model ->exec(); if(!dao::isError()) { + if($execution->realEnd == '') + { + dao::$errors['realEnd'] = $this->lang->execution->realEndNotEmpty; + return false; + } + + if($execution->realEnd > $now) + { + dao::$errors['realEnd'] = $this->lang->execution->realEndNotFuture; + return false; + } + $this->loadModel('score')->create('execution', 'close', $oldExecution); return common::createChanges($oldExecution, $execution); } diff --git a/module/execution/view/close.html.php b/module/execution/view/close.html.php index e2933e2dfa..11ebcd1ed4 100644 --- a/module/execution/view/close.html.php +++ b/module/execution/view/close.html.php @@ -34,7 +34,7 @@ execution->realEnd;?>
- realEnd) && $execution->realEnd != '0000-00-00' ? $execution->realEnd : date('Y-m-d')), "class='form-control form-date'");?> + realEnd) && $execution->realEnd != '0000-00-00' ? $execution->realEnd : date('Y-m-d')), "class='form-control form-date' required");?>
diff --git a/module/execution/view/start.html.php b/module/execution/view/start.html.php index 7b96b36706..6f9e74185c 100644 --- a/module/execution/view/start.html.php +++ b/module/execution/view/start.html.php @@ -30,7 +30,7 @@ execution->realBegan;?>
- realBegan) && $execution->realBegan != '0000-00-00' ? $execution->realBegan : date('Y-m-d')), "class='form-control form-date'");?> + realBegan) && $execution->realBegan != '0000-00-00' ? $execution->realBegan : date('Y-m-d')), "class='form-control form-date' required");?>
diff --git a/module/project/lang/en.php b/module/project/lang/en.php index 26995676bb..6c2b0f6b3d 100644 --- a/module/project/lang/en.php +++ b/module/project/lang/en.php @@ -177,6 +177,9 @@ $lang->project->createExecution = "There is no {$lang->executionCommon} u $lang->project->unlinkExecutionMember = "The user participated in %s executions such as %s%s. Do you want to remove the user from those executions as well? (The data related to this user will not be deleted.)"; $lang->project->unlinkExecutionMembers = "The team members you are removing are also in the execution team of this project. Do you want to remove them from the execution team too?"; +$lang->project->realEndNotEmpty = 'Real End should not be empty.'; +$lang->project->realEndNotFuture = 'Real End should not be a feture date.'; + $lang->project->tenThousand = ''; $lang->project->unitList['CNY'] = 'RMB'; diff --git a/module/project/lang/zh-cn.php b/module/project/lang/zh-cn.php index 540943168e..c3982efcae 100644 --- a/module/project/lang/zh-cn.php +++ b/module/project/lang/zh-cn.php @@ -177,6 +177,9 @@ $lang->project->createExecution = "该项目下没有{$lang->executionCom $lang->project->unlinkExecutionMember = "该用户参与了%s%s%s个{$lang->execution->common},是否同时将其移除?(该用户所产生的数据不会受影响。)"; $lang->project->unlinkExecutionMembers = "移除的团队成员还参与了项目下的执行,是否同步从执行团队中移除?"; +$lang->project->realEndNotEmpty = "实际完成不能为空。"; +$lang->project->realEndNotFuture = "实际完成不能为未来日期。"; + $lang->project->tenThousand = '万'; $lang->project->unitList['CNY'] = '人民币'; diff --git a/module/project/model.php b/module/project/model.php index 0270fd325b..1f4e3cb979 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1206,6 +1206,7 @@ class projectModel extends model $now = helper::now(); $project = fixer::input('post') + ->setDefault('realEnd','') ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) @@ -1288,6 +1289,18 @@ class projectModel extends model ->exec(); if(!dao::isError()) { + if($project->realEnd == '') + { + dao::$errors['realEnd'] = $this->lang->project->realEndNotEmpty; + return false; + } + + if($project->realEnd > $now) + { + dao::$errors['realEnd'] = $this->lang->project->realEndNotFuture; + return false; + } + $this->loadModel('score')->create('project', 'close', $oldProject); return common::createChanges($oldProject, $project); } diff --git a/module/project/view/close.html.php b/module/project/view/close.html.php index 4f0060bbd3..0fd52dabdd 100644 --- a/module/project/view/close.html.php +++ b/module/project/view/close.html.php @@ -34,7 +34,7 @@ project->realEnd;?>
- realEnd) && $project->realEnd != '0000-00-00' ? $project->realEnd : date('Y-m-d')), "class='form-control form-date'");?> + realEnd) && $project->realEnd != '0000-00-00' ? $project->realEnd : date('Y-m-d')), "class='form-control form-date' required");?>