Move getError from controller to model.

This commit is contained in:
zhouxin
2022-03-17 07:50:54 +00:00
parent b705f22460
commit 78263786ed
2 changed files with 18 additions and 5 deletions
+2
View File
@@ -1656,6 +1656,8 @@ class execution extends control
if($this->post->names)
{
$allChanges = $this->execution->batchUpdate();
if(dao::isError()) return print(js::error(dao::getError()));
if(!empty($allChanges))
{
foreach($allChanges as $executionID => $changes)
+16 -5
View File
@@ -633,11 +633,16 @@ class executionModel extends model
if($projectModel == 'scrum' and empty($executionCode))
{
dao::$errors['code'][] = 'execution#' . $executionID . sprintf($this->lang->error->notempty, $this->lang->project->code);
return false;
}
elseif(!empty($executionCode))
{
/* Check unique code for edited executions. */
if(isset($codeList[$executionCode])) dao::$errors['code'][] = 'execution#' . $executionID . sprintf($this->lang->error->unique, $this->lang->project->code, $executionCode);
if(isset($codeList[$executionCode]))
{
dao::$errors['code'][] = 'execution#' . $executionID . sprintf($this->lang->error->unique, $this->lang->project->code, $executionCode);
return false;
}
$codeList[$executionCode] = $executionCode;
}
@@ -651,7 +656,6 @@ class executionModel extends model
if($message) return print(js::alert($message));
}
}
if(dao::isError()) return print(js::error(dao::getError()));
foreach($executions as $executionID => $execution)
{
@@ -660,9 +664,16 @@ class executionModel extends model
$projectID = isset($execution->project) ? $execution->project : $oldExecution->project;
$project = $this->project->getByID($projectID);
if($execution->begin < $project->begin) dao::$errors['begin'] = sprintf($this->lang->execution->errorLetterProject, $project->begin);
if($execution->end > $project->end) dao::$errors['end'] = sprintf($this->lang->execution->errorGreaterProject, $project->end);
if(dao::isError()) return print(js::error(dao::getError()));
if($execution->begin < $project->begin)
{
dao::$errors['begin'] = sprintf($this->lang->execution->errorLetterProject, $project->begin);
return false;
}
if($execution->end > $project->end)
{
dao::$errors['end'] = sprintf($this->lang->execution->errorGreaterProject, $project->end);
return false;
}
$this->dao->update(TABLE_EXECUTION)->data($execution)
->autoCheck($skipFields = 'begin,end')