/**
  * 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)
 {
     $delay = $this->project->getAskDelay($this->request, $this->wasAnswered);
     $href = $this->getTokenHref($this->showToken);
     $html = $this->getHtmlSequence();
     $org = $this->showToken->getOrganization();
     $url = $href->render($this->view);
     switch ($delay) {
         case 0:
             // Redirect at once
             header('Location: ' . $url);
             exit;
         case -1:
             break;
         default:
             // Let the page load after stated interval
             $this->view->headMeta()->appendHttpEquiv('Refresh', $delay . '; url=' . $url);
     }
     $html->h3($this->_('Token'));
     if ($this->token->hasRelation()) {
         $p = $html->pInfo(sprintf($this->_('Welcome %s,'), $this->showToken->getRelation()->getName()));
         $html->pInfo(sprintf($this->_('We kindly ask you to answer a survey about %s.'), $this->showToken->getRespondent()->getName()));
     } else {
         $p = $html->pInfo(sprintf($this->_('Welcome %s,'), $this->showToken->getRespondentName()));
     }
     if ($this->wasAnswered) {
         $html->pInfo(sprintf($this->_('Thank you for answering the "%s" survey.'), $this->token->getSurveyName()));
         $html->pInfo($this->_('Please click the button below to answer the next survey.'));
     } else {
         if ($welcome = $org->getWelcome()) {
             $html->pInfo()->raw(\MUtil_Markup::render($this->_($welcome), 'Bbcode', 'Html'));
         }
         $html->pInfo(sprintf($this->_('Please click the button below to answer the survey for token %s.'), strtoupper($this->showToken->getTokenId())));
     }
     if ($delay > 0) {
         $html->pInfo(sprintf($this->plural('Wait one second to open the survey automatically or click on Cancel to stop.', 'Wait %d seconds to open the survey automatically or click on Cancel to stop.', $delay), $delay));
     }
     $buttonDiv = $html->buttonDiv(array('class' => 'centerAlign'));
     $buttonDiv->actionLink($href, $this->showToken->getSurveyName());
     if ($delay > 0) {
         $buttonDiv->actionLink(array('delay_cancelled' => 1), $this->_('Cancel'));
     }
     if ($next = $this->showToken->getTokenCountUnanswered()) {
         $html->pInfo(sprintf($this->plural('After this survey there is one other survey we would like you to answer.', 'After this survey there are another %d surveys we would like you to answer.', $next), $next));
     }
     if ($sig = $org->getSignature()) {
         $html->pInfo()->raw(\MUtil_Markup::render($this->_($sig), 'Bbcode', 'Html'));
     }
     return $html;
 }
 /**
  * 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)
 {
     $htmlDiv = \MUtil_Html::create()->div(array('class' => 'answer-container'));
     if ($this->tokenId) {
         if ($this->token->exists) {
             if ($this->showHeaders) {
                 $htmlDiv->h3(sprintf($this->_('%s answers for patient number %s'), $this->token->getSurveyName(), $this->token->getPatientNumber()));
                 $htmlDiv->pInfo(sprintf($this->_('Answers for token %s, patient number %s: %s.'), strtoupper($this->tokenId), $this->token->getPatientNumber(), $this->token->getRespondentName()))->appendAttrib('class', 'noprint');
             }
             $table = parent::getHtmlOutput($view);
             $table->setPivot(true, 2, 1);
             $this->applyHtmlAttributes($table);
             $this->class = false;
             $htmlDiv[] = $table;
         } else {
             $htmlDiv->ul(sprintf($this->_('Token %s not found.'), $this->tokenId), array('class' => 'errors'));
         }
     } else {
         $htmlDiv->ul($this->_('No token specified.'), array('class' => 'errors'));
     }
     if ($this->showButtons) {
         $buttonDiv = $htmlDiv->buttonDiv();
         $buttonDiv->actionLink(array(), $this->_('Close'), array('onclick' => 'window.close();'));
         $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();'));
     }
     return $htmlDiv;
 }
 /**
  * Copied from parent, but insert chart instead of table after commented out part
  *
  * @param \Zend_View_Abstract $view
  * @return type
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     //$view->headLink()->prependStylesheet($view->serverUrl() . \GemsEscort::getInstance()->basepath->getBasePath() . '/gems/css/barchart.less', 'screen,print');
     $htmlDiv = \MUtil_Html::create()->div(' ', array('class' => 'barchartcontainer'));
     if ($this->showHeaders) {
         if (isset($this->token)) {
             $htmlDiv->h3(sprintf($this->_('Overview for patient number %s'), $this->token->getPatientNumber()));
             $htmlDiv->pInfo(sprintf($this->_('Overview for patient number %s: %s.'), $this->token->getPatientNumber(), $this->token->getRespondentName()))->appendAttrib('class', 'noprint');
         } else {
             $htmlDiv->pInfo($this->_('No data present'));
         }
     }
     if (!empty($this->data)) {
         $htmlDiv->append($this->getChart());
         // Insert the chart here
     }
     if ($this->showButtons) {
         $buttonDiv = $htmlDiv->buttonDiv();
         $buttonDiv->actionLink(array(), $this->_('Back'), array('onclick' => 'window.history.go(-1); return false;'));
         $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();'));
     }
     // Make vertically resizable
     $view = \Zend_Layout::getMvcInstance()->getView();
     /*$jquery = $view->jQuery();
       $jquery->enable();*/
     \MUtil_JQuery::enableView($view);
     // We need width 100% otherwise it will look strange in print output
     $view->jQuery()->addOnLoad("\$('.barchart').resizable({\r\n            handles: 's',\r\n            resize: function( event, ui ) { ui.element.css({ width: '100%'}); },\r\n            minHeight: 150\r\n            });");
     return $htmlDiv;
 }