Пример #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTeams()
 {
     return $this->hasMany(Teams::className(), ['country' => 'id']);
 }
Пример #2
0
<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use app\models\teams\Teams;
?>

<?php 
echo GridView::widget(['dataProvider' => $teamParticipants, 'summary' => false, 'caption' => 'Турнирная таблица', 'responsive' => false, 'responsiveWrap' => false, 'export' => false, 'columns' => [['header' => 'Место', 'class' => 'yii\\grid\\SerialColumn', 'contentOptions' => ['align' => 'center', 'style' => 'vertical-align:middle'], 'options' => ['class' => 'col-xs-1'], 'headerOptions' => ['style' => 'text-align:center']], ['header' => 'Команда', 'content' => function ($model) {
    return Html::img(Teams::getPath() . '/' . $model['team_logo'], ['width' => 30]) . ' ' . Html::a($model['team_name'], ["games", 'id' => $model['participant']]);
}, 'contentOptions' => ['style' => 'vertical-align:middle'], 'headerOptions' => ['style' => 'text-align:center'], 'options' => ['class' => 'col-xs-9']], ['header' => 'Игры', 'attribute' => 'games_played', 'contentOptions' => ['align' => 'center', 'style' => 'vertical-align:middle'], 'options' => ['class' => 'col-xs-1'], 'headerOptions' => ['style' => 'text-align:center'], 'content' => function ($model) {
    return isset($model['games_played']) ? $model['games_played'] : 0;
}], ['header' => 'Очки', 'contentOptions' => ['align' => 'center', 'style' => 'vertical-align:middle'], 'options' => ['class' => 'col-xs-1'], 'headerOptions' => ['style' => 'text-align:center'], 'content' => function ($model) {
    return isset($model['pts']) ? $model['pts'] : 0;
}]]]);
Пример #3
0
    ?>
            <?php 
    foreach ($tournament['games'] as $k => $tour) {
        ?>
                <?php 
        $form = ActiveForm::begin(['action' => ['site/forecast-save']]);
        ?>
                <?php 
        $content .= extendedGridView::widget(['dataProvider' => $tour, 'summary' => '', 'bordered' => false, 'showHeader' => false, 'caption' => "Тур {$k}. Ваш прогноз", 'captionOptions' => ['colspan' => 4, 'class' => 'text-center normal'], 'columns' => [['content' => function ($model) {
            return '<strong>' . date('d.m.y H:i', $model['date_time_game']) . '</strong>';
        }, 'options' => ['class' => 'col-xs-1'], 'contentOptions' => ['class' => 'reduceDateFont'], 'hAlign' => 'center', 'vAlign' => 'middle'], ['class' => 'kartik\\grid\\ExpandRowColumn', 'value' => function ($model, $key, $index, $column) {
            return extendedGridView::ROW_COLLAPSED;
        }, 'detail' => function ($model, $key, $index, $column) {
            return Yii::$app->controller->renderPartial('_five-last-games', ['details' => $model]);
        }, 'headerOptions' => ['class' => 'kartik-sheet-style'], 'expandOneOnly' => true, 'expandIcon' => "<i class='fa fa-plus-square'></i>", 'collapseIcon' => "<i class='fa fa-minus-square'></i>", 'enableRowClick' => true, 'detailOptions' => ['class' => 'expanded'], 'contentOptions' => ['class' => 'expand-icon']], ['content' => function ($model) use($form) {
            return "<row>" . "<div class = 'text-right col-xs-5'>" . Html::img(Teams::getPath() . '/' . $model['idTeamHome']['idTeam']['team_logo'], ['width' => 30]) . ' ' . Html::a($model['idTeamHome']['idTeam']['team_name'], ['tournaments/games', 'id' => $model['id_team_home']]) . " " . "</div>" . "<div class = 'text-center col-xs-2'>" . "-" . "</div>" . "<div class = 'text-left col-xs-5'>" . " " . Html::a($model['idTeamGuest']['idTeam']['team_name'], ['tournaments/games', 'id' => $model['id_team_guest']]) . ' ' . Html::img(Teams::getPath() . '/' . $model['idTeamGuest']['idTeam']['team_logo'], ['width' => 30]) . "</div>" . "</row>" . "<row>" . "<div class = 'col-xs-12 text-center'>" . Html::input('number', "forecasts[{$model['id_game']}][fscore_home]", isset($model['f_id']) ? $model['fscore_home'] : '', ['class' => 'forecast', 'form' => $form->getID(), 'maxlength' => 2, 'disabled' => $model['date_time_game'] - time() < 60 * 60 ? true : false]) . Html::input('number', "forecasts[{$model['id_game']}][fscore_guest]", isset($model['f_id']) ? $model['fscore_guest'] : '', ['class' => 'forecast', 'maxlength' => 2, 'form' => $form->getID(), 'disabled' => $model['date_time_game'] - time() < 60 * 60 ? true : false]) . "</div>" . "</row>";
        }, 'options' => ['class' => 'col-xs-11'], 'contentOptions' => ['style' => 'font-size: 13px'], 'vAlign' => 'middle']]]);
        ?>
                <?php 
        $content .= "<p class = 'text-right'>" . Html::submitButton('Сохранить', ['class' => 'btn btn-success', 'form' => $form->getId()]) . "</p>";
        ?>
                <?php 
        ActiveForm::end();
        ?>
                <?php 
        $content .= "</form>";
        ?>
            <?php 
    }
    ?>
 public function actionAddParticipants()
 {
     $candidates = Yii::$app->request->post('candidates');
     if (!$candidates) {
         return $this->goBack();
     }
     $participants = Teams::find()->where(['in', 'id_team', $candidates])->all();
     $tournament = Tournaments::findOne(Yii::$app->request->post('tournament'));
     foreach ($participants as $one) {
         $one->link('tournaments', $tournament);
     }
     return $this->goBack();
 }
