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 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 executeManageLabAnalytes(\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()); //All analytes for this PM, we would be assigning task specific analytes from list $pm_lab_analytes = $pm[\Library\Enums\SessionKeys::PmLabAnalytes]; //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::LabAnalytesTab); $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]); $lab_object_properties = \Applications\PMTool\Helpers\CommonHelper::SetDynamicPropertyNamesForDualList("lab_analyte", \Applications\PMTool\Helpers\AnalyteHelper::GetListPropertiesForLabAnalyte()); //Fetch task specific field analytes $task_lab_analytes = \Applications\PMTool\Helpers\AnalyteHelper::GetAndStoreTaskLabAnalytes($this, $sessionTask); $pm_lab_analytes = \Applications\PMTool\Helpers\CommonHelper::FilterObjectsToExcludeRelatedObject($pm_lab_analytes, $task_lab_analytes, "lab_analyte_id"); $data_lab_analyte = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => "labanalyte", \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects_list_right => $task_lab_analytes, \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects_list_left => $pm_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); //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 executeListAll(\Library\HttpRequest $rq) { //Get list of pms stored in session $this->_GetAndStorePmsInSession($rq); $data = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => strtolower($this->module()), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects => $this->app()->user->getAttribute(\Library\Enums\SessionKeys::AllUsers), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower($this->module()))); $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data, $data); $modules = $this->app()->router()->selectedRoute()->phpModules(); $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::active_list, $modules[\Applications\PMTool\Resources\Enums\PhpModuleKeys::active_list]); $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::inactive_list, $modules[\Applications\PMTool\Resources\Enums\PhpModuleKeys::inactive_list]); }
public function executeServiceDiscussion(\Library\HttpRequest $rq) { $discussionId = $rq->getData("discussion_id"); $currentUserObject = $this->user->getAttribute(\Library\Enums\SessionKeys::UserConnected); $data["username"] = $rq->getData("username"); $data["pwd"] = $rq->getData("password"); $data["encrypted_pwd"] = true; //check if user is already logged in and if username and password aren't sent through url if ($currentUserObject instanceof \Applications\PMTool\Models\Dao\User && !isset($data["username"]) && !isset($data["pwd"])) { } else { $authProvider = new \Applications\PMTool\AuthProvider($this->app->config->get("encryption_key"), $this->managers->getManagerOf('Login')); $authProvider->prepareUser($data); 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': break; case 'pm_id': \Applications\PMTool\Helpers\PmHelper::StoreSessionPm($this, $authProvider->getUserType(), true); break; } } } $currentUserObject = $this->user->getAttribute(\Library\Enums\SessionKeys::UserConnected); } $discussionArray = \Applications\PMTool\Helpers\DiscussionHelper::GetDiscussionByIdFromDB($this, $discussionId); $user = \Applications\PMTool\Helpers\CommonHelper::FindObjectByIntValue(intval($currentUserObject->user_id()), 'user_id', $discussionArray[\Library\Enums\SessionKeys::DiscussionPeople]); //check if logged in user is the part of this discussion if ($user) { \Applications\PMTool\Helpers\DiscussionHelper::SetCurrentDiscussion($this->user, $discussionArray[\Library\Enums\SessionKeys::DiscussionObj], $discussionArray[\Library\Enums\SessionKeys::DiscussionPeople]); $currentDiscussion = $discussionArray; if ($currentDiscussion) { $manager = $this->managers()->getManagerOf('User'); $discussion_person = \Applications\PMTool\Helpers\CommonHelper::FindObjectByIntValue(1, 'discussion_person_is_author', $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); } } else { \Applications\PMTool\Helpers\DiscussionHelper::UnsetCurrentDiscussion($this->user); } $modules = $this->app()->router()->selectedRoute()->phpModules(); $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::form_modules, $modules); }
/** * 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 deleteByProjectAndFilters($object, $filters, $projectId) { $tableName = \Applications\PMTool\Helpers\CommonHelper::GetShortClassName($object); $queryArray = array(); $query = ""; foreach ($filters as $filterName => $filterValue) { $queryArray[] = "`{$filterName}` = '{$filterValue}'"; } $query = implode(" AND ", $queryArray); try { $sql = $this->dao->query("DELETE tf.* FROM `{$tableName}` tf JOIN `task` t ON t.`task_id` = tf.`task_id` WHERE {$query} AND t.`project_id` = '{$projectId}';"); $sql->closeCursor(); return true; } catch (Exception $exc) { return false; } }
public function selectOne($object, $where_filter_id = "", $filter_as_string = false) { if ($object->document_id() !== "") { //Check if the user is giving his username and that there is a value $tableName = \Applications\PMTool\Helpers\CommonHelper::GetShortClassName($object); $sql = 'SELECT * FROM `' . $tableName . '` where `document_id` = :document_id LIMIT 0, 1;'; } else { return NULL; } $sth = $this->dao->prepare($sql); $sth->bindValue(':document_id', $object->document_id(), \PDO::PARAM_INT); $sth->execute(); $sth->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, '\\Applications\\PMTool\\Models\\Dao\\Document'); $document_out = $sth->fetch(); $sth->closeCursor(); return $document_out; }
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 deleteByFilters($object, $filters) { $tableName = \Applications\PMTool\Helpers\CommonHelper::GetShortClassName($object); $queryArray = array(); $deleteQuery = "DELETE FROM `{$tableName}` WHERE "; foreach ($filters as $filterName => $filterValue) { $queryArray[] = "`{$filterName}` = :{$filterName}"; } $query = implode(" AND ", $queryArray); $deleteQuery .= $query; $sth = $this->dao->prepare($deleteQuery); foreach ($filters as $filterName => $filterValue) { $sth->bindValue(":{$filterName}", $filterValue, \PDO::PARAM_STR); } try { $sth->execute(); $sth->closeCursor(); return true; } catch (Exception $exc) { return false; } }
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; }
public static function ProcessTaskLocations($caller, $sessionTask, $taskLocations, $file, $formData) { foreach ($taskLocations as $loc_key => $taskLocationObj) { //We have to get the Location names too //Check if exists in Session $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($caller->user()); //Recall session projects $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($caller->user()); $locationRecord = \Applications\PMTool\Helpers\CommonHelper::FindIndexInObjectListById($taskLocationObj->location_id(), "location_id", $sessionProject, \Library\Enums\SessionKeys::ProjectLocations); if (!empty($locationRecord)) { $locationObject = $locationRecord['object']; self::CopyFileForTaskLocation($caller, $taskLocationObj, $locationObject, $file, $formData); } else { throw new \Exception("TaskHelper::ProcessTaskLocations ==> No location object found in ProjectLocations for location_id=" . $taskLocationObj->location_id()); } } }
<?php } } ?> </div> <div></div> <!--The units if any --> <div class="matrix-row matrix-scroll-row"> <?php if (!empty($task_lab_analytes)) { foreach ($analyte_units as $analyte_unit) { ?> <div class="matrix-cell matrix-cell-data"> <?php \Applications\PMTool\Helpers\CommonHelper::generateEllipsisAndTooltipMarkupFor($analyte_unit, $toolTips[Applications\PMTool\Resources\Enums\ViewVariables\Popup::ellipsis_tooltip_settings]['charlimit'], $toolTips[Applications\PMTool\Resources\Enums\ViewVariables\Popup::ellipsis_tooltip_settings]['placement']); ?> </div> <?php } } ?> </div> <div></div> <?php if (!empty($task_locations)) { foreach ($task_locations as $location) { ?> <div class="matrix-row matrix-scroll-row"> <?php
/** * Ajax response for deleteting common field analytes */ public function executeDeleteCommon(\Library\HttpRequest $rq) { // Init result $result = $this->InitResponseWS(); $analyte_deleted = 0; $analyte = \Applications\PMTool\Helpers\CommonHelper::FindIndexInObjectListById($this->dataPost['analyte_id'], "common_field_analyte_id", $_SESSION, \Library\Enums\SessionKeys::CommonFieldAnalytes); if ($analyte["object"] !== NULL) { $manager = $this->managers->getManagerOf($this->module()); $db_result = $manager->delete($analyte["object"], "common_field_analyte_id"); if ($db_result) { unset($_SESSION[\Library\Enums\SessionKeys::CommonFieldAnalytes][$analyte["key"]]); $analyte_deleted = 1; } } $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::FieldAnalyte, "resx_key" => $this->action(), "step" => $analyte_deleted === 1 ? "success" : "error")); }
private static function _PrepareManyTechnicianObjects($dataPost) { $technicians = array(); $technician_names = \Applications\PMTool\Helpers\CommonHelper::StringToArray("\n", $dataPost["names"]); foreach ($technician_names as $name) { $technician = new \Applications\PMTool\Models\Dao\Technician(); $technician->setPm_id($dataPost["pm_id"]); $technician->setTechnician_name($name); $technician->setTechnician_active($dataPost["active"]); array_push($technicians, $technician); } return $technicians; }
public static function AddMessageToThread($caller, $userConnected, $currentDiscussion, $dataPost) { $manager = $caller->managers()->getManagerOf('DiscussionContent'); $discussion_person = \Applications\PMTool\Helpers\CommonHelper::FindObjectByIntValue(intval($userConnected->user_id()), 'user_id', $currentDiscussion[\Library\Enums\SessionKeys::DiscussionPeople]); $discussion_content = new \Applications\PMTool\Models\Dao\Discussion_content(); $discussion_content->setDiscussion_person_id($discussion_person->discussion_person_id()); $discussion_content->setDiscussion_content_message($dataPost['discussion_content_message']); $discussion_content_id = $manager->add($discussion_content); self::GetDiscussionThread($caller, $currentDiscussion); return $discussion_content_id; }
/** * 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")); }
/** * AJAX response for editing a common analyte */ public function executeEditCommonAnalyte(\Library\HttpRequest $rq) { // Init result $result = $this->InitResponseWS(); //\Applications\PMTool\Helpers\CommonHelper::pr($_SESSION[\Library\Enums\SessionKeys::CommonLabAnalytes]); $analyte_id = $this->dataPost['analyte_id']; $analyte_name = $this->dataPost['analyte_name']; $analyte_type = $this->dataPost['analyte_type']; $analyte_edited = 0; if ($analyte_type == 'lab') { $analyteDAO = new \Applications\PMTool\Models\Dao\Common_lab_analyte(); $analyteDAO->setCommon_lab_analyte_id($analyte_id); $analyteDAO->setCommon_lab_analyte_name($analyte_name); $analyteDAO->setCommon_lab_analyte_category_name($analyte_name); //Edit $manager = $this->managers->getManagerOf($this->module()); $result_edit = $manager->edit($analyteDAO, "common_lab_analyte_id"); $analyte = \Applications\PMTool\Helpers\CommonHelper::FindIndexInObjectListById($analyte_id, "common_lab_analyte_id", $_SESSION, \Library\Enums\SessionKeys::CommonLabAnalytes); if ($analyte["object"] !== NULL) { unset($_SESSION[\Library\Enums\SessionKeys::CommonLabAnalytes][$analyte["key"]]); array_push($_SESSION[\Library\Enums\SessionKeys::CommonLabAnalytes], $analyteDAO); } $analyte_edited = 1; } elseif ($analyte_type == 'field') { $analyteDAO = new \Applications\PMTool\Models\Dao\Common_field_analyte(); $analyteDAO->setCommon_field_analyte_id($analyte_id); $analyteDAO->setCommon_field_analyte_name($analyte_name); //Edit $manager = $this->managers->getManagerOf($this->module()); $result_edit = $manager->edit($analyteDAO, "common_field_analyte_id"); $analyte = \Applications\PMTool\Helpers\CommonHelper::FindIndexInObjectListById($analyte_id, "common_field_analyte_id", $_SESSION, \Library\Enums\SessionKeys::CommonFieldAnalytes); if ($analyte["object"] !== NULL) { unset($_SESSION[\Library\Enums\SessionKeys::CommonFieldAnalytes][$analyte["key"]]); array_push($_SESSION[\Library\Enums\SessionKeys::CommonFieldAnalytes], $analyteDAO); } $analyte_edited = 1; } $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::LabAnalyte, "resx_key" => $this->action(), "step" => $analyte_edited === 1 ? "success" : "error")); }
public function executeGetItem(\Library\HttpRequest $rq) { // Init result $result = $this->InitResponseWS(); $technician_id = intval($this->dataPost["technician_id"]); $pm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->app()->user()); $technician_selected = \Applications\PMTool\Helpers\CommonHelper::FindObjectByIntValue($technician_id, "technician_id", $pm[\Library\Enums\SessionKeys::PmTechnicians]); $result["technician"] = $technician_selected; $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Technician, "resx_key" => $this->action(), "step" => $technician_selected !== NULL ? "success" : "error")); }
public function executeIfTaskExists(\Library\HttpRequest $rq) { $result = $this->InitResponseWS(); // Init result $taskSession = \Applications\PMTool\Helpers\TaskHelper::GetSessionTasks($this->user()); $task = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($this->dataPost(), new \Applications\PMTool\Models\Dao\Task()); $match = \Applications\PMTool\Helpers\CommonHelper::FindObjectByStringValue($task->task_name(), "task_name", $taskSession, \Library\Enums\SessionKeys::TaskObj); $result['record_count'] = !$match || empty($match) ? 0 : 1; $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Task, "resx_key" => $this->action(), "step" => $result['record_count'] > 0 ? "success" : "error")); }
public function executeGetNotes(\Library\HttpRequest $rq) { $result = $this->InitResponseWS(); // Init result //Get current task $currSessTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user()); //Init data structure $data['task_id'] = $currSessTask['task_info_obj']->task_id(); //Init PDO $task_note = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($data, new \Applications\PMTool\Models\Dao\Task_note()); $manager = $this->managers->getManagerOf($this->module()); $result_note = $manager->selectMany($task_note, "task_id"); $result_get = 1; $onlyLoggedInUser = $this->dataPost['onlyuser']; $userConnected = \Applications\PMTool\Helpers\UserHelper::GetUserConnectedSession($this->user()); if (!empty($result_note)) { $user_arr = array(); foreach ($result_note as $note_key => $note_obj) { $datauser = null; if (isset($onlyLoggedInUser) && $onlyLoggedInUser == true && $note_obj->task_note_category_value() != $userConnected->user_value()) { unset($result_note[$note_key]); } else { //Fetch user details who posted that note if ($note_obj->task_note_category_type() == 'pm_id') { //Project Manager //Init data structure $datauser['pm_id'] = $note_obj->task_note_category_value(); //Init PDO $pm_user = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($datauser, new \Applications\PMTool\Models\Dao\Project_manager()); $manager = $this->managers->getManagerOf($this->module()); $result_pm_user = $manager->selectMany($pm_user, "pm_id"); //Stuff into main array array_push($user_arr, $result_pm_user[0]->pm_name()); } else { //Technician //Init data structure $datauser['technician_id'] = $note_obj->task_note_category_value(); //Init PDO $tech_user = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($datauser, new \Applications\PMTool\Models\Dao\Technician()); $manager = $this->managers->getManagerOf($this->module()); $result_tech_user = $manager->selectMany($tech_user, "technician_id"); //Stuff into main array array_push($user_arr, $result_tech_user[0]->technician_name()); } } } $result_note = array_values($result_note); $result_get = 1; } //cleanup into a nice array $result['notes'] = $result_note; $result['users'] = !empty($user_arr) ? $user_arr : array(); //\Applications\PMTool\Helpers\CommonHelper::pr($user_arr); $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::ActiveTask, "resx_key" => $this->action(), "step" => $result_get ? "success" : "error")); }
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")); }
private static function _PrepareManyChecklistObjects($dataPost, $task_id) { $checklists = array(); if (preg_match("`^.*,*\$`", $dataPost["checklists"])) { $checklist_arr = \Applications\PMTool\Helpers\CommonHelper::StringToArray(",", $dataPost["checklists"]); } else { $checklist_arr = \Applications\PMTool\Helpers\CommonHelper::StringToArray("\n", $dataPost["checklists"]); } foreach ($checklist_arr as $name) { $checklist = new \Applications\PMTool\Models\Dao\Task_check_list(); $checklist->setTask_id($task_id); $checklist->setTask_check_list_complete('0'); $checklist->setTask_check_list_detail($name); array_push($checklists, $checklist); } return $checklists; }
public function executeIfProviderExists(\Library\HttpRequest $rq) { $result = $this->InitResponseWS(); // Init result $pmSession = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user()); //Check if already list exists in Session $service = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject($this->dataPost(), new \Applications\PMTool\Models\Dao\Service()); if (!array_key_exists(\Library\Enums\SessionKeys::PmServices, $pmSession)) { //No, we have to query db and then populate the list into Session $manager = $this->managers->getManagerOf($this->module()); $allServiceProviders = $manager->selectMany($service, "", true); $pmSession[\Library\Enums\SessionKeys::PmServices] = $allServiceProviders; \Applications\PMTool\Helpers\PmHelper::SetSessionPm($this->user(), $pmSession); } //Now check if Service provider already exists $match = \Applications\PMTool\Helpers\CommonHelper::FindObjectByStringValue($service->service_name(), "service_name", $pmSession[\Library\Enums\SessionKeys::PmServices]); $result['record_count'] = !$match || empty($match) ? 0 : 1; //While editing, check if comparing with self if (!empty($match) && $service->service_id() !== '') { if ($match->service_id() == $service->service_id()) { $result['record_count'] = 0; } } $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Service, "resx_key" => $this->action(), "step" => $result['record_count'] > 0 ? "success" : "error")); }
public function executeIfAllLocationsExist(\Library\HttpRequest $rq) { $result = $this->InitResponseWS(); // Init result //get current project $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user()); //get locations of the current project $sessionLocations = $sessionProject[\Library\Enums\SessionKeys::ProjectLocations]; $postData = $this->dataPost(); $location_names = \Applications\PMTool\Helpers\CommonHelper::StringToArray("\n", $postData["location_names"]); //Loop on the names $redundantLocs = array(); foreach ($location_names as $the_locname) { $location = \Applications\PMTool\Helpers\CommonHelper::PrepareUserObject(array('location_name' => $the_locname), new \Applications\PMTool\Models\Dao\Location()); $match = \Applications\PMTool\Helpers\CommonHelper::FindObjectByStringValue($location->location_name(), "location_name", $sessionLocations); if ($match && !empty($match)) { array_push($redundantLocs, $the_locname); } } $result['record_count'] = empty($redundantLocs) ? 0 : count($redundantLocs); $result['duplicate_locations'] = $redundantLocs; $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Location, "resx_key" => $this->action(), "step" => $result['record_count'] > 0 ? "success" : "error")); }
private function GetTableName($object) { return \Applications\PMTool\Helpers\CommonHelper::GetShortClassName($object); }
private static function _PrepareManyLocationObjects($dataPost, $isAddingTaskLocations = FALSE) { $locations = array(); if ($isAddingTaskLocations) { $data = (array) $dataPost["userData"]; $dataPost["active"] = array_key_exists("active", $data) ? $data["active"] : "0"; $location_names = \Applications\PMTool\Helpers\CommonHelper::StringToArray("\n", $data["names"]); } else { $location_names = \Applications\PMTool\Helpers\CommonHelper::StringToArray("\n", $dataPost["names"]); } foreach ($location_names as $name) { $location = new \Applications\PMTool\Models\Dao\Location(); $location->setProject_id($dataPost["project_id"]); //Check if the $name could be split on "tab" //If yes, we may assume the columns are name, //lat and long and prepare dao accordingly $loc_data = \Applications\PMTool\Helpers\CommonHelper::StringToArray("\t", $name); if (count($loc_data) > 1) { // lat, long $location->setLocation_lat($loc_data[1]); $location->setLocation_long($loc_data[2]); } //name $location->setLocation_name($loc_data[0]); $location->setLocation_active($dataPost["active"]); if (isset($dataPost["visible"])) { $location->setLocation_visible($dataPost["visible"]); } else { $location->setLocation_visible(""); } array_push($locations, $location); } return $locations; }
private static function _PrepareManyCommonAnalyteObjects($dataPost, $isFieldType = TRUE) { $analytes = array(); if (preg_match("`^.*,*\$`", $dataPost["names"])) { $analyte_names = \Applications\PMTool\Helpers\CommonHelper::StringToArray(",", $dataPost["names"]); } else { $analyte_names = \Applications\PMTool\Helpers\CommonHelper::StringToArray("\n", $dataPost["names"]); } foreach ($analyte_names as $name) { $analyte = $isFieldType ? new \Applications\PMTool\Models\Dao\Common_field_analyte() : new \Applications\PMTool\Models\Dao\Common_lab_analyte(); if ($isFieldType) { $analyte->setCommon_field_analyte_name($name); } else { $analyte->setCommon_lab_analyte_name($name); $analyte->setCommon_lab_analyte_category_name($name); } array_push($analytes, $analyte); } return $analytes; }
/** * <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")); }
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; }