コード例 #1
0
 public function executeViewSessionArrays(\Library\HttpRequest $rq)
 {
     $output = array();
     switch ($rq->getData("type")) {
         case "pm":
             $output = var_dump(\Applications\PMTool\Helpers\PmHelper::GetSessionPms($this->user()));
             break;
         case "project":
             $output = var_dump(\Applications\PMTool\Helpers\ProjectHelper::GetSessionProjects($this->user()));
             break;
         case "task":
             $output = var_dump(\Applications\PMTool\Helpers\TaskHelper::GetSessionTasks($this->user()));
             break;
         case "route":
             $output = var_dump($this->user->getAttribute(\Library\Enums\SessionKeys::SessionRoutes));
             break;
         default:
             break;
     }
     echo '<pre>', print_r($output), '</pre>';
     //\Library\HttpResponse::encodeJson($output);
     die;
 }
コード例 #2
0
 /**
  * <p> Retrieve the markers to display on Google Maps and the center position
  * if no items are returned for All Projects</p>
  * <p> This method is called via an AJAX request from the client side. </p>
  * <p> The method receive by inheritance some post data
  * properties JSON object which includes objectTypes as "keys" and nested associative propNames
  * example:
  * "properties": {
  *  "facility_obj": {
  *   "objectLatPropName": "facility_lat",
  *   "objectLngPropName": "facility_long"
  *   },
  *   "project_obj": {
  *   "objectActivePropName": "project_active"
  *   }
  * Since we must use "project_active" property to determine marker icon we must use multiple mapped objects there and we can't send only facility property info
  * For more info:
  * \Applications\PMTool\Helpers\MapHelper::CreateFacilityMarkerItems
  * @link
  * </p>
  * <p>
  * @param object $rq <p>
  * The current HttpRequest.
  * </p>
  * @return mixed $result <p>
  * The result is a standard JSON response containing
  * the specific data to the request, e.g.:
  *  - the list markers for a given filter
  *  - the default position used to center the map (this configured in the appsettings.xml)
  */
 public function executeListAll(\Library\HttpRequest $rq)
 {
     $result = $this->InitResponseWS();
     $dataPost = $this->dataPost();
     $properties = json_decode($dataPost['properties'], true);
     //get current session project
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     //load marker icons from config
     $icons = \Applications\PMTool\Helpers\MapHelper::GetActiveInactiveIcons($this->app()->relative_path, $this->app()->imageUtil, $this->app()->config());
     //create google maps marker items
     $projectLocationMarkers = \Applications\PMTool\Helpers\MapHelper::CreateFacilityMarkerItems(\Applications\PMTool\Helpers\ProjectHelper::GetSessionProjects($this->user()), $properties, $icons);
     $result["defaultPosition"] = \Applications\PMTool\Helpers\MapHelper::GetCoordinatesToCenterOverARegion($this->app()->config());
     $result["items"] = $projectLocationMarkers;
     $result["noLatLngIcon"] = $icons["noLatLng"];
     $result["type"] = "facility";
     $result["activeTask"] = false;
     $result["controls"] = array("markers" => false, "shapes" => false, "ruler" => true);
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Map, "resx_key" => $this->action(), "step" => count($projectLocationMarkers) >= 0 ? "success" : "error"));
 }
コード例 #3
0
 public function executeGetItem(\Library\HttpRequest $rq)
 {
     $result = $this->InitResponseWS();
     $sessionProjects = \Applications\PMTool\Helpers\ProjectHelper::GetSessionProjects($this->user());
     $facilities = \Applications\PMTool\Helpers\CommonHelper::GetObjectListFromSessionArrayBySessionKey($sessionProjects, \Library\Enums\SessionKeys::FacilityObject);
     $facility = \Applications\PMTool\Helpers\CommonHelper::FindObjectByIntValue(intval($this->dataPost["facility_id"]), 'facility_id', $facilities);
     $projects = \Applications\PMTool\Helpers\CommonHelper::GetObjectListFromSessionArrayBySessionKey($sessionProjects, \Library\Enums\SessionKeys::ProjectObject);
     $project = \Applications\PMTool\Helpers\CommonHelper::FindObjectByIntValue(intval($facility->project_id()), 'project_id', $projects);
     $result['data'][0]['facility'] = $facility;
     $result['data'][0]['project'] = $project;
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Facility, "resx_key" => $this->action(), "step" => count($result['data']) > 0 ? "success" : "error"));
 }
