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