/**
  * Creates the model
  *
  * @return \MUtil_Model_ModelAbstract
  */
 protected function createModel()
 {
     $model = $this->loader->getTracker()->getRespondentTrackModel();
     $model->addColumn('CONCAT(gr2t_completed, \'' . $this->_(' of ') . '\', gr2t_count)', 'progress');
     $model->resetOrder();
     $model->set('gtr_track_name', 'label', $this->_('Track'));
     $model->set('gr2t_track_info', 'label', $this->_('Description'));
     $model->set('gr2t_start_date', 'label', $this->_('Start'), 'formatFunction', $this->util->getTranslated()->formatDate, 'default', \MUtil_Date::format(new \Zend_Date(), 'dd-MM-yyyy'));
     $model->set('gr2t_reception_code');
     $model->set('progress', 'label', $this->_('Progress'));
     // , 'tdClass', 'rightAlign', 'thClass', 'rightAlign');
     $model->set('assigned_by', 'label', $this->_('Assigned by'));
     return $model;
 }
 /**
  * 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)
 {
     $html = $this->getHtmlSequence();
     if (!$this->trackData) {
         $html->h2($this->_('Unknown track'));
         $this->addMessage(sprintf($this->_('Unknown track id %s'), $this->trackId));
         return $html;
     }
     if ($this->showHeader) {
         $html->h2(sprintf($this->_('%s track'), $this->trackData['gtr_track_name']));
     }
     if (isset($this->trackData['gtr_date_until']) && $this->trackData['gtr_date_until']) {
         $html->pInfo(sprintf($this->_('This track can be assigned from %s until %s.'), \MUtil_Date::format($this->trackData['gtr_date_start'], \Zend_Date::DATE_LONG), \MUtil_Date::format($this->trackData['gtr_date_until'], \Zend_Date::DATE_LONG)));
     } else {
         $html->pInfo(sprintf($this->_('This track can be assigned since %s.'), \MUtil_Date::format($this->trackData['gtr_date_start'], \Zend_Date::DATE_LONG)));
     }
     return $html;
 }
Beispiel #3
0
 /**
  * Return an array of functions used to process the value
  *
  * @param string $name The real name and not e.g. the key id
  * @return array
  */
 protected function _compile($name)
 {
     $output = array();
     if ($this->model->has($name, 'multiOptions')) {
         $options = $this->model->get($name, 'multiOptions');
         $output['multiOptions'] = function ($value) use($options) {
             return is_scalar($value) && array_key_exists($value, $options) ? $options[$value] : $value;
         };
     }
     if ($this->model->has($name, 'formatFunction')) {
         $output['formatFunction'] = $this->model->get($name, 'formatFunction');
     } elseif ($this->model->has($name, 'dateFormat')) {
         $format = $this->model->get($name, 'dateFormat');
         if (is_callable($format)) {
             $output['dateFormat'] = $format;
         } else {
             $storageFormat = $this->model->get($name, 'storageFormat');
             $output['dateFormat'] = function ($value) use($format, $storageFormat) {
                 return \MUtil_Date::format($value, $format, $storageFormat);
             };
         }
     } elseif ($this->model->has($name, 'numberFormat')) {
         $format = $this->model->get($name, 'numberFormat');
         if (is_callable($format)) {
             $output['numberFormat'] = $format;
         } else {
             $output['numberFormat'] = function ($value) use($format) {
                 return \Zend_Locale_Format::toNumber($value, array('number_format' => $format));
             };
         }
     }
     if ($this->model->has($name, 'markCallback')) {
         $output['markCallback'] = $this->model->get($name, 'markCallback');
     }
     return $output;
 }
 protected function filterDateFormat($value, $dateFormat, $columnName)
 {
     if ($value instanceof \Zend_Date) {
         $year = \MUtil_Date::format($value, 'yyyy');
         $month = \MUtil_Date::format($value, 'MM');
         $day = \MUtil_Date::format($value, 'dd');
         $hours = \MUtil_Date::format($value, 'HH');
         $minutes = \MUtil_Date::format($value, 'mm');
         $seconds = \MUtil_Date::format($value, 'ss');
     } else {
         $time = strtotime($value);
         $year = Date('Y', $time);
         $month = Date('m', $time);
         $day = Date('d', $time);
         $hours = Date('H', $time);
         $minutes = Date('i', $time);
         $seconds = Date('s', $time);
     }
     return PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hours, $minutes, $seconds);
 }
 /**
  * Display the time field
  *
  * @param \MUtil_Date $value
  */
 public function formatTime($value)
 {
     return \MUtil_Html::create('span', ' ', \MUtil_Date::format($value, 'HH:mm ' . \Zend_Date::WEEKDAY_SHORT, $this->_dateStorageFormat));
 }
