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 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]);
 }
 /**
  * Method that edits a a client and returns the result of operation
  * 
  * @param \Library\HttpRequest $rq
  * @return JSON
  */
 public function executeEdit(\Library\HttpRequest $rq)
 {
     $result = $this->InitResponseWS();
     //Load interface to query the database
     $manager = $this->managers->getManagerOf($this->module());
     $result_edit = $manager->edit(\Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($this->dataPost(), new \Applications\PMTool\Models\Dao\Client()), "client_id");
     $result["dataId"] = $this->dataPost["client_id"];
     if ($result_edit) {
         \Applications\PMTool\Helpers\UserHelper::EditUser($this, 'client_id');
         $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetUserSessionProject($this->app()->user(), $this->dataPost["project_id"]);
         $sessionProject[\Library\Enums\SessionKeys::ClientObject] = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($this->dataPost(), new \Applications\PMTool\Models\Dao\Client());
         \Applications\PMTool\Helpers\ProjectHelper::UpdateUserSessionProject($this->app()->user(), $sessionProject);
     }
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Client, "resx_key" => $this->action(), "step" => $result_edit ? "success" : "error"));
 }
 public function executeListAll(\Library\HttpRequest $rq)
 {
     $tabsStatus = \Applications\PMTool\Helpers\CommonHelper::GetTabsStatus($this->user(), \Library\Enums\SessionKeys::TabActiveAnalyte);
     if ($tabsStatus === NULL) {
         \Applications\PMTool\Helpers\AnalyteHelper::AddTabsStatus($this->user());
         $tabsStatus = \Applications\PMTool\Helpers\CommonHelper::GetTabsStatus($this->user(), \Library\Enums\SessionKeys::TabActiveAnalyte);
     }
     $this->page()->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::tabStatus, $tabsStatus);
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->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::AnalyteListAll);
     }
     $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":"analyte", "targetaction": "list", "targetattr": ["active-fieldanalyte-header","inactive-fieldanalyte-header","active-labanalyte-header","inactive-labanalyte-header"]}', $this->app->name());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::tooltip_message, $tooltip_array);
     //Get confirm msg for analyte deletion from showForm screen
     $confirm_msg = \Applications\PMTool\Helpers\PopUpHelper::getConfirmBoxMsg('{"targetcontroller":"analyte", "targetaction": "list", 
             "operation": ["deleteField", "deleteLab", "noAnalyteForProject","noAnalyteAvailable", "laExists"]}', $this->app->name());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::confirm_message, $confirm_msg);
     $pm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user());
     if (!isset($pm[\Library\Enums\SessionKeys::PmFieldAnalytes]) && !isset($pm[\Library\Enums\SessionKeys::PmLabAnalytes]) && count($pm[\Library\Enums\SessionKeys::PmFieldAnalytes]) > 0 && count($pm[\Library\Enums\SessionKeys::PmLabAnalytes]) > 0) {
         \Applications\PMTool\Helpers\AnalyteHelper::StoreListsData($this);
     }
     $pm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user());
     //Fetch prompt box data from xml and pass to view as an array
     $prompt_msg = \Applications\PMTool\Helpers\PopUpHelper::getPromptBoxMsg('{"targetcontroller":"analyte", "targetaction": "listAll", "operation": ["edit"]}', $this->app->name());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::prompt_message, $prompt_msg);
     //variables for the field analyte module
     $field_object_properties = \Applications\PMTool\Helpers\CommonHelper::SetDynamicPropertyNamesForDualList("field_analyte", \Applications\PMTool\Helpers\AnalyteHelper::GetListPropertiesForFieldAnalyte());
     $field_analytes = $pm[\Library\Enums\SessionKeys::PmFieldAnalytes];
     $project_field_analytes = \Applications\PMTool\Helpers\AnalyteHelper::FilterAnalytesByProjectAnalytesList($this);
     $field_analytes = \Applications\PMTool\Helpers\CommonHelper::FilterObjectsToExcludeRelatedObject($field_analytes, $project_field_analytes, "field_analyte_id");
     $data_field_analyte = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => "fieldanalyte", \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects_list_right => $field_analytes, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects_list_left => $project_field_analytes, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_right => $field_object_properties, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_left => $field_object_properties);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Analyte::data_field_analyte, $data_field_analyte);
     //variable for the lab analyte module
     $lab_object_properties = \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList("lab_analyte");
     $lab_analytes = $pm[\Library\Enums\SessionKeys::PmLabAnalytes];
     $project_lab_analytes = \Applications\PMTool\Helpers\AnalyteHelper::FilterAnalytesByProjectAnalytesList($this, FALSE);
     $lab_analytes = \Applications\PMTool\Helpers\CommonHelper::FilterObjectsToExcludeRelatedObject($lab_analytes, $project_lab_analytes, "lab_analyte_id");
     $data_lab_analyte = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => "labanalyte", \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects_list_right => $lab_analytes, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects_list_left => $project_lab_analytes, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_right => $lab_object_properties, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties_left => $lab_object_properties);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Analyte::data_lab_analyte, $data_lab_analyte);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::form_modules, $this->app()->router()->selectedRoute()->phpModules());
 }
 public function executeLabMatrix(\Library\HttpRequest $rq)
 {
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     \Applications\PMTool\Helpers\AnalyteHelper::StoreListsData($this);
     $pm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($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
     //Get task specific lab analytes
     $task_lab_analytes = \Applications\PMTool\Helpers\AnalyteHelper::GetAndStoreTaskLabAnalytes($this, $sessionTask);
     //Check which page to render
     $pg = is_null($rq->getData('pg')) ? 1 : intval($rq->getData('pg')) == 0 ? 1 : intval($rq->getData('pg'));
     //Calculate pages
     $pages = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::returnTotalPagesOfAnalytes($task_lab_analytes, $this->app);
     //Filter paged result set of analytes
     //$task_lab_analytes = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::returnPagedAnalyteObjects($task_lab_analytes, $pg, $this->app);
     //Fetch ELLIPSIS tooltip settings from xml and pass to view as an array
     $ellipsis_tooltip_settings = \Applications\PMTool\Helpers\PopUpHelper::getTooltipEllipsisSettings('{"targetcontroller":"taskLabAnalyte", "targetaction": "labMatrix"}', $this->app->name());
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::ellipsis_tooltip_settings, $ellipsis_tooltip_settings);
     //Task specific locations
     $project_locations = \Applications\PMTool\Helpers\LocationHelper::GetProjectLocations($this, $sessionProject);
     $task_locations = \Applications\PMTool\Helpers\LocationHelper::GetAndStoreTaskLocations($this, $sessionTask);
     //Get LocationLabMatrix relation
     $id_map = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::GetAnalyteMatrixForTask($this, $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id(), 'Lab');
     \Applications\PMTool\Helpers\TaskHelper::SetActiveTab($this->user(), \Applications\PMTool\Resources\Enums\TaskTabKeys::LabSampleMatrixTab);
     $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::task_locations, $task_locations);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::task_lab_analytes, $task_lab_analytes);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::task_analytes_pages, $pages);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::current_page, $pg);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::task_lab_analytes_idmap, $id_map);
     //tab status
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::tabStatus, \Applications\PMTool\Helpers\TaskHelper::GetTabsStatus($this->user()));
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::form_modules, $this->app()->router()->selectedRoute()->phpModules());
 }
 public function executeGetTaskCoc(\Library\HttpRequest $rq)
 {
     // Init result
     $result = $this->InitResponseWS();
     $task_id = intval($this->dataPost["task_id"]);
     //Init PDO
     $task_coc_info = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($this->dataPost(), new \Applications\PMTool\Models\Dao\Task_coc_info());
     $manager = $this->managers->getManagerOf($this->module());
     $result_coc = $manager->selectMany($task_coc_info, "task_id");
     $task_coc_info = count($result_coc) > 0 ? $result_coc[0] : new \Applications\PMTool\Models\Dao\Task_coc_info();
     $sessionPm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user());
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->user());
     $task_coc_info->setProject_number($sessionProject[\Library\Enums\SessionKeys::ProjectObject]->project_id());
     $task_coc_info->setResults_to_name($sessionPm[\Library\Enums\SessionKeys::PmObject]->pm_name());
     $task_coc_info->setResults_to_company($sessionPm[\Library\Enums\SessionKeys::PmObject]->pm_comp_name());
     $task_coc_info->setResults_to_address($sessionPm[\Library\Enums\SessionKeys::PmObject]->pm_address());
     $task_coc_info->setResults_to_phone($sessionPm[\Library\Enums\SessionKeys::PmObject]->pm_phone());
     $task_coc_info->setResults_to_email($sessionPm[\Library\Enums\SessionKeys::PmObject]->pm_email());
     $result["task_coc"] = $task_coc_info;
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Task, "resx_key" => $this->action(), "step" => $result_coc !== NULL ? "success" : "error"));
 }
 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 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 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);
 }
