/**
  * A list of all participating organizations.
  *
  * @return \MUtil_Html_HtmlElement
  */
 private function _getOrganizationsList()
 {
     $html = new \MUtil_Html_Sequence();
     $sql = '
         SELECT *
         FROM gems__organizations
         WHERE gor_active=1 AND gor_url IS NOT NULL AND gor_task IS NOT NULL
         ORDER BY gor_name';
     // $organizations = array();
     // $organizations = array(key($organizations) => reset($organizations));
     $organizations = $this->db->fetchAll($sql);
     $orgCount = count($organizations);
     switch ($orgCount) {
         case 0:
             return $html->pInfo(sprintf($this->_('%s is still under development.'), $this->project->getName()));
         case 1:
             $organization = reset($organizations);
             $p = $html->pInfo(sprintf($this->_('%s is run by: '), $this->project->getName()));
             $p->a($organization['gor_url'], $organization['gor_name']);
             $p->append('.');
             $html->pInfo()->sprintf($this->_('Please contact the %s if you have any questions regarding %s.'), $organization['gor_name'], $this->project->getName());
             return $html;
         default:
             $p = $html->pInfo(sprintf($this->_('%s is a collaboration of these organizations:'), $this->project->getName()));
             $data = \MUtil_Lazy::repeat($organizations);
             $ul = $p->ul($data, array('class' => 'indent'));
             $li = $ul->li();
             $li->a($data->gor_url->call($this, '_'), $data->gor_name, array('rel' => 'external'));
             $li->append(' (');
             $li->append($data->gor_task->call(array($this, '_')));
             $li->append(')');
             $html->pInfo()->sprintf($this->_('You can contact any of these organizations if you have questions regarding %s.'), $this->project->getName());
             return $html;
     }
 }
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     parent::getHtmlOutput($view);
     $respondentModel = $this->model;
     $respondentData = $this->data;
     $respondentId = $this->respondentId;
     $html = $this->getHtmlSequence();
     if (empty($this->data)) {
         $html->p()->b(sprintf($this->_('Unknown respondent %s'), $respondentId));
         return $html;
     }
     $bridge = $respondentModel->getBridgeFor('itemTable', array('class' => 'browser table'));
     $bridge->setRepeater(\MUtil_Lazy::repeat(array($respondentData)));
     $bridge->th($this->_('Respondent information'), array('colspan' => 4));
     $bridge->setColumnCount(2);
     foreach ($respondentModel->getItemsOrdered() as $name) {
         if ($label = $respondentModel->get($name, 'label')) {
             $bridge->addItem($name, $label);
         }
     }
     $tableContainer = \MUtil_Html::create()->div(array('class' => 'table-container'));
     $tableContainer[] = $bridge->getTable();
     $html->h2($this->_('Respondent information') . ': ' . $respondentId);
     $html[] = $tableContainer;
     $html->hr();
     return $html;
 }
 /**
  * Place to set the data to display
  *
  * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge
  * @return void
  */
 protected function addTableCells(\MUtil_Model_Bridge_VerticalTableBridge $bridge)
 {
     $bridge->setColumnCount(1);
     $HTML = \MUtil_Html::create();
     $bridge->tdh($this->getCaption(), array('colspan' => 2));
     // Caption for tracks
     $trackLabel = $this->_('Assigned tracks');
     if ($menuItem = $this->findMenuItem('track', 'index')) {
         $href = $menuItem->toHRefAttribute($this->request, $bridge);
         $bridge->tdh(array('class' => 'linked'))->a($href, $trackLabel);
     } else {
         $bridge->tdh($trackLabel, array('class' => 'linked'));
     }
     $bridge->tr();
     // ROW 1
     $bridge->addItem($bridge->gr2o_patient_nr, $this->_('Respondent nr: '));
     $rowspan = 10;
     // Column for tracks
     $tracksModel = $this->model->getRespondentTracksModel();
     $tracksData = \MUtil_Lazy::repeat($tracksModel->load(array('gr2o_patient_nr' => $this->repeater->gr2o_patient_nr, 'gr2o_id_organization' => $this->repeater->gr2o_id_organization), array('gr2t_created' => SORT_DESC)));
     $tracksList = $HTML->div($tracksData, array('class' => 'tracksList'));
     $tracksList->setOnEmpty($this->_('No tracks'));
     if ($menuItem = $this->findMenuItem('track', 'show-track')) {
         $href = $menuItem->toHRefAttribute($tracksData, array('gr2o_patient_nr' => $this->repeater->gr2o_patient_nr));
         $tracksTarget = $tracksList->p()->a($href);
     } else {
         $tracksTarget = $tracksList->p();
     }
     $tracksTarget->strong($tracksData->gtr_track_name);
     $tracksTarget[] = ' ';
     $tracksTarget->em($tracksData->gr2t_track_info, array('renderWithoutContent' => false));
     $tracksTarget[] = ' ';
     $tracksTarget[] = \MUtil_Lazy::call($this->util->getTranslated()->formatDate, $tracksData->gr2t_created);
     $bridge->td($tracksList, array('rowspan' => $rowspan, 'class' => 'linked tracksList'));
     // OTHER ROWS
     $bridge->addItem($HTML->spaced($bridge->itemIf('grs_last_name', array($bridge->grs_last_name, ',')), $bridge->grs_first_name, $bridge->grs_surname_prefix), $this->_('Respondent'));
     $bridge->addItem('grs_gender');
     $bridge->addItem('grs_birthday');
     $bridge->addItem('grs_email');
     $bridge->addItem('gr2o_created');
     $bridge->addItem('gr2o_created_by');
     if ($this->onclick) {
         // TODO: can we not use $repeater?
         $href = array('location.href=\'', $this->onclick, '\';');
         foreach ($bridge->tbody() as $tr) {
             foreach ($tr as $td) {
                 if (strpos($td->class, 'linked') === false) {
                     $td->onclick = $href;
                 } else {
                     $td->onclick = 'event.cancelBubble=true;';
                 }
             }
         }
         $bridge->tbody()->onclick = '// Dummy for CSS';
     }
 }
 /**
  * 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()
 {
     if ($this->model) {
         $this->model->setIfExists('grs_email', 'itemDisplay', array('MUtil_Html_AElement', 'ifmail'));
         $this->model->setIfExists('gr2o_comments', 'rowspan', 2);
         if ($this->showConsentWarning && $this->model->has('gr2o_consent')) {
             $this->model->set('gr2o_consent', 'formatFunction', array($this, 'checkConsent'));
         }
         if (!$this->repeater) {
             if (!$this->respondent) {
                 $this->repeater = $this->model->loadRepeatable();
             } else {
                 $data = array($this->respondent->getArrayCopy());
                 $this->repeater = \MUtil_Lazy::repeat($data);
             }
         }
         return true;
     }
     return false;
 }
Esempio n. 5
0
 /**
  * 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()
 {
     if (!$this->repeater) {
         $this->repeater = \MUtil_Lazy::repeat($this->data);
     } else {
         // We do not know whether there is any link between
         // the data and the repeater, so do not use the data
         $this->data = null;
     }
     // If onEmpty is set, we alwars have output
     if ($this->onEmpty) {
         return true;
     }
     // Is there any data in the repeater?
     return $this->repeater->__start();
 }
 /**
  * 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()
 {
     if ($this->model) {
         $this->model->setIfExists('grs_email', 'itemDisplay', array('MUtil_Html_AElement', 'ifmail'));
         $this->model->setIfExists('gr2o_comments', 'rowspan', 2);
         if ($this->showConsentWarning && $this->model->has('gr2o_consent')) {
             $this->model->set('gr2o_consent', 'formatFunction', array($this, 'checkConsent'));
         }
         if (!$this->repeater) {
             if (!$this->respondentData) {
                 $this->repeater = $this->model->loadRepeatable();
             } else {
                 // In case a single array of values was passed: make nested
                 if (is_array(reset($this->respondentData))) {
                     $data = $this->respondentData;
                 } else {
                     $data = array($this->respondentData);
                 }
                 $this->repeater = \MUtil_Lazy::repeat($data);
             }
         }
         return true;
     }
     return false;
 }
Esempio n. 7
0
 /**
  * Returns a \MUtil_Lazy_RepeatableInterface for the items in the model
  *
  * @param mixed $filter True to use the stored filter, array to specify a different filter
  * @param mixed $sort True to use the stored sort, array to specify a different sort
  * @return \MUtil_Lazy_RepeatableInterface
  */
 public function loadRepeatable($filter = true, $sort = true)
 {
     return \MUtil_Lazy::repeat($this->loadIterator($filter, $sort));
 }
 public function getFieldTable($id)
 {
     $tData = $this->getModel()->loadTable($id);
     if (!$tData) {
         return sprintf($this->_('%s no longer exists in the database.'), $id);
     }
     if (\Gems_Model_DbaModel::STATE_DEFINED == $tData['state']) {
         return sprintf($this->_('%s does not yet exist in the database.'), ucfirst($tData['type']));
     }
     if ('table' !== $tData['type']) {
         return sprintf($this->_('%s object does exist.'), ucfirst($tData['type']));
     }
     try {
         $table = new \Zend_DB_Table(array(\Zend_Db_Table_Abstract::NAME => $id, \Zend_Db_Table_Abstract::ADAPTER => $tData['db']));
         $data = \MUtil_Lazy::repeat($table->info('metadata'));
         $html = new \MUtil_Html_TableElement($data);
         $html->addColumn($data->COLUMN_NAME, 'Column');
         $html->addColumn($data->DATA_TYPE, 'Type');
         $html->addColumn($data->LENGTH, 'Length');
         $html->addColumn($data->SCALE, 'Precision');
         $html->addColumn($data->UNSIGNED, 'Unsigned');
         $html->addColumn($data->NULLABLE, 'Nullable');
         $html->addColumn($data->DEFAULT, 'Default');
     } catch (\Zend_Db_Table_Exception $zdte) {
         $html = $this->_('Object is not a table.');
     }
     return $html;
 }
