public function executeManageCoc(\Library\HttpRequest $rq)
 {
     \Applications\PMTool\Helpers\TaskHelper::SetActiveTab($this->user(), \Applications\PMTool\Resources\Enums\TaskTabKeys::CocTab);
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->user());
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user());
     //Task tab status
     $tab_status_arr = \Applications\PMTool\Helpers\TaskHelper::TabStatusFor($sessionTask);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_tab_status_keys, $tab_status_arr);
     //Task tab status
     //Analyte Matrix tab status
     $showLabMatrixTabs = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::DoesAnalytesAndLocationsExistsFor($sessionTask, $this, 'Lab');
     $showFieldMatrixTabs = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::DoesAnalytesAndLocationsExistsFor($sessionTask, $this, 'Field');
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_show_lab_matrix, $showLabMatrixTabs);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_show_field_matrix, $showFieldMatrixTabs);
     //Analyte Matrix tab status
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentProject, $sessionProject[\Library\Enums\SessionKeys::ProjectObject]);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentTask, $sessionTask[\Library\Enums\SessionKeys::TaskObj]);
     $labServices = \Applications\PMTool\Helpers\TaskHelper::getLabServicesForTask($this, $sessionTask, "Laboratory");
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::labServices, $labServices);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentPm, \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user()));
     if ($rq->getData("mode") === "edit") {
         $this->page->addVar("task_editing_header", $this->resxData["task_legend_edit"]);
     } else {
         $this->page->addVar("task_editing_header", $this->resxData["task_legend_add"]);
     }
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::tabStatus, \Applications\PMTool\Helpers\TaskHelper::GetTabsStatus($this->app()->user()));
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::form_modules, $this->app()->router()->selectedRoute()->phpModules());
 }
 /**
  * Method that receives the call from JS Client to login a user
  *
  * @param \Library\HttpRequest $rq: the request
  * @return json object A JSON object with the result bool value and success/error message
  */
 public function executeAuthenticate(\Library\HttpRequest $rq)
 {
     //Initialize the response to error.
     $result = $this->InitResponseWS();
     //Let's retrieve the inputs from AJAX POST request
     $data_sent = $this->dataPost();
     $authProvider = new AuthProvider($this->app->config->get("encryption_key"), $this->managers->getManagerOf('Login'));
     $authProvider->prepareUser($data_sent);
     if ($authProvider->getUser() instanceof \Library\Interfaces\IUser) {
         $this->app->auth->authenticate($authProvider->getUser());
         $this->user->setAttribute(\Library\Enums\SessionKeys::UserTypeObject, $authProvider->getUserType());
         if ($authProvider->getUser()) {
             $user = $this->app->user;
             $routes = array_filter($this->app->router->routes(), function ($route) use($user) {
                 return count($route->role()) == 0 || in_array($user->getRole(), $route->role());
             });
             \Applications\PMTool\Helpers\UserHelper::SaveRoutes($user, $routes);
             switch ($authProvider->getUser()->getType()) {
                 case 'technician_id':
                     \Applications\PMTool\Helpers\TaskHelper::UnsetCurrentSessionTask($this->user);
                     break;
                 case 'pm_id':
                     \Applications\PMTool\Helpers\PmHelper::StoreSessionPm($this, $authProvider->getUserType(), true);
                     break;
             }
             $result = $this->InitResponseWS("success");
             $result['role'] = $user->getRole();
         }
     }
     //return the JSON data
     echo \Library\HttpResponse::encodeJson($result);
 }
 public function executeManageServices(\Library\HttpRequest $rq)
 {
     // Set $current_project for breadcrumb
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentProject, $sessionProject[\Library\Enums\SessionKeys::ProjectObject]);
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user());
     //Task tab status
     $tab_status_arr = \Applications\PMTool\Helpers\TaskHelper::TabStatusFor($sessionTask);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_tab_status_keys, $tab_status_arr);
     //Task tab status
     //Analyte Matrix tab status
     $showLabMatrixTabs = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::DoesAnalytesAndLocationsExistsFor($sessionTask, $this, 'Lab');
     $showFieldMatrixTabs = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::DoesAnalytesAndLocationsExistsFor($sessionTask, $this, 'Field');
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_show_lab_matrix, $showLabMatrixTabs);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_show_field_matrix, $showFieldMatrixTabs);
     //Analyte Matrix tab status
     \Applications\PMTool\Helpers\TaskHelper::SetActiveTab($this->user(), \Applications\PMTool\Resources\Enums\TaskTabKeys::ServicesTab);
     $sessionPm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user());
     $pm_services = \Applications\PMTool\Helpers\ServiceHelper::GetPmServices($this, $sessionPm);
     $task_services = \Applications\PMTool\Helpers\ServiceHelper::GetAndStoreTaskServices($this, $sessionTask);
     // filter the pm services after we retrieve the task services
     $pm_services = \Applications\PMTool\Helpers\ServiceHelper::FilterServicesToExcludeTaskServices($pm_services, $task_services);
     $task_services = \Applications\PMTool\Helpers\ServiceHelper::CategorizeTheList($task_services, "service_type");
     $pm_services = \Applications\PMTool\Helpers\ServiceHelper::CategorizeTheList($pm_services, "service_type");
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentPm, $sessionPm[\Library\Enums\SessionKeys::PmObject]);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentTask, $sessionTask[\Library\Enums\SessionKeys::TaskObj]);
     $this->page->addVar("HasItemsToDisplay", \Applications\PMTool\Helpers\PmHelper::DoesPmHaveActiveServices($this->user()));
     $data = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => strtolower($this->module()), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::categorized_list_right => $pm_services, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::categorized_list_left => $task_services, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_right => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower("service")), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_left => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower("service")));
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data, $data);
     //tab status
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::tabStatus, \Applications\PMTool\Helpers\TaskHelper::GetTabsStatus($this->user()));
     //form modules
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::form_modules, $this->app()->router()->selectedRoute()->phpModules());
 }
 public function executeManageLocations(\Library\HttpRequest $rq)
 {
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user());
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->user());
     //Task tab status
     $tab_status_arr = \Applications\PMTool\Helpers\TaskHelper::TabStatusFor($sessionTask);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_tab_status_keys, $tab_status_arr);
     //Task tab status
     //Analyte Matrix tab status
     $showLabMatrixTabs = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::DoesAnalytesAndLocationsExistsFor($sessionTask, $this, 'Lab');
     $showFieldMatrixTabs = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::DoesAnalytesAndLocationsExistsFor($sessionTask, $this, 'Field');
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_show_lab_matrix, $showLabMatrixTabs);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_show_field_matrix, $showFieldMatrixTabs);
     //Analyte Matrix tab status
     \Applications\PMTool\Helpers\TaskHelper::SetActiveTab($this->user(), \Applications\PMTool\Resources\Enums\TaskTabKeys::LocationsTab);
     $project_locations = \Applications\PMTool\Helpers\LocationHelper::GetProjectLocations($this, $sessionProject);
     $task_locations = \Applications\PMTool\Helpers\LocationHelper::GetAndStoreTaskLocations($this, $sessionTask);
     //filter the project locations after we retrieve the task locations
     $project_locations = \Applications\PMTool\Helpers\LocationHelper::FilterLocationsToExcludeTaskLocations($project_locations, $task_locations);
     //Fetch tooltip data from xml and pass to view as an array
     $tooltip_array = \Applications\PMTool\Helpers\PopUpHelper::getTooltipMsgForAttribute('{"targetcontroller":"taskLocation", "targetaction": "locations", "targetattr": ["active-taskLocation-header","inactive-taskLocation-header"]}', $this->app->name());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::tooltip_message, $tooltip_array);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentProject, $sessionProject[\Library\Enums\SessionKeys::ProjectObject]);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentTask, $sessionTask[\Library\Enums\SessionKeys::TaskObj]);
     $this->page->addVar("HasItemsToDisplay", \Applications\PMTool\Helpers\ProjectHelper::DoesProjectHasActiveLocations($this->user()));
     $data_left = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => strtolower($this->module()), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects_list_left => $task_locations, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_left => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower("location")));
     $data_right = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => strtolower($this->module()), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects_list_right => $project_locations, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_right => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower("location")));
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data_left, $data_left);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data_right, $data_right);
     //tab status
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::tabStatus, \Applications\PMTool\Helpers\TaskHelper::GetTabsStatus($this->user()));
     //form modules
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::form_modules, $this->app()->router()->selectedRoute()->phpModules());
 }
 public function executeListAll(\Library\HttpRequest $rq)
 {
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentProject, $sessionProject[\Library\Enums\SessionKeys::ProjectObject]);
     //Fetch tooltip data from xml and pass to view as an array
     $tooltip_array = \Applications\PMTool\Helpers\PopUpHelper::getTooltipMsgForAttribute('{"targetcontroller":"service", "targetaction": "list", "targetattr": ["active-service-header","inactive-service-header"]}', $this->app->name());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::tooltip_message, $tooltip_array);
     $sessionPm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user());
     $pm_services = \Applications\PMTool\Helpers\ServiceHelper::GetPmServices($this, $sessionPm, NULL, TRUE);
     $project_services = \Applications\PMTool\Helpers\ServiceHelper::GetAndStoreProjectServices($this, $sessionProject);
     // filter the pm services after we retrieve the project services
     $pm_services = \Applications\PMTool\Helpers\ServiceHelper::FilterServicesToExcludeProjectServices($pm_services, $project_services);
     $project_services = \Applications\PMTool\Helpers\ServiceHelper::CategorizeTheList($project_services, "service_type");
     $pm_services = \Applications\PMTool\Helpers\ServiceHelper::CategorizeTheList($pm_services, "service_type");
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentPm, $sessionPm[\Library\Enums\SessionKeys::PmObject]);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentProject, $sessionProject[\Library\Enums\SessionKeys::ProjectObject]);
     $data = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => "service", \Applications\PMTool\Resources\Enums\ViewVariablesKeys::categorized_list_right => $pm_services, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::categorized_list_left => $project_services, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_right => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower("service")), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_left => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower("service")));
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data, $data);
     //tab status
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::tabStatus, \Applications\PMTool\Helpers\TaskHelper::GetTabsStatus($this->user()));
     //form modules
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::form_modules, $this->app()->router()->selectedRoute()->phpModules());
 }
 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;
 }
 public function executeSaveLabMatrix(\Library\HttpRequest $rq)
 {
     // Init result
     $result = $this->InitResponseWS();
     //Our current Session
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user());
     $sess_task_id = $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id();
     $result_save = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::SaveAnalyteMatrixForTask($this, $sess_task_id, $this->dataPost['lab_matrix'], 'Lab');
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Task, "resx_key" => $this->action(), "step" => $result_save ? "success" : "error"));
 }
