public static function RefreshProjectObjectsForCurrentPm($caller) { $pm = PmHelper::GetCurrentSessionPm($caller->user()); $projectObj = new \Applications\PMTool\Models\Dao\Project(); $projectObj->setPm_id($pm[\Library\Enums\SessionKeys::PmObject]->pm_id()); $dal = $caller->managers()->getManagerOf("Project"); $projects = $dal->selectMany($projectObj, "pm_id"); $sessionProjects = self::GetSessionProjects($caller->user()); foreach ($projects as $project) { $key = \Library\Enums\SessionKeys::ProjectKey . $project->project_id(); if (array_key_exists($key, $sessionProjects)) { $sessionProjects[$key][\Library\Enums\SessionKeys::ProjectObject] = $project; } else { throw new \Exception(__CLASS__ . '::' . __METHOD__ . " => key not found in SessionProjects (" . $key . ")"); } } self::SetSessionProjects($caller->user(), $sessionProjects); }
/** * Method that get a project and returns the result of operation * * @param \Library\HttpRequest $rq * @return JSON */ public function executeSetCurrentProject(\Library\HttpRequest $rq) { $result = $this->InitResponseWS(); // Init result $manager = $this->managers()->getManagerOf('Project'); $projectEdit = new \Applications\PMTool\Models\Dao\Project(); $pm = $this->user->getAttribute(\Library\Enums\SessionKeys::CurrentPm); $pm = $pm[\Library\Enums\SessionKeys::PmObject]; $pm_id = $pm->pm_id(); $projectEdit->setPm_id($pm_id); $projectEdit->setProject_is_default(0); if (!$manager->edit($projectEdit, 'pm_id')) { throw new \Exception(__CLASS__ . "->" . __METHOD__ . " => Project Edit failed for PM ID=" . $pm_id); } $project_id = $this->dataPost["project_id"]; $projectEdit->setProject_id($project_id); $projectEdit->setProject_is_default(1); if (!$manager->edit($projectEdit, 'project_id')) { throw new \Exception(__CLASS__ . "->" . __METHOD__ . " => Project Edit failed for Project ID=" . $project_id); } else { \Applications\PMTool\Helpers\ProjectHelper::RefreshProjectObjectsForCurrentPm($this); } $project = \Applications\PMTool\Helpers\ProjectHelper::GetAndStoreCurrentProject($this->user(), $project_id); $result["dataId"] = $project->project_id(); \Applications\PMTool\Helpers\TaskHelper::UnsetCurrentSessionTask($this->user()); $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Project, "resx_key" => $this->action(), "step" => $project != NULL ? "success" : "error")); }
public function executeListTasks(\Library\HttpRequest $rq) { $modules = $this->app()->router()->selectedRoute()->phpModules(); \Applications\PMTool\Helpers\DiscussionHelper::UnsetCurrentDiscussion($this->user()); $technician = $this->user()->getAttribute(\Library\Enums\SessionKeys::UserTypeObject); $project = new \Applications\PMTool\Models\Dao\Project(); $project->setPm_id($technician->pm_id()); //Load interface to query the database for projects $manager = $this->managers->getManagerOf('Project'); $lists[\Library\Enums\SessionKeys::UserProjects] = $manager->selectMany($project, "pm_id"); //Load interface to query the database for facilities $manager = $this->managers->getManagerOf('Facility'); $lists[\Library\Enums\SessionKeys::UserProjectFacilityList] = $manager->selectMany($project, "pm_id"); //Load interface to query the database for clients $manager = $this->managers->getManagerOf('Client'); $lists[\Library\Enums\SessionKeys::UserProjectClientList] = $manager->selectMany($project, "pm_id"); //SessionPM $manager = $this->managers->getManagerOf('Pm'); $pm = new \Applications\PMTool\Models\Dao\Project_manager(); $pm->setPm_id($technician->pm_id()); $pms = $manager->selectMany($pm, 'pm_id'); \Applications\PMTool\Helpers\PmHelper::StoreSessionPm($this, $pms[0], true); $ProjectsSession = \Applications\PMTool\Helpers\ProjectHelper::StoreSessionProjects($this, $lists); \Applications\PMTool\Helpers\TaskHelper::GetTasksForTechnician($this, $technician); $tasks = \Applications\PMTool\Helpers\TaskHelper::GetSessionTasks($this->user()); if (!is_array($tasks)) { $tasks = array(); } $task_id = $rq->getData("task_id"); $data = array(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::module => 'task', \Applications\PMTool\Resources\Enums\ViewVariablesKeys::objects => \Applications\PMTool\Helpers\CommonHelper::GetObjectListFromSessionArrayBySessionKey($tasks, \Library\Enums\SessionKeys::TaskObj), \Applications\PMTool\Resources\Enums\ViewVariablesKeys::properties => \Applications\PMTool\Helpers\CommonHelper::SetPropertyNamesForDualList(strtolower('task'))); $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::data, $data); $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user()); if ($sessionTask) { \Applications\PMTool\Helpers\ProjectHelper::GetAndStoreCurrentProject($this->user(), $sessionTask[\Library\Enums\SessionKeys::TaskObj]->project_id()); } else { $this->user()->unsetAttribute(\Library\Enums\SessionKeys::CurrentProject); } if (count($tasks) == 1) { $firstTask = reset($tasks); $task_id = $firstTask[\Library\Enums\SessionKeys::TaskObj]->task_id(); } //Set passed task as current task if ($task_id !== '' && !is_null($task_id)) { $sessionTask = \Applications\PMTool\Helpers\TaskHelper::SetCurrentSessionTask($this->user(), NULL, $task_id); $taskObj = $sessionTask[\Library\Enums\SessionKeys::TaskObj]; $manager = $this->managers()->getManagerOf('Project'); $project = new \Applications\PMTool\Models\Dao\Project(); $project->setProject_id($taskObj->project_id()); $projects = $manager->selectMany($project, 'project_id'); if ($projects) { \Applications\PMTool\Helpers\ProjectHelper::GetAndStoreCurrentProject($this->user(), $taskObj->project_id()); } //check if we passed a redirect URL too if ($rq->getData("onSuccess") !== '' && !is_null($rq->getData("onSuccess"))) { //rediect to it $this->Redirect($rq->getData("onSuccess")); } } $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->user); if (count($tasks) == 1) { $this->Redirect(\Library\Enums\ResourceKeys\UrlKeys::MobileMap); } $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentTask, $sessionTask[\Library\Enums\SessionKeys::TaskObj]); //Fetch tooltip data from xml and pass to view as an array $tooltip_array = \Applications\PMTool\Helpers\PopUpHelper::getTooltipMsgForAttribute('{"targetcontroller":"task", "targetaction": "list", "targetattr": ["active-task-header","inactive-task-header"]}', $this->app->name()); $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::tooltip_message, $tooltip_array); //Get confirm msg for project deletion from context menu $confirm_msg = \Applications\PMTool\Helpers\PopUpHelper::getConfirmBoxMsg('{"targetcontroller":"task", "targetaction": "list", "operation": ["activate","addUniqueCheck"]}', $this->app->name()); $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::confirm_message, $confirm_msg); //Fetch prompt box data from xml and pass to view as an array //Also let's just fetch the message for the showForm view and reuse it $prompt_msg = \Applications\PMTool\Helpers\PopUpHelper::getPromptBoxMsg('{"targetcontroller":"task", "targetaction": "view", "operation": ["addNullCheck","addNullCheckForCopy"]}', $this->app->name()); $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::prompt_message, $prompt_msg); $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\ViewVariables\Popup::popup_msg, $modules[\Applications\PMTool\Resources\Enums\PhpModuleKeys::popup_msg]); $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::prompt_msg, $modules[\Applications\PMTool\Resources\Enums\PhpModuleKeys::popup_prompt]); $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariables\Popup::tooltip_message_module, $modules[\Applications\PMTool\Resources\Enums\PhpModuleKeys::tooltip_msg]); $this->page->addVar(\Applications\PMTool\Resources\Enums\ViewVariablesKeys::currentProject, $sessionProject[\Library\Enums\SessionKeys::ProjectObject]); }