/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Contract::find(); $contractTable = Contract::tableName(); $playerTable = Player::tableName(); $teamTable = Team::tableName(); $seasonTable = Season::tableName(); $ampluaTable = Amplua::tableName(); $query->joinWith(['player' => function ($query) use($playerTable) { $query->from(['player' => $playerTable]); }]); $query->joinWith(['team' => function ($query) use($teamTable) { $query->from(['team' => $teamTable]); }]); $query->joinWith(['teamFrom' => function ($query) use($teamTable) { $query->from(['teamFrom' => $teamTable]); }]); $query->joinWith(['season' => function ($query) use($seasonTable) { $query->from(['season' => $seasonTable]); }]); $query->joinWith(['amplua' => function ($query) use($ampluaTable) { $query->from(['amplua' => $ampluaTable]); }]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); $addSortAttributes = ["player.lastname", "teamFrom.name", "team.name", "season.name", "amplua.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(["{$contractTable}.id" => $this->id, 'command_id' => $this->command_id, 'season_id' => $this->season_id, 'amplua_id' => $this->amplua_id, 'number' => $this->number, 'command_from_id' => $this->command_from_id, 'year_from' => $this->year_from, 'year_till' => $this->year_till, 'matches' => $this->matches, 'goals' => $this->goals, 'is_active' => $this->is_active, 'debut' => $this->debut, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'teamFrom.name', $this->getAttribute('teamFrom.name')])->andFilterWhere(['like', 'team.name', $this->getAttribute('team.name')])->andFilterWhere(['like', 'player.lastname', $this->getAttribute('player.lastname')])->andFilterWhere(['like', 'season.name', $this->getAttribute('season.name')])->andFilterWhere(['like', 'amplua.name', $this->getAttribute('amplua.name')]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tournament::find(); $tournamentTable = Tournament::tableName(); $teamTable = Team::tableName(); $leagueTable = League::tableName(); $championshipTable = Championship::tableName(); $seasonTable = Season::tableName(); $query->joinWith(['team' => function ($query) use($teamTable) { $query->from(['team' => $teamTable]); }]); $query->joinWith(['league' => function ($query) use($leagueTable) { $query->from(['league' => $leagueTable]); }]); $query->joinWith(['championship' => function ($query) use($championshipTable) { $query->from(['championship' => $championshipTable]); }]); $query->joinWith(['season' => function ($query) use($seasonTable) { $query->from(['season' => $seasonTable]); }]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20], 'sort' => ['defaultOrder' => ['points' => SORT_DESC]]]); // enable sorting for the related columns $addSortAttributes = ["team.name", "league.name", "championship.name", "season.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(["{$tournamentTable}id" => $this->id, 'command_id' => $this->command_id, 'championship_id' => $this->championship_id, 'season_id' => $this->season_id, 'played' => $this->played, 'won' => $this->won, 'draw' => $this->draw, 'lost' => $this->lost, 'goals_for' => $this->goals_for, 'goals_against' => $this->goals_against, 'points' => $this->points, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'fair_play' => $this->fair_play, 'league_id' => $this->league_id]); $query->andFilterWhere(['like', 'team.name', $this->getAttribute('team.name')]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = TeamCoach::find(); $teamCoachTable = TeamCoach::tableName(); $coachTable = Coach::tableName(); $teamTable = Team::tableName(); $seasonTable = Season::tableName(); $query->joinWith(['coach' => function ($query) use($coachTable) { $query->from(['coach' => $coachTable]); }]); $query->joinWith(['team' => function ($query) use($teamTable) { $query->from(['team' => $teamTable]); }]); $query->joinWith(['season' => function ($query) use($seasonTable) { $query->from(['season' => $seasonTable]); }]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); $addSortAttributes = ["coach.name", "team.name", "season.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(["{$teamCoachTable}.id" => $this->id, 'team_id' => $this->team_id, 'season_id' => $this->season_id, 'coach_id' => $this->coach_id, 'is_main' => $this->is_main]); $query->andFilterWhere(['like', 'coach.name', $this->getAttribute('coach.name')])->andFilterWhere(['like', 'team.name', $this->getAttribute('team.name')])->andFilterWhere(['like', 'season.name', $this->getAttribute('season.name')]); return $dataProvider; }
/** * Lists all Tournament models. * @return mixed */ public function actionIndex() { $searchModel = new TournamentSearch(); $tournamentTable = $searchModel::tableName(); $seasonTable = Season::tableName(); $seasons = Season::find()->innerJoin($tournamentTable, "{$tournamentTable}.season_id = {$seasonTable}.id")->orderBy(['name' => SORT_DESC])->all(); $availableSeasons = ArrayHelper::map($seasons, 'id', 'name'); $leagueTable = League::tableName(); $leagues = League::find()->innerJoin($tournamentTable, "{$tournamentTable}.league_id = {$leagueTable}.id")->all(); $availableLeagues = ArrayHelper::map($leagues, 'id', 'name'); $queryParams = Yii::$app->request->queryParams; if (count($queryParams) == 0) { $queryParams['TournamentSearch']['season_id'] = array_keys($availableSeasons)[0]; } $dataProvider = $searchModel->search($queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'availableSeasons' => $availableSeasons, 'availableLeagues' => $availableLeagues]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Career::find(); $team = new Team(); $league = new League(); $season = new Season(); $player = new Player(); $careerTable = Career::tableName(); $teamTable = Team::tableName(); $leagueTable = League::tableName(); $seasonTable = Season::tableName(); $playerTable = Player::tableName(); $query->joinWith(['team' => function ($query) use($teamTable) { $query->from(['team' => $teamTable]); }]); $query->joinWith(['league' => function ($query) use($leagueTable) { $query->from(['league' => $leagueTable]); }]); $query->joinWith(['player' => function ($query) use($playerTable) { $query->from(['player' => $playerTable]); }]); $query->joinWith(['season' => function ($query) use($seasonTable) { $query->from(['season' => $seasonTable]); }]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); $addSortAttributes = ['team.name', 'player.lastname', 'league.name', 'season.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(["{$careerTable}.id" => $this->id, 'player_id' => $this->player_id, 'season_id' => $this->season_id, 'championship_matches' => $this->championship_matches, 'championship_goals' => $this->championship_goals, 'cup_matches' => $this->cup_matches, 'cup_goals' => $this->cup_goals, 'euro_matches' => $this->euro_matches, 'euro_goals' => $this->euro_goals, 'avg_mark' => $this->avg_mark, 'goal_passes' => $this->goal_passes]); $query->andFilterWhere(['like', "team.name", $this->getAttribute('team.name')])->andFilterWhere(['like', "player.lastname", $this->getAttribute('player.lastname')])->andFilterWhere(['like', "league.name", $this->getAttribute('league.name')])->andFilterWhere(['like', "season.name", $this->getAttribute('season.name')]); return $dataProvider; }
<?php use common\models\TransferType; use common\models\Season; use yii\helpers\Html; use yii\grid\GridView; use yii\helpers\ArrayHelper; /* @var $this yii\web\View */ /* @var $searchModel common\models\TransferSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Трансферы'; $this->params['breadcrumbs'][] = $this->title; $transferTable = $searchModel::tableName(); $seasonTable = Season::tableName(); $seasons = Season::find()->innerJoin($transferTable, "{$transferTable}.season_id = {$seasonTable}.id")->all(); $seasonFilter = ArrayHelper::map($seasons, 'id', 'name'); ?> <div class="transfer-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Добавить трансфер', ['create'], ['class' => 'btn btn-success']); ?>
/** * Display list of arbiters in json format * * @param string $q Query for search * @return mixed Json data */ public function actionSeasonList($query = null) { if ($query == null) { throw new NotFoundHttpException('The requested page does not exist.'); } $search = urldecode($query); $query = new Query(); $query->select('id as value, name as text')->from(Season::tableName())->where(['like', 'name', $search])->orderBy('name')->limit(10); $command = $query->createCommand(); $data = $command->queryAll(); $out = array_values($data); header("Content-type: text/html; charset=utf-8"); echo Json::encode($out); }
/** * Url: /info|composition|achievements|record-holders/{$id} * @param $tab string Team id * @param bool|int $id int Team id * @return mixed * @throws NotFoundHttpException */ public function actionTeam($tab, $id = false) { if ($id === false) { $id = Team::TEAM_DK_FIRST_FULL_NAME; } $team = Team::findOne($id); $tabs = ['info', 'composition', 'achievements', 'record-holders']; if (!isset($team) || !in_array($tab, $tabs)) { throw new NotFoundHttpException('The requested page does not exist.'); } if ($tab == 'composition') { $availableTeams = [Team::TEAM_DK_FIRST_FULL_NAME => Team::findOne(Team::TEAM_DK_FIRST_FULL_NAME), Team::TEAM_DK_M => Team::findOne(Team::TEAM_DK_M), Team::TEAM_DK2 => Team::findOne(Team::TEAM_DK2), Team::TEAM_U19 => Team::findOne(Team::TEAM_U19)]; $seasonTable = Season::tableName(); $availableSeasons = Season::find()->innerJoinWith('contracts')->where(['window' => Season::WINDOW_WINTER])->andWhere(["command_id" => $id])->orderBy(["{$seasonTable}.id" => SORT_DESC])->all(); $availableSeasonsIds = []; foreach ($availableSeasons as $season) { $availableSeasonsIds[] = $season->id; } if (isset($_GET['season']) && in_array($_GET['season'], $availableSeasonsIds)) { $activeSeason = $_GET['season']; } else { $activeSeason = $availableSeasonsIds[0]; } $composition = Contract::find()->where(['is_active' => 1, 'season_id' => $activeSeason, 'command_id' => $team->id])->orderBy(['amplua_id' => SORT_ASC])->all(); $mainCoach = TeamCoach::find()->where(['is_main' => 1, 'season_id' => $activeSeason, 'team_id' => $id])->one(); $teamCoaches = TeamCoach::find()->where(['season_id' => $activeSeason, 'team_id' => $id, 'is_main' => 0])->all(); $data = ['teamModel' => $team, 'availableSeasons' => $availableSeasons, 'activeSeason' => $activeSeason, 'availableTeams' => $availableTeams, 'activeTeam' => $team->id, 'composition' => $composition, 'mainCoach' => $mainCoach, 'teamCoaches' => $teamCoaches]; } else { $information = MainInfo::find()->all(); $info = []; foreach ($information as $data) { $info[$data->name] = $data; } $data = compact('team', 'info'); } return $this->render('@frontend/views/site/index', ['templateType' => 'col2', 'title' => 'Dynamomania.com | ' . $team->name, 'columnFirst' => ['nav-bar' => ['view' => '@frontend/views/team/menu', 'data' => compact('team', 'tab')], 'content' => ['view' => '@frontend/views/team/tab-' . $tab, 'data' => $data]], 'columnSecond' => ['tournament' => SiteBlock::getshortNews(50), 'banner1' => SiteBlock::getBanner(Banner::REGION_NEWS), 'banner2' => SiteBlock::getBanner(Banner::REGION_NEWS), 'banner3' => SiteBlock::getBanner(Banner::REGION_NEWS), 'banner4' => SiteBlock::getBanner(Banner::REGION_NEWS), 'banner5' => SiteBlock::getBanner(Banner::REGION_NEWS)]]); }