예제 #8
0
 /**
  * Task Copy: Main method
  * Copies the task corresponding to the passed task id
  * and based on that copies all other dependencies into
  * the new task thus created
  */
 public static function copyTaskWithDependencies($caller, $source_task_id, $new_task_name, $usr)
 {
     $taskDAO = new \Applications\PMTool\Models\Dao\Task();
     $taskDAO->setTask_id($source_task_id);
     $dal = $caller->managers()->getManagerOf("Task");
     $source_task = $dal->selectMany($taskDAO, "task_id");
     //Create new task out of this
     $taskDAO = null;
     $taskDAO = new \Applications\PMTool\Models\Dao\Task();
     $taskDAO->setProject_id($source_task[0]->project_id());
     $taskDAO->setTask_name($new_task_name);
     $taskDAO->setTask_deadline($source_task[0]->task_deadline());
     $taskDAO->setTask_instructions($source_task[0]->task_instructions());
     $taskDAO->setTask_trigger_cal($source_task[0]->task_trigger_cal());
     $taskDAO->setTask_trigger_cal_value($source_task[0]->task_trigger_cal_value());
     $taskDAO->setTask_trigger_pm($source_task[0]->task_trigger_pm());
     $taskDAO->setTask_trigger_ext($source_task[0]->task_trigger_ext());
     $taskDAO->setTask_active($source_task[0]->task_active());
     $taskDAO->setTask_req_form($source_task[0]->task_req_form());
     $taskDAO->setTask_req_field_analyte($source_task[0]->task_req_field_analyte());
     $taskDAO->setTask_req_lab_analyte($source_task[0]->task_req_lab_analyte());
     $taskDAO->setTask_req_service($source_task[0]->task_req_service());
     $taskDAO->setTask_start_date($source_task[0]->task_start_date());
     $taskDAO->setTask_activated($source_task[0]->task_activated());
     $new_task_id = $dal->add($taskDAO);
     //Copy the relations too
     //FieldAnalyteLocation
     TaskHelper::copyTaskFieldAnalyteLocation($caller, $source_task_id, $new_task_id);
     //LabAnalyteLocation
     TaskHelper::copyTaskLabAnalyteLocation($caller, $source_task_id, $new_task_id);
     //TaskCocInfo
     TaskHelper::copyTaskTaskCocInfo($caller, $source_task_id, $new_task_id);
     //TaskFieldAnalyte
     TaskHelper::copyTaskTaskFieldAnalyte($caller, $source_task_id, $new_task_id);
     //TaskLabAnalyte
     TaskHelper::copyTaskTaskLabAnalyte($caller, $source_task_id, $new_task_id);
     //Task_location
     TaskHelper::copyTaskTaskLocation($caller, $source_task_id, $new_task_id);
     //Task_service
     TaskHelper::copyTaskTaskService($caller, $source_task_id, $new_task_id);
     //Task_technician
     TaskHelper::copyTaskTaskTechnician($caller, $source_task_id, $new_task_id);
     //Task_template_form
     TaskHelper::copyTaskTaskTemplateForm($caller, $source_task_id, $new_task_id);
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($usr);
     $taskDAO->setTask_id($new_task_id);
     array_push($sessionProject[\Library\Enums\SessionKeys::ProjectTasks], \Library\Enums\SessionKeys::TaskKey . $taskDAO->task_id());
     if ($new_task_id > 0) {
         \Applications\PMTool\Helpers\TaskHelper::AddSessionTask($usr, $taskDAO);
         \Applications\PMTool\Helpers\ProjectHelper::SetUserSessionProject($usr, $sessionProject);
     }
     return $new_task_id;
 }
 /**
  * Starts communication with 
  * entities with passed parameters
  */
 public static function StartCommunicationWith($caller, $selection_type, $selection_id)
 {
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($caller->user());
     $taskDiscussions = \Applications\PMTool\Helpers\DiscussionHelper::GetAllTaskDiscussions($caller, $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id());
     if ($selection_type == 'technician_id') {
         $technicians = \Applications\PMTool\Helpers\TechnicianHelper::GetAndStoreTaskTechnicians($caller, $sessionTask);
         foreach ($technicians as $technician) {
             if ($technician->technician_id() == $selection_id) {
                 $manager = $caller->managers()->getManagerOf('User');
                 $user = $manager->selectUserByTypeId('technician_id', $technician->technician_id());
                 break;
             }
         }
     } else {
         if ($selection_type == 'service_id') {
             $services = \Applications\PMTool\Helpers\ServiceHelper::GetAndStoreTaskServices($caller, $sessionTask);
             foreach ($services as $service) {
                 if ($service->service_id() == $selection_id) {
                     $manager = $caller->managers()->getManagerOf('User');
                     $user = $manager->selectUserByTypeId('service_id', $service->service_id());
                     break;
                 }
             }
         } else {
             if ($selection_type == 'pm_id') {
                 $sessionPm = $caller->user->getAttribute(\Library\Enums\SessionKeys::CurrentPm);
                 $currentPmObject = $sessionPm[\Library\Enums\SessionKeys::PmObject];
                 if ($currentPmObject->pm_id() == $selection_id) {
                     $manager = $caller->managers()->getManagerOf('User');
                     $user = $manager->selectUserByTypeId('pm_id', $currentPmObject->pm_id());
                 }
             }
         }
     }
     //we can add more users later if we choose to add more people in same discussion
     $discussionUsers = array($caller->user()->getAttribute(\Library\Enums\SessionKeys::UserConnected), $user);
     $discussion = \Applications\PMTool\Helpers\DiscussionHelper::CheckIfDiscussionExistsByUsers($caller, $caller->user()->getAttribute(\Library\Enums\SessionKeys::UserConnected), $user, $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id());
     if ($discussion === false) {
         $discussion = \Applications\PMTool\Helpers\DiscussionHelper::CreateNewDiscussion($caller, $discussionUsers, $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id());
     }
     //in case create discussion returned false we will check if discussion is false again
     if ($discussion !== false) {
         $manager = $caller->managers()->getManagerOf('DiscussionPerson');
         $discussion_person = new \Applications\PMTool\Models\Dao\Discussion_person();
         $discussion_person->setDiscussion_id($discussion->discussion_id());
         //select all connected people so we can store them in session
         $discussion_people = $manager->selectMany($discussion_person, 'discussion_id');
         \Applications\PMTool\Helpers\DiscussionHelper::SetCurrentDiscussion($caller->user(), $discussion, $discussion_people);
         $return_val = true;
     } else {
         $return_val = false;
     }
     return $return_val;
 }
 public static function UpdateTaskTechnicians($caller)
 {
     $result = $caller->InitResponseWS();
     // Init result
     $dataPost = $caller->dataPost();
     $result["rows_affected"] = 0;
     $result["technician_ids"] = str_getcsv($dataPost["technician_ids"], ',');
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($caller->user());
     $task_technicians = array();
     foreach ($result["technician_ids"] as $id) {
         $task_technician = new \Applications\PMTool\Models\Dao\Task_technician();
         $task_technician->setTechnician_id($id);
         $task_technician->setTask_id($sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id());
         $dal = $caller->managers()->getManagerOf($caller->module());
         if ($dataPost["action"] === "add") {
             $result["rows_affected"] += $dal->add($task_technician) >= 0 ? 1 : 0;
         } else {
             $result["rows_affected"] += $dal->delete($task_technician, "technician_id") ? 1 : 0;
         }
         array_push($task_technicians, $task_technician);
     }
     $sessionTask[\Library\Enums\SessionKeys::TaskTechnicians] = $task_technicians;
     \Applications\PMTool\Helpers\TaskHelper::SetSessionTask($caller->user(), $sessionTask);
     return $result;
 }
 public function executeManageForms(\Library\HttpRequest $rq)
 {
     // Set $current_project for breadcrumb
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user());
     //Task tab status
     $tab_status_arr = \Applications\PMTool\Helpers\TaskHelper::TabStatusFor($sessionTask);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_tab_status_keys, $tab_status_arr);
     //Task tab status
     //Analyte Matrix tab status
     $showLabMatrixTabs = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::DoesAnalytesAndLocationsExistsFor($sessionTask, $this, 'Lab');
     $showFieldMatrixTabs = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::DoesAnalytesAndLocationsExistsFor($sessionTask, $this, 'Field');
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_show_lab_matrix, $showLabMatrixTabs);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Task::task_show_field_matrix, $showFieldMatrixTabs);
     //Analyte Matrix tab status
     \Applications\PMTool\Helpers\TaskHelper::SetActiveTab($this->user(), \Applications\PMTool\Resources\Enums\TaskTabKeys::FormsTab);
     $sessionPm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user());
     //$pm_services = \Applications\PMTool\Helpers\ServiceHelper::GetPmServices($this, $sessionPm);
     $masterForms = \Applications\PMTool\Helpers\FormHelper::GetMasterForms($this, $sessionProject);
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     $userForms = \Applications\PMTool\Helpers\FormHelper::GetUserForms($this, $sessionProject);
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     \Applications\PMTool\Helpers\FormHelper::GetProjectForms($this, $sessionProject);
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     $projectForms = \Applications\PMTool\Helpers\FormHelper::GetFormsFromProjectForms($this->user(), $sessionProject);
     $taskForms = \Applications\PMTool\Helpers\FormHelper::GetTaskForms($this, $sessionTask);
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user());
     if (isset($projectForms[\Applications\PMTool\Resources\Enums\ViewVariablesKeys::master_forms]) && !empty($projectForms[\Applications\PMTool\Resources\Enums\ViewVariablesKeys::master_forms])) {
         $filteredMasterForms = \Applications\PMTool\Helpers\FormHelper::FilterFormsToExclude($projectForms[\Applications\PMTool\Resources\Enums\ViewVariablesKeys::master_forms], $taskForms, 'master_form_id');
     }
     if (isset($projectForms[\Applications\PMTool\Resources\Enums\ViewVariablesKeys::user_forms]) && !empty($projectForms[\Applications\PMTool\Resources\Enums\ViewVariablesKeys::user_forms])) {
         $filteredUserForms = \Applications\PMTool\Helpers\FormHelper::FilterFormsToExclude($projectForms[\Applications\PMTool\Resources\Enums\ViewVariablesKeys::user_forms], $taskForms, 'user_form_id');
     }
     $taskForms = \Applications\PMTool\Helpers\FormHelper::GetFormsFromTaskForms($this->user(), $sessionProject, $sessionTask);
     //$this->page->addVar("HasItemsToDisplay", \Applications\PMTool\Helpers\PmHelper::DoesPmHaveActiveServices($this->user()));
     if (!empty($filteredMasterForms)) {
         $filteredMasterForms = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::master_forms => $filteredMasterForms);
     } else {
         $filteredMasterForms = array();
     }
     if (!empty($filteredUserForms)) {
         $filteredUserForms = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::user_forms => $filteredUserForms);
     } else {
         $filteredUserForms = array();
     }
     $templateForms = array_merge($filteredUserForms, $filteredMasterForms);
     $data = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => strtolower($this->module()), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::categorized_list_right => $templateForms, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::categorized_list_left => $taskForms, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_right => \Applications\PMTool\Helpers\FormHelper::SetPropertyNamesForDualList(), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_left => \Applications\PMTool\Helpers\FormHelper::SetPropertyNamesForDualList());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data, $data);
     //tab status
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::tabStatus, \Applications\PMTool\Helpers\TaskHelper::GetTabsStatus($this->user()));
     //form modules
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::form_modules, $this->app()->router()->selectedRoute()->phpModules());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentProject, $sessionProject[\Library\Enums\SessionKeys::ProjectObject]);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentPm, $sessionPm[\Library\Enums\SessionKeys::PmObject]);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentTask, $sessionTask[\Library\Enums\SessionKeys::TaskObj]);
 }
 /**
  * Gets the web form data matrix for task location
  */
 public function executeGetWebFormMatrixWithData(\Library\HttpRequest $rq)
 {
     $result = $this->InitResponseWS();
     // Init result
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->app()->user());
     $task_id = $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id();
     $matrix = \Applications\PMTool\Helpers\MobileHelper::GetFieldMatrixDataFromDB($this, $task_id, $this->dataPost['loc_id']);
     //Assign result
     $result['matrix'] = $matrix;
     $forms_found = true;
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Mobile, "resx_key" => $this->action(), "step" => $forms_found ? "success" : "error"));
 }
 public function executeSetStatusCheckList(\Library\HttpRequest $rq)
 {
     //Init result
     $result = $this->InitResponseWS();
     $dataPost = $this->dataPost();
     $error = true;
     //Get current task
     $currSessTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user());
     $task_id = $currSessTask['task_info_obj']->task_id();
     $checklist = new \Applications\PMTool\Models\Dao\Task_check_list();
     $checklist->setTask_check_list_id($dataPost['id']);
     $manager = $this->managers()->getManagerOf($this->module());
     $checklists = $manager->selectMany($checklist, 'task_check_list_id');
     if (count($checklists) > 0) {
         $checklist = $checklists[0];
         //check if checklist is part of the current task
         if ($checklist->task_id() == $task_id) {
             $checklist->setTask_check_list_complete($dataPost['complete']);
             $result_edit = $manager->edit($checklist, 'task_check_list_id');
         }
     }
     if (isset($result_edit) && $result_edit) {
         $error = false;
     }
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::TaskChecklist, "resx_key" => $this->action(), "step" => $error ? "error" : "success"));
 }
