/** * 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]); }
<?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']); ?>
<?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
<?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(); ?>
<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 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\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
/** * 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)]]); }