public function getReviewReason() { $history = self::getHistoryStatus($this->record_id); if (!$history) { return false; } $reason = $history->reason; if (!$reason) { return false; } $reasonsList = Reasons::listReasonsRequestDeactivation(); return $reason->code == Reasons::OTHER ? $reason->description : $reasonsList[$reason->code]; }
/** * @param Record $record * @return string */ private function getForm(Record $record) { $user = Yii::$app->user; switch (true) { case $record->status_id == CaseStatus::AWAITING_DEACTIVATION && $user->can('ApproveDeactivation'): $model = new DeactivateForm(['record_id' => $record->id]); $reasonsList = Reasons::listReasonsRejectingDeactivationRequest(); return $this->controller()->renderPartial('../forms/deactivate', ['action' => Url::to(['deactivate', 'id' => $record->id]), 'model' => $model, 'reasonsList' => $reasonsList]); case in_array($record->status_id, [CaseStatus::COMPLETE, CaseStatus::FULL_COMPLETE]) && $user->can('RequestDeactivation'): $model = new RequestDeactivateForm(); $reasonsList = Reasons::listReasonsRequestDeactivation(); return $this->controller()->renderPartial('../forms/request-deactivation', ['action' => Url::to(['RequestDeactivation', 'id' => $record->id]), 'model' => $model, 'reasonsList' => $reasonsList]); default: return ''; } }