예제 #14
0
 public function executeDelete(\Library\HttpRequest $rq)
 {
     // Init result
     $result = $this->InitResponseWS();
     $pm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user());
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user());
     $db_result = FALSE;
     $form_id = intval($this->dataPost["form_id"]);
     if ($this->dataPost["form_type"] == "user_form") {
         //Check if the service to be deleted is the Project manager's
         $form_selected = \Applications\PMTool\Helpers\FormHelper::GetAUserForm($this->user(), $form_id);
         //Load interface to query the database
         if ($form_selected !== NULL) {
             $manager = $this->managers->getManagerOf("UserForm");
             $manager->setRootDirectory($this->app()->config()->get(\Library\Enums\AppSettingKeys::RootDocumentUpload));
             $manager->setWebDirectory($this->app()->config()->get(\Library\Enums\AppSettingKeys::BaseUrl) . $this->app()->config()->get(\Library\Enums\AppSettingKeys::RootUploadsFolderPath));
             $db_result = $manager->deleteWithFile($form_selected, "form_id");
             if ($db_result) {
                 //since we don't have foreign keys set because this is a relationship between 3 tables we must manually delete all project_form records, we also need to manually remove task forms
                 //remove project forms from session
                 $relationProjectForms = \Applications\PMTool\Helpers\FormHelper::GetProjectForms($this, $sessionProject);
                 $filteredProjectForms = \Applications\PMTool\Helpers\FormHelper::FilterFormsByGivenId($relationProjectForms, 'user_form_id', $form_id);
                 $sessionProject[\Library\Enums\SessionKeys::ProjectForms] = $filteredProjectForms;
                 if ($sessionTask !== FALSE) {
                     $relationTaskForms = \Applications\PMTool\Helpers\FormHelper::GetTaskForms($this, $sessionTask);
                     $filteredTaskForms = \Applications\PMTool\Helpers\FormHelper::FilterFormsByGivenId($relationTaskForms, 'user_form_id', $form_id);
                     $sessionTask[\Library\Enums\SessionKeys::TaskForms] = $filteredTaskForms;
                     \Applications\PMTool\Helpers\TaskHelper::SetCurrentSessionTask($this->user(), $sessionTask);
                 }
                 //delete from db
                 $projectForm = new \Applications\PMTool\Models\Dao\Project_form();
                 $projectForm->setUser_form_id($form_id);
                 $manager = $this->managers->getManagerOf("ProjectForm");
                 $manager->delete($projectForm, "user_form_id");
                 $taskForm = new \Applications\PMTool\Models\Dao\Task_template_form();
                 $taskForm->setUser_form_id($form_id);
                 $manager = $this->managers->getManagerOf("TaskForm");
                 $manager->delete($taskForm, "user_form_id");
                 //remove user forms from session
                 $match = \Applications\PMTool\Helpers\CommonHelper::FindIndexInObjectListById($form_selected->form_id(), "form_id", $sessionProject[\Library\Enums\SessionKeys::ProjectAvailableForms], \Library\Enums\SessionKeys::ProjectUserForms);
                 unset($sessionProject[\Library\Enums\SessionKeys::ProjectAvailableForms][\Library\Enums\SessionKeys::ProjectUserForms][$match["key"]]);
                 \Applications\PMTool\Helpers\ProjectHelper::SetCurrentSessionProject($this->user(), $sessionProject);
             }
         }
     } elseif ($this->dataPost["form_type"] == "master_form") {
         //delete from db
         //Project form
         $projectForm = new \Applications\PMTool\Models\Dao\Project_form();
         $projectForm->setMaster_form_id($form_id);
         $manager = $this->managers->getManagerOf("ProjectForm");
         $manager->delete($projectForm, "master_form_id");
         //Task template form
         $taskForm = new \Applications\PMTool\Models\Dao\Task_template_form();
         $taskForm->setMaster_form_id($form_id);
         $manager = $this->managers->getManagerOf("TaskForm");
         $manager->delete($taskForm, "master_form_id");
         //Now for the master form
         $masterFormDAO = new \Applications\PMTool\Models\Dao\Master_form();
         $masterFormDAO->setForm_id($form_id);
         $dal = $this->managers()->getManagerOf("MasterForm");
         $matchingForms = $dal->selectMany($masterFormDAO, "form_id");
         $db_result = $dal->deleteWithFileV2($matchingForms[0], "form_id");
     }
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Form, "resx_key" => $this->action(), "step" => $db_result !== FALSE ? "success" : "error"));
 }
 /**
  * Add a new location from the TaskLocationInfo popup
  */
 public function executeAddLocMob(\Library\HttpRequest $rq)
 {
     // Init result
     $result = $this->InitResponseWS();
     //Get session project
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     //Sesion project falicity
     $sessProjFacilityObj = $_SESSION[\Library\Enums\SessionKeys::UserSessionProjects]['project_' . $sessionProject[\Library\Enums\SessionKeys::ProjectObject]->project_id()][\Library\Enums\SessionKeys::FacilityObject];
     //Get current Session task
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user());
     //Extract image data from POST
     $locImages = json_decode($this->dataPost['images']);
     //Unset image data from POST so that we may create the DAO
     unset($this->dataPost['images']);
     //Set some extra variables
     $this->dataPost['project_id'] = $sessionProject[\Library\Enums\SessionKeys::ProjectObject]->project_id();
     $this->dataPost['location_active'] = 1;
     $this->dataPost['location_visible'] = 0;
     $locationDAO = new \Applications\PMTool\Models\Dao\Location();
     $location = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($this->dataPost(), $locationDAO);
     $manager = $this->managers->getManagerOf($this->module());
     $new_location_id = $manager->add($location);
     //Based on that let's create the Task Location object
     $tl_data = array('task_id' => $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id(), 'location_id' => $new_location_id, 'task_location_status' => 0);
     $task_location = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($tl_data, new \Applications\PMTool\Models\Dao\Task_location());
     $manager = $this->managers()->getManagerOf('TaskLocation');
     $task_location_id = $manager->add($task_location);
     //Process the images
     foreach ($locImages as $theLocImage) {
         $manager = $this->managers()->getManagerOf('Document');
         $docObj = $manager->getRecordsMatchingDocumentValue($theLocImage);
         //Our new document value is
         $newDocumentValue = $new_location_id . '_' . $docObj[0]->document_value();
         //Rename the file on disk
         rename('./uploads/location/' . $docObj[0]->document_value(), './uploads/location/' . $newDocumentValue);
         //Update the document value into the Dal
         $docObj[0]->setDocument_value($newDocumentValue);
         //and commit the edit
         $result_edit = $manager->edit($docObj[0], "document_id");
     }
     //Add to the field_analyte_location table
     $task_id = $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id();
     \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::CreateFALocationRelationForFT($this, $task_id, $new_location_id);
     //Set the newly created id to the object
     $location->setLocation_id($new_location_id);
     //Update session var
     array_push($sessionProject[\Library\Enums\SessionKeys::ProjectLocations], $location);
     \Applications\PMTool\Helpers\ProjectHelper::SetUserSessionProject($this->app()->user(), $sessionProject);
     /*\Applications\PMTool\Helpers\CommonHelper::pr($_SESSION[\Library\Enums\SessionKeys::UserSessionProjects]['project_' . 
       $sessionProject[\Library\Enums\SessionKeys::ProjectObject]->project_id()]);*/
     $result_add = true;
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Location, "resx_key" => $this->action(), "step" => $result_add ? "success" : "error"));
 }
 /**
  * Method that get a project and returns the result of operation
  * 
  * @param \Library\HttpRequest $rq
  * @return JSON
  */
 public function executeSetCurrentProject(\Library\HttpRequest $rq)
 {
     $result = $this->InitResponseWS();
     // Init result
     $manager = $this->managers()->getManagerOf('Project');
     $projectEdit = new \Applications\PMTool\Models\Dao\Project();
     $pm = $this->user->getAttribute(\Library\Enums\SessionKeys::CurrentPm);
     $pm = $pm[\Library\Enums\SessionKeys::PmObject];
     $pm_id = $pm->pm_id();
     $projectEdit->setPm_id($pm_id);
     $projectEdit->setProject_is_default(0);
     if (!$manager->edit($projectEdit, 'pm_id')) {
         throw new \Exception(__CLASS__ . "->" . __METHOD__ . " => Project Edit failed for PM ID=" . $pm_id);
     }
     $project_id = $this->dataPost["project_id"];
     $projectEdit->setProject_id($project_id);
     $projectEdit->setProject_is_default(1);
     if (!$manager->edit($projectEdit, 'project_id')) {
         throw new \Exception(__CLASS__ . "->" . __METHOD__ . " => Project Edit failed for Project ID=" . $project_id);
     } else {
         \Applications\PMTool\Helpers\ProjectHelper::RefreshProjectObjectsForCurrentPm($this);
     }
     $project = \Applications\PMTool\Helpers\ProjectHelper::GetAndStoreCurrentProject($this->user(), $project_id);
     $result["dataId"] = $project->project_id();
     \Applications\PMTool\Helpers\TaskHelper::UnsetCurrentSessionTask($this->user());
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Project, "resx_key" => $this->action(), "step" => $project != NULL ? "success" : "error"));
 }
