/**
  * Returns a text element for autosearch. Can be overruled.
  *
  * The form / html elements to search on. Elements can be grouped by inserting null's between them.
  * That creates a distinct group of elements
  *
  * @param array $data The $form field values (can be usefull, but no need to set them)
  * @return array Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks.
  */
 protected function getAutoSearchElements(array $data)
 {
     $elements = parent::getAutoSearchElements($data);
     $orgs = $this->currentUser->getRespondentOrganizations();
     if (count($orgs) > 1) {
         $elements[] = $this->_createSelectElement('gap_id_organization', $orgs, $this->_('(all organizations)'));
     }
     $locations = $this->loader->getAgenda()->getLocations();
     if (count($locations) > 1) {
         $elements[] = $this->_createSelectElement('gap_id_location', $locations, $this->_('(all locations)'));
     }
     $elements[] = null;
     $this->_addPeriodSelectors($elements, 'gap_admission_time');
     return $elements;
 }
 /**
  * Returns the default search values for this class instance.
  *
  * Used to specify the filter when no values have been entered by the user.
  *
  * @return array
  */
 public function getDefaultSearchData()
 {
     if ($this->getModel()->isMultiOrganization()) {
         $orgId = $this->currentUser->getCurrentOrganizationId();
         $orgs = $this->currentUser->getRespondentOrganizations();
         if (isset($orgs[$orgId])) {
             return array(\MUtil_Model::REQUEST_ID2 => $orgId);
         }
     }
     return parent::getDefaultSearchData();
 }
 /**
  * Get form elements for the specific Export
  * @param  \Gems_Form $form existing form type
  * @param  array data existing options set in the form
  * @return array of form elements
  */
 public function getFormElements(\Gems_Form $form, &$data)
 {
     $form->activateJQuery();
     $dbLookup = $this->util->getDbLookup();
     $translated = $this->util->getTranslated();
     $noRound = array(self::NoRound => $this->_('No round description'));
     $empty = $translated->getEmptyDropdownArray();
     $dateOptions = array();
     \MUtil_Model_Bridge_FormBridge::applyFixedOptions('date', $dateOptions);
     $organizations = $this->currentUser->getRespondentOrganizations();
     $tracks = $empty + $this->util->getTrackData()->getAllTracks();
     $rounds = $empty + $noRound + $dbLookup->getRoundsForExport(isset($data['tid']) ? $data['tid'] : null);
     $surveys = $dbLookup->getSurveysForExport(isset($data['tid']) ? $data['tid'] : null, isset($data['rounds']) ? $data['rounds'] : null);
     $yesNo = $translated->getYesNo();
     $elements = array();
     $element = $form->createElement('textarea', 'ids');
     $element->setLabel($this->_('Respondent id\'s'))->setAttrib('cols', 60)->setAttrib('rows', 4)->setDescription($this->_('Not respondent nr, but respondent id as exported here.'));
     $elements[] = $element;
     $element = $form->createElement('select', 'tid');
     $element->setLabel($this->_('Tracks'))->setMultiOptions($tracks);
     $elements[] = $element;
     if (isset($data['tid']) && $data['tid']) {
         $element = $form->createElement('radio', 'tid_fields');
         $element->setLabel($this->_('Export fields'))->setMultiOptions($yesNo);
         $elements[] = $element;
         if (!array_key_exists('tid_fields', $data)) {
             $data['tid_fields'] = 1;
         }
     }
     $element = $form->createElement('select', 'rounds');
     $element->setLabel($this->_('Round description'))->setMultiOptions($rounds);
     $elements[] = $element;
     $element = $form->createElement('multiselect', 'sid');
     $element->setLabel($this->_('Survey'))->setMultiOptions($surveys)->setDescription($this->_('Use CTRL or Shift to select more'));
     $elements[] = $element;
     $element = $form->createElement('multiCheckbox', 'oid');
     $element->setLabel($this->_('Organization'))->setMultiOptions($organizations);
     $elements[] = $element;
     if (\MUtil_Bootstrap::enabled()) {
         $element = new \MUtil_Bootstrap_Form_Element_ToggleCheckboxes('toggleOrg', array('selector' => 'input[name^=oid]'));
     } else {
         $element = new \Gems_JQuery_Form_Element_ToggleCheckboxes('toggleOrg', array('selector' => 'input[name^=oid]'));
     }
     $element->setLabel($this->_('Toggle'));
     $elements[] = $element;
     $element = $form->createElement('datePicker', 'valid_from', $dateOptions);
     $element->setLabel($this->_('Valid from'));
     $elements[] = $element;
     $element = $form->createElement('datePicker', 'valid_until', $dateOptions);
     $element->setLabel($this->_('Valid until'));
     $elements[] = $element;
     if (\MUtil_Bootstrap::enabled()) {
         $element = new \MUtil_Bootstrap_Form_Element_ToggleCheckboxes('toggleOrg', array('selector' => 'input[name^=oid]'));
     } else {
         $element = new \Gems_JQuery_Form_Element_ToggleCheckboxes('toggleOrg', array('selector' => 'input[name^=oid]'));
     }
     $element = $form->createElement('checkbox', 'column_identifiers');
     $element->setLabel($this->_('Column Identifiers'));
     $element->setDescription($this->_('Prefix the column labels with an identifier. (A) Answers, (TF) Trackfields, (D) Description'));
     $elements[] = $element;
     //unset($data['records']);
     if (!empty($data['sid'])) {
         $filters = $this->getFilters($data);
         foreach ($filters as $key => $filter) {
             unset($data['records_' . $key]);
             $model = $this->getModel($filter, $data);
             $survey = $this->loader->getTracker()->getSurvey(intval($filter['gto_id_survey']));
             $recordCount = $model->loadPaginator($filter)->getTotalItemCount();
             $element = $form->createElement('exhibitor', 'records_' . $key);
             $element->setValue($survey->getName() . ': ' . sprintf($this->_('%s records found.'), $recordCount));
             //$element->setValue($survey->getName());
             $elements[] = $element;
         }
     }
     if ($this->project->hasResponseDatabase()) {
         $this->addResponseDatabaseForm($form, $data, $elements);
     }
     return $elements;
 }
 /**
  *
  * @param array $data The $form field values (can be usefull, but no need to set them)
  * @return array of organization id => name
  */
 protected function getOrganizationList(array $data)
 {
     return $this->currentUser->getRespondentOrganizations();
 }