コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * Process the data and return the answers that should be changed.
  *
  * Storing the changed values is handled by the calling function.
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @return array Containing the changed values
  */
 public function processTokenData(\Gems_Tracker_Token $token)
 {
     if (!$token->getReceptionCode()->isSuccess()) {
         return;
     }
     $answers = $token->getRawAnswers();
     if (isset($answers['informedconsent'])) {
         $consent = $this->util->getConsent($answers['informedconsent']);
         if ($consent->exists) {
             // Is existing consent description as answer
             $consentCode = $consent->getDescription();
         } else {
             if ($answers['informedconsent']) {
                 // Uses start of consent description as answer (LS has only 5 chars for an answer option)
                 $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_description LIKE ? ORDER BY gco_order", $answers['informedconsent'] . '%');
             } else {
                 $consentCode = false;
             }
             if (!$consentCode) {
                 if ($answers['informedconsent']) {
                     // Code not found, use first positive consent
                     $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_code != ? ORDER BY gco_order", $this->util->getConsentRejected());
                 } else {
                     // Code not found, use first negative consent
                     $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_code = ? ORDER BY gco_order", $this->util->getConsentRejected());
                 }
             }
         }
         $respondent = $token->getRespondent();
         $values = array('gr2o_patient_nr' => $respondent->getPatientNumber(), 'gr2o_id_organization' => $respondent->getOrganizationId(), 'gr2o_consent' => $consentCode);
         $respondent->getRespondentModel()->save($values);
     }
     return false;
 }