예제 #17
0
 private static function ProcessListAnalytesTasks($caller, $result, $params)
 {
     $result["arrayOfValues"] = str_getcsv($params["dataPost"]["arrayOfValues"], ',');
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($caller->user());
     foreach ($result["arrayOfValues"] as $id) {
         $setMethodObjId = "set" . ucfirst($params["objPropId"]);
         $params["object"]->{$setMethodObjId}($id);
         $params["object"]->setTask_id($sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id());
         $dal = $caller->managers()->getManagerOf($caller->module());
         if ($params["dataPost"]["action"] === "add") {
             $analyte = $params["objPropId"] === "field_analyte_id" ? new \Applications\PMTool\Models\Dao\Task_field_analyte() : new \Applications\PMTool\Models\Dao\Task_lab_analyte();
             $analyte->setTask_id($sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id());
             $setMethodObjId = "set" . ucfirst($params["objPropId"]);
             $analyte->{$setMethodObjId}($id);
             $newId = $dal->add($analyte);
             $result["rows_affected"] += 1;
             $sessionTaskAnalytes = $sessionTask[$params["sessionKey"]];
             array_push($sessionTaskAnalytes, $analyte);
             $sessionTask[$params["sessionKey"]] = $sessionTaskAnalytes;
             //Set up task field_analyte_location relationship
             if ($params["objPropId"] === "field_analyte_id") {
                 \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::CreateLocationFARelationForFT($caller, $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id(), $id);
             }
         } else {
             $result["rows_affected"] += $dal->delete($params["object"], $params["objPropId"]) ? 1 : 0;
             //TODO: remove object deleted from array list
             $propId = $params["objPropId"];
             $match = CommonHelper::FindIndexInObjectListById($params["object"]->{$propId}(), $params["objPropId"], $sessionTask, $params["sessionKey"]);
             unset($sessionTask[$params["sessionKey"]][$match["key"]]);
         }
     }
     //\Applications\PMTool\Helpers\ProjectHelper::SetUserSessionProject($caller->user(), $sessionProject);
     return $result;
 }
