public function actionDetails($id)
 {
     $user = Yii::$app->user;
     Yii::$app->user->returnUrl = Yii::$app->request->url;
     $tournament = Tournaments::findOne($id);
     if ($tournament === null) {
         throw new NotFoundHttpException('Запрашиваемая страница не найдена.');
     }
     $teamParticipants = new ArrayDataProvider(['allModels' => Result::getStandings($id), 'pagination' => false]);
     //games list prep
     if (Yii::$app->request->post('tours')) {
         $tours = Yii::$app->request->post('tours');
     } else {
         $tours = range(1, $tournament->num_tours, 1);
     }
     for ($i = 1; $i <= $tournament->num_tours; $i++) {
         $tour_list[$i] = "{$i} тур";
     }
     $forecasters = new ActiveDataProvider(['query' => UsersTournaments::find()->forecastersStandings($id), 'pagination' => false]);
     //if guest or not participating in the tournament
     if ($user->isGuest || !$user->identity->isUserParticipatesInTournament($id)) {
         $tourGames = Games::getGamesGroupedByTour($id, $tours);
         $viewFile = 'tournamentDetailsGuest';
         $winners = [];
         $forecastedStandings = [];
     } else {
         $forecastedStandings = new ArrayDataProvider(['allModels' => Result::getForecastedStandings($id, $user->id), 'pagination' => false]);
         $tourGames = Games::getGamesGroupedByTourWithForecast($id, $tours, $user->id);
         $viewFile = 'tournamentDetailsUser';
         //preparing tournament winners forecast form
         $winners = new TopTeamsForm($user->id, $id);
         if ($winners->load(Yii::$app->request->post()) && $winners->validate()) {
             if (time() < $tournament->wfDueTo) {
                 $winners->edit();
                 Yii::$app->getSession()->setFlash('success', 'Прогноз на призеров турнира успешно сохранен');
             } else {
                 Yii::$app->getSession()->setFlash('success', 'Не нужно пытаться обмануть :)');
             }
             return $this->refresh();
         }
     }
     $data = compact('tournament', 'teamParticipants', 'forecasters', 'tour_list', 'tourGames', 'winners', 'forecastedStandings');
     if ($tournament->is_active == Tournaments::FINISHED) {
         $data['additionalPoints'] = implode('</br>', Top3TeamsForecast::getClarifications($user->id, $id));
         $userTournamentsModel = UsersTournaments::find()->where(['id_tournament' => $id])->andWhere(['id_user' => $user->id])->with('winnersForecast')->one();
         if (!empty($userTournamentsModel)) {
             $data['totalAdditionalPoints'] = $userTournamentsModel->calculateAdditionalPoints();
         }
     } else {
         $data['additionalPoints'] = '';
         $data['totalAdditionalPoints'] = '';
     }
     return $this->render($viewFile, $data);
 }