/** * Displays all matches and a possibility to register or not. * @return mixed Match view */ public function actionIndex() { $registrationSearchModel = new RegistrationSearch(); $registrationDataProvider = $registrationSearchModel->search(Yii::$app->request->queryParams); if (!($golfer = Golfer::me())) { throw new NotFoundHttpException('You are not a golfer.'); } $registrationDataProvider->query->andWhere(['golfer_id' => $golfer->id]); $now = date('Y-m-d H:i:s'); // single matches (not part of a tournament) $matchesSearchModel = new MatchSearch(); $matchesDataProvider = $matchesSearchModel->search(Yii::$app->request->queryParams); $matchesDataProvider->query->andWhere(['parent_id' => null])->andWhere(['>', 'start_date', $now]); // single tournaments not part of a season /* select c.id as tournament_id, count(c.id) as tot_count from competition c, competition m where c.competition_type = 'TOURNAMENT' and m.competition_type = 'MATCH' and m.parent_id = c.id and c.status = 'OPEN' group by c.id having tot_count = 1 */ $q = new Query(); $q->select(['c.id as competition_id', 'count(c.id) as tot_count'])->from('competition c, competition m')->andWhere(['c.parent_id' => null])->andWhere(['c.competition_type' => Competition::TYPE_TOURNAMENT])->andWhere(['m.competition_type' => Competition::TYPE_MATCH])->andWhere('m.parent_id = c.id')->andWhere(['c.status' => Competition::STATUS_OPEN])->andWhere(['m.status' => Competition::STATUS_OPEN])->andWhere(['>', 'm.start_date', $now])->groupBy('c.id'); $tournament_ids = []; foreach ($q->each() as $tournament) { $tournament_ids[] = $tournament['competition_id']; } $tournamentsSearchModel = new TournamentSearch(); $tournamentsDataProvider = $tournamentsSearchModel->search(Yii::$app->request->queryParams); $tournamentsDataProvider->query->andWhere(['id' => $tournament_ids]); // seasons $seasonsSearchModel = new SeasonSearch(); $seasonsDataProvider = $seasonsSearchModel->search(Yii::$app->request->queryParams); $seasonsDataProvider->query->andWhere(['status' => Competition::STATUS_OPEN]); return $this->render('index', ['registrationSearchModel' => $registrationSearchModel, 'registrationDataProvider' => $registrationDataProvider, 'matchesSearchModel' => $matchesSearchModel, 'matchesDataProvider' => $matchesDataProvider, 'tournamentsSearchModel' => $tournamentsSearchModel, 'tournamentsDataProvider' => $tournamentsDataProvider, 'seasonsSearchModel' => $seasonsSearchModel, 'seasonsDataProvider' => $seasonsDataProvider]); }
/** * Lists all Registration models. * @return mixed */ public function actionTees($id) { $competition = $this->findCompetition($id); $searchModel = new RegistrationSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider->query->andWhere(['competition_id' => intval($id)]); return $this->render('tees', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'competition' => $competition]); }
/* @var $model common\models\Flight */ $this->title = $model->id; $this->params['breadcrumbs'][] = ['label' => Yii::t('igolf', 'Competitions'), 'url' => ['competition/index']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('igolf', 'Flights'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="flight-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a(Yii::t('igolf', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'competition.name', 'position', 'note', 'created_at', 'updated_at']]); ?> <?php $searchModel = new RegistrationSearch(); $dataProvider = $searchModel->search(['RegistrationSearch' => ['flight_id' => $model->id]]); echo $this->render('../registration/list', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); ?> </div>