/** * Task copy: Lab_analyte_location * Fetches the related Lab_analyte_location for the * original task and creates the relation with the new * Task created in "copyTaskWithDependencies" */ public static function copyTaskLabAnalyteLocation($caller, $source_task_id, $target_task_id) { $lalDAO = new \Applications\PMTool\Models\Dao\Lab_analyte_location(); $lalDAO->setTask_id($source_task_id); $dal = $caller->managers()->getManagerOf("Task"); $allLals = $dal->selectMany($lalDAO, "task_id"); if (count($allLals) > 0) { //fals found, loop and remap with the new task id foreach ($allLals as $lal) { $lalDAO = null; $lalDAO = new \Applications\PMTool\Models\Dao\Lab_analyte_location(); $lalDAO->setTask_id($target_task_id); $lalDAO->setLab_analyte_id($lal->lab_analyte_id()); $lalDAO->setLocation_id($lal->location_id()); //Save $dal->add($lalDAO); } } }