/**
  * form elements for extra options for this particular export option
  * @param  \MUtil_Form $form Current form to add the form elements
  * @param  array $data current options set in the form
  * @return array Form elements
  */
 public function getFormElements(&$form, &$data)
 {
     $element = $form->createElement('multiCheckbox', 'format');
     $element->setLabel($this->_('Excel options'))->setMultiOptions(array('formatVariable' => $this->_('Export questions instead of variable names'), 'formatAnswer' => $this->_('Format answers')));
     $elements[] = $element;
     return $elements;
 }
 /**
  * form elements for extra options for this particular export option
  * @param  \MUtil_Form $form Current form to add the form elements
  * @param  array $data current options set in the form
  * @return array Form elements
  */
 public function getFormElements(&$form, &$data)
 {
     $element = $form->createElement('multiCheckbox', 'format');
     $element->setLabel($this->_('Excel options'))->setMultiOptions(array('formatVariable' => $this->_('Export labels instead of field names'), 'formatAnswer' => $this->_('Format answers')))->setBelongsTo($this->getName())->setSeparator('');
     $elements['format'] = $element;
     return $elements;
 }
 /**
  * form elements for extra options for this particular export option
  * @param  \MUtil_Form $form Current form to add the form elements
  * @param  array $data current options set in the form
  * @return array Form elements
  */
 public function getFormElements(&$form, &$data)
 {
     $element = $form->createElement('multiCheckbox', 'format');
     $element->setLabel($this->_('CSV options'))->setMultiOptions(array('addHeader' => $this->_('Add headers with column names'), 'formatVariable' => $this->_('Export labels instead of field names'), 'formatAnswer' => $this->_('Format answers')))->setBelongsTo($this->getName());
     $elements['format'] = $element;
     $element = $form->createElement('select', 'delimiter');
     $element->setLabel($this->_('Delimiter'))->setMultiOptions(array(',' => ',', ';' => ';'))->setBelongsTo($this->getName());
     $elements['delimiter'] = $element;
     return $elements;
 }
 protected function getAutoSearchSubmit(\MUtil_Model_ModelAbstract $model, \MUtil_Form $form)
 {
     return $form->createElement('submit', self::SEARCH_BUTTON, array('label' => $this->_('Search'), 'class' => 'button small'));
     //return new \Zend_Form_Element_Submit(self::SEARCH_BUTTON, array('label' => $this->_('Search'), 'class' => 'button small'));
 }
Example #5
0
 /**
  * Add a new element
  *
  * $element may be either a string element type, or an object of type
  * \Zend_Form_Element. If a string element type is provided, $name must be
  * provided, and $options may be optionally provided for configuring the
  * element.
  *
  * If a \Zend_Form_Element is provided, $name may be optionally provided,
  * and any provided $options will be ignored.
  *
  * @param  string|\Zend_Form_Element $element
  * @param  string $name
  * @param  array|\Zend_Config $options
  * @throws \Zend_Form_Exception on invalid element
  * @return \Zend_Form (continuation pattern)
  */
 public function addElement($element, $name = null, $options = null)
 {
     parent::addElement($element, $name, $options);
     if ($this->isAutoSubmit()) {
         if (null !== $name) {
             $element = $this->getElement($name);
         }
         $this->_enableAutoSubmitElement($element);
     }
     return $this;
 }
 /**
  * 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()
 {
     $sql = "SELECT COALESCE(gto_round_description, '') AS label,\n                        SUM(\n                            CASE\n                            WHEN gto_completion_time IS NOT NULL\n                            THEN 1\n                            ELSE 0\n                            END\n                        ) AS completed,\n                        SUM(\n                            CASE\n                            WHEN gto_completion_time IS NULL AND\n                                gto_valid_from < CURRENT_TIMESTAMP AND\n                                (gto_valid_until > CURRENT_TIMESTAMP OR gto_valid_until IS NULL)\n                            THEN 1\n                            ELSE 0\n                            END\n                        ) AS waiting,\n                        COUNT(*) AS any\n                    FROM gems__tokens INNER JOIN\n                        gems__surveys ON gto_id_survey = gsu_id_survey INNER JOIN\n                        gems__rounds ON gto_id_round = gro_id_round INNER JOIN\n                        gems__respondent2track ON gto_id_respondent_track = gr2t_id_respondent_track INNER JOIN\n                        gems__reception_codes AS rcto ON gto_reception_code = rcto.grc_id_reception_code INNER JOIN\n                        gems__reception_codes AS rctr ON gr2t_reception_code = rctr.grc_id_reception_code\n                    WHERE gto_id_respondent = ? AND\n                        gro_active = 1 AND\n                        gsu_active = 1 AND\n                        rcto.grc_success = 1 AND\n                        rctr.grc_success = 1\n                    GROUP BY COALESCE(gto_round_description, '')\n                    ORDER BY MIN(COALESCE(gto_round_order, 100000)), gto_round_description";
     // \MUtil_Echo::track($this->respondentId);
     $tabLabels = $this->db->fetchAll($sql, $this->respondentId);
     if ($tabLabels) {
         $default = null;
         $filters = array();
         $noOpen = true;
         $tabs = array();
         foreach ($tabLabels as $row) {
             $name = '_' . \MUtil_Form::normalizeName($row['label']);
             $label = $row['label'] ? $row['label'] : $this->_('empty');
             if ($row['waiting']) {
                 $label = sprintf($this->_('%s (%d open)'), $label, $row['waiting']);
             } else {
                 $label = $label;
             }
             if (!$row['label']) {
                 $label = \MUtil_Html::create('em', $label);
             }
             $filters[$name] = $row['label'];
             $tabs[$name] = $label;
             if ($noOpen && $row['completed'] > 0) {
                 $default = $name;
             }
             if ($row['waiting'] > 0) {
                 $default = $name;
                 $noOpen = false;
             }
         }
         if (null === $default) {
             reset($filters);
             $default = key($filters);
         }
         // Set the model
         $reqFilter = $this->request->getParam($this->getParameterKey());
         if (!isset($filters[$reqFilter])) {
             $reqFilter = $default;
         }
         if ('' === $filters[$reqFilter]) {
             $this->model->setMeta('tab_filter', array("(gto_round_description IS NULL OR gto_round_description = '')"));
         } else {
             $this->model->setMeta('tab_filter', array('gto_round_description' => $filters[$reqFilter]));
         }
         // \MUtil_Echo::track($tabs, $reqFilter, $default, $tabLabels);
         $this->defaultTab = $default;
         $this->_tabs = $tabs;
     }
     return $this->_tabs && parent::hasHtmlOutput();
 }
 /**
  * Creates an empty form. Allows overruling in sub-classes.
  *
  * @param mixed $options
  * @return \Zend_Form
  */
 protected function createForm($options = null)
 {
     $form = new \MUtil_Form($options);
     if (MUtil_Bootstrap::enabled()) {
         $form->activateBootstrap();
     }
     return $form;
 }