Пример #5
0
 /**
  * Finds the teams model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return teams the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Teams::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #6
0
use kartik\grid\GridView;
use app\models\teams\Teams;
/**
 * @var $team
 * @var $tournament
 * @var $games
 */
$this->title = 'Игры ' . $team->idTeam->team_name . ' в турнире ' . $tournament->idTournament->tournament_name;
$this->params['breadcrumbs'][] = ['label' => 'Турниры', 'url' => '/tournaments'];
$this->params['breadcrumbs'][] = ['label' => $tournament->idTournament->tournament_name, 'url' => ['tournaments/details', 'id' => $tournament->idTournament->id_tournament]];
$this->params['breadcrumbs'][] = 'Игры ' . $team->idTeam->team_name;
?>

<div class="row">
    <div class="col-xs-12 col-xs-offset-0 col-sm-offset-1 col-sm-10">
        <div class="row">
            <?php 
echo GridView::widget(['dataProvider' => $games, 'responsive' => false, 'responsiveWrap' => false, 'hover' => true, 'export' => false, 'showHeader' => false, 'bordered' => false, 'caption' => $this->title, 'options' => ['style' => 'margin-top: 30px', 'class' => 'col-xs-12 col-sm-10 col-md-8 col-lg-6'], 'summary' => '', 'columns' => [['attribute' => 'date_time_game', 'content' => function ($model) {
    return '<strong>' . date('d.m.y H:i', $model->dtime) . '</strong>';
}, 'options' => ['class' => 'col-xs-1 col-sm-2'], 'contentOptions' => ['class' => 'reduceDateFont'], 'hAlign' => 'center', 'vAlign' => 'middle'], ['content' => function ($model) use($team) {
    return $model->home_participant_id == $team->id ? Html::img(Teams::getPath() . '/' . $model->home_logo, ['width' => 30]) . ' ' . '<strong>' . $model->home_team . '</strong>' : Html::img(Teams::getPath() . '/' . $model->home_logo, ['width' => 30]) . ' ' . $model->home_team;
}, 'options' => ['class' => 'col-xs-3 col-sm-4'], 'hAlign' => 'right', 'vAlign' => 'middle'], ['content' => function ($model) {
    return "<strong>" . $model->home_score . ' : ' . $model->guest_score . "</strong>";
}, 'options' => ['class' => 'col-xs-4 col-sm-2'], 'hAlign' => 'center', 'vAlign' => 'middle'], ['content' => function ($model) use($team) {
    return $model->guest_participant_id == $team->id ? Html::img(Teams::getPath() . '/' . $model->guest_logo, ['width' => 30]) . ' ' . '<strong>' . $model->guest_team . '</strong>' : Html::img(Teams::getPath() . '/' . $model->guest_logo, ['width' => 30]) . ' ' . $model->guest_team;
}, 'options' => ['class' => 'col-xs-4'], 'hAlign' => 'left', 'vAlign' => 'middle']]]);
?>
        </div>
    </div>
