protected function createModel($detailed, $action) { $model = new \Gems_Model_JoinModel('chartconfig', 'gems__chart_config', 'gcc'); $empty = $this->loader->getUtil()->getTranslated()->getEmptyDropdownArray(); $model->set('gcc_tid', 'label', $this->_('Track'), 'multiOptions', $empty + $this->db->fetchPairs('SELECT gtr_id_track, gtr_track_name FROM gems__tracks ORDER BY gtr_track_name;'), 'onchange', 'this.form.submit();'); $model->set('gcc_rid', 'label', $this->_('Round')); $model->set('gcc_sid', 'label', $this->_('Survey'), 'multiOptions', $empty + $this->db->fetchPairs('SELECT gsu_id_survey, gsu_survey_name FROM gems__surveys ORDER BY gsu_survey_name;')); $model->set('gcc_code', 'label', $this->_('Survey code')); $model->set('gcc_description', 'label', $this->_('Description')); $roundStatement = 'SELECT gro_id_round, concat_ws(" ", gro_id_order, gro_survey_name, gro_round_description) FROM gems__rounds ORDER BY gro_id_order;'; if ($detailed) { if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getParams(); if (array_key_exists('gcc_tid', $data) && !empty($data['gcc_tid'])) { $trackId = (int) $data['gcc_tid']; $roundStatement = 'SELECT gro_id_round, concat_ws(" ", gro_id_order, gro_survey_name, gro_round_description) FROM gems__rounds WHERE gro_id_track = ' . $trackId . ' ORDER BY gro_id_order;'; } } $default = '[ { "question_code":[ "SCORE1", "SCORE2" ], "question_text":"DSM scores", "grid":false, "min":25, "max":100, "rulers":[ { "value":60, "class":"negative", "label":"lower" }, { "value":69, "class":"positive", "label":"upper" } ] } ]'; $model->set('gcc_config', 'label', $this->_('Config'), 'elementClass', 'textArea', 'default', $default); if ($action == 'show') { $model->set('gcc_config', 'formatFunction', array($this, 'formatjsonpre')); } $model->setOnLoad('gcc_config', array($this, 'formatjson')); } $model->set('gcc_rid', 'multiOptions', $empty + $this->db->fetchPairs($roundStatement)); return $model; }