Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Countries::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'country', $this->country]);
     return $dataProvider;
 }
Пример #2
0
/* @var $model app\models\tournaments\tournaments */
/* @var $form yii\widgets\ActiveForm */
?>

<div class = "row">
    <div class="col-xs-8 col-sm-6 col-md-4 col-lg-3">
        <?php 
$form = ActiveForm::begin();
?>

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

            <?php 
echo $form->field($model, 'country', ['template' => '{label} <div class="row"><div class="col-xs-10">{input}{error}{hint}</div></div>'])->dropDownList(ArrayHelper::map(Countries::find()->orderBy('country', 'asc')->all(), 'id', 'country'), ['prompt' => '---Выберите страну---']);
?>

            <?php 
echo $form->field($model, 'num_tours', ['template' => '{label} <div class="row"><div class="col-xs-5 col-sm-3">{input}{error}{hint}</div></div>'])->textInput();
?>

            <?php 
echo $form->field($model, 'startsOn', ['template' => '{label} <div class="row"><div class="col-xs-12 col-sm-8">{input}{error}{hint}</div></div>'])->widget(DatePicker::className(), ['removeButton' => false, 'pluginOptions' => ['autoclose' => true, 'format' => 'dd.mm.yyyy', 'todayHighlight' => true], 'options' => ['value' => isset($model->startsOn) ? date('d.m.Y', $model->startsOn) : '']]);
?>

            <?php 
echo $form->field($model, 'wfDueTo', ['template' => '{label} <div class="row"><div class="col-xs-12 col-sm-8">{input}{error}{hint}</div></div>'])->widget(DatePicker::className(), ['removeButton' => false, 'pluginOptions' => ['autoclose' => true, 'format' => 'dd.mm.yyyy', 'todayHighlight' => true], 'options' => ['value' => isset($model->wfDueTo) ? date('d.m.Y', $model->wfDueTo) : '']]);
?>

            <?php 
Пример #3
0
 public static function getCountriesArray()
 {
     $countries = Countries::find()->orderBy(['country' => SORT_ASC])->asArray()->all();
     return ArrayHelper::map($countries, 'id', 'country');
 }
Пример #4
0
    <div class="col-xs-12 col-xs-offset-0 col-sm-offset-1 col-sm-10 tournaments-index">

        <h1><?php 
echo Html::encode($this->title);
?>
</h1>
        <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

        <p>
            <?php 
echo Html::a(Yii::t('app', 'Create', ['modelClass' => 'Tournaments']), ['create'], ['class' => 'btn btn-success']);
?>
        </p>

        <div class="row">
            <?php 
echo extendedGridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'options' => ['class' => 'col-xs-12 col-md-10 col-lg-8'], 'columns' => [['attribute' => 'id_tournament', 'filter' => false, 'options' => ['class' => 'col-xs-1'], 'contentOptions' => ['align' => 'center', 'style' => 'vertical-align:middle'], 'headerOptions' => ['style' => 'text-align:center']], ['attribute' => 'tournament_name', 'filter' => false, 'contentOptions' => ['style' => 'vertical-align:middle'], 'headerOptions' => ['style' => 'text-align:center'], 'options' => ['class' => 'col-xs-3'], 'content' => function ($model) {
    return Html::a($model->tournament_name, ['tournaments/update', 'id' => $model->id_tournament]);
}, 'format' => 'url'], ['header' => 'Игры', 'filter' => false, 'contentOptions' => ['align' => 'center', 'style' => 'vertical-align:middle'], 'headerOptions' => ['style' => 'text-align:center'], 'options' => ['class' => 'col-xs-2'], 'content' => function ($model) {
    return Html::a('Игры турнира', ['games/index', 'tournament' => $model->id_tournament]);
}, 'format' => 'url'], ['attribute' => 'country', 'contentOptions' => ['align' => 'center', 'style' => 'vertical-align:middle'], 'headerOptions' => ['style' => 'text-align:center'], 'content' => function ($model) {
    return Html::a($model->country0->country, ["countries/update", 'id' => $model->country]);
}, 'format' => 'url', 'filter' => ArrayHelper::map(Countries::find()->orderBy('country', 'asc')->all(), 'id', 'country'), 'filterInputOptions' => ['class' => 'form-control'], 'options' => ['class' => 'col-xs-2']], ['attribute' => 'num_tours', 'filter' => false, 'header' => 'Туры', 'contentOptions' => ['align' => 'center', 'style' => 'vertical-align:middle'], 'headerOptions' => ['style' => 'text-align:center'], 'options' => ['class' => 'col-xs-1']], ['attribute' => 'is_active', 'content' => function ($model) {
    return $model->status;
}, 'options' => ['class' => 'col-xs-2'], 'headerOptions' => ['style' => 'text-align:center'], 'contentOptions' => ['align' => 'center', 'style' => 'vertical-align:middle'], 'filter' => ['0' => 'Не начался', '1' => 'Проходит', '2' => 'Закончен']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'options' => ['class' => 'hidden-xs'], 'headerOptions' => ['style' => 'text-align:center'], 'contentOptions' => ['align' => 'center', 'style' => 'vertical-align:middle']]]]);
?>
        </div>
    </div>
</div>
Пример #5
0
 public static function getFinishedTournamentsOnePerCountry()
 {
     $countries = Countries::find()->select('id')->column();
     $query = [];
     foreach ($countries as $country) {
         $query[] = self::find()->where(['country' => $country])->andWhere(['is_active' => self::FINISHED])->orderBy(['startsOn' => SORT_DESC])->limit(1);
     }
     if (!empty($query)) {
         $toExecute = $query[0];
         $i = 1;
         while (isset($query[$i])) {
             $toExecute = $toExecute->union($query[$i]);
             $i++;
         }
         $tournaments = $toExecute->column();
     } else {
         $tournaments = [];
     }
     if (!empty($tournaments)) {
         return self::unionQueryPrep($tournaments);
     } else {
         return UsersTournaments::find()->findModel(NULL, NULL)->all();
     }
 }
Пример #6
0
/* @var $model app\models\teams\teams */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="row">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data', 'class' => 'col-xs-8 col-sm-6 col-md-4 col-lg-3']]);
?>

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

    <?php 
echo $form->field($model, 'country')->dropDownList(ArrayHelper::map(Countries::find()->orderBy('country', 'asc')->all(), 'id', 'country'), ['prompt' => '---Выберите страну---']);
?>

    <?php 
if ($model->isNewRecord) {
    echo $form->field($model, 'team_logo')->label('Логотип')->fileInput();
} else {
    ?>

            <div class = 'form-group field-teams-team_logo'>
                <label class="control-label" for="logo">Логотип</label>
                <?php 
    echo Html::img($model->fileUrl, ['id' => 'logo', 'width' => 100]);
    ?>
            </div>