/** * 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; }
/** * 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 = Season::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; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Season::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->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; }
/** * Finds the Season model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Season the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Season::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php echo $form->field($model, 'championship_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Championship::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите чемпионат...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> </div> <div class="row"> <div class="col-sm-6"> <?php echo $form->field($model, 'league_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(League::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите лигу...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-sm-6"> <?php $seasons = ArrayHelper::map(Season::find()->where(['>', 'id', 42])->all(), 'id', 'name'); foreach ($seasons as $key => $season) { if (strpos($season, '/') === false) { unset($seasons[$key]); } } echo $form->field($model, 'season_id')->widget(Select2::classname(), ['data' => $seasons, 'language' => 'ru', 'options' => ['placeholder' => 'Выберите сезон...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> </div> <div class="row"> <div class="col-sm-3"><?php echo $form->field($model, 'won')->textInput(); ?>
<?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']); ?>
/** * @return \yii\db\ActiveQuery */ public function getNumber($seasonID = false) { if (!$seasonID) { $seasonID = Season::find()->where(['window' => Season::WINDOW_WINTER])->orderBy(['id' => SORT_DESC])->one(); } $number = Contract::find()->where(['player_id' => $this->id])->andWhere(['season_id' => $seasonID->id])->one(); return isset($number->number) ? $number->number : '-'; }
/** * @inheritdoc */ public function getParentCandidates($add_empty = true) { return ArrayHelper::map(['' => ''] + Season::find()->asArray()->all(), 'id', 'name'); }
<?php use yii\helpers\Url; use common\models\TournamentSettings; use common\models\Season; /** * @var $this yii\web\View * @var $tournamentData array Array of common\models\Tournament * @var $championshipsData array Array of available championships * @var $seasonsData array Array of available seasons **/ $tournamentTableSettings = TournamentSettings::tableName(); $seasonTable = Season::tableName(); $currentSeason = array_values($seasonsData)[0]; $currentSeasonValue = $currentSeason->value; foreach ($seasonsData as $season) { if ($season->active) { $currentSeasonValue = $season->value; } } $settings = TournamentSettings::find()->where(['season_id' => $currentSeasonValue])->one(); $positions = preg_replace('/\\s+/', '', $settings->cl_positions); $ECLpositionsArray = explode(",", $positions); $positions = preg_replace('/\\s+/', '', $settings->el_positions); $ELpositionsArray = explode(",", $positions); $positions = preg_replace('/\\s+/', '', $settings->reduction_positions); $reductionPositionsArray = explode(",", $positions); $priorityCriteria = []; $count = 0; if (isset($settings->win_weight)) { $priorityCriteria[$count]['value'] = $settings->win_weight;
<?php use yii\helpers\Html; use yii\grid\GridView; use yii\helpers\ArrayHelper; use common\models\Season; /* @var $this yii\web\View */ /* @var $searchModel common\models\ForwardSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Бомбардиры'; $this->params['breadcrumbs'][] = $this->title; $seasons = Season::find()->innerJoinWith('forwards')->all(); $seasonFilter = ArrayHelper::map($seasons, 'id', 'name'); ?> <div class="forward-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']); ?> </p> <?php
<?php 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\ContractSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Игроки команд'; $this->params['breadcrumbs'][] = $this->title; $contractTable = $searchModel::tableName(); $seasonTable = Season::tableName(); $seasons = Season::find()->innerJoin($contractTable, "{$contractTable}.season_id = {$seasonTable}.id")->all(); $seasonFilter = ArrayHelper::map($seasons, 'id', 'name'); ?> <div class="contract-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']); ?> <?php
<?php use yii\helpers\Html; use yii\grid\GridView; use yii\helpers\ArrayHelper; use common\models\Season; /* @var $this yii\web\View */ /* @var $searchModel common\models\TournamentSettingsSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Настройки турнирной таблицы'; $this->params['breadcrumbs'][] = $this->title; $settingsTable = $searchModel::tableName(); $seasonTable = Season::tableName(); $seasons = Season::find()->innerJoin($settingsTable, "{$settingsTable}.season_id = {$seasonTable}.id")->all(); $seasonFilter = ArrayHelper::map($seasons, 'id', 'name'); ?> <div class="tournament-settings-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']); ?> <?php
/** * 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; }
<div class="col-sm-6"> <?php echo $form->field($model, 'championship_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Championship::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите турнир...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-sm-6"> <?php echo $form->field($model, 'league_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(League::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите лигу...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> </div> <div class="row"> <div class="col-sm-6"> <?php echo $form->field($model, 'season_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Season::find()->orderBy(['id' => SORT_DESC])->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите сезон...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-sm-6"> <?php echo $form->field($model, 'championship_part_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(ChampionshipPart::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите этап турнира...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> </div> <div class="row"> <div class="col-sm-6"> <?php $availableStadiums = []; if (!$model->isNewRecord) { $stadium = Stadium::findOne($model->stadium_id);
/** * @return \yii\db\ActiveQuery */ public function getSeason() { return $this->hasOne(Season::className(), ['id' => 'season_id']); }
/** * 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)]]); }