/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Competition::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['eventsSetName'] = ['asc' => ['{{%events_set}}.name' => SORT_ASC], 'desc' => ['{{%events_set}}.name' => SORT_DESC]];
     $dataProvider->sort->attributes['sportName'] = ['asc' => ['{{%sport}}.name' => SORT_ASC], 'desc' => ['{{%sport}}.name' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         $query->joinWith('{{@eventsSet}}');
         $query->joinWith('{{@sport}}');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'sport_id' => $this->sport_id, 'events_set_id' => $this->events_set_id, 'date_start' => $this->date_start, 'date_finish' => $this->date_finish, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'location', $this->location]);
     $query->joinWith(['eventsSet' => function ($q) {
         $q->where('{{%events_set}}.name LIKE "%' . $this->eventsSetName . '%"');
     }]);
     $query->joinWith(['sport' => function ($q) {
         $q->where('{{%sport}}.name LIKE "%' . $this->sportName . '%"');
     }]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Lists all Competition models.
  * @return mixed
  */
 public function actionIndex()
 {
     $now = date('Y-m-d H:i:s');
     /** Competition open for registration by golfer.
      */
     $registrationSearch = new CompetitionSearch();
     $registrationProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_OPEN])->andWhere(['>', 'registration_begin', $now])->andWhere(['<', 'registration_end', $now])]);
     /** Competition ready to be played.
      */
     $startSearch = new CompetitionSearch();
     $startProvider = new ActiveDataProvider(['query' => Match::find()->where(['status' => Competition::STATUS_READY])->andWhere(['<', 'registration_end', $now])->andWhere(['>', 'start_date', $now])]);
     /** Competition for results.
      */
     $resultSearch = new MatchSearch();
     $resultProvider = new ActiveDataProvider(['query' => Match::find()->where(['status' => Competition::STATUS_READY])]);
     /** Competition awaiting results entry.
      *  Registration must be READY and in the past (terminated).
      */
     $result2Search = new CompetitionSearch();
     $result2Provider = new ActiveDataProvider(['query' => Competition::find()->andWhere(['status' => Competition::STATUS_OPEN])->andWhere(['!=', 'competition_type', Competition::TYPE_MATCH])]);
     /** Planned competition.
      *  Registration must be OPEN and we must be before the registration 
      */
     $planSearch = new CompetitionSearch();
     $planProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_OPEN])->andWhere(['>', 'registration_begin', $now])]);
     /** Closed or terminated competition.
      *  Registration must be CLOSED. 
      */
     $closedSearch = new CompetitionSearch();
     $closedProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_CLOSED])]);
     $allSearch = new CompetitionSearch();
     $allProvider = new ActiveDataProvider(['query' => Competition::find()]);
     return $this->render('index', ['registrationProvider' => $registrationProvider, 'registrationSearch' => $registrationSearch, 'startProvider' => $startProvider, 'startSearch' => $startSearch, 'resultProvider' => $resultProvider, 'resultSearch' => $resultSearch, 'result2Provider' => $result2Provider, 'result2Search' => $result2Search, 'planProvider' => $planProvider, 'planSearch' => $planSearch, 'closedProvider' => $closedProvider, 'closedSearch' => $closedSearch]);
 }
