/** * @deprecated */ public static function updateHoursWorked($taskId, $totalHours) { trigger_error("CTask::updateHoursWorked() has been deprecated in v3.1 and will be removed by v4.0. Please use CTask->updateHoursWorked2() instead.", E_USER_NOTICE); $task = new CTask(); $task->updateHoursWorked2($taskId, $totalHours); }
/** * Updates the variable information on the task. * * @param int $notUsed not used * @param int $task_id that task id of task this task log is for * * @return void * * @access protected */ protected function updateTaskSummary($notUsed = null, $task_id) { $task = new CTask(); $task->overrideDatabase($this->_query); $task->load($task_id); $q = $this->_getQuery(); if ($this->_perms->checkModuleItem('tasks', 'edit', $task_id)) { if ($this->task_log_percent_complete <= 100) { $q->addQuery('task_log_percent_complete, task_log_date'); $q->addTable('task_log'); $q->addWhere('task_log_task = ' . (int) $task_id); $q->addOrder('task_log_date DESC, task_log_id DESC'); $q->setLimit(1); $results = $q->loadHash(); $percentComplete = $results['task_log_percent_complete']; } else { $percentComplete = 100; } $old_end_date = new w2p_Utilities_Date($task->task_end_date); $new_end_date = new w2p_Utilities_Date($this->task_log_task_end_date); $new_end_date->setHour($old_end_date->getHour()); $new_end_date->setMinute($old_end_date->getMinute()); $task_end_date = $new_end_date->format(FMT_DATETIME_MYSQL); /* * We're using a database update here instead of store() because a * bunch of other things happen when you call store().. like the * processing of contacts, departments, etc. */ $q = $this->_getQuery(); $q->addTable('tasks'); $q->addUpdate('task_percent_complete', $percentComplete); $q->addUpdate('task_end_date', $task_end_date); $q->addWhere('task_id = ' . (int) $task_id); $success = $q->exec(); if (!$success) { $this->_AppUI->setMsg($task->getError(), UI_MSG_ERROR, true); } $task->pushDependencies($task_id, $task_end_date); } $q->addQuery('SUM(task_log_hours)'); $q->addTable('task_log'); $q->addWhere('task_log_task = ' . (int) $task_id); $totalHours = $q->loadResult(); $task->updateHoursWorked2($task_id, $totalHours); $task->updateDynamics(); }