</div>
Пример #7
0
 public function getTeams()
 {
     return $this->hasMany(\app\models\teams\Teams::className(), ['id_team' => 'id_team'])->viaTable('{{%team_tournaments}}', ['id_tournament' => 'id_tournament']);
 }
Пример #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdTeam()
 {
     return $this->hasOne(Teams::className(), ['id_team' => 'id_team']);
 }
Пример #9
0
    ?>

            <?php 
    $content = '';
    ?>
            <?php 
    $content .= "<p class = 'text-right'>" . Html::a("<i class = 'fa fa-list-alt'></i> Все игры", ['tournaments/details', 'id' => $tournament['id_tournament']]) . "</p>";
    ?>
            <?php 
    foreach ($tournament['games'] as $k => $tour) {
        ?>
                <?php 
        $content .= extendedGridView::widget(['dataProvider' => $tour, 'summary' => '', 'showHeader' => false, 'showPageSummary' => true, 'caption' => "Тур {$k}", 'captionOptions' => ['colspan' => 4, 'class' => 'text-center normal'], 'columns' => [['content' => function ($model) {
            return '<strong>' . date('d.m.y H:i', $model['date_time_game']) . '</strong>';
        }, 'options' => ['class' => 'col-xs-1'], 'contentOptions' => ['class' => 'reduceDateFont'], 'hAlign' => 'center', 'vAlign' => 'middle'], ['content' => function ($model) {
            return "<row>" . "<div class = 'text-right col-xs-4'>" . Html::img(Teams::getPath() . '/' . $model['idTeamHome']['idTeam']['team_logo'], ['width' => 30]) . ' ' . $model['idTeamHome']['idTeam']['team_name'] . " " . "</div>" . "<div class = 'text-center col-xs-4'>" . "<strong>" . $model['score_home'] . " - " . $model['score_guest'] . "</strong>" . "</div>" . "<div class = 'text-left col-xs-4'>" . " " . $model['idTeamGuest']['idTeam']['team_name'] . ' ' . Html::img(Teams::getPath() . '/' . $model['idTeamGuest']['idTeam']['team_logo'], ['width' => 30]) . "</div>" . "</row>" . "<div class='clearfix visible-xs-block'></div>" . "<row>" . "<div class = 'col-xs-4 col-xs-offset-4 col-lg-2 col-lg-offset-5 text-center'>" . Html::tag('div', isset($model['f_id']) ? $model['fscore_home'] . ' - ' . $model['fscore_guest'] : " - ", ['class' => !isset($model['f_id']) ? '' : ($model['fpoints'] == 0 ? 'bg-danger' : ($model['fpoints'] == 1 ? 'bg-info' : ($model['fpoints'] == 3 ? 'bg-success' : ($model['fpoints'] == 2 ? 'bg-warning' : ''))))]) . "</div>" . "<div class = 'col-xs-3 col-xs-offset-1 col-lg-2 col-lg-offset-3 text-right'>" . Html::tag('span', isset($model['f_id']) ? "Очки: " . $model['fpoints'] : '', []) . "</div>" . "</row>";
        }, 'attribute' => 'fpoints', 'pageSummary' => function ($summary, $data, $widget) {
            return "<div class = 'row'>" . "<div class = 'col-xs-10'>" . "<p class = 'pull-left'>Всего очков в туре:</p>" . "</div>" . "<div class = 'col-xs-2'>" . "<p class = 'pull-left'>{$summary}</p>" . "</div>" . "</div>";
        }, 'options' => ['class' => 'col-xs-11'], 'contentOptions' => ['style' => 'font-size: 13px'], 'vAlign' => 'middle']]]);
        ?>
            <?php 
    }
    ?>

            <?php 
    echo Collapse::widget(['encodeLabels' => false, 'items' => [['label' => "<i class = 'fa fa-futbol-o fa-spin'></i>" . '  ' . $tournament['tournament'], 'content' => $content]]]);
    ?>
        <?php 
}
?>
    </div>