当前位置: 首页>>代码示例>>PHP>>正文


PHP Gems_Util::getReceptionCode方法代码示例

本文整理汇总了PHP中Gems_Util::getReceptionCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Gems_Util::getReceptionCode方法的具体用法?PHP Gems_Util::getReceptionCode怎么用?PHP Gems_Util::getReceptionCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gems_Util的用法示例。


在下文中一共展示了Gems_Util::getReceptionCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setReceptionCode

 /**
  * Set the reception code for a respondent and cascade non-success codes to the
  * tracks / surveys.
  *
  * @param string $patientId   Can be empty if $respondentId is passed
  * @param int $organizationId
  * @param string $newCode     String or \Gems_Util_ReceptionCode
  * @param int $respondentId   Pass when at hand, is looked up otherwise
  * @param string $oldCode     Pass when at hand as tring or \Gems_Util_ReceptionCode, is looked up otherwise
  * @return \Gems_Util_ReceptionCode The new code reception code object for further processing
  */
 public function setReceptionCode($patientId, $organizationId, $newCode, $respondentId = null, $oldCode = null)
 {
     if ($newCode instanceof \Gems_Util_ReceptionCode) {
         $code = $newCode;
         $newCode = $code->getCode();
     } else {
         $code = $this->util->getReceptionCode($newCode);
     }
     $userId = $this->currentUser->getUserId();
     // Perform actual save, but not for simple stop codes.
     if ($code->isForRespondents()) {
         if (null === $oldCode) {
             $oldCode = $this->getReceptionCode($patientId, $organizationId, $respondentId);
         }
         if ($oldCode instanceof \Gems_Util_ReceptionCode) {
             $oldCode = $oldCode->getCode();
         }
         // If the code wasn't set already
         if ($oldCode !== $newCode) {
             $values['gr2o_reception_code'] = $newCode;
             $values['gr2o_changed'] = new \MUtil_Db_Expr_CurrentTimestamp();
             $values['gr2o_changed_by'] = $userId;
             if ($patientId) {
                 // Update though primamry key is prefered
                 $where = 'gr2o_patient_nr = ? AND gr2o_id_organization = ?';
                 $where = $this->db->quoteInto($where, $patientId, null, 1);
             } else {
                 $where = 'gr2o_id_user = ? AND gr2o_id_organization = ?';
                 $where = $this->db->quoteInto($where, $respondentId, null, 1);
             }
             $where = $this->db->quoteInto($where, $organizationId, null, 1);
             $this->db->update('gems__respondent2org', $values, $where);
         }
     }
     // Is the respondent really removed
     if (!$code->isSuccess()) {
         // Only check for $respondentId when it is really needed
         if (null === $respondentId) {
             $respondentId = $this->util->getDbLookup()->getRespondentId($patientId, $organizationId);
         }
         // Cascade to tracks
         // the responsiblilty to handle it correctly is on the sub objects now.
         $tracks = $this->loader->getTracker()->getRespondentTracks($respondentId, $organizationId);
         foreach ($tracks as $track) {
             if ($track->setReceptionCode($code, null, $userId)) {
                 $this->addChanged();
             }
         }
     }
     if ($code->isForRespondents()) {
         $this->handleRespondentChanged($patientId, $organizationId, $respondentId);
     }
     return $code;
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:65,代码来源:RespondentModel.php

示例2: getReceptionCode

 /**
  * Return the \Gems_Util_ReceptionCode object
  *
  * @return \Gems_Util_ReceptionCode reception code
  */
 public function getReceptionCode()
 {
     return $this->util->getReceptionCode($this->_gemsData['gr2o_reception_code']);
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:9,代码来源:Respondent.php

示例3: setReceptionCode

 /**
  * Set the reception code for this respondent track and make sure the
  * necessary cascade to the tokens and thus the source takes place.
  *
  * @param string $code The new (non-success) reception code or a \Gems_Util_ReceptionCode object
  * @param string $comment Comment for tokens. False values leave value unchanged
  * @param int $userId The current user
  * @return int 1 if the token has changed, 0 otherwise
  */
 public function setReceptionCode($code, $comment, $userId)
 {
     // Make sure it is a \Gems_Util_ReceptionCode object
     if (!$code instanceof \Gems_Util_ReceptionCode) {
         $code = $this->util->getReceptionCode($code);
     }
     $changed = 0;
     // Apply this code both only when it is a track code.
     // Patient level codes are just cascaded to the tokens.
     //
     // The exception is of course when the exiting values must
     // be overwritten, e.g. when cooperation is retracted.
     if ($code->isForTracks() || $code->isOverwriter()) {
         $values['gr2t_reception_code'] = $code->getCode();
     }
     $values['gr2t_comment'] = $comment;
     $changed = $this->_updateTrack($values, $userId);
     // Stopcodes have a different logic.
     if ($code->isStopCode()) {
         // Cascade stop to tokens
         foreach ($this->getTokens() as $token) {
             if ($token->hasSuccesCode() && !$token->isCompleted()) {
                 $changed += $token->setReceptionCode($code, $comment, $userId);
             }
         }
         $changed = max($changed, 1);
         // Update token count / completion
         $this->_checkTrackCount($userId);
     } elseif (!$code->isSuccess()) {
         // Cascade code to tokens
         foreach ($this->getTokens() as $token) {
             if ($token->hasSuccesCode()) {
                 $token->setReceptionCode($code, $comment, $userId);
             }
         }
     }
     return $changed;
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:47,代码来源:RespondentTrack.php

示例4: setReceptionCode

 /**
  * Set the reception code for this token and make sure the necessary
  * cascade to the source takes place.
  *
  * @param string $code The new (non-success) reception code or a \Gems_Util_ReceptionCode object
  * @param string $comment Comment False values leave value unchanged
  * @param int $userId The current user
  * @return int 1 if the token has changed, 0 otherwise
  */
 public function setReceptionCode($code, $comment, $userId)
 {
     // Make sure it is a \Gems_Util_ReceptionCode object
     if (!$code instanceof \Gems_Util_ReceptionCode) {
         $code = $this->util->getReceptionCode($code);
     }
     $values['gto_reception_code'] = $code->getCode();
     if ($comment) {
         $values['gto_comment'] = $comment;
     }
     // \MUtil_Echo::track($values);
     $changed = $this->_updateToken($values, $userId);
     if ($changed) {
         if ($code->isOverwriter() || !$code->isSuccess()) {
             $survey = $this->getSurvey();
             // Update the consent code in the source
             if ($survey->inSource($this)) {
                 $survey->updateConsent($this);
             }
         }
     }
     return $changed;
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:32,代码来源:Token.php

示例5: execute

 /**
  * Should handle execution of the task, taking as much (optional) parameters as needed
  *
  * The parameters should be optional and failing to provide them should be handled by
  * the task
  *
  * @param array $row Row to save
  */
 public function execute($row = null, $noToken = \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR, $tokenCompletion = \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR)
 {
     // \MUtil_Echo::track($row);
     if ($row) {
         $answers = $row;
         $double = false;
         $token = null;
         $tracker = $this->loader->getTracker();
         $userId = $this->loader->getCurrentUser()->getUserId();
         // \Gems_Tracker::$verbose = true;
         $batch = $this->getBatch();
         $batch->addToCounter('imported');
         // Remove all "non-answer" fields
         unset($answers['token'], $answers['patient_id'], $answers['organization_id'], $answers['track_id'], $answers['survey_id'], $answers['completion_date'], $answers['gto_id_token']);
         if (isset($row['survey_id'])) {
             $model = $tracker->getSurvey($row['survey_id'])->getAnswerModel('en');
             foreach ($answers as $key => &$value) {
                 if ($value instanceof \Zend_Date) {
                     $value = $value->toString($model->getWithDefault($key, 'storageFormat', 'yyyy-MM-dd HH:mm:ss'));
                 }
             }
         }
         if (isset($row['token']) && $row['token']) {
             $token = $tracker->getToken($row['token']);
             if ($token->exists && $token->isCompleted() && $token->getReceptionCode()->isSuccess()) {
                 $currentAnswers = $token->getRawAnswers();
                 $usedAnswers = array_intersect_key($answers, $currentAnswers);
                 // \MUtil_Echo::track($currentAnswers, $answers, $usedAnswers);
                 if ($usedAnswers) {
                     foreach ($usedAnswers as $name => $value) {
                         if (null === $answers[$name] || $answers[$name] == $this->targetModel->get($name, 'default')) {
                             // There is no value to set, so do not set the value
                             unset($answers[$name]);
                         } elseif (!(null === $value || $value == $this->targetModel->get($name, 'default'))) {
                             // The value was already set
                             $double = true;
                             // But no break because of previous unsets
                             // break;
                         }
                     }
                 }
             }
         }
         if (!($token && $token->exists)) {
             if (!(isset($row['track_id']) && $row['track_id'])) {
             }
             // create token?
         }
         if ($answers) {
             if ($double) {
                 if (\Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_OVERWRITE == $tokenCompletion) {
                     $code = $this->util->getReceptionCode('redo');
                     $oldComment = "";
                     if ($token->getComment()) {
                         $oldComment .= "\n\n";
                         $oldComment .= $this->_('Previous comments:');
                         $oldComment .= "\n";
                         $oldComment .= $token->getComment();
                     }
                     $newComment = sprintf($this->_('Token %s overwritten by import.'), $token->getTokenId());
                     $replacementTokenId = $token->createReplacement($newComment . $oldComment, $userId);
                     $count = $batch->addToCounter('overwritten', 1);
                     $batch->setMessage('overwritten', sprintf($this->plural('%d token overwrote an existing token.', '%d tokens overwrote existing tokens.', $count), $count));
                     $oldToken = $token;
                     $token = $tracker->getToken($replacementTokenId);
                     // Add the old answers to the new answer set as the new answers OVERWRITE the old data
                     $answers = $answers + $currentAnswers;
                     // Make sure the Next token is set right
                     $oldToken->setNextToken($token);
                     $oldToken->setReceptionCode($code, sprintf($this->_('Token %s overwritten by import.'), $token->getTokenId()) . $oldComment, $userId);
                 } else {
                     $oldComment = "";
                     if ($token->getComment()) {
                         $oldComment .= "\n\n";
                         $oldComment .= $this->_('Previous comments:');
                         $oldComment .= "\n";
                         $oldComment .= $token->getComment();
                     }
                     $newComment = sprintf($this->_('More answers for token %s by import.'), $token->getTokenId());
                     $replacementTokenId = $token->createReplacement($newComment . $oldComment, $userId);
                     $count = $batch->addToCounter('addedAnswers', 1);
                     $batch->setMessage('addedAnswers', sprintf($this->plural('%d token was imported as a new extra token.', '%d tokens were imported as a new extra token.', $count), $count));
                     $oldToken = $token;
                     $token = $tracker->getToken($replacementTokenId);
                     // Make sure the Next token is set right
                     $oldToken->setNextToken($token);
                     $oldToken->setReceptionCode($oldToken->getReceptionCode(), sprintf($this->_('Additional answers in imported token %s.'), $token->getTokenId()) . $oldComment, $userId);
                 }
             }
             // There are still answers left to save
             // Make sure the token is known
             $token->getUrl($this->locale->getLanguage(), $userId);
//.........这里部分代码省略.........
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:101,代码来源:SaveAnswerTask.php


注:本文中的Gems_Util::getReceptionCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。