Example #1
2
<?php

use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use kartik\detail\DetailView;
use common\models\Facility;
use common\models\Golfer;
use common\models\User;
use yii2mod\selectize\Selectize;
/* @var $this yii\web\View */
/* @var $model common\models\Golfer */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('igolf', 'Golfers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="golfer-view">

    <?php 
echo DetailView::widget(['model' => $model, 'panel' => ['heading' => '<h3>' . $model->name . '</h3>'], 'labelColOptions' => ['style' => 'width: 30%'], 'attributes' => ['name', 'email:email', 'phone', 'handicap', ['attribute' => 'gender', 'type' => DetailView::INPUT_RADIO_LIST, 'items' => ['' => Yii::t('igolf', 'Unspecified')] + Golfer::getLocalizedConstants('GENDER_')], ['attribute' => 'hand', 'type' => DetailView::INPUT_RADIO_LIST, 'items' => ['' => Yii::t('igolf', 'Unspecified')] + Golfer::getLocalizedConstants('HAND_')], 'homecourse', ['attribute' => 'facility_id', 'value' => isset($model->facility) ? $model->facility->name : '', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ['' => 'Select home course...'] + ArrayHelper::map(Facility::find()->where(['>', 'id', 0])->asArray()->all(), 'id', 'name'), 'widgetOptions' => ['pluginOptions' => ['items' => ArrayHelper::map(Facility::find()->where(['>', 'id', 0])->asArray()->all(), 'id', 'name')]]], ['attribute' => 'user_id', 'label' => 'User', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(['' => ''] + User::find()->orderBy('username')->asArray()->all(), 'id', 'username'), 'value' => isset($model->user) ? $model->user->username : '******']]]);
?>

</div>
Example #2
0
 /**
  * Finds the Competition model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Competition the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Golfer::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Golfer::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'handicap' => $this->handicap, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'hand', $this->hand])->andFilterWhere(['like', 'homecourse', $this->homecourse]);
     return $dataProvider;
 }
Example #4
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]);
     }
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGolfer()
 {
     return $this->hasOne(Golfer::className(), ['id' => 'golfer_id']);
 }
Example #6
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();
Example #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGolfers()
 {
     return $this->hasMany(Golfer::className(), ['facility_id' => 'id']);
 }
Example #8
0
?>

    <?php 
echo $form->field($model, 'homecourse')->textInput(['maxlength' => 80]);
?>

    <?php 
echo $form->field($model, 'facility_id')->widget(Selectize::className(), ['items' => ['' => 'Select home course...'] + ArrayHelper::map(Facility::find()->where(['>', 'id', 0])->asArray()->all(), 'id', 'name')]);
?>

    <?php 
echo $form->field($model, 'gender')->radioList(Golfer::getLocalizedConstants('GENDER_'));
?>

    <?php 
echo $form->field($model, 'hand')->radioList(Golfer::getLocalizedConstants('HAND_'));
?>

    <?php 
echo $form->field($model, 'handicap')->textInput();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('igolf', 'Create') : Yii::t('igolf', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Example #9
0
/* @var $model app\models\Registration */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="registration-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'competition_id')->dropDownList(ArrayHelper::map(Competition::find()->where(['status' => Competition::STATUS_OPEN])->asArray()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'golfer_id')->dropDownList(ArrayHelper::map(Golfer::find()->asArray()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'status')->dropDownList($model::getLocalizedConstants('STATUS_'));
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('igolf', 'Create') : Yii::t('igolf', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Example #10
0
 /**
  * @return  Golfer Currently logged in user as Golfer
  */
 public static function me()
 {
     return Golfer::findOne(['user_id' => Yii::$app->user->id]);
 }
Example #11
0
?>
<div class="golfer-profile-index">

	<div class="row">
		<div class="col-lg-8">
			<?php 
if (!$model) {
    ?>
				<div class="alert alert-info">
					Your are not registered as a golfer.
				</div>
			<?php 
} else {
    ?>
    <?php 
    echo DetailView::widget(['model' => $model, 'panel' => ['heading' => '<h3>' . Html::encode($this->title) . '</h3>'], 'labelColOptions' => ['style' => 'width: 30%'], 'formOptions' => ['action' => Url::to(['view', 'id' => $model->id])], 'attributes' => ['name', 'email:email', 'phone', 'handicap', ['attribute' => 'gender', 'type' => DetailView::INPUT_RADIO_LIST, 'items' => ['' => Yii::t('igolf', 'Unspecified')] + Golfer::getLocalizedConstants('GENDER_')], ['attribute' => 'hand', 'type' => DetailView::INPUT_RADIO_LIST, 'items' => ['' => Yii::t('igolf', 'Unspecified')] + Golfer::getLocalizedConstants('HAND_')], ['label' => Yii::t('igolf', 'Home Course'), 'attribute' => 'facility_id', 'value' => isset($model->facility) ? $model->facility->name : '', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ['' => 'Select home course...'] + ArrayHelper::map(Facility::find()->where(['>', 'id', 0])->asArray()->all(), 'id', 'name'), 'widgetOptions' => ['pluginOptions' => ['items' => ArrayHelper::map(Facility::find()->where(['>', 'id', 0])->asArray()->all(), 'id', 'name')]]]]]);
    ?>

			<?php 
}
?>
		</div>
		
		<div class="col-lg-4">
		    <h3><?php 
echo Yii::t('goflleague', 'Menu');
?>
</h3>

		    <h3><?php 
echo Yii::t('goflleague', 'Enter score');
 /**
  * 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());
 }
 public function actionGolferSearch($id, $target, $term = '')
 {
     $model = $this->findCompetition($id);
     $golfers = Golfer::find()->all();
     $availables = [];
     foreach ($golfers as $golfer) {
         $availables[$golfer->id] = $golfer->name;
     }
     $registrations = Registration::find()->where(['competition_id' => $id, 'status' => array(Registration::STATUS_PENDING, Registration::STATUS_REGISTERED)])->all();
     $registereds = [];
     foreach ($registrations as $registration) {
         $registereds[$registration->golfer_id] = $availables[$registration->golfer_id];
         unset($availables[$registration->golfer_id]);
     }
     $result = [];
     if (!empty($term)) {
         foreach (${$target} as $golfer) {
             if (strpos($golfer, $term) !== false) {
                 $id = Golfer::findOne(['name' => $golfer]);
                 $result[$id->id] = $golfer;
             }
         }
     } else {
         $result = ${$target};
     }
     return Html::renderSelectOptions('', $result);
 }
Example #14
0
<?php

use common\models\Golfer;
use kartik\detail\DetailView;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Start */
$this->title = $model->competition->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('igolf', 'Competitions'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->competition->name, 'url' => ['competition/view', 'id' => $model->competition_id]];
$this->params['breadcrumbs'][] = Yii::t('igolf', 'Starts');
?>
<div class="start-view">

    <?php 
echo DetailView::widget(['model' => $model, 'panel' => ['heading' => '<h2>' . $this->title . '</h2>'], 'labelColOptions' => ['style' => 'width: 30%'], 'attributes' => [['attribute' => 'gender', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Golfer::getLocalizedConstants('GENDER_')], 'age_min', 'age_max', 'handicap_min', 'handicap_max', ['attribute' => 'tees_id', 'value' => $model->tees->name, 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map($model->competition->course->getTeesWithHoles()->all(), 'id', 'name')], ['attribute' => 'created_at', 'options' => ['readonly' => true], 'format' => 'datetime'], ['attribute' => 'updated_at', 'options' => ['readonly' => true], 'format' => 'datetime']]]);
?>

</div>