Esempio n. 9
0
 /**
  * Add the elements from the model to the bridge for the current step
  *
  * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge
  * @param \MUtil_Model_ModelAbstract $model
  */
 protected function addStep3(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model)
 {
     if ($this->loadSourceModel()) {
         $this->displayHeader($bridge, $this->_('Upload successful!'));
         $this->displayErrors($bridge, $this->_('Check the input visually.'));
         // \MUtil_Echo::track($this->sourceModel->load());
         $element = $bridge->getForm()->createElement('html', 'importdisplay');
         $repeater = \MUtil_Lazy::repeat(new \LimitIterator($this->sourceModel->loadIterator(), 0, 20));
         $table = new \MUtil_Html_TableElement($repeater, array('class' => $this->formatBoxClass));
         foreach ($this->sourceModel->getItemsOrdered() as $name) {
             $table->addColumn($repeater->{$name}, $name);
         }
         // Extra div for CSS settings
         $element->setValue(new \MUtil_Html_HtmlElement('div', $table, array('class' => $this->formatBoxClass)));
         $bridge->addElement($element);
     } else {
         $this->displayHeader($bridge, $this->_('Upload error!'));
         $this->displayErrors($bridge);
         $this->nextDisabled = true;
     }
 }
 /**
  * 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();
 }