예제 #18
0
 /**
  * <p> Retrieve complete marker items based on latitude, longitude and active properties of Location objects with no task and Location objects with task linked
  * </p>
  * <p> Build as an output an associative array in the Google Maps API format
  * </p>
  * @param array $locations <p>
  * 2 element array with nested array for locations with no tasks and for locations with tasks linked
  * array(
  * "\Library\Enums\SessionKeys::TaskLocations" => $projectLocationsArray,
  * "\Library\Enums\SessionKeys::ProjectLocations" => $taskLocationsArray
  * )
  * </p>
  * @param string $properties <p>
  * Associative object->property list
  * @return array $markers <p>
  * The array with location info and nested array "marker" in Google Maps API format
  * </p>
  */
 public static function CreateTaskLocationMarkerItems($caller, $locations, $properties, $icons, $activeTask)
 {
     $markers = array();
     $marker = array();
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($caller->app()->user());
     $taskLocations = $sessionTask[\Library\Enums\SessionKeys::TaskLocations];
     $locationObjectType = reset($properties);
     foreach ($locations as $locationType => $currentLocations) {
         foreach ($currentLocations as $location) {
             if (isset($locationObjectType["objectLatPropName"]) && isset($locationObjectType["objectLngPropName"]) && self::CheckCoordinateValue($location->{$locationObjectType}["objectLatPropName"]()) && self::CheckCoordinateValue($location->{$locationObjectType}["objectLngPropName"]())) {
                 $marker["marker"]["lat"] = $location->{$locationObjectType}["objectLatPropName"]();
                 $marker["marker"]["lng"] = $location->{$locationObjectType}["objectLngPropName"]();
                 $marker["id"] = $location->{$locationObjectType}["objectIdPropName"]();
                 $marker["marker"]["title"] = $marker["name"] = $location->{$locationObjectType}["objectNamePropName"]();
                 $marker["noLatLng"] = false;
             } else {
                 $marker["noLatLng"] = true;
                 $marker["id"] = $location->{$locationObjectType}["objectIdPropName"]();
                 $marker["name"] = $location->{$locationObjectType}["objectNamePropName"]();
             }
             $marker["active"] = $location->{$locationObjectType}["objectActivePropName"]();
             if (isset($locationObjectType["objectActivePropName"])) {
                 if ($locationType == \Library\Enums\SessionKeys::TaskLocations) {
                     $taskLocationObj = \Applications\PMTool\Helpers\CommonHelper::FindObjectByIntValue(intval($location->location_id()), 'location_id', $taskLocations);
                     if ($taskLocationObj) {
                         if ($taskLocationObj->task_location_status() == 2 and $activeTask) {
                             $marker["marker"]["icon"] = $icons['taskFinished'];
                         } else {
                             if ($taskLocationObj->task_location_status() == 1 and $activeTask) {
                                 $marker["marker"]["icon"] = $icons['taskInProcess'];
                             } else {
                                 $marker["marker"]["icon"] = $icons['task'];
                             }
                         }
                     }
                     $marker["task"] = true;
                 } else {
                     $marker["marker"]["icon"] = $location->{$locationObjectType}["objectActivePropName"]() ? $icons["locationActiveSmall"] : $icons["locationInactive"];
                     $marker["task"] = false;
                 }
             }
             if (!isset($marker["marker"]["lat"]) && !isset($marker["marker"]["lng"])) {
                 unset($marker["marker"]);
             }
             $markers[] = $marker;
         }
     }
     return $markers;
 }
