* Fix the error if the object does not exist.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user