コード例 #4
0
 /**
  * Method that edits a project and facility from map modal
  *
  * @param \Library\HttpRequest $rq
  * @return JSON
  */
 public function executeMapEdit(\Library\HttpRequest $rq)
 {
     // Init result
     $result = $this->InitResponseWS();
     $dataPost = json_decode($this->dataPost["params"], true);
     $sessionProjects = \Applications\PMTool\Helpers\ProjectHelper::GetSessionProjects($this->user());
     if ($dataPost["project"]["project_id"]) {
         $sessionProject = $sessionProjects[\Library\Enums\SessionKeys::ProjectKey . $dataPost["project"]["project_id"]];
         $facility = $sessionProject[\Library\Enums\SessionKeys::FacilityObject];
         $project = $sessionProject[\Library\Enums\SessionKeys::ProjectObject];
     }
     if ($facility !== NULL && $project !== NULL) {
         //Init PDO
         $facility = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($dataPost["facility"], $facility);
         $project = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($dataPost["project"], $project);
         $manager = $this->managers->getManagerOf($this->module());
         $result_edit["facility"] = $manager->edit($facility, "facility_id");
         $manager = $this->managers->getManagerOf("Project");
         $result_edit["project"] = $manager->edit($project, "project_id");
         $result["data"]["facility"] = $facility;
         $result["data"]["project"] = $project;
     }
     //Update this project in session projects list
     if ($result_edit) {
         $sessionProject[\Library\Enums\SessionKeys::ProjectObject] = $project;
         $sessionProject[\Library\Enums\SessionKeys::FacilityObject] = $facility;
         $sessionProjects[\Library\Enums\SessionKeys::ProjectKey . $dataPost["project"]["project_id"]] = $sessionProject;
         \Applications\PMTool\Helpers\ProjectHelper::SetSessionProjects($this->user(), $sessionProjects);
     }
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Project, "resx_key" => $this->action(), "step" => $result_edit ? "success" : "error"));
 }
コード例 #5
0
 public static function SetCurrentProjectIfPmHasOnlyOneAndReturnProjects(\Library\User $user)
 {
     $projects = \Applications\PMTool\Helpers\ProjectHelper::GetSessionProjects($user);
     $pm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($user);
     $project_ids = count($pm[\Library\Enums\SessionKeys::PmProjectIds]) > 0 ? $pm[\Library\Enums\SessionKeys::PmProjectIds] : FALSE;
     if (count($projects) === 1 && $project_ids !== FALSE) {
         \Applications\PMTool\Helpers\ProjectHelper::SetCurrentSessionProject($user, $projects[\Library\Enums\SessionKeys::ProjectKey . $project_ids[0]]);
     } else {
         if (count($projects) > 1 && $project_ids !== FALSE) {
             $project_objects = \Applications\PMTool\Helpers\CommonHelper::GetListObjectsInSessionByKey($user, \Library\Enums\SessionKeys::ProjectObject);
             $project = \Applications\PMTool\Helpers\CommonHelper::FindObjectByIntValue(1, 'project_is_default', $project_objects);
             if ($project !== false) {
                 \Applications\PMTool\Helpers\ProjectHelper::SetCurrentSessionProject($user, $projects[\Library\Enums\SessionKeys::ProjectKey . $project->project_id()]);
             }
         }
     }
     return $projects;
 }