Пример #11
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;
 }
Пример #12
0
 public static function GetAUserForm(\Library\User $user, $form_id)
 {
     $match = NULL;
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($user);
     $forms = $sessionProject[\Library\Enums\SessionKeys::ProjectAvailableForms][\Library\Enums\SessionKeys::ProjectUserForms];
     if ($forms !== NULL) {
         $match = CommonHelper::FindObjectByIntValue($form_id, "form_id", $forms);
     }
     return $match;
 }
Пример #13
0
 public function executeUpdateItems(\Library\HttpRequest $rq)
 {
     $result = $this->InitResponseWS();
     // Init result
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     $result["rows_affected"] = 0;
     //Get the service objects from ids received
     $user_form_ids = str_getcsv($this->dataPost["userFormIds"], ',');
     $master_form_ids = str_getcsv($this->dataPost["masterFormIds"], ',');
     $masterForms = $sessionProject[\Library\Enums\SessionKeys::ProjectAvailableForms][\Library\Enums\SessionKeys::ProjectMasterForms];
     $userForms = $sessionProject[\Library\Enums\SessionKeys::ProjectAvailableForms][\Library\Enums\SessionKeys::ProjectUserForms];
     $matchedMasterFormElements = $this->FindObjectsFromIds(array("filter" => "form_id", "ids" => $master_form_ids, "objects" => $masterForms));
     $matchedUserFormElements = $this->FindObjectsFromIds(array("filter" => "form_id", "ids" => $user_form_ids, "objects" => $userForms));
     $project_id = $sessionProject[\Library\Enums\SessionKeys::ProjectObject]->project_id();
     foreach ($matchedMasterFormElements as $form) {
         $manager = $this->managers->getManagerOf("ProjectForm");
         $projectForm = new \Applications\PMTool\Models\Dao\Project_form();
         $projectForm->setProject_id($project_id);
         $projectForm->setMaster_form_id($form->form_id());
         $projectForm->setUser_form_id(null);
         if ($this->dataPost["action"] == "add") {
             $manager->add($projectForm);
             $result["rows_affected"] += 1;
         } else {
             if ($this->dataPost["action"] == "remove") {
                 $returnRemove = $manager->deleteByFilters($projectForm, array("project_id" => $project_id, "master_form_id" => $form->form_id()));
                 $result["rows_affected"] += $returnRemove ? 1 : 0;
                 //if we remove project form relationship we need to remove all child task form relationships also
                 $manager = $this->managers->getManagerOf("TaskForm");
                 $taskForm = new \Applications\PMTool\Models\Dao\Task_template_form();
                 $taskForm->setUser_form_id(null);
                 $taskForm->setMaster_form_id($form->form_id());
                 $taskForm->setTask_id(null);
                 $manager->deleteByProjectAndFilters($taskForm, array("master_form_id" => $form->form_id()), $project_id);
             }
         }
     }
     foreach ($matchedUserFormElements as $form) {
         $manager = $this->managers->getManagerOf("ProjectForm");
         $projectForm = new \Applications\PMTool\Models\Dao\Project_form();
         $projectForm->setProject_id($project_id);
         $projectForm->setMaster_form_id(null);
         $projectForm->setUser_form_id($form->form_id());
         if ($this->dataPost["action"] == "add") {
             $returnAdd = $manager->add($projectForm);
             $result["rows_affected"] += $returnAdd >= 0 ? 1 : 0;
         } else {
             if ($this->dataPost["action"] == "remove") {
                 $returnRemove = $manager->deleteByFilters($projectForm, array("project_id" => $project_id, "user_form_id" => $form->form_id()));
                 $result["rows_affected"] += $returnRemove ? 1 : 0;
                 //if we remove project form relationship we need to remove all child task form relationships also
                 $manager = $this->managers->getManagerOf("TaskForm");
                 $taskForm = new \Applications\PMTool\Models\Dao\Task_template_form();
                 $taskForm->setUser_form_id($form->form_id());
                 $taskForm->setMaster_form_id(null);
                 $taskForm->setTask_id(null);
                 $manager->deleteByProjectAndFilters($taskForm, array("user_form_id" => $form->form_id()), $project_id);
             }
         }
     }
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Form, "resx_key" => $this->action(), "step" => $result["rows_affected"] > 0 ? "success" : "error"));
 }
 /**
  * Checks if any analyte (based on analyte type)
  * and location exists for the passed task.
  *
  * Returns true if both are present, false if
  * either doesn't.
  */
 public static function DoesAnalytesAndLocationsExistsFor($sessionTask, $caller, $analyte_type = 'Lab')
 {
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($caller->app()->user());
     //Store all analytes for this task
     \Applications\PMTool\Helpers\AnalyteHelper::StoreListsData($caller);
     //Task specific locations
     $project_locations = \Applications\PMTool\Helpers\LocationHelper::GetProjectLocations($caller, $sessionProject);
     $task_locations = \Applications\PMTool\Helpers\LocationHelper::GetAndStoreTaskLocations($caller, $sessionTask);
     $analyte_count = 0;
     if ($analyte_type === 'Lab') {
         //check for LAB analytes
         //Get task specific lab analytes
         $task_lab_analytes = \Applications\PMTool\Helpers\AnalyteHelper::GetAndStoreTaskLabAnalytes($caller, $sessionTask);
         //\Applications\PMTool\Helpers\CommonHelper::pr($task_locations);
         $analyte_count = count($task_lab_analytes);
     } else {
         //check for FIELD analytes
         $task_field_analytes = \Applications\PMTool\Helpers\AnalyteHelper::GetAndStoreTaskFieldAnalytes($caller, $sessionTask);
         $analyte_count = count($task_field_analytes);
     }
     if ($analyte_count > 0 && count($task_locations) > 0) {
         return true;
     } else {
         return false;
     }
 }
