コード例 #1
0
 /**
  * Returns the task specific documents from the 
  * Document table for this task
  */
 public static function GetDocumentsForActiveTask($activeTask, $caller)
 {
     //First thing, let's get the task location id's for this active task
     $taskLocationDAO = new \Applications\PMTool\Models\Dao\Task_location();
     $taskLocationDAO->setTask_id($activeTask[\Library\Enums\SessionKeys::TaskObj]->task_id());
     $dal = $caller->managers()->getManagerOf("Task");
     $location_data = $dal->selectMany($taskLocationDAO, "task_id");
     //Fetch all documents
     //Ideally we need a method in BaseManager which would let us
     //query a db field with "LIKE operator" or selectMany should
     //be modified to do the same
     $documentDAO = new \Applications\PMTool\Models\Dao\Document();
     $dal = $caller->managers()->getManagerOf("Document");
     $documents = $dal->selectManyByCategoryAndId("task_location");
     $docData = array();
     //Return empty array if there are no documents found
     if (count($documents) === 0) {
         return $docData;
     }
     //Otherwise loop on the location data
     foreach ($location_data as $location) {
         foreach ($documents as $doc) {
             if (strpos($doc->document_value(), $location->task_location_id() . '_') === 0) {
                 array_push($docData, $doc);
             }
         }
     }
     //Return the doc array
     return $docData;
 }
コード例 #2
0
 public static function UpdateTaskLocations($caller)
 {
     $result = $caller->InitResponseWS();
     // Init result
     $dataPost = $caller->dataPost();
     $result["rows_affected"] = 0;
     $result["location_ids"] = str_getcsv($dataPost["location_ids"], ',');
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($caller->user());
     $task_locations = array();
     foreach ($result["location_ids"] as $id) {
         $task_location = new \Applications\PMTool\Models\Dao\Task_location();
         $task_location->setLocation_id($id);
         $task_location->setTask_id($sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id());
         $task_location->setTask_location_status(0);
         $dal = $caller->managers()->getManagerOf($caller->module());
         if ($dataPost["action"] === "add") {
             $result["rows_affected"] += $dal->add($task_location) >= 0 ? 1 : 0;
             //At the same time create the relationship in "field_analyte_location"
             \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::CreateFALocationRelationForFT($caller, $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id(), $id);
         } else {
             $result["rows_affected"] += $dal->delete($task_location, "location_id") ? 1 : 0;
         }
         array_push($task_locations, $task_location);
     }
     $sessionTask[\Library\Enums\SessionKeys::TaskLocations] = $task_locations;
     \Applications\PMTool\Helpers\TaskHelper::SetSessionTask($caller->user(), $sessionTask);
     return $result;
 }
コード例 #3
0
 /**
  * Task copy: Task_location
  * Fetches the related Task_location for the
  * original task and creates the relation with the new
  * Task created in "copyTaskWithDependencies"
  */
 public static function copyTaskTaskLocation($caller, $source_task_id, $target_task_id)
 {
     $tlDAO = new \Applications\PMTool\Models\Dao\Task_location();
     $tlDAO->setTask_id($source_task_id);
     $dal = $caller->managers()->getManagerOf("Task");
     $allTls = $dal->selectMany($tlDAO, "task_id");
     if (count($allTls) > 0) {
         //fals found, loop and remap with the new task id
         foreach ($allTls as $tl) {
             $tlDAO = null;
             $tlDAO = new \Applications\PMTool\Models\Dao\Task_location();
             $tlDAO->setTask_id($target_task_id);
             $tlDAO->setLocation_id($tl->location_id());
             $tlDAO->setTask_location_status($tl->task_location_status());
             //Save
             $id = $dal->add($tlDAO);
         }
     }
 }
コード例 #4
0
 /**
  * Creates a new relation in the "field_analyte_location" table based on 
  * the passed task_id, fa_id. so more or les same as the above method, only
  * iterates over location instead of FAs
  */
 public static function CreateLocationFARelationForFT($caller, $task_id, $fa_id)
 {
     //Get the location data for the task id
     $tlDAO = new \Applications\PMTool\Models\Dao\Task_location();
     $tlDAO->setTask_id($task_id);
     $dal = $caller->managers()->getManagerOf("TaskLocation");
     $relation_data = $dal->selectMany($tlDAO, "task_id");
     //Loop on the above and start preparing data for "field_analyte_location"
     if (count($relation_data) > 0) {
         $manager = $caller->managers()->getManagerOf('FieldAnalyteLocation');
         foreach ($relation_data as $loc_rec) {
             //Check if the relationship is not already existing
             if (!$manager->ifMatrixDataExistsFor($task_id, $loc_rec->location_id(), $fa_id)) {
                 //Add to the "field_analyte_location" table
                 $data = array('task_id' => $task_id, 'location_id' => $loc_rec->location_id(), 'field_analyte_id' => $fa_id, 'field_analyte_location_result' => '');
                 //Init PDO
                 $field_analyte_location = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($data, new \Applications\PMTool\Models\Dao\Field_analyte_location());
                 $result_save_relation = $manager->add($field_analyte_location);
             }
         }
     }
 }