/**
  * Lists all Competition models of interest for Starter.
  * @return mixed
  */
 public function actionIndex()
 {
     $now = date('Y-m-d H:i:s');
     /** Competition open for registration by starter.
      *  For starters, a competition is open for registration from the day it exists (ie before official registration opens),
      *  to the day the competition is 'published'.
      *  So any competition in status OPEN can accept registrations.
      */
     $registrationSearch = new CompetitionSearch();
     $registrationProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_OPEN])]);
     /** Competition ready to be prepared. It must be a Match.
      *  Registration must be officially closed, and competition cannot be started yet.
      *  So any competition in status OPEN, after the closing registration date is ready to be prepared.
      */
     $startSearch = new CompetitionSearch();
     $startProvider = new ActiveDataProvider(['query' => Match::find()->where(['status' => Competition::STATUS_OPEN])->andWhere(['<', 'registration_end', $now])]);
     /** Competition ready to be played.
      *  Registration must be READY and in the past (terminated).
      */
     $readySearch = new CompetitionSearch();
     $readyProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_READY])->andWhere(['>=', 'start_date', $now])]);
     /** Planned competition.
      *  Registration must be OPEN and we must be before the registration 
      */
     $planSearch = new CompetitionSearch();
     $planProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_OPEN])->andWhere(['>', 'registration_begin', $now])]);
     /** Closed or terminated competition.
      *  Registration must be CLOSED. 
      */
     $closedSearch = new CompetitionSearch();
     $closedProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_CLOSED])]);
     $allSearch = new CompetitionSearch();
     $allProvider = new ActiveDataProvider(['query' => Competition::find()]);
     return $this->render('index', ['registrationProvider' => $registrationProvider, 'registrationSearch' => $registrationSearch, 'startProvider' => $startProvider, 'startSearch' => $startSearch, 'readyProvider' => $readyProvider, 'readySearch' => $readySearch, 'planProvider' => $planProvider, 'planSearch' => $planSearch, 'closedProvider' => $closedProvider, 'closedSearch' => $closedSearch]);
 }
 /**
  * Lists all Competition models.
  * @return mixed
  */
 public function actionIndex()
 {
     $now = date('Y-m-d H:i:s');
     /** Competition open for registration by golfer.
      */
     $registrationSearch = new CompetitionSearch();
     $registrationProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_OPEN])->andWhere(['>', 'registration_begin', $now])->andWhere(['<', 'registration_end', $now])]);
     /** Competition ready to be played.
      */
     $startSearch = new CompetitionSearch();
     $startProvider = new ActiveDataProvider(['query' => Match::find()->where(['status' => Competition::STATUS_READY])->andWhere(['<', 'registration_end', $now])->andWhere(['>', 'start_date', $now])]);
     /** Competition for results.
      */
     $resultSearch = new MatchSearch();
     $resultProvider = new ActiveDataProvider(['query' => Match::find()->where(['status' => Competition::STATUS_READY])]);
     /** Competition awaiting results entry.
      *  Registration must be READY and in the past (terminated).
      */
     $result2Search = new CompetitionSearch();
     $result2Provider = new ActiveDataProvider(['query' => Competition::find()->andWhere(['status' => Competition::STATUS_OPEN])->andWhere(['!=', 'competition_type', Competition::TYPE_MATCH])]);
     /** Planned competition.
      *  Registration must be OPEN and we must be before the registration 
      */
     $planSearch = new CompetitionSearch();
     $planProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_OPEN])->andWhere(['>', 'registration_begin', $now])]);
     /** Closed or terminated competition.
      *  Registration must be CLOSED. 
      */
     $closedSearch = new CompetitionSearch();
     $closedProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_CLOSED])]);
     $allSearch = new CompetitionSearch();
     $allProvider = new ActiveDataProvider(['query' => Competition::find()]);
     return $this->render('index', ['registrationProvider' => $registrationProvider, 'registrationSearch' => $registrationSearch, 'startProvider' => $startProvider, 'startSearch' => $startSearch, 'resultProvider' => $resultProvider, 'resultSearch' => $resultSearch, 'result2Provider' => $result2Provider, 'result2Search' => $result2Search, 'planProvider' => $planProvider, 'planSearch' => $planSearch, 'closedProvider' => $closedProvider, 'closedSearch' => $closedSearch]);
 }
 /**
  * Lists all Competition models of interest for Starter.
  * @return mixed
  */
 public function actionIndex()
 {
     $now = date('Y-m-d H:i:s');
     /** Competitions that are ready to be played.
      */
     $readySearch = new CompetitionSearch();
     $readyProvider = new ActiveDataProvider(['query' => Match::find()->where(['status' => Competition::STATUS_READY])->andWhere(['<=', 'start_date', $now])]);
     /** Ongoing competition.
      */
     $openSearch = new CompetitionSearch();
     $openProvider = new ActiveDataProvider(['query' => Match::find()->where(['status' => Competition::STATUS_READY])->andWhere(['>', 'start_date', $now])]);
     /** Competitions that are ready to be played.
      */
     $openTournamentSearch = new CompetitionSearch();
     $openTournamentProvider = new ActiveDataProvider(['query' => Competition::find()->where(['competition_type' => [Competition::TYPE_TOURNAMENT, Competition::TYPE_SEASON], 'status' => Competition::STATUS_OPEN])]);
     /** Competitions that are ready to be played.
      */
     $readyTournamentSearch = new CompetitionSearch();
     $readyTournamentProvider = new ActiveDataProvider(['query' => Competition::find()->where(['competition_type' => [Competition::TYPE_TOURNAMENT, Competition::TYPE_SEASON], 'status' => Competition::STATUS_READY])]);
     /** Awaiting scores competition.
      *  Registration must be OPEN and we must be before the registration 
      */
     $completedSearch = new CompetitionSearch();
     $completedProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_COMPLETED])]);
     /** Closed or terminated competition.
      *  Registration must be CLOSED. 
      */
     $closedSearch = new CompetitionSearch();
     $closedProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_CLOSED])]);
     return $this->render('index', ['readyProvider' => $readyProvider, 'readySearch' => $readySearch, 'openProvider' => $openProvider, 'openSearch' => $openSearch, 'completedProvider' => $completedProvider, 'completedSearch' => $completedSearch, 'closedProvider' => $closedProvider, 'closedSearch' => $closedSearch, 'openTournamentSearch' => $openTournamentSearch, 'openTournamentProvider' => $openTournamentProvider, 'readyTournamentSearch' => $readyTournamentSearch, 'readyTournamentProvider' => $readyTournamentProvider]);
 }
