Exemplo n.º 1
0
 /**
  * Creates a new Practice model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Practice();
     $golfer = Golfer::me();
     $model->golfer_id = $golfer->id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 2
0
<?php

use common\models\Golfer;
use kartik\grid\GridView;
use yii\bootstrap\Alert;
use yii\helpers\Html;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel app\models\SeasonSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$me = Golfer::me();
?>
<div class="tournament-index">

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'panel' => ['heading' => '<h4>' . Yii::t('igolf', 'Simple Matches') . '</h4>', 'before' => Yii::t('igolf', 'Single match or multiple matches tournaments, not part of a larger competition.'), 'beforeOptions' => ['class' => 'alert-info']], 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['label' => Yii::t('igolf', 'Competition'), 'value' => function ($model, $key, $index, $widget) {
    return $model->name;
}], ['label' => Yii::t('igolf', 'From'), 'format' => 'date', 'value' => function ($model, $key, $index, $widget) {
    return $model->getStartDate();
}], ['label' => Yii::t('igolf', 'To'), 'format' => 'date', 'value' => function ($model, $key, $index, $widget) {
    return $model->getEndDate();
}], ['label' => Yii::t('igolf', 'Registration start date'), 'value' => function ($model, $key, $index, $widget) {
    return $model->registration_begin;
}], ['label' => Yii::t('igolf', 'Registration end date'), 'value' => function ($model, $key, $index, $widget) {
    return $model->registration_end;
}], ['label' => Yii::t('igolf', 'Handicap'), 'value' => function ($model, $key, $index, $widget) {
    return $model->handicap_min . '-' . $model->handicap_max;
}], ['label' => Yii::t('igolf', 'Age'), 'value' => function ($model, $key, $index, $widget) {
    return $model->age_min . '-' . $model->age_max;
}], 'name', ['label' => Yii::t('igolf', 'Number of Matches'), 'value' => function ($model, $key, $index, $widget) {
    return $model->getMatches()->count();
Exemplo n.º 3
0
 /**
  * Deregister currently logged user from competition
  * @param  [type] $competition_type Season, Tournament, or Match.
  * @param  [type] $competition_id   Identifier of competition
  * @return [type]                   Action to do after. Set flash on success/error.
  */
 public function actionDeregister($id)
 {
     if (!($me = Golfer::me())) {
         Yii::$app->session->setFlash('error', 'You need to be a registered golfer of this site to register to matches.');
     } else {
         $model = Competition::findOne($id);
         if ($model->deregister($me)) {
             Yii::$app->session->setFlash('success', Yii::t('igolf', 'You deregistered from competition "{0}".', $model->name));
         } else {
             Yii::$app->session->setFlash('error', Yii::t('igolf', 'You cannot deregister from competition "{0}".', $model->name));
         }
     }
     return $this->redirect(Yii::$app->request->getReferrer());
 }
Exemplo n.º 4
0
 public function actionIndex()
 {
     return $this->render('index', ['model' => Golfer::me()]);
 }