*Finish task #45150.

This commit is contained in:
zhengrunyu
2021-12-01 10:14:15 +08:00
parent a4426db6f0
commit 3e4fa30030
8 changed files with 42 additions and 57 deletions
+18 -30
View File
@@ -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();