/** * 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 executeDelete(\Library\HttpRequest $rq) { // Init result $result = $this->InitResponseWS(); $db_result = FALSE; $technician_id = intval($this->dataPost["technician_id"]); $pm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->app()->user()); //Check if the technician to be deleted is the Project manager's $filter = \Applications\PMTool\Helpers\CommonHelper::FindIndexInObjectListById($technician_id, "technician_id", $pm, \Library\Enums\SessionKeys::PmTechnicians); //Load interface to query the database if ($filter["object"] !== NULL) { $manager = $this->managers->getManagerOf($this->module()); $db_result = $manager->delete($filter["object"], "technician_id"); if ($db_result) { unset($pm[\Library\Enums\SessionKeys::PmTechnicians][$filter["key"]]); \Applications\PMTool\Helpers\PmHelper::SetSessionPm($this->app()->user(), $pm); } } $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Technician, "resx_key" => $this->action(), "step" => $db_result !== FALSE ? "success" : "error")); }
/** * 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")); }
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()); } } }
public function executeDelete(\Library\HttpRequest $rq) { // Init result $result = $this->InitResponseWS(); $pm = \Applications\PMTool\Helpers\PmHelper::GetCurrentSessionPm($this->user()); $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetCurrentSessionProject($this->app()->user()); $sessionTask = \Applications\PMTool\Helpers\TaskHelper::GetCurrentSessionTask($this->user()); $db_result = FALSE; $form_id = intval($this->dataPost["form_id"]); if ($this->dataPost["form_type"] == "user_form") { //Check if the service to be deleted is the Project manager's $form_selected = \Applications\PMTool\Helpers\FormHelper::GetAUserForm($this->user(), $form_id); //Load interface to query the database if ($form_selected !== NULL) { $manager = $this->managers->getManagerOf("UserForm"); $manager->setRootDirectory($this->app()->config()->get(\Library\Enums\AppSettingKeys::RootDocumentUpload)); $manager->setWebDirectory($this->app()->config()->get(\Library\Enums\AppSettingKeys::BaseUrl) . $this->app()->config()->get(\Library\Enums\AppSettingKeys::RootUploadsFolderPath)); $db_result = $manager->deleteWithFile($form_selected, "form_id"); if ($db_result) { //since we don't have foreign keys set because this is a relationship between 3 tables we must manually delete all project_form records, we also need to manually remove task forms //remove project forms from session $relationProjectForms = \Applications\PMTool\Helpers\FormHelper::GetProjectForms($this, $sessionProject); $filteredProjectForms = \Applications\PMTool\Helpers\FormHelper::FilterFormsByGivenId($relationProjectForms, 'user_form_id', $form_id); $sessionProject[\Library\Enums\SessionKeys::ProjectForms] = $filteredProjectForms; if ($sessionTask !== FALSE) { $relationTaskForms = \Applications\PMTool\Helpers\FormHelper::GetTaskForms($this, $sessionTask); $filteredTaskForms = \Applications\PMTool\Helpers\FormHelper::FilterFormsByGivenId($relationTaskForms, 'user_form_id', $form_id); $sessionTask[\Library\Enums\SessionKeys::TaskForms] = $filteredTaskForms; \Applications\PMTool\Helpers\TaskHelper::SetCurrentSessionTask($this->user(), $sessionTask); } //delete from db $projectForm = new \Applications\PMTool\Models\Dao\Project_form(); $projectForm->setUser_form_id($form_id); $manager = $this->managers->getManagerOf("ProjectForm"); $manager->delete($projectForm, "user_form_id"); $taskForm = new \Applications\PMTool\Models\Dao\Task_template_form(); $taskForm->setUser_form_id($form_id); $manager = $this->managers->getManagerOf("TaskForm"); $manager->delete($taskForm, "user_form_id"); //remove user forms from session $match = \Applications\PMTool\Helpers\CommonHelper::FindIndexInObjectListById($form_selected->form_id(), "form_id", $sessionProject[\Library\Enums\SessionKeys::ProjectAvailableForms], \Library\Enums\SessionKeys::ProjectUserForms); unset($sessionProject[\Library\Enums\SessionKeys::ProjectAvailableForms][\Library\Enums\SessionKeys::ProjectUserForms][$match["key"]]); \Applications\PMTool\Helpers\ProjectHelper::SetCurrentSessionProject($this->user(), $sessionProject); } } } elseif ($this->dataPost["form_type"] == "master_form") { //delete from db //Project form $projectForm = new \Applications\PMTool\Models\Dao\Project_form(); $projectForm->setMaster_form_id($form_id); $manager = $this->managers->getManagerOf("ProjectForm"); $manager->delete($projectForm, "master_form_id"); //Task template form $taskForm = new \Applications\PMTool\Models\Dao\Task_template_form(); $taskForm->setMaster_form_id($form_id); $manager = $this->managers->getManagerOf("TaskForm"); $manager->delete($taskForm, "master_form_id"); //Now for the master form $masterFormDAO = new \Applications\PMTool\Models\Dao\Master_form(); $masterFormDAO->setForm_id($form_id); $dal = $this->managers()->getManagerOf("MasterForm"); $matchingForms = $dal->selectMany($masterFormDAO, "form_id"); $db_result = $dal->deleteWithFileV2($matchingForms[0], "form_id"); } $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Form, "resx_key" => $this->action(), "step" => $db_result !== FALSE ? "success" : "error")); }