* Fix the error if the object does not exist.

This commit is contained in:
dingguodong
2023-08-21 11:10:20 +08:00
parent 5e93dbec89
commit b0c67e15e3
2 changed files with 10 additions and 4 deletions
+1 -1
View File
@@ -537,7 +537,7 @@ class task extends control
}
$changes = $this->task->deleteWorkhour($effortID);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
if(dao::isError() || empty($changes)) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$actionID = $this->loadModel('action')->create('task', $taskID, 'DeleteEstimate');
$this->action->logHistory($actionID, $changes);
+9 -3
View File
@@ -1789,13 +1789,19 @@ class taskModel extends model
*
* @param int $effortID
* @access public
* @return void
* @return array|false
*/
public function deleteWorkhour(int $effortID)
{
$effort = $this->getEffortByID($effortID);
$task = $this->getById($effort->objectID);
$now = helper::now();
if(empty($effort))
{
dao::$errors[] = $this->lang->notFound;
return false;
}
$task = $this->getById($effort->objectID);
$now = helper::now();
/* Compute the left and consumed workhour of the task. */
$consumed = $task->consumed - $effort->consumed;