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());
 }
Exemplo n.º 2
0
 public static function getLabServicesForTask($caller, $sessionTask, $filterCategory)
 {
     $labServices = $taskServices = array();
     if (isset($sessionTask[\Library\Enums\SessionKeys::TaskServices]) && count($sessionTask[\Library\Enums\SessionKeys::TaskServices]) > 0) {
         $taskServices = \Applications\PMTool\Helpers\ServiceHelper::GetServicesFromTaskServices($caller->user(), $sessionTask);
     } else {
         $taskServices = ServiceHelper::GetAndStoreTaskServices($caller, $sessionTask);
         $sessionTask[\Library\Enums\SessionKeys::TaskServices] = $taskServices;
         TaskHelper::SetSessionTask($caller->user(), $sessionTask);
     }
     foreach ($taskServices as $service) {
         if ($service['service_type'] === $filterCategory) {
             array_push($labServices, $service);
         }
     }
     return $labServices;
 }
 /**
  * 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 function executeCommunications(\Library\HttpRequest $rq)
 {
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->user());
     //Check if a project needs to be selected in order to display this page
     if (!$sessionProject) {
         $this->Redirect(\Library\Enums\ResourceKeys\UrlKeys::ProjectsSelectProject . "?onSuccess=" . \Library\Enums\ResourceKeys\UrlKeys::TaskAddPrompt);
     }
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::SetCurrentSessionTask($this->user(), NULL, $rq->getData("task_id"));
     //\Applications\PMTool\Helpers\CommonHelper::pr($sessionTask);
     $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]);
     \Applications\PMTool\Helpers\ActiveTaskHelper::SetActiveTab($this->user(), \Applications\PMTool\Resources\Enums\ActiveTaskTabKeys::ActiveTaskCommTab);
     //Get current Discussion from session and set for view
     $currentDiscussion = \Applications\PMTool\Helpers\DiscussionHelper::GetCurrentDiscussion($this->user);
     if ($currentDiscussion) {
         $manager = $this->managers()->getManagerOf('User');
         $discussion_person = \Applications\PMTool\Helpers\DiscussionHelper::GetOtherDiscussionPerson($this->user(), $currentDiscussion[\Library\Enums\SessionKeys::DiscussionPeople]);
         $discussion_user_type = $manager->selectUserTypeObjectByUserId($discussion_person->user_id());
         if ($discussion_user_type) {
             $currentDiscussion['comm_with'] = $discussion_user_type;
             $currentDiscussion['comm_type'] = \Applications\PMTool\Helpers\UserHelper::FindUserTypeFromObject($discussion_user_type);
         }
         $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentDiscussion, $currentDiscussion);
     }
     //Let's get this task specific services
     $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);
     //Categorize the list for showing in the list
     $task_services = \Applications\PMTool\Helpers\ServiceHelper::CategorizeTheList($task_services, "service_type");
     //load forms
     $documents = \Applications\PMTool\Helpers\ActiveTaskHelper::GetDocumentsForActiveTask($sessionTask, $this);
     //Set data for frontend
     $data = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => strtolower($this->module()), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::categorized_list_left => $task_services, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_left => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower("service")));
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data, $data);
     //use group list right for popup task location form attachments
     $data_right = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => strtolower('document'), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects_list_right => $documents, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_right => \Applications\PMTool\Helpers\ActiveTaskHelper::SetPropertyNamesOfDocumentsForDualList());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data_right, $data_right);
     //Similarly let's get the task specific technicians
     $sessionPm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user());
     $pm_technicians = \Applications\PMTool\Helpers\TechnicianHelper::GetPmTechnicians($this, $sessionPm);
     $task_technicians = \Applications\PMTool\Helpers\TechnicianHelper::GetAndStoreTaskTechnicians($this, $sessionTask);
     // filter the pm technicians after we retrieve the task technicians
     $pm_technicians = \Applications\PMTool\Helpers\TechnicianHelper::FilterTechniciansToExcludeTaskTechnicians($pm_technicians, $task_technicians);
     //\Applications\PMTool\Helpers\CommonHelper::pr($task_technicians);
     //Check if the technician count for this task is only one, if so
     //startComm for this technician
     if (count($task_technicians) === 1 and !$currentDiscussion) {
         //Only one, let's start comm
         \Applications\PMTool\Helpers\ActiveTaskHelper::StartCommunicationWith($this, 'technician_id', $task_technicians[0]->technician_id());
         header("Location: http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
         exit;
     }
     $data_left = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => strtolower($this->module()), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects_list_left => $task_technicians, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_left => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower("technician")));
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data_left, $data_left);
     //Fetch tooltip data from xml and pass to view as an array
     $tooltip_array = \Applications\PMTool\Helpers\PopUpHelper::getTooltipMsgForAttribute('{"targetcontroller":"activeTask", "targetaction": "communications", "targetattr": ["h4-taskcomm-leftcol-gi", "h4-taskcomm-rightcol-gi","h4-taskcomm-services-gi","h4-taskcomm-technicians-gi"]}', $this->app->name());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::tooltip_message, $tooltip_array);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::activeTaskTabStatus, \Applications\PMTool\Helpers\ActiveTaskHelper::GetTabsStatus($this->app()->user()));
     $modules = $this->app()->router()->selectedRoute()->phpModules();
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::form_modules, $modules);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::popup_prompt_list, $modules['group_list_right']);
 }
 /**
  * Ajax response for auto complete
  * returns JSON of matching service categories
  */
 public function executeGetServiceCategoriesAutoComplete(\Library\HttpRequest $rq)
 {
     $result = $this->InitResponseWS();
     // Init result
     //Get services
     $sessionPm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user());
     $pm_services = \Applications\PMTool\Helpers\ServiceHelper::GetPmServices($this, $sessionPm, NULL, TRUE);
     $categories = \Applications\PMTool\Helpers\ServiceHelper::GetMatchingServiceCategories($pm_services, $this->dataPost['search']);
     $result['matches'] = $categories;
     $scFound = true;
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Service, "resx_key" => $this->action(), "step" => $scFound ? "success" : "error"));
 }
 public function executeGetItem(\Library\HttpRequest $rq)
 {
     // Init result
     $result = $this->InitResponseWS();
     $service_id = intval($this->dataPost["service_id"]);
     $service_selected = \Applications\PMTool\Helpers\ServiceHelper::GetAService($this->user(), $service_id);
     $result["service"] = $service_selected;
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Service, "resx_key" => $this->action(), "step" => $service_selected !== NULL ? "success" : "error"));
 }
 public function executeCommunications(\Library\HttpRequest $rq)
 {
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->user());
     //Check if a project needs to be selected in order to display this page
     if (!$sessionProject) {
         $this->Redirect(\Library\Enums\ResourceKeys\UrlKeys::MobileTasks);
     }
     $sessionPm = $this->user->getAttribute(\Library\Enums\SessionKeys::CurrentPm);
     $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user());
     //\Applications\PMTool\Helpers\CommonHelper::pr($sessionTask);
     $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(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentPm, $sessionPm[\Library\Enums\SessionKeys::PmObject]);
     //Get current Discussion from session and set for view
     $currentDiscussion = \Applications\PMTool\Helpers\DiscussionHelper::GetCurrentDiscussion($this->user);
     if ($currentDiscussion) {
         $manager = $this->managers()->getManagerOf('User');
         $discussion_person = \Applications\PMTool\Helpers\DiscussionHelper::GetOtherDiscussionPerson($this->user(), $currentDiscussion[\Library\Enums\SessionKeys::DiscussionPeople]);
         $discussion_user_type = $manager->selectUserTypeObjectByUserId($discussion_person->user_id());
         if ($discussion_user_type) {
             $currentDiscussion['comm_with'] = $discussion_user_type;
             $currentDiscussion['comm_type'] = \Applications\PMTool\Helpers\UserHelper::FindUserTypeFromObject($discussion_user_type);
         }
         $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentDiscussion, $currentDiscussion);
     }
     $task_services = \Applications\PMTool\Helpers\ServiceHelper::GetAndStoreTaskServices($this, $sessionTask);
     $task_services = \Applications\PMTool\Helpers\ServiceHelper::CategorizeTheList($task_services, "service_type");
     $data = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => 'activetask', \Applications\PMTool\Resources\Enums\ViewVariablesKeys::categorized_list_left => $task_services, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_left => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower("service")));
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data, $data);
     $task_technicians = \Applications\PMTool\Helpers\TechnicianHelper::GetAndStoreTaskTechnicians($this, $sessionTask);
     $task_technicians = \Applications\PMTool\Helpers\CommonHelper::FilterObjectsToExcludeRelatedObject($task_technicians, array($this->user()->getAttribute(\Library\Enums\SessionKeys::UserTypeObject)), 'technician_id');
     $data_left = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => 'activetask', \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects_list_left => $task_technicians, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_left => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower("technician")));
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data_left, $data_left);
     $modules = $this->app()->router()->selectedRoute()->phpModules();
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::form_modules, $modules);
 }