/** * Called after the check that all required registry values * have been set correctly has run. * * @return void * / public function afterRegistry() { parent::afterRegistry(); } /** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { if (!$this->importModel instanceof \MUtil_Model_ModelAbstract) { $surveyId = $this->request->getParam(\MUtil_Model::REQUEST_ID); if ($surveyId) { $this->formData['survey'] = $surveyId; $this->_survey = $this->loader->getTracker()->getSurvey($surveyId); $surveys[$surveyId] = $this->_survey->getName(); $elementClass = 'Exhibitor'; $tracks = $this->util->getTranslated()->getEmptyDropdownArray() + $this->util->getTrackData()->getTracksBySurvey($surveyId); } else { $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $trackData = $this->util->getTrackData(); $surveys = $empty + $trackData->getActiveSurveys(); $tracks = $empty + $trackData->getAllTracks(); $elementClass = 'Select'; } parent::createModel(); $order = $this->importModel->getOrder('trans') - 5; $this->importModel->set('survey', 'label', $this->_('Survey'), 'elementClass', $elementClass, 'multiOptions', $surveys, 'onchange', 'this.form.submit();', 'order', $order, 'required', true); $this->importModel->set('track', 'label', $this->_('Track'), 'description', $this->_('Optionally assign answers only within a single track'), 'multiOptions', $tracks); $this->importModel->set('skipUnknownPatients', 'label', $this->_('Skip unknowns'), 'default', 0, 'description', $this->_('What to do when the respondent does not exist'), 'elementClass', 'Checkbox', 'multiOptions', $this->util->getTranslated()->getYesNo()); $tokenCompleted = array(\Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_OVERWRITE => $this->_('Delete old token and create new'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_DOUBLE => $this->_('Create new extra set of answers'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR => $this->_('Abort the import'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_SKIP => $this->_('Skip the token')); $this->importModel->set('tokenCompleted', 'label', $this->_('When token completed'), 'default', \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR, 'description', $this->_('What to do when an imported token has already been completed'), 'elementClass', 'Radio', 'multiOptions', $tokenCompleted); $tokenTreatments = array(\Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR => $this->_('Abort the import'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_SKIP => $this->_('Skip the token')); $this->importModel->set('noToken', 'label', $this->_('Token does not exist'), 'default', \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR, 'description', $this->_('What to do when no token exist to import to'), 'elementClass', 'Radio', 'multiOptions', $tokenTreatments); if (\MUtil_Bootstrap::enabled()) { $this->importModel->set('tokenCompleted', 'separator', ''); } else { $this->importModel->set('trans', 'separator', '<br/>'); } } return $this->importModel; }
public function __construct(\Gems_Tracker_Survey $survey, \Gems_Tracker_Source_SourceInterface $source) { parent::__construct($survey->getName(), 'gems__tokens', 'gto'); $this->addTable('gems__reception_codes', array('gto_reception_code' => 'grc_id_reception_code')); $this->addColumn('CASE WHEN grc_success = 1 AND gto_valid_from <= CURRENT_TIMESTAMP AND gto_completion_time IS NULL AND (gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP) THEN 1 ELSE 0 END', 'can_be_taken'); $this->addColumn("CASE WHEN grc_success = 1 THEN '' ELSE 'deleted' END", 'row_class'); $this->source = $source; $this->survey = $survey; $this->addAnswersToModel(); }
public function __construct(\Gems_Tracker_Survey $survey, \Gems_Tracker_Source_SourceInterface $source) { parent::__construct($survey->getName(), 'gems__tokens', 'gto'); $this->addTable('gems__reception_codes', array('gto_reception_code' => 'grc_id_reception_code')); // Add relations $this->addLeftTable('gems__track_fields', array('gto_id_relationfield' => 'gtf_id_field', 'gtf_field_type = "relation"')); // Add relation fields $this->addLeftTable('gems__respondent_relations', array('gto_id_relation' => 'grr_id', 'gto_id_respondent' => 'grr_id_respondent')); // Add relation $this->set('grr_name', 'column_expression', new Zend_Db_Expr('CONCAT_WS(" ", gems__respondent_relations.grr_first_name, gems__respondent_relations.grr_last_name)')); $this->addColumn('CASE WHEN grc_success = 1 AND gto_valid_from <= CURRENT_TIMESTAMP AND gto_completion_time IS NULL AND (gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP) THEN 1 ELSE 0 END', 'can_be_taken'); $this->addColumn("CASE WHEN grc_success = 1 THEN '' ELSE 'deleted' END", 'row_class'); $this->source = $source; $this->survey = $survey; $this->addAnswersToModel(); }
/** * Create the snippets content * * This is a stub function either override getHtmlOutput() or override render() * * @param \Zend_View_Abstract $view Just in case it is needed here * @return \MUtil_Html_HtmlInterface Something that can be rendered */ public function getHtmlOutput(\Zend_View_Abstract $view) { $div = \MUtil_Html::create('div'); if ($this->surveyId && $this->data) { $div->h3(sprintf($this->_('Questions in survey %s'), $this->survey->getName())); $div->append(parent::getHtmlOutput($view)); } else { $this->addMessage($this->_('Survey not found')); if ($this->surveyId) { $div->pInfo(sprintf($this->_('Survey %s does not exist.'), $this->surveyId)); } else { $div->pInfo($this->_('Survey not specified.')); } } $item = $this->menu->getCurrentParent(); if ($item) { $div->append($item->toActionLink($this->_('Cancel'), $this->request)); } return $div; }