public static function GetTechniciansFromTaskTechnicians(\Library\User $user, $sessionTask) { $matches = array(); $sessionPm = PmHelper::GetCurrentSessionPm($user); foreach ($sessionPm[\Library\Enums\SessionKeys::PmTechnicians] as $technician) { foreach ($sessionTask[\Library\Enums\SessionKeys::TaskTechnicians] as $task_technician) { if (intval($technician->technician_id()) === intval($task_technician->technician_id())) { array_push($matches, $technician); break; } } } return $matches; }
public static function RefreshProjectObjectsForCurrentPm($caller) { $pm = PmHelper::GetCurrentSessionPm($caller->user()); $projectObj = new \Applications\PMTool\Models\Dao\Project(); $projectObj->setPm_id($pm[\Library\Enums\SessionKeys::PmObject]->pm_id()); $dal = $caller->managers()->getManagerOf("Project"); $projects = $dal->selectMany($projectObj, "pm_id"); $sessionProjects = self::GetSessionProjects($caller->user()); foreach ($projects as $project) { $key = \Library\Enums\SessionKeys::ProjectKey . $project->project_id(); if (array_key_exists($key, $sessionProjects)) { $sessionProjects[$key][\Library\Enums\SessionKeys::ProjectObject] = $project; } else { throw new \Exception(__CLASS__ . '::' . __METHOD__ . " => key not found in SessionProjects (" . $key . ")"); } } self::SetSessionProjects($caller->user(), $sessionProjects); }
public static function AddAnalyte($caller, $result, $isFieldType, $isCommon) { $manager = $caller->managers()->getManagerOf($caller->module()); $dataPost = $caller->dataPost(); if (!$isCommon) { $pm = PmHelper::GetCurrentSessionPm($caller->user()); $dataPost["pm_id"] = $pm[\Library\Enums\SessionKeys::PmObject]->pm_id(); } $origin = ""; if (array_key_exists("origin", $dataPost)) { $origin = $dataPost["origin"]; } $analytes = array(); $analyteObj = null; if ($isCommon) { $analyteObj = $isFieldType ? new \Applications\PMTool\Models\Dao\Common_field_analyte() : new \Applications\PMTool\Models\Dao\Common_lab_analyte(); } else { $analyteObj = $isFieldType ? new \Applications\PMTool\Models\Dao\Field_analyte() : new \Applications\PMTool\Models\Dao\Lab_analyte(); } if (array_key_exists("names", $dataPost)) { $analytes = !$isCommon ? self::_PrepareManyAnalyteObjects($dataPost, $isFieldType) : self::_PrepareManyCommonAnalyteObjects($dataPost, $isFieldType); } else { array_push($analytes, CommonHelper::PrepareUserObject($dataPost, $analyteObj)); } $result["dataIn"] = $analytes; $result["dataId"] = 0; $result["error"] = array("hasError" => FALSE, "code" => 0, "message" => ""); $commonSessiongKey = $isFieldType ? \Library\Enums\SessionKeys::CommonFieldAnalytes : \Library\Enums\SessionKeys::CommonLabAnalytes; $commonAnalytes = self::GetCommonAnalytes($caller->user(), $commonSessiongKey); foreach ($analytes as $analyte) { $result["dataId"] = 0; $result["dataId"] = $manager->add($analyte); if ($result["dataId"] < 0) { $result["error"]["hasError"] = TRUE; $result["error"]["code"] = $result["dataId"]; $result["error"]["message"] = "Some items couldn't be added to the database"; } elseif ($isFieldType && !$isCommon) { $analyte->setField_analyte_id($result["dataId"]); if (strcmp($origin, "task") === 0) { self::AddProjectAnalyte($caller, $analyte, $dataPost); } array_push($pm[\Library\Enums\SessionKeys::PmFieldAnalytes], $analyte); } elseif (!$isFieldType && !$isCommon) { $analyte->setLab_analyte_id($result["dataId"]); array_push($pm[\Library\Enums\SessionKeys::PmLabAnalytes], $analyte); } elseif ($isFieldType && $isCommon) { $analyte->setCommon_field_analyte_id($result["dataId"]); array_push($commonAnalytes, $analyte); } else { $commonSessiongKey = \Library\Enums\SessionKeys::CommonLabAnalytes; $analyte->setCommon_lab_analyte_id($result["dataId"]); array_push($commonAnalytes, $analyte); } } if ($isCommon) { self::SetCommonAnalytes($caller->user(), $commonSessiongKey, $commonAnalytes); } else { PmHelper::SetSessionPm($caller->user(), $pm); } return $result; }
public static function GetServicesFromTaskServices(\Library\User $user, $sessionTask) { $matches = array(); $sessionPm = PmHelper::GetCurrentSessionPm($user); foreach ($sessionTask[\Library\Enums\SessionKeys::TaskServices] as $task_service) { foreach ($sessionPm[\Library\Enums\SessionKeys::PmServices] as $service) { if (intval($service->service_id()) === intval($task_service->service_id())) { array_push($matches, $service); break; } } } return $matches; }