Example #4
0
 public function actionIndex()
 {
     if (Yii::$app->user->isGuest) {
         return $this->render('index');
     }
     $now = date('Y-m-d H:i:s');
     $competitions = new ActiveDataProvider(['query' => Match::find()->andWhere(['>', 'start_date', $now])]);
     return $this->render('golfer', ['competitions' => $competitions]);
 }
Example #5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Match::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'course_id' => $this->course_id, 'holes' => $this->holes, 'rule_id' => $this->rule_id, 'start_date' => $this->start_date, 'registration_begin' => $this->registration_begin, 'registration_end' => $this->registration_end, 'handicap_min' => $this->handicap_min, 'handicap_max' => $this->handicap_max, 'age_min' => $this->age_min, 'age_max' => $this->age_max, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'competition_type', $this->competition_type])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $matches = Match::find()->with('team', 'competition')->orderBy(['date_time' => SORT_DESC])->asArray()->all();
     $trainingMatches = TrainingMatch::find()->with('greenPlayers', 'purplePlayers')->orderBy(['date_time' => SORT_DESC])->asArray()->all();
     $trainingMatchStandings = TrainingMatchStandings::find()->one()->sorted();
     $playersStatisticSummary = PlayerStatisticSummary::find()->with(['player' => function ($query) {
         $query->with('playerLastResultsAggregated');
     }])->orderBy(['count_points' => SORT_DESC, 'count_games' => SORT_ASC])->limit(5)->asArray()->all();
     $playersRatingLebedev = PlayerRatingLebedevSummary::find()->with(['player' => function ($query) {
         $query->with('playerLastResultsAggregated');
     }])->orderBy(['rating_lebedev_avg' => SORT_DESC])->limit(5)->asArray()->all();
     return $this->render('index', ['matches' => $matches, 'trainingMatches' => $trainingMatches, 'trainingMatchStandings' => $trainingMatchStandings, 'playersStatisticSummary' => $playersStatisticSummary, 'playersRatingLebedev' => $playersRatingLebedev]);
 }
