/** * Adds columns from the model to the bridge that creates the browse table. * * Overrule this function to add different columns to the browse table, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_TableBridge $bridge * @param \MUtil_Model_ModelAbstract $model * @return void */ protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { // \MUtil_Model::$verbose = true; // // Initiate data retrieval for stuff needed by links $bridge->gr2o_patient_nr; $bridge->gr2o_id_organization; $bridge->gr2t_id_respondent_track; $HTML = \MUtil_Html::create(); $roundIcon[] = \MUtil_Lazy::iif($bridge->gto_icon_file, \MUtil_Html::create('img', array('src' => $bridge->gto_icon_file, 'class' => 'icon')), \MUtil_Lazy::iif($bridge->gro_icon_file, \MUtil_Html::create('img', array('src' => $bridge->gro_icon_file, 'class' => 'icon')))); $bridge->addMultiSort('gsu_survey_name', $roundIcon); $bridge->addSortable('ggp_name'); $bridge->addSortable('calc_used_date', null, $HTML->if($bridge->is_completed, 'disabled date', 'enabled date')); $bridge->addSortable('gto_changed'); $bridge->addSortable('assigned_by', $this->_('Assigned by')); // If we are allowed to see the result of the survey, show them $user = $this->loader->getCurrentUser(); if ($user->hasPrivilege('pr.respondent.result')) { $bridge->addSortable('gto_result', $this->_('Score'), 'date'); } $bridge->useRowHref = false; $actionLinks[] = $this->createMenuLink($bridge, 'track', 'answer'); $actionLinks[] = array($bridge->ggp_staff_members->if($this->createMenuLink($bridge, 'ask', 'take'), $bridge->calc_id_token->strtoupper()), 'class' => $bridge->ggp_staff_members->if(null, $bridge->calc_id_token->if('token'))); // calc_id_token is empty when the survey has been completed // Remove nulls $actionLinks = array_filter($actionLinks); if ($actionLinks) { $bridge->addItemLink($actionLinks); } $this->addTokenLinks($bridge); }
/** * 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->trackName) { $html->h3(sprintf($this->_('Surveys in %s track'), $this->trackName)); } $trackRepeater = $this->getRepeater($this->trackId); $table = $html->div(array('class' => 'table-container'))->table($trackRepeater, array('class' => 'browser table')); if ($link = $this->findMenuItem('project-tracks', 'questions')) { $table->tr()->onclick = array('location.href=\'', $link->toHRefAttribute($trackRepeater), '\';'); $table->addColumn($link->toActionLinkLower($trackRepeater)); } $surveyName[] = $trackRepeater->gsu_survey_name; $surveyName[] = \MUtil_Lazy::iif($trackRepeater->gro_icon_file, \MUtil_Html::create('img', array('src' => $trackRepeater->gro_icon_file, 'class' => 'icon'))); $table->addColumn($surveyName, $this->_('Survey')); $table->addColumn($trackRepeater->gro_round_description, $this->_('Details')); $table->addColumn($trackRepeater->ggp_name, $this->_('By')); $table->addColumn($trackRepeater->gsu_survey_description->call(array(__CLASS__, 'oneLine')), $this->_('Description')); return $html; }
/** * Adds columns from the model to the bridge that creates the browse table. * * Overrule this function to add different columns to the browse table, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_TableBridge $bridge * @param \MUtil_Model_ModelAbstract $model * @return void */ protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { // Signal the bridge that we need these values $bridge->gr2t_id_respondent_track; $bridge->gr2o_patient_nr; $bridge->tr()->appendAttrib('class', \MUtil_Lazy::iif($bridge->gro_id_round, $bridge->row_class, array($bridge->row_class, ' inserted'))); $title = \MUtil_Html::create()->strong($this->_('+')); $showLinks[] = $this->createMenuLink($bridge, 'track', 'show', $title); // Remove nulls $showLinks = array_filter($showLinks); // Columns $bridge->addSortable('gsu_survey_name')->append(\MUtil_Lazy::iif($bridge->gro_icon_file, \MUtil_Lazy::iif($bridge->gto_icon_file, \MUtil_Html::create('img', array('src' => $bridge->gto_icon_file, 'class' => 'icon')), \MUtil_Lazy::iif($bridge->gro_icon_file, \MUtil_Html::create('img', array('src' => $bridge->gro_icon_file, 'class' => 'icon')))))); $bridge->addSortable('gto_round_description'); $bridge->addSortable('ggp_name'); $bridge->addSortable('gto_valid_from', null, 'date'); $bridge->addSortable('gto_completion_time', null, 'date'); $bridge->addSortable('gto_valid_until', null, 'date'); if ($this->loader->getCurrentUser()->hasPrivilege('pr.respondent.result')) { $bridge->addSortable('gto_result', $this->_('Score'), 'date'); } $actionLinks[] = $this->createMenuLink($bridge, 'track', 'answer'); $actionLinks[] = array($bridge->ggp_staff_members->if($this->createMenuLink($bridge, 'ask', 'take'), $bridge->can_be_taken->if($bridge->calc_id_token->strtoupper())), 'class' => $bridge->ggp_staff_members->if(null, $bridge->calc_id_token->if('token'))); // Remove nulls $actionLinks = array_filter($actionLinks); if ($actionLinks) { $bridge->addItemLink($actionLinks); } if ($showLinks) { foreach ($showLinks as $showLink) { if ($showLink) { $showLink->title = array($this->_('Token'), $bridge->gto_id_token->strtoupper()); } } $bridge->addItemLink($showLinks); } }
/** * Adds columns from the model to the bridge that creates the browse table. * * Overrule this function to add different columns to the browse table, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_TableBridge $bridge * @param \MUtil_Model_ModelAbstract $model * @return void */ protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $br = \MUtil_Html::create('br'); if ($this->showSelected) { $selectedClass = \MUtil_Lazy::iff(\MUtil_Lazy::comp($bridge->gto_id_token, '==', $this->tokenId), 'selectedColumn', null); } else { $selectedClass = null; } $bridge->th($this->_('Status')); $td = $bridge->tdh(\MUtil_Lazy::first($bridge->grc_description, $this->_('OK'))); $td->appendAttrib('class', $selectedClass); $bridge->th($this->_('Question')); if ($model->has('grr_name') && $model->has('gtf_field_name')) { $td = $bridge->tdh(\MUtil_Lazy::iif($bridge->grr_name, array($bridge->grr_name, $br)), \MUtil_Lazy::iif($bridge->gtf_field_name, array($bridge->gtf_field_name, $br)), $bridge->gto_round_description, \MUtil_Lazy::iif($bridge->gto_round_description, $br), \MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from)); } else { $td = $bridge->tdh($bridge->gto_round_description, \MUtil_Lazy::iif($bridge->gto_round_description, $br), \MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from)); } $td->appendAttrib('class', $selectedClass); $td->appendAttrib('class', $bridge->row_class); // Apply filter on the answers displayed $answerNames = $model->getItemsOrdered(); if ($this->answerFilter instanceof \Gems_Tracker_Snippets_AnswerNameFilterInterface) { $answerNames = $this->answerFilter->filterAnswers($bridge, $model, $answerNames); } foreach ($answerNames as $name) { $label = $model->get($name, 'label'); if (null !== $label) { // Was strlen($label), but this ruled out empty sub-questions $bridge->thd($label, array('class' => $model->get($name, 'thClass'))); $td = $bridge->td($bridge->{$name}); $td->appendAttrib('class', 'answer'); $td->appendAttrib('class', $selectedClass); $td->appendAttrib('class', $bridge->row_class); } } $bridge->th($this->_('Token')); $tokenUpper = $bridge->gto_id_token->strtoupper(); if ($this->showTakeButton && ($menuItem = $this->menu->find(array('controller' => 'ask', 'action' => 'take', 'allowed' => true)))) { $source = new \Gems_Menu_ParameterSource(); $source->setTokenId($bridge->gto_id_token); $source->offsetSet('can_be_taken', $bridge->can_be_taken); $link = $menuItem->toActionLink($source); if ($link) { $link->title = array($this->_('Token'), $tokenUpper); } $td = $bridge->tdh($bridge->can_be_taken->if($link, $tokenUpper)); } else { $td = $bridge->tdh($tokenUpper); } $td->appendAttrib('class', $selectedClass); $td->appendAttrib('class', $bridge->row_class); }
/** * Add first columns (group) from the model to the bridge that creates the browse table. * * You can actually add more than one column in this function, but just call all four functions * with the default columns in each * * Overrule this function to add different columns to the browse table, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_TableBridge $bridge * @param \MUtil_Model_ModelAbstract $model * @return void */ protected function addBrowseColumn3(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $br = \MUtil_Html::create('br'); if ($model->hasAlias('gems__respondent2track')) { $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('gr2t_track_info', 'label', $this->_('Track description')); $items = $this->findMenuItems('track', 'show-track'); $track = 'gtr_track_name'; if ($items) { $menuItem = reset($items); if ($menuItem instanceof \Gems_Menu_MenuAbstract) { $href = $menuItem->toHRefAttribute($this->request, $bridge, array('gr2t_id_respondent_track' => $bridge->gr2t_id_respondent_track)); $track = array(); $track[0] = \MUtil_Lazy::iif($bridge->gr2t_id_respondent_track, \MUtil_Html::create()->a($href, $bridge->gtr_track_name, array('onclick' => "event.cancelBubble = true;"))); $track[1] = $bridge->createSortLink('gtr_track_name'); } } $bridge->addMultiSort($track, $br, 'gr2t_track_info'); } else { $citysep = \MUtil_Html::raw(' '); // $bridge->itemIf($bridge->grs_zipcode, \MUtil_Html::raw(' ')); $bridge->addMultiSort('grs_address_1', $br, 'grs_zipcode', $citysep, 'grs_city'); } }
public function addItemWhen($condition, $name = null, $label = null, array $attr = array()) { $attr['renderWithoutContent'] = false; if (null === $name) { $name = $condition; } if (is_string($condition)) { $condition = $this->{$condition}; } list($attr, $hattr) = $this->_checkAttributesFor($name, $attr); $this->_checkColumnNewRow(); if ($this->labelTh) { $this->table->tdh(\MUtil_Lazy::iif($condition, $this->_checkLabel($label, $name)), $hattr); } else { $this->table->td(\MUtil_Lazy::iif($condition, $this->_checkLabel($label, $name)), $hattr); } $this->table->td(\MUtil_Lazy::iif($condition, $this->_getLazyName($name)), $attr); $this->_checkColumnAdded($attr); return $this; }