コード例 #1
0
 /**
  * Returns the date to use to calculate the ValidUntil if any
  *
  * @param string $fieldSource Source for field from round
  * @param string $fieldName Name from round
  * @param int $prevRoundId Id from round
  * @param \Gems_Tracker_Token $token
  * @param \Gems_Tracker_RespondentTrack $respTrack
  * @param \MUtil_Date $validFrom The calculated new valid from value or null
  * @return \MUtil_Date date time or null
  */
 protected function getValidUntilDate($fieldSource, $fieldName, $prevRoundId, \Gems_Tracker_Token $token, \Gems_Tracker_RespondentTrack $respTrack, $validFrom)
 {
     $date = null;
     switch ($fieldSource) {
         case parent::NO_TABLE:
             break;
         case parent::TOKEN_TABLE:
             // Always uses the current token
             if ($fieldName == 'gto_valid_from') {
                 // May be changed but is not yet stored
                 $date = $validFrom;
             } else {
                 // No previous here, date is always from this tokens date
                 $date = $token->getDateTime($fieldName);
             }
             break;
         case parent::ANSWER_TABLE:
             if ($prev = $token->getPreviousSuccessToken()) {
                 $date = $prev->getAnswerDateTime($fieldName);
             }
             break;
         case parent::APPOINTMENT_TABLE:
         case parent::RESPONDENT_TRACK_TABLE:
             $date = $respTrack->getDate($fieldName);
             break;
     }
     return $date;
 }