/** * 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; }
public static function GetAndStoreTaskLocations($caller, $sessionTask) { $sessionTasks = $caller->user()->getAttribute(\Library\Enums\SessionKeys::SessionTasks); $taskLocation = new \Applications\PMTool\Models\Dao\Task_location(); $taskLocation->setTask_id($sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id()); // if (!(count($sessionTask[\Library\Enums\SessionKeys::TaskLocations]) > 0)) { $dal = $caller->managers()->getManagerOf("TaskLocation"); $sessionTask[\Library\Enums\SessionKeys::TaskLocations] = $dal->selectMany($taskLocation, "task_id"); // } TaskHelper::SetSessionTask($caller->user(), $sessionTask); TaskHelper::SetCurrentSessionTask($caller->user(), $sessionTask); return self::GetLocationsFromTaskLocations($caller->user(), $sessionTask); }
/** * Test statistics chart * * @param array $statistics * @param string $result * @param array $settings * @dataProvider statisticsChartProvider */ public function testStatisticsChart(array $statistics, $result, array $settings) { $this->skipUnless(CakePlugin::loaded('GoogleChart'), 'Please install imsamurai/cakephp-google-chart for this test'); $View = new View(); $Helper = new TaskHelper($View, $settings); $this->assertStringMatchesFormat($result, $Helper->statistics($statistics) . $View->fetch('script')); }