예제 #19
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;
 }
 public function executeGetDiscussionThread(\Library\HttpRequest $rq)
 {
     $result = $this->InitResponseWS();
     $currentSessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user());
     $currentDiscussion = \Applications\PMTool\Helpers\DiscussionHelper::GetCurrentDiscussion($this->user);
     $discussionNames = array();
     if ($currentDiscussion) {
         foreach ($currentDiscussion[\Library\Enums\SessionKeys::DiscussionPeople] as $person) {
             $manager = $this->managers()->getManagerOf('User');
             $userTypeObject = $manager->selectUserTypeObjectByUserId($person->user_id());
             $userType = \Applications\PMTool\Helpers\UserHelper::FindUserTypeFromObject($userTypeObject);
             if ($userType == 'pm_id') {
                 $discussionNames[$person->discussion_person_id()] = $userTypeObject->pm_name();
             } else {
                 if ($userType == 'technician_id') {
                     $discussionNames[$person->discussion_person_id()] = $userTypeObject->technician_name();
                 } else {
                     if ($userType == 'service_id') {
                         $discussionNames[$person->discussion_person_id()] = $userTypeObject->service_name();
                     }
                 }
             }
             if ($person->discussion_person_is_author() != 1) {
                 $result['user_type'] = $userType;
             }
         }
         $thread = \Applications\PMTool\Helpers\DiscussionHelper::GetDiscussionThread($this, $currentDiscussion);
         $time = $this->dataPost['time'];
         if (isset($time) && !is_null('time') && $thread) {
             $thread = \Applications\PMTool\Helpers\DiscussionHelper::SliceThread($thread, $time);
         }
         if ($thread) {
             foreach ($thread as &$content) {
                 foreach ($discussionNames as $id => $name) {
                     if ($id == $content->discussion_person_id()) {
                         $content->user_name = $name;
                         break;
                     }
                 }
             }
             $result['thread'] = $thread;
         }
         $result['discussion'] = $currentDiscussion[\Library\Enums\SessionKeys::DiscussionObj];
         $result['success'] = true;
     } else {
         $result['success'] = false;
     }
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::ActiveTask, "resx_key" => $this->action(), "step" => $result['success'] ? "success" : "error"));
 }
