/** * Process the data and do what must be done * * Storing the changed $values is handled by the calling function. * * @param \Gems_Tracker_RespondentTrack $respTrack Gems respondent track object * @param int $userId The current userId * @return void */ public function processFieldUpdate(\Gems_Tracker_RespondentTrack $respTrack, $userId) { $agenda = $this->loader->getAgenda(); $change = false; $token = $respTrack->getFirstToken(); if (!$token) { return; } do { if ($token->isCompleted()) { continue; } $appId = $respTrack->getRoundAfterAppointmentId($token->getRoundId()); // Not a round without appointment id if ($appId !== false) { if ($appId) { $appointment = $agenda->getAppointment($appId); } else { $appointment = null; } if ($appointment && $appointment->isActive()) { $newCode = \GemsEscort::RECEPTION_OK; $newText = null; } else { $newCode = 'skip'; $newText = $this->_('Skipped until appointment is set'); } $oldCode = \GemsEscort::RECEPTION_OK === $newCode ? 'skip' : \GemsEscort::RECEPTION_OK; $curCode = $token->getReceptionCode()->getCode(); // \MUtil_Echo::track($token->getTokenId(), $curCode, $oldCode, $newCode); if ($oldCode === $curCode && $curCode !== $newCode) { $change = true; $token->setReceptionCode($newCode, $newText, $userId); } } } while ($token = $token->getNextToken()); if ($change) { $respTrack->refresh(); } }