/**
  * Adds rows 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_VerticalTableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function addShowTableRows(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $items = $model->getItemsOrdered();
     foreach ($items as $name) {
         if ($model->get($name, 'type') === \MUtil_Model::TYPE_CHILD_MODEL) {
             $this->submodel = $model->get($name, 'model');
             $subitems = $this->submodel->getItemsOrdered();
         }
     }
     if (isset($subitems) && is_array($subitems)) {
         $items = array_diff($items, $subitems);
     }
     foreach ($items as $name) {
         if ($label = $model->get($name, 'label')) {
             $bridge->addItem($name, $label);
         }
     }
     /*if ($subitems) {
           $bridge->addItem('gctt', 'moo');
       }*/
     if ($model->has('row_class')) {
         // Make sure deactivated rounds are show as deleted
         foreach ($bridge->getTable()->tbody() as $tr) {
             foreach ($tr as $td) {
                 if ('td' === $td->tagName) {
                     $td->appendAttrib('class', $bridge->row_class);
                 }
             }
         }
     }
 }
 /**
  * Use findmenuitem for the abort action so we get the right id appended
  *
  * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  */
 protected function setShowTableFooter(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $footer = $bridge->tfrow();
     $footer[] = $this->getQuestion();
     $footer[] = ' ';
     $footer->actionLink(array($this->confirmParameter => 1), $this->_('Yes'));
     $footer[] = ' ';
     $footer->actionLink($this->findMenuItem($this->request->getControllerName(), $this->abortAction)->toHRefAttribute($this->request), $this->_('No'));
 }
 /**
  * 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';
     }
 }
 /**
  * Set the footer of the browse table.
  *
  * Overrule this function to set the header differently, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function setShowTableFooter(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $row = $bridge->getRow();
     parent::setShowTableFooter($bridge, $model);
     if (isset($row['gla_respondent_id'], $row['gla_organization']) && $this->menuList instanceof \Gems_Menu_MenuList) {
         $patientNr = $this->util->getDbLookup()->getPatientNr($row['gla_respondent_id'], $row['gla_organization']);
         $this->menuList->addParameterSources(array('gr2o_patient_nr' => $patientNr, 'gr2o_id_organization' => $row['gla_organization']));
         $this->menuList->addByController('respondent', 'show', $this->_('Show respondent'));
     }
 }
 /**
  * Adds rows 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_VerticalTableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function addShowTableRows(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     if ($this->addOnclickEdit) {
         $menuItem = $this->getEditMenuItem();
         if ($menuItem) {
             // Add click to edit
             $bridge->tbody()->onclick = array('location.href=\'', $menuItem->toHRefAttribute($this->request), '\';');
         }
     }
     parent::addShowTableRows($bridge, $model);
 }
 /**
  * Adds rows 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_VerticalTableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function addShowTableRows(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     foreach ($model->getItemsOrdered() as $name) {
         if ($label = $model->get($name, 'label')) {
             $bridge->addItem($name, $label);
         }
     }
     if ($model->has('row_class')) {
         // Make sure deactivated rounds are show as deleted
         foreach ($bridge->getTable()->tbody() as $tr) {
             foreach ($tr as $td) {
                 if ('td' === $td->tagName) {
                     $td->appendAttrib('class', $bridge->row_class);
                 }
             }
         }
     }
 }
 /**
  * Set the footer of the browse table.
  *
  * Overrule this function to set the header differently, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function setShowTableFooter(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $footer = $bridge->tfrow();
     $footer[] = $this->getQuestion();
     $footer[] = ' ';
     $footer->actionLink(array($this->confirmParameter => 1), $this->_('Yes'));
     $footer[] = ' ';
     $footer->actionLink(array($this->request->getActionKey() => $this->abortAction), $this->_('No'));
 }
 /**
  * Set the footer of the browse table.
  *
  * Overrule this function to set the header differently, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function setShowTableFooter(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $fparams = array('class' => 'centerAlign');
     $row = $bridge->getRow();
     if (isset($row[$this->filterWhen]) && $row[$this->filterWhen]) {
         $count = $this->db->fetchOne("SELECT COUNT(*) FROM gems__appointments WHERE " . $this->getWhere());
         if ($count) {
             $footer = $bridge->tfrow($fparams);
             $footer[] = sprintf($this->plural('This will delete %d appointment. Are you sure?', 'This will delete %d appointments. Are you sure?', $count), $count);
             $footer[] = ' ';
             $footer->actionLink(array($this->confirmParameter => 1), $this->_('Yes'));
             $footer[] = ' ';
             $footer->actionLink(array($this->request->getActionKey() => $this->abortAction), $this->_('No'));
         } else {
             $this->addMessage($this->_('Clean up not needed!'));
             $bridge->tfrow($this->_('No clean up needed, no appointments exist.'), $fparams);
         }
     } else {
         $this->addMessage($this->_('Clean up filter disabled!'));
         $bridge->tfrow($this->_('No clean up possible.'), array('class' => 'centerAlign'));
     }
     if ($this->displayMenu) {
         if (!$this->menuList) {
             $this->menuList = $this->menu->getCurrentMenuList($this->request, $this->_('Cancel'));
             $this->menuList->addCurrentSiblings();
         }
         if ($this->menuList instanceof \Gems_Menu_MenuList) {
             $this->menuList->addParameterSources($bridge);
         }
         $bridge->tfrow($this->menuList, $fparams);
     }
 }
 /**
  *
  * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge
  * @return void
  */
 protected function addOnClick(\MUtil_Model_Bridge_VerticalTableBridge $bridge)
 {
     if ($this->onclick) {
         $bridge->tbody()->onclick = array('location.href=\'', $this->onclick, '\';');
     }
 }
 /**
  * Place to set the data to display
  *
  * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge
  * @return void
  */
 protected function addTableCells(\MUtil_Model_Bridge_VerticalTableBridge $bridge)
 {
     $HTML = \MUtil_Html::create();
     $bridge->caption($this->getCaption());
     $br = $HTML->br();
     $address[] = $bridge->grs_address_1;
     $address[] = $br;
     if ($this->model->has('grs_address_2')) {
         $address[] = $bridge->grs_address_2;
         $address[] = $bridge->itemIf('grs_address_2', $br);
     }
     $address[] = $bridge->grs_zipcode;
     $address[] = $bridge->itemIf('grs_zipcode', new \MUtil_Html_Raw('  '));
     $address[] = $bridge->grs_city;
     // ROW 0
     $label = $this->model->get('gr2o_patient_nr', 'label');
     // Try to read label from model...
     if (empty($label)) {
         $label = $this->_('Respondent nr: ');
         // ...but have a fall-back
     }
     $bridge->addItem($bridge->gr2o_patient_nr, $label);
     $bridge->addItem($HTML->spaced($bridge->itemIf('grs_last_name', array($bridge->grs_last_name, ',')), $bridge->grs_gender, $bridge->grs_first_name, $bridge->grs_surname_prefix), $this->_('Respondent'));
     // ROW 1
     $bridge->addItem('grs_birthday');
     $bridge->addItem('grs_phone_1');
     // ROW 2
     $bridge->addItem('grs_email');
     $bridge->addItem($address, $this->_('Address'));
 }
 /**
  * Adds rows 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_VerticalTableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function addShowTableRows(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $this->_roundData = $bridge->getRow();
     if ($this->trackEngine instanceof \Gems_Tracker_Engine_StepEngineAbstract) {
         $this->trackEngine->updateRoundModelToItem($model, $this->_roundData, $this->locale->getLanguage());
     }
     $bridge->addItem('gro_id_track');
     $bridge->addItem('gro_id_survey');
     $bridge->addItem('gro_round_description');
     $bridge->addItem('gro_id_order');
     $bridge->addItem('gro_icon_file');
     if ($model->has('ggp_name')) {
         $bridge->addItem('ggp_name');
     } elseif ($model->has('gro_id_relationfield')) {
         $bridge->addItem('gro_id_relationfield');
     }
     $bridge->addItem($model->get('valid_after', 'value'));
     $this->_addIf(array('gro_valid_after_source', 'gro_valid_after_id', 'gro_valid_after_field'), $bridge, $model);
     if ($model->has('gro_valid_after_length', 'label')) {
         $bridge->addItem(array($bridge->gro_valid_after_length, ' ', $bridge->gro_valid_after_unit), $model->get('gro_valid_after_length', 'label'));
     }
     $bridge->addItem($model->get('valid_for', 'value'));
     $this->_addIf(array('gro_valid_for_source', 'gro_valid_for_id', 'gro_valid_for_field'), $bridge, $model);
     if ($model->has('gro_valid_for_length', 'label')) {
         $bridge->addItem(array($bridge->gro_valid_for_length, ' ', $bridge->gro_valid_for_unit), $model->get('gro_valid_after_length', 'label'));
     }
     $bridge->addItem('gro_active');
     // Preven empty row when no changed events exist
     if ($label = $model->get('gro_changed_event', 'label')) {
         $bridge->addItem('gro_changed_event');
     }
     $bridge->addItem('gro_code');
     $bridge->addItem('org_specific_round');
     if ($this->_roundData['org_specific_round']) {
         $bridge->addItem('organizations');
     }
     $menuItem = $this->menu->find(array($this->request->getControllerKey() => $this->request->getControllerName(), $this->request->getActionKey() => 'edit'));
     if ($menuItem) {
         $bridge->tbody()->onclick = array('location.href=\'', $menuItem->toHRefAttribute($this->request), '\';');
     }
 }