Beispiel #6
0
 /**
  * Generates a fake element that just displays the item with a hidden extra value field.
  *
  * @access public
  *
  * @param string|array $name If a string, the element name.  If an
  * array, all other parameters are ignored, and the array elements
  * are extracted in place of added parameters.
  *
  * @param mixed $value The element value.
  *
  * @param array $attribs Attributes for the element tag.
  *
  * @return string The element XHTML.
  */
 public function exhibitor($name, $value = null, $attribs = null)
 {
     $result = $value;
     if (isset($attribs['default'])) {
         if (null === $result) {
             $result = $attribs['default'];
         }
     }
     if (isset($attribs['multiOptions'])) {
         $multiOptions = $attribs['multiOptions'];
         if (is_array($multiOptions)) {
             /*
              *  Sometimes a field is an array and will be formatted later on using the
              *  formatFunction -> handle each element in the array.
              */
             if (is_array($result)) {
                 foreach ($result as $key => $arrayValue) {
                     if (array_key_exists($arrayValue, $multiOptions)) {
                         $result[$key] = $multiOptions[$arrayValue];
                     }
                 }
             } else {
                 if (array_key_exists($result, $multiOptions)) {
                     $result = $multiOptions[$result];
                 }
             }
         }
     }
     if (isset($attribs['formatFunction'])) {
         $callback = $attribs['formatFunction'];
         $result = call_user_func($callback, $result);
     } elseif (isset($attribs['dateFormat'])) {
         $dateFormat = $attribs['dateFormat'];
         $storageFormat = isset($attribs['storageFormat']) ? $attribs['storageFormat'] : null;
         $result = \MUtil_Date::format($result, $dateFormat, $storageFormat);
         if ($storageFormat && $value instanceof \Zend_Date) {
             $value = $value->toString($storageFormat);
         }
     }
     if (isset($attribs['itemDisplay'])) {
         $function = $attribs['itemDisplay'];
         if (is_callable($function)) {
             $result = call_user_func($function, $result);
         } elseif (is_object($function)) {
             if ($function instanceof \MUtil_Html_ElementInterface || method_exists($function, 'append')) {
                 $object = clone $function;
                 $result = $object->append($result);
             }
         } elseif (is_string($function)) {
             // Assume it is a html tag when a string
             $result = \MUtil_Html::create($function, $result);
         }
     }
     if ($result instanceof \MUtil_Html_HtmlInterface) {
         $result = $result->render($this->view);
     }
     // By all appearance not in use.
     /* if (isset($attribs['callback'])) {
            $callback = $attribs['callback'];
            $result = $callback($result);
        } */
     if (isset($attribs['nohidden']) && $attribs['nohidden'] || is_array($value)) {
         return $result;
     } else {
         if ($value instanceof \Zend_Date) {
             $value = $value->toString('yyyy-MM-dd HH:mm:ss');
         }
         return $this->_hidden($name, $value) . $result;
     }
 }
 /**
  * This is the actual format function, copied from the Exhibitor for field
  *
  * @param type $name
  * @param type $result
  *@param \MUtil_Model_ModelAbstract $model
  * @return type
  */
 private function _format($name, $result, $model)
 {
     static $view = null;
     if (!isset($this->_options[$name])) {
         $this->_options[$name] = $model->get($name, array('default', 'multiOptions', 'formatFunction', 'dateFormat', 'storageFormat', 'itemDisplay'));
     }
     $options = $this->_options[$name];
     foreach ($options as $key => $value) {
         switch ($key) {
             case 'default':
                 if (is_null($result)) {
                     $result = $value;
                 }
                 break;
             case 'multiOptions':
                 $multiOptions = $value;
                 if (is_array($multiOptions)) {
                     /*
                      *  Sometimes a field is an array and will be formatted later on using the
                      *  formatFunction -> handle each element in the array.
                      */
                     if (is_array($result)) {
                         foreach ($result as $key => $value) {
                             if (array_key_exists($value, $multiOptions)) {
                                 $result[$key] = $multiOptions[$value];
                             }
                         }
                     } else {
                         if (array_key_exists($result, $multiOptions)) {
                             $result = $multiOptions[$result];
                         }
                     }
                 }
                 break;
             case 'formatFunction':
                 $callback = $value;
                 $result = call_user_func($callback, $result);
                 break;
             case 'dateFormat':
                 if (array_key_exists('formatFunction', $options)) {
                     // if there is a formatFunction skip the date formatting
                     continue;
                 }
                 $dateFormat = $value;
                 $storageFormat = $model->get($name, 'storageFormat');
                 $result = \MUtil_Date::format($result, $dateFormat, $storageFormat);
                 break;
             case 'itemDisplay':
                 $function = $value;
                 if (is_callable($function)) {
                     $result = call_user_func($function, $result);
                 } elseif (is_object($function)) {
                     if ($function instanceof \MUtil_Html_ElementInterface || method_exists($function, 'append')) {
                         $object = clone $function;
                         $result = $object->append($result);
                     }
                 } elseif (is_string($function)) {
                     // Assume it is a html tag when a string
                     $result = \MUtil_Html::create($function, $result);
                 }
             default:
                 break;
         }
     }
     if (is_object($result)) {
         // If it is Lazy, execute it
         if ($result instanceof \MUtil_Lazy_LazyInterface) {
             $result = \MUtil_Lazy::rise($result);
         }
         // If it is Html, render it
         if ($result instanceof \MUtil_Html_HtmlInterface) {
             if (is_null($view)) {
                 $viewRenderer = \Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
                 if (null === $viewRenderer->view) {
                     $viewRenderer->initView();
                 }
                 $view = $viewRenderer->view;
             }
             $result = $result->render($view);
         }
     }
     return $result;
 }
 protected function filterDateFormat($value, $dateFormat, $columnName)
 {
     $storageFormat = $this->model->get($columnName, 'storageFormat');
     return \MUtil_Date::format($value, $dateFormat, $storageFormat);
 }
 /**
  * Filter the data in a row so that correct values are being used
  * @param  array $row a row in the model
  * @return array The filtered row
  */
 protected function filterRow($row)
 {
     $exportRow = array();
     foreach ($row as $columnName => $result) {
         if ($this->model->get($columnName, 'label')) {
             $options = $this->model->get($columnName, $this->modelFilterAttributes);
             foreach ($options as $optionName => $optionValue) {
                 switch ($optionName) {
                     case 'multiOptions':
                         $multiOptions = $optionValue;
                         if (is_array($multiOptions)) {
                             /*
                              *  Sometimes a field is an array and will be formatted later on using the
                              *  formatFunction -> handle each element in the array.
                              */
                             if (is_array($result)) {
                                 foreach ($result as $key => $value) {
                                     if (array_key_exists($value, $multiOptions)) {
                                         $result[$key] = $multiOptions[$value];
                                     }
                                 }
                             } else {
                                 if (array_key_exists($result, $multiOptions)) {
                                     $result = $multiOptions[$result];
                                 }
                             }
                         }
                         break;
                     case 'formatFunction':
                         $callback = $optionValue;
                         if (!is_array($callback) && method_exists($this, $callback)) {
                             $result = call_user_func(array($this, $callback), $result);
                         } else {
                             $result = call_user_func($callback, $result);
                         }
                         break;
                     case 'dateFormat':
                         if (array_key_exists('formatFunction', $options)) {
                             // if there is a formatFunction skip the date formatting
                             continue;
                         }
                         $dateFormat = $optionValue;
                         $storageFormat = $this->model->get($columnName, 'storageFormat');
                         $result = \MUtil_Date::format($result, $dateFormat, $storageFormat);
                         break;
                     case 'itemDisplay':
                         $function = $optionValue;
                         if (is_callable($function)) {
                             $result = call_user_func($function, $result);
                         } elseif (is_object($function)) {
                             if ($function instanceof \MUtil_Html_ElementInterface || method_exists($function, 'append')) {
                                 $object = clone $function;
                                 $result = $object->append($result);
                             }
                         } elseif (is_string($function)) {
                             // Assume it is a html tag when a string
                             $result = \MUtil_Html::create($function, $result);
                         }
                     default:
                         break;
                 }
             }
             if ($result instanceof \MUtil_Html_ElementInterface) {
                 if ($result->count() > 0) {
                     $result = $result[0];
                 } elseif ($result instanceof \MUtil_Html_AElement) {
                     $href = $result->href;
                     $result = $href[0];
                 }
             }
             $exportRow[$columnName] = $result;
         }
     }
     return $exportRow;
 }
 /**
  * Update the token data when a Mail has been sent.
  * @param  integer $tokenId TokenId to update. If none is supplied, use the current token
  */
 public function updateToken($tokenId = false)
 {
     if (!$tokenId) {
         $tokenId = $this->token->getTokenId();
     }
     $tokenData['gto_mail_sent_num'] = new \Zend_Db_Expr('gto_mail_sent_num + 1');
     $tokenData['gto_mail_sent_date'] = \MUtil_Date::format(new \Zend_Date(), 'yyyy-MM-dd');
     $this->db->update('gems__tokens', $tokenData, $this->db->quoteInto('gto_id_token = ?', $tokenId));
 }
 protected function processValue($name, $value, $model = false)
 {
     if (!$model) {
         $model = $this->model;
     }
     $result = $value;
     if ($default = $model->get($name, 'default')) {
         if (null === $result) {
             $result = $default;
         }
     }
     if ($formatFunction = $model->get($name, 'formatFunction')) {
         $result = call_user_func($formatFunction, $result);
     } elseif ($dateFormat = $model->get($name, 'dateFormat')) {
         $storageFormat = $model->get($name, 'storageFormat');
         $result = \MUtil_Date::format($result, $dateFormat, $storageFormat);
     }
     if ($itemDisplay = $model->get($name, 'itemDisplay')) {
         if (is_callable($itemDisplay)) {
             $result = call_user_func($itemDisplay, $result);
         } elseif (is_object($itemDisplay)) {
             if ($itemDisplay instanceof \MUtil_Html_ElementInterface || method_exists($itemDisplay, 'append')) {
                 $object = clone $itemDisplay;
                 $result = $object->append($result);
             }
         } elseif (is_string($itemDisplay)) {
             // Assume it is a html tag when a string
             $result = \MUtil_Html::create($itemDisplay, $result);
         }
     }
     return $result;
 }
 /**
  * Helper function to generate a period query string
  *
  * @param array $filter A filter array or $request->getParams()
  * @param \Zend_Db_Adapter_Abstract $db
  * @param $inFormat Optional format to use for date when reading
  * @param $outFormat Optional format to use for date in query
  * @return string
  */
 public static function getPeriodFilter(array &$filter, \Zend_Db_Adapter_Abstract $db, $inFormat = null, $outFormat = null)
 {
     $from = array_key_exists('datefrom', $filter) ? $filter['datefrom'] : null;
     $until = array_key_exists('dateuntil', $filter) ? $filter['dateuntil'] : null;
     $period = array_key_exists(self::PERIOD_DATE_USED, $filter) ? $filter[self::PERIOD_DATE_USED] : null;
     unset($filter[self::PERIOD_DATE_USED], $filter['datefrom'], $filter['dateuntil']);
     if (!$period) {
         return;
     }
     if (null === $outFormat) {
         $outFormat = 'yyyy-MM-dd';
     }
     if (null === $inFormat) {
         $inFormat = \MUtil_Model_Bridge_FormBridge::getFixedOption('date', 'dateFormat');
     }
     if ($from && \Zend_Date::isDate($from, $inFormat)) {
         $datefrom = $db->quote(\MUtil_Date::format($from, $outFormat, $inFormat));
     } else {
         $datefrom = null;
     }
     if ($until && \Zend_Date::isDate($until, $inFormat)) {
         $dateuntil = $db->quote(\MUtil_Date::format($until, $outFormat, $inFormat));
     } else {
         $dateuntil = null;
     }
     if (!($datefrom || $dateuntil)) {
         return;
     }
     switch ($period[0]) {
         case '_':
             // overlaps
             $periods = explode(' ', substr($period, 1));
             if ($datefrom && $dateuntil) {
                 return sprintf('(%1$s <= %4$s OR (%1$s IS NULL AND %2$s IS NOT NULL)) AND
                             (%2$s >= %3$s OR %2$s IS NULL)', $db->quoteIdentifier($periods[0]), $db->quoteIdentifier($periods[1]), $datefrom, $dateuntil);
             }
             if ($datefrom) {
                 return sprintf('%2$s >= %3$s OR (%2$s IS NULL AND %1$s IS NOT NULL)', $db->quoteIdentifier($periods[0]), $db->quoteIdentifier($periods[1]), $datefrom);
             }
             if ($dateuntil) {
                 return sprintf('%1$s <= %3$s OR (%1$s IS NULL AND %2$s IS NOT NULL)', $db->quoteIdentifier($periods[0]), $db->quoteIdentifier($periods[1]), $dateuntil);
             }
             return;
         case '-':
             // within
             $periods = explode(' ', substr($period, 1));
             if ($datefrom && $dateuntil) {
                 return sprintf('%1$s >= %3$s AND %2$s <= %4$s', $db->quoteIdentifier($periods[0]), $db->quoteIdentifier($periods[1]), $datefrom, $dateuntil);
             }
             if ($datefrom) {
                 return sprintf('%1$s >= %3$s AND (%2$s IS NULL OR %2$s >= %3$s)', $db->quoteIdentifier($periods[0]), $db->quoteIdentifier($periods[1]), $datefrom);
             }
             if ($dateuntil) {
                 return sprintf('%2$s <= %3$s AND (%1$s IS NULL OR %1$s <= %3$s)', $db->quoteIdentifier($periods[0]), $db->quoteIdentifier($periods[1]), $dateuntil);
             }
             return;
         default:
             if ($datefrom && $dateuntil) {
                 return sprintf('%s BETWEEN %s AND %s', $db->quoteIdentifier($period), $datefrom, $dateuntil);
             }
             if ($datefrom) {
                 return sprintf('%s >= %s', $db->quoteIdentifier($period), $datefrom);
             }
             if ($dateuntil) {
                 return sprintf('%s <= %s', $db->quoteIdentifier($period), $dateuntil);
             }
             return;
     }
 }
 /**
  * A ModelAbstract->setOnSave() function that returns the input
  * date as a valid date.
  *
  * @see \MUtil_Model_ModelAbstract
  *
  * @param mixed $value The value being saved
  * @param boolean $isNew True when a new item is being saved
  * @param string $name The name of the current field
  * @param array $context Optional, the other values being saved
  * @return \Zend_Date
  */
 public function formatSaveDate($value, $isNew = false, $name = null, array $context = array())
 {
     if ($name && !(null === $value || $value instanceof \Zend_Db_Expr || \MUtil_String::startsWith($value, 'current_', true))) {
         $saveFormat = $this->getWithDefault($name, 'storageFormat', \Zend_Date::ISO_8601);
         if ($value instanceof \Zend_Date) {
             return $value->toString($saveFormat);
         } else {
             $displayFormat = $this->get($name, 'dateFormat');
             try {
                 return \MUtil_Date::format($value, $saveFormat, $displayFormat);
             } catch (\Zend_Exception $e) {
                 if (\Zend_Date::isDate($value, $saveFormat)) {
                     return $value;
                 }
                 throw $e;
             }
         }
     }
     return $value;
 }
 /**
  * Exports a single track
  *
  * @param \Gems_Tracker_RespondentTrack $respTrack
  */
 protected function _exportTrack(\Gems_Tracker_RespondentTrack $respTrack)
 {
     if (!$this->_isTrackInFilter($respTrack)) {
         return;
     }
     $trackModel = $this->loader->getTracker()->getRespondentTrackModel();
     $trackModel->applyDetailSettings($respTrack->getTrackEngine(), false);
     $trackModel->resetOrder();
     $trackModel->set('gtr_track_name', 'label', $this->_('Track'));
     $trackModel->set('gr2t_track_info', 'label', $this->_('Description'), 'description', $this->_('Enter the particulars concerning the assignment to this respondent.'));
     $trackModel->set('assigned_by', 'label', $this->_('Assigned by'));
     $trackModel->set('gr2t_start_date', 'label', $this->_('Start'), 'formatFunction', $this->util->getTranslated()->formatDate, 'default', \MUtil_Date::format(new \Zend_Date(), 'dd-MM-yyyy'));
     $trackModel->set('gr2t_reception_code');
     $trackModel->set('gr2t_comment', 'label', $this->_('Comment'));
     $trackModel->setFilter(array('gr2t_id_respondent_track' => $respTrack->getRespondentTrackId()));
     $trackData = $trackModel->loadFirst();
     $this->html->h3($this->_('Track') . ' ' . $trackData['gtr_track_name']);
     $bridge = $trackModel->getBridgeFor('itemTable', array('class' => 'browser table'));
     $bridge->setRepeater(\MUtil_Lazy::repeat(array($trackData)));
     $bridge->th($this->_('Track information'), array('colspan' => 2));
     $bridge->setColumnCount(1);
     foreach ($trackModel->getItemsOrdered() as $name) {
         if ($label = $trackModel->get($name, 'label')) {
             $bridge->addItem($name, $label);
         }
     }
     $tableContainer = \MUtil_Html::create()->div(array('class' => 'table-container'));
     $tableContainer[] = $bridge->getTable();
     $this->html[] = $tableContainer;
     $this->html->br();
     $this->_exportTrackTokens($respTrack);
     $this->html->hr();
 }
 /**
  * Returns an array of elements for check fields during password reset and/or
  * 'label name' => 'required value' pairs. vor asking extra questions before allowing
  * a password change.
  *
  * Default is asking for the username but you can e.g. ask for someones birthday.
  *
  * @return array Of 'label name' => 'required values' or \Zend_Form_Element elements
  */
 protected function loadResetPasswordCheckFields()
 {
     // CHECK ON SOMEONES BIRTHDAY
     // Birthdays are usually not defined for staff but the do exist for respondents
     if ($value = $this->_getVar('user_birthday')) {
         $label = $this->_('Your birthday');
         $birthdayElem = new \Gems_JQuery_Form_Element_DatePicker('birthday');
         $birthdayElem->setLabel($label)->setOptions(\MUtil_Model_Bridge_FormBridge::getFixedOptions('date'))->setStorageFormat(\Zend_Date::ISO_8601);
         if ($format = $birthdayElem->getDateFormat()) {
             $valueFormatted = \MUtil_Date::format($value, $format, $birthdayElem->getStorageFormat());
         } else {
             $valueFormatted = $value;
         }
         $validator = new \Zend_Validate_Identical($valueFormatted);
         $validator->setMessage(sprintf($this->_('%s is not correct.'), $label), \Zend_Validate_Identical::NOT_SAME);
         $birthdayElem->addValidator($validator);
         return array($birthdayElem);
     }
     // */
     return array($this->_('Username') => $this->getLoginName());
 }
 /**
  * Translate the set form options to a valid filter for the model
  * @param  array data existing options set in the form
  * @return array Filter for the model
  */
 public function getFilters($data)
 {
     $filters = array();
     $dateOutFormat = 'yyyy-MM-dd';
     $dateInFormat = \MUtil_Model_Bridge_FormBridge::getFixedOption('date', 'dateFormat');
     if (isset($data['sid']) && is_array($data['sid'])) {
         foreach ($data['sid'] as $surveyId) {
             if ($surveyId) {
                 $filter = array();
                 if (isset($data['ids'])) {
                     $idStrings = $data['ids'];
                     $idArray = preg_split('/[\\s,;]+/', $idStrings, -1, PREG_SPLIT_NO_EMPTY);
                     if ($idArray) {
                         // Make sure output is OK
                         // $idArray = array_map(array($this->db, 'quote'), $idArray);
                         $filter['gto_id_respondent'] = $idArray;
                     }
                 }
                 if ($this->project->hasResponseDatabase()) {
                     $this->getResponseDatabaseFilter($data, $filter);
                 }
                 /*if ($this->project->hasResponseDatabase()) {
                       $this->_getResponseDatabaseFilter($data, $filter);
                   }*/
                 if (isset($data['tid']) && !empty($data['tid'])) {
                     $filter['gto_id_track'] = $data['tid'];
                 }
                 if (isset($data['sid'])) {
                     $filter['gto_id_survey'] = $surveyId;
                 }
                 if (isset($data['rounds']) && !empty($data['rounds'])) {
                     $filter['gto_round_description'] = $data['rounds'];
                 }
                 if (isset($data['oid'])) {
                     $filter['gto_id_organization'] = $data['oid'];
                 } else {
                     //Invalid id so when nothing selected... we get nothing
                     // $filter['organizationid'] = '-1';
                 }
                 if (isset($data['valid_from']) && !empty($data['valid_from'])) {
                     $filter[] = "gto_valid_from >= " . $this->db->quote(\MUtil_Date::format($data['valid_from'], $dateOutFormat, $dateInFormat)) . "";
                 }
                 if (isset($data['valid_until']) && !empty($data['valid_until'])) {
                     $filter[] = "gto_valid_until >= " . $this->db->quote(\MUtil_Date::format($data['valid_until'], $dateOutFormat, $dateInFormat)) . "";
                 }
                 /*if (isset($data['valid_until'])) {
                       $filter[] = 'gto_valid_until >= ' . $data['valid_until'];
                   }*/
                 $filter['grc_success'] = 1;
                 $filter[] = "gto_completion_time IS NOT NULL";
                 // Consent codes
                 /*$filter['consentcode'] = array_diff(
                                 (array) $this->util->getConsentTypes(),
                                 (array) $this->util->getConsentRejected()
                                 );
                 		*/
                 $filters[] = $filter;
             }
         }
     }
     // \Gems_Tracker::$verbose = true;
     return $filters;
 }
 /**
  * Converting the field value when saving to a respondent track
  *
  * @param array $currentValue The current value
  * @param array $fieldData The other values loaded so far
  * @return mixed the new value
  */
 public function onFieldDataSave($currentValue, array $fieldData)
 {
     if (null === $currentValue || $currentValue instanceof \Zend_Db_Expr || \MUtil_String::startsWith($currentValue, 'current_', true)) {
         return $currentValue;
     }
     $saveFormat = $this->getStorageFormat();
     if ($currentValue instanceof \Zend_Date) {
         return $currentValue->toString($saveFormat);
     } else {
         $displayFormat = \MUtil_Model_Bridge_FormBridge::getFixedOption('date', 'dateFormat');
         $returnDate = \MUtil_Date::format($currentValue, $saveFormat, $displayFormat);
         if (is_null($returnDate)) {
             if (\Zend_Date::isDate($currentValue, $saveFormat)) {
                 return $currentValue;
             }
         }
         return $returnDate;
     }
     return (string) $currentValue;
 }