예제 #21
0
 /**
  * <p> Retrieve the markers to display on Google Maps and the center position
  * if no items are returned for the Current Project Task Locations</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": {
  *  "location_obj": {
  *      "objectLatPropName": "location_lat",
  *      "objectLngPropName": "location_long",
  *      "objectActivePropName": "location_active"
  *      }
  *   }
  * For more info:
  * \Applications\PMTool\Helpers\MapHelper::CreateTaskLocationMarkerItems
  * @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 executeListCurrentProjectTasks(\Library\HttpRequest $rq)
 {
     $result = $this->InitResponseWS();
     $dataPost = $this->dataPost();
     $properties = json_decode($dataPost['properties'], true);
     //get facility location info
     $defaultLocationProperties = $properties['defaultLocation'];
     //unset default location because we don't want to show facility marker
     unset($properties['defaultLocation']);
     //get current sesion project and refresh project's locations then get current session task
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     //get project_id and load locations from DB
     $project_id = $sessionProject[\Library\Enums\SessionKeys::ProjectObject]->project_id();
     $sessionProject[\Library\Enums\SessionKeys::ProjectLocations] = $locations = \Applications\PMTool\Helpers\LocationHelper::GetLocationListFromDB($this, $project_id);
     //store updated session
     \Applications\PMTool\Helpers\ProjectHelper::SetUserSessionProject($this->user(), $sessionProject);
     $sessionProject[\Library\Enums\SessionKeys::ProjectLocations] = $this->_GetAndStoreLocationsInSession($sessionProject);
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->app()->user());
     //create two arrays with current project's locations, one for locations linked with the task and other unlinked
     $taskLocations = \Applications\PMTool\Helpers\LocationHelper::GetAndStoreTaskLocations($this, $sessionTask);
     $projectLocations = \Applications\PMTool\Helpers\LocationHelper::GetProjectLocations($this, $sessionProject, $taskLocations);
     $locations = array(\Library\Enums\SessionKeys::TaskLocations => $taskLocations, \Library\Enums\SessionKeys::ProjectLocations => $projectLocations);
     //load marker icons from config
     $icons = \Applications\PMTool\Helpers\MapHelper::GetActiveInactiveIcons($this->app()->relative_path, $this->app()->imageUtil, $this->app()->config());
     if (isset($properties['activeTask']) && $properties['activeTask']) {
         $activeTask = $result["activeTask"] = true;
     } else {
         $activeTask = $result["activeTask"] = false;
     }
     //create google maps marker items
     $projectLocationMarkers = \Applications\PMTool\Helpers\MapHelper::CreateTaskLocationMarkerItems($this, $locations, $properties, $icons, $activeTask);
     $result["noLatLngIcon"] = $icons["taskNoLatLng"];
     $result["activeIcon"] = $icons["task"];
     $result["inactiveIcon"] = $icons["task"];
     $result["items"] = $projectLocationMarkers;
     $result["defaultPosition"] = \Applications\PMTool\Helpers\MapHelper::GetCoordinatesToCenterOverARegion($this->app()->config());
     $result["boundary"] = \Applications\PMTool\Helpers\MapHelper::GetBoundary($sessionProject);
     $result["facility_id"] = $sessionProject[\Library\Enums\SessionKeys::FacilityObject]->facility_id();
     $result["project_id"] = $sessionProject[\Library\Enums\SessionKeys::FacilityObject]->project_id();
     $result["type"] = 'task';
     $noCoordinateMarkers = count(array_filter($projectLocationMarkers, function ($item) {
         return !$item['noLatLng'];
     }));
     if ($noCoordinateMarkers == 0) {
         $defaultLocations = \Applications\PMTool\Helpers\MapHelper::BuildLatAndLongCoordFromGeoObjects(array(\Applications\PMTool\Helpers\CommonHelper::GetValueFromArrayByKey($sessionProject, $defaultLocationProperties['object'])), $defaultLocationProperties['objectLatPropName'], $defaultLocationProperties['objectLngPropName']);
         if (count($defaultLocations) > 0) {
             $result['defaultPosition'] = $defaultLocations[0];
         }
     }
     $result["controls"] = array("markers" => true, "shapes" => true, "ruler" => true);
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Map, "resx_key" => $this->action(), "step" => count($projectLocationMarkers) >= 0 ? "success" : "error"));
 }
예제 #22
0
 public function executeGetLocationSpecificForms(\Library\HttpRequest $rq)
 {
     $result = $this->InitResponseWS();
     // Init result
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->app()->user());
     $task_id = $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id();
     $forms = \Applications\PMTool\Helpers\TaskHelper::getFormsforTaskLocation($this, $task_id, $this->dataPost['loc_id']);
     //Assign result
     $result['location_form_data'] = $forms;
     $forms_found = true;
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Task, "resx_key" => $this->action(), "step" => $forms_found ? "success" : "error"));
 }