public static function PrepareTechnicianObject($dataPost, $oldObject = null) { if (!is_null($oldObject)) { $technician = $oldObject; } else { $technician = new \Applications\PMTool\Models\Dao\Technician(); } $technician->setTechnician_id($dataPost["technician_id"]); $technician->setTechnician_name($dataPost["technician_name"]); $technician->setTechnician_phone(!array_key_exists('technician_phone', $dataPost) ? "" : $dataPost["technician_phone"]); $technician->setTechnician_active(!array_key_exists('technician_active', $dataPost) ? "" : $dataPost["technician_active"]); return $technician; }
public function executeGetItem(\Library\HttpRequest $rq) { $result = $this->InitResponseWS(); $userId = $this->dataPost["user_id"]; $users = \Applications\PMTool\Helpers\UserHelper::GetAndStoreUsersInSession($this); $user = $result['user'] = \Applications\PMTool\Helpers\CommonHelper::FindObjectByIntValue(intval($userId), 'user_id', $users); if ($user instanceof \Applications\PMTool\Models\Dao\User) { if ($user->user_type() == "pm_id") { $pm = new \Applications\PMTool\Models\Dao\Project_manager(); $pm->setPm_id($user->user_value()); $manager = $this->managers->getManagerOf('Pm'); $pms = $manager->selectMany($pm, 'pm_id'); $pm = $pms[0]; $result['pm'] = $pm; } else { if ($user->user_type() == "technician_id") { $technician = new \Applications\PMTool\Models\Dao\Technician(); $technician->setTechnician_id($user->user_value()); $manager = $this->managers->getManagerOf('Technician'); $technicians = $manager->selectMany($technician, 'technician_id'); $technician = $technicians[0]; $result['technician'] = $technician; } } } else { $result['user'] = array(); } $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::User, "resx_key" => $this->action(), "step" => count($result['user']) ? "success" : "error")); }