Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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();
?>
Ejemplo n.º 3
0
 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);
 }