예제 #3
0
 /**
  * Lists all Competition models of interest for Starter.
  * @return mixed
  */
 public function actionIndex()
 {
     $now = date('Y-m-d H:i:s');
     /** Competition open for registration by starter.
      *  For starters, a competition is open for registration from the day it exists (ie before official registration opens),
      *  to the day the competition is 'published'.
      *  So any competition in status OPEN can accept registrations.
      */
     $registrationSearch = new CompetitionSearch();
     $registrationProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_OPEN])]);
     /** Competition ready to be prepared. It must be a Match.
      *  Registration must be officially closed, and competition cannot be started yet.
      *  So any competition in status OPEN, after the closing registration date is ready to be prepared.
      */
     $startSearch = new CompetitionSearch();
     $startProvider = new ActiveDataProvider(['query' => Match::find()->where(['status' => Competition::STATUS_OPEN])->andWhere(['<', 'registration_end', $now])]);
     /** Competition ready to be played.
      *  Registration must be READY and in the past (terminated).
      */
     $readySearch = new CompetitionSearch();
     $readyProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_READY])->andWhere(['>=', 'start_date', $now])]);
     /** Planned competition.
      *  Registration must be OPEN and we must be before the registration 
      */
     $planSearch = new CompetitionSearch();
     $planProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_OPEN])->andWhere(['>', 'registration_begin', $now])]);
     /** Closed or terminated competition.
      *  Registration must be CLOSED. 
      */
     $closedSearch = new CompetitionSearch();
     $closedProvider = new ActiveDataProvider(['query' => Competition::find()->where(['status' => Competition::STATUS_CLOSED])]);
     $allSearch = new CompetitionSearch();
     $allProvider = new ActiveDataProvider(['query' => Competition::find()]);
     return $this->render('index', ['registrationProvider' => $registrationProvider, 'registrationSearch' => $registrationSearch, 'startProvider' => $startProvider, 'startSearch' => $startSearch, 'readyProvider' => $readyProvider, 'readySearch' => $readySearch, 'planProvider' => $planProvider, 'planSearch' => $planSearch, 'closedProvider' => $closedProvider, 'closedSearch' => $closedSearch]);
 }
예제 #4
0
 /**
  * Lists all Registration models for approval.
  * @return mixed
  */
 public function actionCompetitions()
 {
     $searchModel = new CompetitionSearch();
     $query = Competition::find();
     $query->andWhere(['status' => Competition::STATUS_OPEN]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     return $this->render('competitions', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
예제 #5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Competition::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'start_date' => $this->start_date, 'course_id' => $this->course_id, 'holes' => $this->holes, 'rule_id' => $this->rule_id, '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, 'recurrence_id' => $this->recurrence_id, 'max_players' => $this->max_players, 'cba' => $this->cba, 'tour' => $this->tour, 'flight_size' => $this->flight_size, 'flight_time' => $this->flight_time, 'flight_window' => $this->flight_window, 'registration_time' => $this->registration_time, 'final_rule_id' => $this->final_rule_id, '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', 'status', $this->status])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'player_type', $this->player_type])->andFilterWhere(['like', 'registration_special', $this->registration_special]);
     return $dataProvider;
 }
예제 #6
0
 /**
  * Lists all Competition models of interest for Starter.
  * @return mixed
  */
 public function actionTournaments()
 {
     $now = date('Y-m-d H:i:s');
     /** Awaiting scores competition.
      *  Registration must be OPEN and we must be before the registration 
      */
     $completedSearch = new CompetitionSearch();
     $completedProvider = new ActiveDataProvider(['query' => Competition::find()->where(['competition_type' => [Competition::TYPE_TOURNAMENT, Competition::TYPE_SEASON], 'status' => Competition::STATUS_COMPLETED])]);
     /** Closed or terminated competition.
      *  Registration must be CLOSED. 
      */
     $closedSearch = new CompetitionSearch();
     $closedProvider = new ActiveDataProvider(['query' => Competition::find()->where(['competition_type' => [Competition::TYPE_TOURNAMENT, Competition::TYPE_SEASON], 'status' => Competition::STATUS_CLOSED])]);
     return $this->render('tournaments', ['readyProvider' => $readyProvider, 'readySearch' => $readySearch, 'openProvider' => $openProvider, 'openSearch' => $openSearch, 'completedProvider' => $completedProvider, 'completedSearch' => $completedSearch, 'closedProvider' => $closedProvider, 'closedSearch' => $closedSearch]);
 }
예제 #7
0
파일: _form.php 프로젝트: kleitz/golfleague
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @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>