Пример #15
0
 public static function UpdateProjectServices($caller)
 {
     $result = $caller->InitResponseWS();
     // Init result
     $dataPost = $caller->dataPost();
     $result["rows_affected"] = 0;
     $result["service_ids"] = str_getcsv($dataPost["arrayOfValues"], ',');
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($caller->user());
     $project_services = array();
     foreach ($result["service_ids"] as $id) {
         $project_service = new \Applications\PMTool\Models\Dao\Project_service();
         $project_service->setService_id($id);
         $project_service->setProject_id($sessionProject[\Library\Enums\SessionKeys::ProjectObject]->project_id());
         $dal = $caller->managers()->getManagerOf($caller->module());
         if ($dataPost["action"] === "add") {
             $result["rows_affected"] += $dal->add($project_service) >= 0 ? 1 : 0;
         } else {
             $result["rows_affected"] += $dal->delete($project_service, "service_id") ? 1 : 0;
         }
         array_push($project_services, $project_service);
     }
     $sessionProject[\Library\Enums\SessionKeys::ProjectServices] = $project_services;
     \Applications\PMTool\Helpers\ProjectHelper::SetUserSessionProject($caller->user(), $sessionProject);
     return $result;
 }
Пример #16
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;
 }
Пример #17
0
 private static function ProcessListAnalytes($caller, $result, $params)
 {
     $result["arrayOfValues"] = str_getcsv($params["dataPost"]["arrayOfValues"], ',');
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($caller->user());
     foreach ($result["arrayOfValues"] as $id) {
         $setMethodObjId = "set" . ucfirst($params["objPropId"]);
         $params["object"]->{$setMethodObjId}($id);
         $params["object"]->setProject_id($sessionProject[\Library\Enums\SessionKeys::ProjectObject]->project_id());
         $dal = $caller->managers()->getManagerOf($caller->module());
         if ($params["dataPost"]["action"] === "add") {
             $analyte = $params["objPropId"] === "field_analyte_id" ? new \Applications\PMTool\Models\Dao\Project_field_analyte() : new \Applications\PMTool\Models\Dao\Project_lab_analyte();
             $analyte->setProject_id($sessionProject[\Library\Enums\SessionKeys::ProjectObject]->project_id());
             $setMethodObjId = "set" . ucfirst($params["objPropId"]);
             $analyte->{$setMethodObjId}($id);
             $newId = $dal->add($analyte);
             $result["rows_affected"] += 1;
             $sessionProjectAnalytes = $sessionProject[$params["sessionKey"]];
             array_push($sessionProjectAnalytes, $analyte);
             $sessionProject[$params["sessionKey"]] = $sessionProjectAnalytes;
         } 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"], $sessionProject, $params["sessionKey"]);
             unset($sessionProject[$params["sessionKey"]][$match["key"]]);
         }
     }
     \Applications\PMTool\Helpers\ProjectHelper::SetUserSessionProject($caller->user(), $sessionProject);
     return $result;
 }
 /**
  * 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"));
 }
 private function _GetLocationFromSession($location_id)
 {
     $locationMatch = array();
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     $locations = $sessionProject[\Library\Enums\SessionKeys::ProjectLocations];
     foreach (array_keys($locations) as $index => $key) {
         if (intval($locations[$key]->location_id()) === $location_id) {
             $locationMatch["object"] = $locations[$key];
             $locationMatch["key"] = $key;
             break;
         }
     }
     return $locationMatch;
 }
 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"));
 }
Пример #21
0
 public static function UpdateLocations($caller)
 {
     $result = $caller->InitResponseWS();
     // Init result
     $dataPost = $caller->dataPost();
     $rows_affected = 0;
     //Get the location objects from ids received
     $result["location_ids"] = str_getcsv($dataPost["location_ids"], ',');
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($caller->user());
     $locations = $sessionProject[\Library\Enums\SessionKeys::ProjectLocations];
     $matchedElements = $caller->FindObjectsFromIds(array("filter" => "location_id", "ids" => $result["location_ids"], "objects" => $locations));
     $result["rows_affected"] = 0;
     foreach ($matchedElements as $location) {
         $active = $dataPost["action"] === "active" ? TRUE : FALSE;
         $location->setLocation_active($active);
         $manager = $caller->managers()->getManagerOf($caller->module());
         $result["rows_affected"] += $manager->edit($location, "location_id") ? 1 : 0;
         if ($active === false) {
             $task_location = new \Applications\PMTool\Models\Dao\Task_location();
             $task_location->setLocation_id($location->location_id());
             $manager = $caller->managers()->getManagerOf("TaskLocation");
             $manager->delete($task_location, "location_id");
         }
         //self::DeleteLocation($caller,'TaskLocation',$location,'location_id');
     }
     self::GetLocationList($caller, $sessionProject);
     return $result;
 }
 public function executeFieldData(\Library\HttpRequest $rq)
 {
     \Applications\PMTool\Helpers\ActiveTaskHelper::AddTabsStatus($this->user());
     \Applications\PMTool\Helpers\AnalyteHelper::StoreListsData($this);
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->user());
     \Applications\PMTool\Helpers\AnalyteHelper::StoreListsData($this);
     //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"));
     //Get task specific field analytes
     $task_field_analytes = \Applications\PMTool\Helpers\AnalyteHelper::GetAndStoreTaskFieldAnalytes($this, $sessionTask);
     //Check which page to render
     $pg = is_null($rq->getData('pg')) ? 1 : intval($rq->getData('pg')) == 0 ? 1 : intval($rq->getData('pg'));
     //Calculate pages
     $pages = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::returnTotalPagesOfAnalytes($task_field_analytes, $this->app);
     //Filter paged result set of analytes
     //$task_field_analytes = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::returnPagedAnalyteObjects($task_field_analytes, $pg, $this->app);
     //Task specific locations
     $project_locations = \Applications\PMTool\Helpers\LocationHelper::GetProjectLocations($this, $sessionProject);
     $task_locations = \Applications\PMTool\Helpers\LocationHelper::GetAndStoreTaskLocations($this, $sessionTask);
     //Get LocationLabMatrix relation
     $id_map = \Applications\PMTool\Helpers\TaskAnalyteMatrixHelper::GetFieldDataMatrixForTaskWithResult($this, $sessionTask[\Library\Enums\SessionKeys::TaskObj]->task_id());
     //\Applications\PMTool\Helpers\CommonHelper::pr($id_map);
     $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::ActiveTaskFieldDataTab);
     //Fetch tooltip data from xml and pass to view as an array
     $tooltip_array = \Applications\PMTool\Helpers\PopUpHelper::getTooltipMsgForAttribute('{"targetcontroller":"activeTask", "targetaction": "showForm", "targetattr": ["h4-taskstatus-leftcol-gi", "h4-taskstatus-rightcol-gi", "h4-taskstatus-notes-gi", "h4-taskstatus-notesrecord-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()));
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::form_modules, $this->app()->router()->selectedRoute()->phpModules());
     //--------
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::task_locations, $task_locations);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::task_field_analytes, $task_field_analytes);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::task_analytes_pages, $pages);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::current_page, $pg);
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::task_field_analytes_idmap, $id_map);
     //footer task id
     $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::task_id, $rq->getData("task_id"));
 }
Пример #23
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"));
 }
Пример #24
0
 public function executeUpdateItems(\Library\HttpRequest $rq)
 {
     $result = $this->InitResponseWS();
     // Init result
     $rows_affected = 0;
     //Get the task objects from ids received
     $task_ids = str_getcsv($this->dataPost["task_ids"], ',');
     $sessionTasks = \Applications\PMTool\Helpers\TaskHelper::GetSessionTasks($this->app()->user());
     $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user());
     foreach ($task_ids as $id) {
         $sessionTask = $sessionTasks[\Library\Enums\SessionKeys::TaskKey . $id];
         $task = $sessionTask[\Library\Enums\SessionKeys::TaskObj];
         $task->setTask_active($this->dataPost["action"] === "active" ? TRUE : FALSE);
         $task_activated = $task->task_activated();
         //check if task is already not activated and mark accordingly
         if ($task_activated === '0' or is_null($task_activated)) {
             $task->setTask_activated('1');
         }
         $manager = $this->managers->getManagerOf($this->module);
         $rows_affected += $manager->edit($task, "task_id") ? 1 : 0;
         //Create Location specific PDFs for this task
         //Also check if task is already activated earlier, if so we don't want file copy feature again
         if (($task_activated === '0' or is_null($task_activated)) && $this->dataPost["action"] === "active" && $rows_affected > 0) {
             \Applications\PMTool\Helpers\TaskHelper::CreateLocationSpecificPDF($sessionTask, $this);
         }
     }
     \Applications\PMTool\Helpers\TaskHelper::SetSessionTasks($this->app()->user(), $sessionTasks);
     $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Task, "resx_key" => $this->action(), "step" => $rows_affected === count($task_ids) ? "success" : "error"));
 }