diff --git a/module/execution/config.php b/module/execution/config.php index 0410b19d98..0d83ad91fe 100644 --- a/module/execution/config.php +++ b/module/execution/config.php @@ -17,8 +17,12 @@ $app->loadLang('task'); $config->execution->task = new stdclass(); $config->execution->create = new stdclass(); $config->execution->edit = new stdclass(); -$config->execution->create->requiredFields = 'name,code,begin,end'; -$config->execution->edit->requiredFields = 'name,code,begin,end'; +$config->execution->start = new stdclass(); +$config->execution->close = new stdclass(); +$config->execution->create->requiredFields = 'name,code,begin,end'; +$config->execution->edit->requiredFields = 'name,code,begin,end'; +$config->execution->start->requiredFields = 'realBegan'; +$config->execution->close->requiredFields = 'realEnd'; $config->execution->customBatchEditFields = 'days,type,teamname,status,desc,PO,QD,PM,RD'; diff --git a/module/execution/control.php b/module/execution/control.php index 35340f8ba9..b6d4b86007 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -3442,7 +3442,7 @@ class execution extends control public function ajaxUpdateKanban($executionID = 0, $enterTime = '', $browseType = '', $groupBy = '') { $enterTime = date('Y-m-d H:i:s', $enterTime); - $lastEditedTime = $this->dao->select("max(lastEditedTime) as lastEditedTime")->from(TABLE_KANBANLANE)->where('execution')->eq($executionID)->fetch('lastEditedTime'); + $lastEditedTime = $this->dao->select("max(lastEditedTime) as lastEditedTime")->from(TABLE_KANBANLANE)->where('execution')->eq($executionID)->fetch(); if($lastEditedTime > $enterTime) { diff --git a/module/execution/lang/en.php b/module/execution/lang/en.php index e0ee3196dd..73c5a6ce9d 100644 --- a/module/execution/lang/en.php +++ b/module/execution/lang/en.php @@ -355,10 +355,6 @@ $lang->execution->unfinishedTask = "[%s] unfinished tasks. "; $lang->execution->unresolvedBug = "[%s] unresolved bugs. "; $lang->execution->projectNotEmpty = 'Project cannot be empty.'; $lang->execution->confirmStoryToTask = $lang->SRCommon . '%s are converted to tasks in the current. Do you want to convert them anyways?'; -$lang->execution->realBeganNotEmpty = 'Actual Begin should not be empty.'; -$lang->execution->realBeganNotFuture = 'Actual Begin should be < = today.'; -$lang->execution->realEndNotEmpty = 'Actual End should not be empty.'; -$lang->execution->realEndNotFuture = 'Actual End should be < = today.'; /* Statistics. */ $lang->execution->charts = new stdclass(); diff --git a/module/execution/lang/zh-cn.php b/module/execution/lang/zh-cn.php index ff3f9d29b5..880679eb6d 100644 --- a/module/execution/lang/zh-cn.php +++ b/module/execution/lang/zh-cn.php @@ -356,10 +356,6 @@ $lang->execution->unfinishedTask = "[%s]个未完成的任务,"; $lang->execution->unresolvedBug = "[%s]个未解决的bug,"; $lang->execution->projectNotEmpty = '所属项目不能为空。'; $lang->execution->confirmStoryToTask = '%s' . $lang->SRCommon . '已经在当前' . $lang->execution->common . '中转了任务,请确认是否重复转任务。'; -$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 bdbdca88a0..abdac4d7ff 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -708,27 +708,23 @@ class executionModel extends model */ public function start($executionID) { - $oldExecution = $this->getById($executionID); - $now = helper::now(); + $oldExecution = $this->getById($executionID); + $now = helper::now(); + $requiredFields = $this->config->execution->start->requiredFields; $execution = fixer::input('post') ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) - ->remove('comment')->get(); + ->remove('comment') + ->get(); - if($execution->realBegan == '') - { - dao::$errors['realBegan'] = $this->lang->execution->realBeganNotEmpty; - return false; - } - if($execution->realBegan > helper::today()) - { - dao::$errors['realBegan'] = $this->lang->execution->realBeganNotFuture; - return false; - } - - $this->dao->update(TABLE_EXECUTION)->data($execution)->autoCheck()->where('id')->eq((int)$executionID)->exec(); + $this->dao->update(TABLE_EXECUTION)->data($execution) + ->autoCheck() + ->check($requiredFields, 'notempty') + ->checkIF($execution->realBegan != '', 'realBegan', 'le', helper::today()) + ->where('id')->eq((int)$executionID) + ->exec(); if(!dao::isError()) return common::createChanges($oldExecution, $execution); } @@ -866,9 +862,10 @@ class executionModel extends model */ public function close($executionID) { - $oldExecution = $this->getById($executionID); - $now = helper::now(); - + $oldExecution = $this->getById($executionID); + $now = helper::now(); + $requiredFields = $this->config->execution->close->requiredFields; + $execution = fixer::input('post') ->setDefault('status', 'closed') ->setDefault('closedBy', $this->app->user->account) @@ -878,20 +875,11 @@ class executionModel extends model ->remove('comment') ->get(); - if($execution->realEnd == '') - { - dao::$errors['realEnd'] = $this->lang->execution->realEndNotEmpty; - return false; - } - - if($execution->realEnd > helper::today()) - { - dao::$errors['realEnd'] = $this->lang->execution->realEndNotFuture; - return false; - } - $this->dao->update(TABLE_EXECUTION)->data($execution) ->autoCheck() + ->check($requiredFields,'notempty') + ->checkIF($execution->realEnd != '', 'realEnd', 'le', helper::today()) + ->checkIF($execution->realEnd != '', 'realEnd', 'ge', $oldExecution->realBegan) ->where('id')->eq((int)$executionID) ->exec(); diff --git a/module/project/config.php b/module/project/config.php index 0559cdf897..533677538d 100644 --- a/module/project/config.php +++ b/module/project/config.php @@ -18,6 +18,12 @@ $config->project->edit = new stdclass(); $config->project->create->requiredFields = 'name,code,begin,end'; $config->project->edit->requiredFields = 'name,code,begin,end'; +$config->project->start = new stdclass(); +$config->project->start->requiredFields = 'realBegan'; + +$config->project->close = new stdclass(); +$config->project->close->requiredFields = 'realEnd'; + $config->project->sortFields = new stdclass(); $config->project->sortFields->id = 'id'; $config->project->sortFields->begin = 'begin'; diff --git a/module/project/lang/zh-cn.php b/module/project/lang/zh-cn.php index 4f4e07f18b..eed3169c52 100644 --- a/module/project/lang/zh-cn.php +++ b/module/project/lang/zh-cn.php @@ -180,9 +180,6 @@ $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 4b49d23069..c89a7ade68 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1172,15 +1172,20 @@ class projectModel extends model { $oldProject = $this->getById($projectID, $type); $now = helper::now(); + $requiredFields = $this->config->project->start->requiredFields; $project = fixer::input('post') - ->add('realBegan', helper::today()) ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->remove('comment')->get(); - $this->dao->update(TABLE_PROJECT)->data($project)->autoCheck()->where('id')->eq((int)$projectID)->exec(); + $this->dao->update(TABLE_PROJECT)->data($project) + ->autoCheck() + ->check($requiredFields, 'notempty') + ->checkIF($project->realBegan != '', 'realBegan', 'le', helper::today()) + ->where('id')->eq((int)$projectID) + ->exec(); if(!dao::isError()) return common::createChanges($oldProject, $project); } @@ -1316,6 +1321,7 @@ class projectModel extends model { $oldProject = $this->getById($projectID); $now = helper::now(); + $requiredFields = $this->config->project->close->requiredFields; $project = fixer::input('post') ->setDefault('status', 'closed') @@ -1326,19 +1332,11 @@ class projectModel extends model ->remove('comment') ->get(); - if($project->realEnd == '') - { - dao::$errors['realEnd'] = $this->lang->project->realEndNotEmpty; - return false; - } - if($project->realEnd > helper::today()) - { - dao::$errors['realEnd'] = $this->lang->project->realEndNotFuture; - return false; - } - $this->dao->update(TABLE_PROJECT)->data($project) ->autoCheck() + ->check($requiredFields, 'notempty') + ->checkIF($project->realEnd != '', 'realEnd', 'le', helper::today()) + ->checkIF($project->realEnd != '', 'realEnd', 'ge', $oldProject->realBegan) ->where('id')->eq((int)$projectID) ->exec();