Example #7
0
 public function run()
 {
     $calendarEvents = [];
     // 1. Events
     foreach (Event::find()->orderBy('event_start')->each() as $event) {
         $calendarEvents[] = $event->getFullCalendarEvent();
     }
     // 2. Matches
     foreach (Match::find()->each() as $match) {
         foreach ($match->getEvents() as $event) {
             $calendarEvents[] = $event->getFullCalendarEvent();
         }
     }
     return $this->render('calendar', ['events' => $calendarEvents, 'months' => 3]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MatchEvent::find();
     $match = new Match();
     $matchEventTable = MatchEvent::tableName();
     $matchTable = Match::tableName();
     $query->joinWith(['match' => function ($query) use($matchTable) {
         $query->from(['match' => $matchTable]);
     }]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(["{$matchEventTable}.id" => $this->id, 'match_id' => $this->match_id, 'match_event_type_id' => $this->match_event_type_id, 'composition_id' => $this->composition_id, 'minute' => $this->minute, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'substitution_id' => $this->substitution_id, 'additional_minute' => $this->additional_minute, 'is_hidden' => $this->is_hidden, 'position' => $this->position]);
     $query->andFilterWhere(['like', "notes", $this->notes]);
     return $dataProvider;
 }
 /**
  * Creates a new Composition model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($matchId = null, $teamId = null)
 {
     $model = new Composition();
     if (!isset($matchId) || !isset($teamId)) {
         throw new \yii\web\BadRequestHttpException('Unidentified matchId and teamId');
     }
     $match = Match::findOne($matchId);
     $team = Team::findOne($teamId);
     if (!isset($match) || !isset($team)) {
         throw new \yii\web\BadRequestHttpException('Unidentified match and team models');
     }
     $model->command_id = $teamId;
     $model->match_id = $matchId;
     $model->is_basis = 1;
     $contractTeams = Team::getContractTeams();
     if (in_array($teamId, $contractTeams)) {
         $model->contract_type = Composition::CONTRACT_TYPE;
         $contractModel = new Contract();
         $contractModel->season_id = $match->season_id;
         $contractModel->is_active = 1;
     } else {
         $model->contract_type = Composition::MEMBERSHIP_TYPE;
         $contractModel = new Membership();
     }
     $contractModel->command_id = $teamId;
     if ($model->load(Yii::$app->request->post()) && $contractModel->load(Yii::$app->request->post()) && $contractModel->validate()) {
         if ($contractModel->save(false)) {
             $model->contract_id = $contractModel->id;
             $model->number = $contractModel->number;
             $model->save();
         }
         if (Yii::$app->request->isAjax) {
             $out = ['success' => 'true'];
             return Json::encode($out);
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         if (Yii::$app->request->isAjax) {
             return $this->renderAjax('create', ['model' => $model, 'contractModel' => $contractModel]);
         }
         return $this->render('create', ['model' => $model, 'contractModel' => $contractModel]);
     }
 }
Example #10
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Match;
/* @var $this yii\web\View */
/* @var $model common\models\Flight */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="flight-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'competition_id')->dropDownList(ArrayHelper::map(Match::find()->asArray()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'position')->textInput();
?>

    <?php 
echo $form->field($model, 'note')->textInput(['maxlength' => 80]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('igolf', 'Create') : Yii::t('igolf', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
 /**
  * Vote for selected float answer
  * @param $matchID int
  * @return mixed Json
  */
 public function actionAutogen($matchID)
 {
     $match = \common\models\Match::findOne($matchID);
     if (!isset($match)) {
         throw new NotFoundHttpException('Страница не найдена.');
     }
     if (in_array($match->teamHome->id, \common\models\Team::getTeamsConstants())) {
         $ourTeam = $match->teamHome;
         $opponentTeam = $match->teamGuest;
     } else {
         $ourTeam = $match->teamGuest;
         $opponentTeam = $match->teamHome;
     }
     $basisPlayers = \common\models\Composition::find()->where(['match_id' => $match->id, 'command_id' => $ourTeam->id, 'is_basis' => 1])->all();
     $compositionTable = \common\models\Composition::tableName();
     $matchEventTable = \common\models\MatchEvent::tableName();
     $substitutionPlayers = \common\models\Composition::find()->innerJoin($matchEventTable, "{$matchEventTable}.substitution_id = {$compositionTable}.id")->where([$compositionTable . '.match_id' => $match->id, 'command_id' => $ourTeam->id])->all();
     $teamPlayers = array_merge($basisPlayers, $substitutionPlayers);
     $question = new Question();
     $question->title = 'Оценки игрокам ' . $ourTeam->name . ' в матче с ' . $opponentTeam->name;
     $question->voutes = 0;
     $question->is_active = 1;
     $question->is_float = 1;
     $question->is_multipart = 0;
     $question->mark = 0;
     if ($question->save()) {
         foreach ($teamPlayers as $teamPlayer) {
             $answer = new Question();
             $answer->parent_id = $question->id;
             $answer->title = $teamPlayer->name;
             $answer->mark = 0;
             $answer->save();
         }
     }
     return $this->redirect(['view', 'id' => $question->id]);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMatches()
 {
     return $this->hasMany(Match::className(), ['team_id' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMatches()
 {
     return $this->hasMany(Match::className(), ['championship_part_id' => 'id']);
 }
 /**
  * Url: /match/rss.xml
  * Rss output of last match events
  * @return mixed 
  */
 public function actionEventsRss()
 {
     Yii::$app->response->format = Response::FORMAT_RAW;
     $headers = Yii::$app->response->headers;
     $headers->add('Content-Type', 'text/xml; charset=utf-8');
     $matches = Match::find()->innerJoinWith('matchEvents')->orderBy(['date' => SORT_DESC])->groupBy(Match::tableName() . '.id')->limit(10)->all();
     $translations = [];
     $yandexSportAPI = file_get_contents("http://api.sport.yandex.ru/public/events.xml");
     foreach ($matches as $match) {
         $events = MatchEvent::find()->where(['not', ['is_hidden' => 1]])->andWhere(['match_id' => $match->id])->orderBy(['created_at' => SORT_DESC])->all();
         // yandexTeamId Dynamo 78662
         // competition_id Y 1999 D 2 Ukrainian Premier League
         // competition_id = 2004 D 12 UPL Supercup 2015
         // competition_id = 1998 D 5 UEFA Champions League
         // competition_id = 000000021099 D 20 European Championship Qualification
         if ($match->championship_id == 2) {
             $competition = 1999;
         } elseif ($match->championship_id == 12) {
             $competition = 2004;
         } elseif ($match->championship_id == 5) {
             $competition = 1998;
         } elseif ($match->championship_id == 20) {
             $competition = '000000021099';
         } else {
             $competition = 0;
         }
         if (!$competition) {
             continue;
         }
         $matches = [];
         $matchDate = date('Y-m-d', strtotime($match->date));
         $pattern = "@<event.*competition=\"{$competition}\".*id=\"(.*)\".*start_date=\"{$matchDate}.*/>@U";
         preg_match($pattern, $yandexSportAPI, $matches);
         $eventID = count($matches) && isset($matches[1]) ? $matches[1] : 0;
         $translation = ['link' => Url::to('/match/' . $match->id), 'id' => $match->id, 'competition_id' => $competition, 'event_id' => $eventID, 'comments' => []];
         $minute = 0;
         $comments = [];
         foreach ($events as $event) {
             $minute = $event->minute ? $event->minute : $minute;
             $comment = ['id' => $event->id, 'time' => $minute, 'text' => htmlspecialchars(strip_tags($event->notes, "<a><p><br>"))];
             $comments[] = (object) $comment;
         }
         $translation['comments'] = $comments;
         $translations[] = (object) $translation;
     }
     return $this->renderPartial('@frontend/views/site/translation_rss', compact('translations'));
 }
Example #15
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getHomeMatches()
 {
     return $this->hasMany(Match::className(), ['command_home_id' => 'id']);
 }
Example #16
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Match::find();
     $championship = new Championship();
     $teamHome = new Team();
     $stadium = new Stadium();
     $arbiter = new Arbiter();
     $championshipPart = new ChampionshipPart();
     $matchTable = Match::tableName();
     $championshipTable = Championship::tableName();
     $championshipPartTable = ChampionshipPart::tableName();
     $teamTable = Team::tableName();
     $stadiumTable = Stadium::tableName();
     $arbiterTable = Arbiter::tableName();
     $query->joinWith(['championship' => function ($query) use($championshipTable) {
         $query->from(['championship' => $championshipTable]);
     }]);
     $query->joinWith(['teamHome' => function ($query) use($teamTable) {
         $query->from(['teamHome' => $teamTable]);
     }]);
     $query->joinWith(['teamGuest' => function ($query) use($teamTable) {
         $query->from(['teamGuest' => $teamTable]);
     }]);
     $query->joinWith(['arbiterMain' => function ($query) use($arbiterTable) {
         $query->from(['arbiterMain' => $arbiterTable]);
     }]);
     $query->joinWith(['arbiterAssistant1' => function ($query) use($arbiterTable) {
         $query->from(['arbiterAssistant1' => $arbiterTable]);
     }]);
     $query->joinWith(['arbiterAssistant2' => function ($query) use($arbiterTable) {
         $query->from(['arbiterAssistant2' => $arbiterTable]);
     }]);
     $query->joinWith(['arbiterAssistant3' => function ($query) use($arbiterTable) {
         $query->from(['arbiterAssistant3' => $arbiterTable]);
     }]);
     $query->joinWith(['arbiterAssistant4' => function ($query) use($arbiterTable) {
         $query->from(['arbiterAssistant4' => $arbiterTable]);
     }]);
     $query->joinWith(['arbiterReserve' => function ($query) use($arbiterTable) {
         $query->from(['arbiterReserve' => $arbiterTable]);
     }]);
     $query->joinWith(['championshipPart' => function ($query) use($championshipPartTable) {
         $query->from(['championshipPart' => $championshipPartTable]);
     }]);
     $query->joinWith(['stadium' => function ($query) use($stadiumTable) {
         $query->from(['stadium' => $stadiumTable]);
     }]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['date' => SORT_DESC]]]);
     // enable sorting for the related columns
     $addSortAttributes = ["championship.name", "teamHome.name", "teamGuest.name", "arbiterMain.name", "arbiterAssistant1.name", "arbiterAssistant2.name", "arbiterAssistant3.name", "arbiterAssistant4.name", "arbiterReserve.name", "championshipPart.name", "stadium.name"];
     foreach ($addSortAttributes as $addSortAttribute) {
         $dataProvider->sort->attributes[$addSortAttribute] = ['asc' => [$addSortAttribute => SORT_ASC], 'desc' => [$addSortAttribute => SORT_DESC]];
     }
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(["{$matchTable}.id" => $this->id, 'is_visible' => $this->is_visible, 'home_shots' => $this->home_shots, 'guest_shots' => $this->guest_shots, 'home_shots_in' => $this->home_shots_in, 'guest_shots_in' => $this->guest_shots_in, 'home_offsides' => $this->home_offsides, 'guest_offsides' => $this->guest_offsides, 'home_corners' => $this->home_corners, 'guest_corners' => $this->guest_corners, 'home_fouls' => $this->home_fouls, 'guest_fouls' => $this->guest_fouls, 'home_yellow_cards' => $this->home_yellow_cards, 'guest_yellow_cards' => $this->guest_yellow_cards, 'home_red_cards' => $this->home_red_cards, 'guest_red_cards' => $this->guest_red_cards, 'home_goals' => $this->home_goals, 'guest_goals' => $this->guest_goals, 'is_finished' => $this->is_finished, "{$matchTable}.championship_id" => $this->championship_id, "{$matchTable}.season_id" => $this->season_id, "{$matchTable}.league_id" => $this->league_id, "{$matchTable}.command_home_id" => $this->command_home_id, "{$matchTable}.command_guest_id" => $this->command_guest_id]);
     $createdTime = strtotime($this->created_at);
     $startDay = date("Y-m-d 00:00:00", $createdTime);
     $endDay = date("Y-m-d 00:00:00", $createdTime + 60 * 60 * 24);
     if ($this->created_at) {
         $query->andFilterWhere(['between', 'created_at', $startDay, $endDay]);
     }
     $updatedTime = strtotime($this->updated_at);
     $startDay = date("Y-m-d 00:00:00", $updatedTime);
     $endDay = date("Y-m-d 00:00:00", $updatedTime + 60 * 60 * 24);
     if ($this->updated_at) {
         $query->andFilterWhere(['between', 'updated_at', $startDay, $endDay]);
     }
     $date = strtotime($this->date);
     $startDay = date("Y-m-d 00:00:00", $date);
     $endDay = date("Y-m-d 00:00:00", $date + 60 * 60 * 24);
     if ($this->date) {
         $query->andFilterWhere(['between', 'date', $startDay, $endDay]);
     }
     $query->andFilterWhere(['like', 'round', $this->round])->andFilterWhere(['like', 'announcement', $this->announcement])->andFilterWhere(['like', "teamHome.name", $this->getAttribute('teamHome.name')])->andFilterWhere(['like', "teamGuest.name", $this->getAttribute('teamGuest.name')])->andFilterWhere(['like', 'championship.name', $this->getAttribute('championship.name')])->andFilterWhere(['like', 'arbiterMain.name', $this->getAttribute('arbiterMain.name')])->andFilterWhere(['like', 'arbiterAssistant1.name', $this->getAttribute('arbiterAssistant1.name')])->andFilterWhere(['like', 'arbiterAssistant2.name', $this->getAttribute('arbiterAssistant2.name')])->andFilterWhere(['like', 'arbiterAssistant3.name', $this->getAttribute('arbiterAssistant3.name')])->andFilterWhere(['like', 'arbiterAssistant4.name', $this->getAttribute('arbiterAssistant4.name')])->andFilterWhere(['like', 'arbiterReserve.name', $this->getAttribute('arbiterReserve.name')])->andFilterWhere(['like', 'championshipPart.name', $this->getAttribute('championshipPart.name')])->andFilterWhere(['like', 'stadium.name', $this->getAttribute('stadium.name')]);
     return $dataProvider;
 }
Example #17
0
 /**
  * Get match name
  * @return string
  */
 public function getMatchName()
 {
     $matchTable = Match::tableName();
     $relationTable = Relation::tableName();
     $match = Match::find()->innerJoin($relationTable, "{$matchTable}.id = {$relationTable}.parent_id")->where(["{$relationTable}.relationable_type" => Relation::RELATIONABLE_ALBUM, "{$relationTable}.relationable_id" => $this->id])->one();
     if (!isset($match)) {
         return 'Матч не найден';
     } else {
         $date = date('d.m.Y', strtotime($match->date));
         return $match->name . ' (' . $date . ')';
     }
     return '';
 }
Example #18
0
 /**
  * Get block with slider about previous and future matches
  * @return array Data
  */
 public static function getMatchesSlider()
 {
     $selectTeamsOI = [Team::TEAM_DK_FIRST_FULL_NAME, Team::TEAM_UKRAINE];
     $sliderPreviousMatches = Match::find()->where(['is_visible' => 1])->andWhere(['<', 'date', date('Y-m.d H:i:s')])->andWhere(['or', ["command_home_id" => $selectTeamsOI[0]], ["command_guest_id" => $selectTeamsOI[0]], ["command_home_id" => $selectTeamsOI[1]], ["command_guest_id" => $selectTeamsOI[1]]])->orderBy(['date' => SORT_DESC])->limit(5)->all();
     $sliderPreviousMatches = array_reverse($sliderPreviousMatches);
     $sliderFutureMatches = Match::find()->where(['>', 'date', date('Y-m.d H:i:s')])->andWhere(['or', ["command_home_id" => $selectTeamsOI[0]], ["command_guest_id" => $selectTeamsOI[0]], ["command_home_id" => $selectTeamsOI[1]], ["command_guest_id" => $selectTeamsOI[1]]])->orderBy(['date' => SORT_ASC])->limit(5)->all();
     $sliderMatches = array_merge($sliderPreviousMatches, $sliderFutureMatches);
     $block = ['view' => '@frontend/views/blocks/matches_slider_block', 'data' => ['matches' => $sliderMatches]];
     return $block;
 }
Example #19
0
 /**
  * find a document instance and returns it property typed.
  *
  * @return app\models\{Document,Bid,Order,Bill} the document
  */
 public static function findCompetition($id)
 {
     $model = Competition::findOne($id);
     if ($model) {
         switch ($model->competition_type) {
             case self::TYPE_MATCH:
                 return Match::findOne($id);
                 break;
             case self::TYPE_TOURNAMENT:
                 return Tournament::findOne($id);
                 break;
             case self::TYPE_SEASON:
                 return Season::findOne($id);
                 break;
         }
     }
     return null;
 }
 /**
  * @param integer $matchID
  * @return Json Name of match
  */
 public function actionMatchName($matchID)
 {
     $model = Match::findOne($matchID);
     if (!isset($model->id)) {
         return Json::encode(['data' => 'Матч не найден']);
     }
     $date = date('d.m.Y', strtotime($model->date));
     return Json::encode(['data' => $model->name . ' (' . $date . ')']);
 }
Example #21
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMatch()
 {
     return $this->hasOne(Match::className(), ['id' => 'parent_id']);
 }
Example #22
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMatch()
 {
     return $this->hasMany(Match::className(), ['stadium_id' => 'id']);
 }