/** * Task Copy: Main method * Copies the task corresponding to the passed task id * and based on that copies all other dependencies into * the new task thus created */ public static function copyTaskWithDependencies($caller, $source_task_id, $new_task_name, $usr) { $taskDAO = new \Applications\PMTool\Models\Dao\Task(); $taskDAO->setTask_id($source_task_id); $dal = $caller->managers()->getManagerOf("Task"); $source_task = $dal->selectMany($taskDAO, "task_id"); //Create new task out of this $taskDAO = null; $taskDAO = new \Applications\PMTool\Models\Dao\Task(); $taskDAO->setProject_id($source_task[0]->project_id()); $taskDAO->setTask_name($new_task_name); $taskDAO->setTask_deadline($source_task[0]->task_deadline()); $taskDAO->setTask_instructions($source_task[0]->task_instructions()); $taskDAO->setTask_trigger_cal($source_task[0]->task_trigger_cal()); $taskDAO->setTask_trigger_cal_value($source_task[0]->task_trigger_cal_value()); $taskDAO->setTask_trigger_pm($source_task[0]->task_trigger_pm()); $taskDAO->setTask_trigger_ext($source_task[0]->task_trigger_ext()); $taskDAO->setTask_active($source_task[0]->task_active()); $taskDAO->setTask_req_form($source_task[0]->task_req_form()); $taskDAO->setTask_req_field_analyte($source_task[0]->task_req_field_analyte()); $taskDAO->setTask_req_lab_analyte($source_task[0]->task_req_lab_analyte()); $taskDAO->setTask_req_service($source_task[0]->task_req_service()); $taskDAO->setTask_start_date($source_task[0]->task_start_date()); $taskDAO->setTask_activated($source_task[0]->task_activated()); $new_task_id = $dal->add($taskDAO); //Copy the relations too //FieldAnalyteLocation TaskHelper::copyTaskFieldAnalyteLocation($caller, $source_task_id, $new_task_id); //LabAnalyteLocation TaskHelper::copyTaskLabAnalyteLocation($caller, $source_task_id, $new_task_id); //TaskCocInfo TaskHelper::copyTaskTaskCocInfo($caller, $source_task_id, $new_task_id); //TaskFieldAnalyte TaskHelper::copyTaskTaskFieldAnalyte($caller, $source_task_id, $new_task_id); //TaskLabAnalyte TaskHelper::copyTaskTaskLabAnalyte($caller, $source_task_id, $new_task_id); //Task_location TaskHelper::copyTaskTaskLocation($caller, $source_task_id, $new_task_id); //Task_service TaskHelper::copyTaskTaskService($caller, $source_task_id, $new_task_id); //Task_technician TaskHelper::copyTaskTaskTechnician($caller, $source_task_id, $new_task_id); //Task_template_form TaskHelper::copyTaskTaskTemplateForm($caller, $source_task_id, $new_task_id); $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($usr); $taskDAO->setTask_id($new_task_id); array_push($sessionProject[\Library\Enums\SessionKeys::ProjectTasks], \Library\Enums\SessionKeys::TaskKey . $taskDAO->task_id()); if ($new_task_id > 0) { \Applications\PMTool\Helpers\TaskHelper::AddSessionTask($usr, $taskDAO); \Applications\PMTool\Helpers\ProjectHelper::SetUserSessionProject($usr, $sessionProject); } return $new_task_id; }