private static function sendReminder($tour, $tournament, $users) { $subject = "Напоминание: сделайте прогноз на матчи {$tour} тура турнира " . Tournaments::findOne($tournament)->tournament_name; $firstGameStarts = date('d-m-Y в H:i', ArrayHelper::getValue(Result::find()->select(['min(dtime) as dtime'])->where(['id_tournament' => $tournament, 'tour' => $tour])->all()[0], 'dtime')); $tours = Games::getNumberOfGamesPerTour($tournament); foreach ($users as $user) { if (Forecasts::getUserForecastTour($user->id, $tournament, $tours)[$tour] == 0) { $description = "Вы не сделали прогноз на матчи {$tour} тура турнира " . Tournaments::findOne($tournament)->tournament_name . ". Поторопитесь, первая игра тура начинается <strong>{$firstGameStarts}</strong>"; } else { $description = "Вы сделали прогноз не на все матчи: {$tour} тура турнира " . Tournaments::findOne($tournament)->tournament_name . ". Поторопитесь, первая игра тура начинается {$firstGameStarts}"; } $content = new ArrayDataProvider(['allModels' => Forecasts::getTourUserForecastStatus($tour, $tournament, $user->id), 'sort' => false, 'pagination' => false]); $messages[] = Yii::$app->mailer->compose('reminder', ['content' => $content, 'description' => $description, 'user' => $user])->setFrom([Yii::$app->params['adminEmail'] => 'Sportforecast'])->setTo($user->email)->setSubject($subject); //adding a record to the DB $reminder = self::getReminder($user->id, $tournament, $tour); $reminder->save(); } if (!empty($messages)) { Yii::$app->mailer->sendMultiple($messages); } return true; }
public function actionTour($tour, $tournament, $user) { $forecastStatus = Forecasts::getTourUserForecastStatus($tour, $tournament, $user); $forecast = new ArrayDataProvider(['allModels' => $forecastStatus]); return $this->renderAjax('tour', ['forecast' => $forecast]); }