public function _setDoneTime() { try { $this->task->get(); } catch (Task_Not_Found $e) { return; } $items = new Item(); $items->where("start >=", $this->start); $items->where("end <=", $this->end); $items->where("state", ITEM_STATE_DONE); $items->get_by_related($this->task); $this->doneTime = 0; /*** @var Item $item */ foreach ($items as $item) { $this->doneTime += $item->getLength(); } $this->checkForAchieveOrNot(); }