/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { if ($this->respondent instanceof \Gems_Tracker_Respondent) { if (!$this->patientId) { $this->patientId = $this->respondent->getPatientNumber(); } if (!$this->organizationId) { $this->organizationId = $this->respondent->getOrganizationId(); } } // Try to get $this->respondentTrackId filled if (!$this->respondentTrackId) { if ($this->respondentTrack) { $this->respondentTrackId = $this->respondentTrack->getRespondentTrackId(); } else { $this->respondentTrackId = $this->request->getParam(\Gems_Model::RESPONDENT_TRACK); } } // Try to get $this->respondentTrack filled if ($this->respondentTrackId && !$this->respondentTrack) { $this->respondentTrack = $this->loader->getTracker()->getRespondentTrack($this->respondentTrackId); } // Set the user id if (!$this->userId) { $this->userId = $this->loader->getCurrentUser()->getUserId(); } if ($this->respondentTrack) { // We are updating $this->createData = false; // Try to get $this->trackEngine filled if (!$this->trackEngine) { // Set the engine used $this->trackEngine = $this->respondentTrack->getTrackEngine(); } } else { // We are inserting $this->createData = true; $this->saveLabel = $this->_($this->_('Add track')); // Try to get $this->trackId filled if (!$this->trackId) { if ($this->trackEngine) { $this->trackId = $this->trackEngine->getTrackId(); } else { $this->trackId = $this->request->getParam(\Gems_Model::TRACK_ID); } } // Try to get $this->trackEngine filled if ($this->trackId && !$this->trackEngine) { $this->trackEngine = $this->loader->getTracker()->getTrackEngine($this->trackId); } if (!($this->trackEngine && $this->patientId && $this->organizationId && $this->userId)) { throw new \Gems_Exception_Coding('Missing parameter for ' . __CLASS__ . ': could not find data for editing a respondent track nor the track engine, patientId and organizationId needed for creating one.'); } } return parent::hasHtmlOutput(); }
/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { if (!$this->trackId) { if (isset($this->trackData['gtr_id_track'])) { $this->trackId = $this->trackData['gtr_id_track']; } elseif ($this->trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) { $this->trackId = $this->trackEngine->getTrackId(); } } if (!$this->trackName) { if (isset($this->trackData['gtr_track_name'])) { $this->trackName = $this->trackData['gtr_track_name']; } elseif ($this->trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) { $this->trackName = $this->trackEngine->getTrackName(); } } return (bool) $this->trackName && parent::hasHtmlOutput(); }
/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { if ($this->trackEngine && !$this->trackId) { $this->trackId = $this->trackEngine->getTrackId(); } if ($this->trackId) { // Try to get $this->trackEngine filled if (!$this->trackEngine) { // Set the engine used $this->trackEngine = $this->loader->getTracker()->getTrackEngine($this->trackId); } } else { return false; } if (!$this->roundId) { $this->roundId = $this->request->getParam(\Gems_Model::ROUND_ID); } return $this->roundId && parent::hasHtmlOutput(); }
/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { if ($this->trackEngine && !$this->trackId) { $this->trackId = $this->trackEngine->getTrackId(); } if ($this->trackId) { // We are updating $this->createData = false; // Try to get $this->trackEngine filled if (!$this->trackEngine) { // Set the engine used $this->trackEngine = $this->loader->getTracker()->getTrackEngine($this->trackId); } } else { // We are inserting $this->createData = true; $this->saveLabel = $this->_($this->_('Add new track')); } return parent::hasHtmlOutput(); }
/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { if (!$this->multiTracks) { return false; } if (!$this->trackData) { if (!$this->trackId) { if ($this->trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) { $this->trackId = $this->trackEngine->getTrackId(); } else { return false; } } $trackModel = new \MUtil_Model_TableModel('gems__tracks'); $this->trackData = $trackModel->loadFirst(array('gtr_id_track' => $this->trackId)); } elseif (!$this->trackId) { $this->trackId = $this->trackData['gtr_id_track']; } return parent::hasHtmlOutput(); }
/** * * @return \Gems_Task_TaskRunnerBatch */ protected function getExportBatch($load = true) { if ($this->_batch) { return $this->_batch; } $this->_batch = $this->loader->getTaskRunnerBatch('track_export_' . $this->trackEngine->getTrackId()); if (!$load || $this->_batch->isFinished()) { return $this->_batch; } if (!$this->_batch->isLoaded()) { $filename = \MUtil_File::createTemporaryIn(GEMS_ROOT_DIR . '/var/tmp/export/track'); $trackId = $this->trackEngine->getTrackId(); $this->_batch->setSessionVariable('filename', $filename); $this->_batch->addTask('Tracker\\Export\\ProjectVersionExportTask'); $this->_batch->addTask('Tracker\\Export\\MainTrackExportTask', $this->trackEngine->getTrackId(), $this->formData['orgs']); if (isset($this->formData['fields']) && is_array($this->formData['fields'])) { // \MUtil_Echo::track($this->formData['fields']); foreach ($this->formData['fields'] as $fieldId) { $this->_batch->addTask('Tracker\\Export\\TrackFieldExportTask', $trackId, $fieldId); } } $model = $this->getModel(); foreach ($model->getCol('surveyId') as $surveyId) { $this->_batch->addTask('Tracker\\Export\\TrackSurveyExportTask', $trackId, $surveyId); } if (isset($this->formData['rounds']) && is_array($this->formData['rounds'])) { foreach ($this->formData['rounds'] as $roundId) { $this->_batch->addTask('Tracker\\Export\\TrackRoundExportTask', $trackId, $roundId); } } } else { $filename = $this->_batch->getSessionVariable('filename'); } $this->_batch->setVariable('file', fopen($filename, 'a')); return $this->_batch; }
/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { // Apply translations if (!$this->showAnswersTranslated) { // Here, not in e.g. __construct as these vars may be set during initiation $this->showAnswersNone = $this->_($this->showAnswersNone); $this->showAnswersRemoved = $this->_($this->showAnswersRemoved); $this->showAnswersSeparator = $this->_($this->showAnswersSeparator); $this->showAnswersTranslated = true; } // Overrule any setting of these values from source $this->data = null; $this->repeater = null; if (!$this->surveyId) { if ($this->token instanceof \Gems_Tracker_Token && $this->token->exists) { $this->surveyId = $this->token->getSurveyId(); } elseif ($this->trackData && !$this->trackId) { // Look up key values from trackData if (isset($this->trackData['gsu_id_survey'])) { $this->surveyId = $this->trackData['gsu_id_survey']; } elseif (isset($this->trackData['gro_id_survey'])) { $this->surveyId = $this->trackData['gro_id_survey']; } elseif (!$this->trackId) { if (isset($this->trackData['gtr_id_track'])) { $this->trackId = $this->trackData['gtr_id_track']; } elseif (isset($this->trackData['gro_id_track'])) { $this->trackId = $this->trackData['gro_id_track']; } } } if (!$this->trackId && $this->trackEngine) { $this->trackId = $this->trackEngine->getTrackId(); } if ($this->trackId && !$this->surveyId) { // Use the track ID to get the id of the first active survey $this->surveyId = $this->db->fetchOne('SELECT gro_id_survey FROM gems__rounds WHERE gro_active = 1 AND gro_id_track = ? ORDER BY gro_id_order', $this->trackId); } } // \MUtil_Echo::track($this->surveyId, $this->trackId); // Get the survey if ($this->surveyId && !$this->survey instanceof \Gems_Tracker_Survey) { $this->survey = $this->loader->getTracker()->getSurvey($this->surveyId); } // Load the data if ($this->survey instanceof \Gems_Tracker_Survey && $this->survey->exists) { $this->data = \MUtil_Ra::addKey($this->survey->getQuestionInformation($this->locale->getLanguage()), 'key'); //\MUtil_Echo::track($this->data); } return parent::hasHtmlOutput(); }
/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { if (!$this->multiTracks) { return false; } $this->tracker = $this->loader->getTracker(); if (!$this->respondentTrackId) { $this->respondentTrackId = $this->request->getParam(\Gems_Model::RESPONDENT_TRACK); } if ($this->respondentTrackId) { if (!$this->respondentTrack instanceof \Gems_Tracker_RespondentTrack) { $this->respondentTrack = $this->tracker->getRespondentTrack($this->respondentTrackId); } } if ($this->respondentTrack instanceof \Gems_Tracker_RespondentTrack) { if (!$this->respondentTrackId) { $this->respondentTrackId = $this->respondentTrack->getRespondentTrackId(); } $this->trackId = $this->respondentTrack->getTrackId(); if (!$this->respondentId) { $this->respondentId = $this->respondentTrack->getRespondentId(); } if (!$this->organizationId) { $this->organizationId = $this->respondentTrack->getOrganizationId(); } $this->caption = $this->_('Other assignments of this track to this respondent.'); $this->onEmpty = $this->_('This track is assigned only once to this respondent.'); } else { if ($this->respondent instanceof \Gems_Tracker_Respondent) { if (!$this->respondentId) { $this->respondentId = $this->respondent->getId(); } if (!$this->organizationId) { $this->organizationId = $this->respondent->getOrganizationId(); } } $this->caption = $this->_('Existing assignments of this track to this respondent.'); $this->onEmpty = $this->_('This track is not assigned to this respondent.'); } if (!$this->trackId) { $this->trackId = $this->request->getParam(\Gems_Model::TRACK_ID); } if (!$this->trackId && $this->trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) { $this->trackId = $this->trackEngine->getTrackId(); } return $this->trackId && $this->respondentId && $this->organizationId && parent::hasHtmlOutput(); }
/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { // Try to set $this->respondentTrackId, it can be ok when not set if (!$this->respondentTrackId) { if ($this->respondentTrack) { $this->respondentTrackId = $this->respondentTrack->getRespondentTrackId(); } else { $this->respondentTrackId = $this->request->getParam(\Gems_Model::RESPONDENT_TRACK); } } // First attempt at trackId if (!$this->trackId && $this->trackEngine) { $this->trackId = $this->trackEngine->getTrackId(); } // Check if a sufficient set of data is there if (!($this->trackId || $this->patientId || $this->organizationId)) { // Now we really need $this->respondentTrack if (!$this->respondentTrack) { if ($this->respondentTrackId) { $this->respondentTrack = $this->loader->getTracker()->getRespondentTrack($this->respondentTrackId); } else { // Parameters not valid return false; } } } if (!$this->trackId) { $this->trackId = $this->respondentTrack->getTrackId(); } if (!$this->patientId) { $this->patientId = $this->respondentTrack->getPatientNumber(); } if (!$this->organizationId) { $this->organizationId = $this->respondentTrack->getOrganizationId(); } // \MUtil_Echo::track($this->trackId, $this->patientId, $this->organizationId, $this->respondentTrackId); return $this->getModel()->loadFirst() && parent::hasHtmlOutput(); }