Пример #1
0
<?php

use yii\helpers\Html;
use yii\helpers\Url;
use kartik\grid\GridView;
use common\models\Registration;
use common\models\Competition;
/* @var $this yii\web\View */
/* @var $searchModel app\models\RegistrationSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<div class="registration-list">

     <?php 
echo GridView::widget(['options' => ['id' => 'registration'], 'dataProvider' => $dataProvider, 'panel' => ['heading' => '<h4>' . $this->title . '</h4>', 'footer' => false], 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'export' => false, 'columns' => [['attribute' => 'golfer_name', 'label' => Yii::t('igolf', 'Golfer'), 'value' => function ($model, $key, $index, $widget) {
    return $model->golfer->name;
}], 'tees.name', 'flight.id', 'team.id', ['attribute' => 'status', 'value' => function ($model, $key, $index, $widget) {
    return Yii::t('igolf', $model->status);
}, 'filter' => Registration::getLocalizedPreCompetitionStatuses()]]]);
?>

</div>
Пример #2
0
<div class="registration-index">

     <?php 
echo GridView::widget(['options' => ['id' => 'registration'], 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'panel' => ['heading' => '<h4>' . $this->title . '</h4>', 'footer' => false], 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'export' => false, 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'competition_name', 'label' => Yii::t('igolf', 'Competition'), 'value' => function ($model, $key, $index, $widget) {
    return $model->competition->name;
}, 'visible' => $competition === null], ['attribute' => 'competition_type', 'label' => Yii::t('igolf', 'Competition Type'), 'value' => function ($model, $key, $index, $widget) {
    return Yii::t('igolf', $model->competition->competition_type);
}, 'filter' => Competition::getLocalizedConstants('TYPE_'), 'visible' => $competition === null], ['attribute' => 'golfer_name', 'label' => Yii::t('igolf', 'Golfer'), 'value' => function ($model, $key, $index, $widget) {
    return $model->golfer->name;
}], ['label' => Yii::t('igolf', 'Created At'), 'attribute' => 'created_at', 'format' => 'datetime', 'value' => function ($model, $key, $index, $widget) {
    return new DateTime($model->created_at);
}], ['label' => Yii::t('igolf', 'Last Update'), 'attribute' => 'updated_at', 'format' => 'datetime', 'value' => function ($model, $key, $index, $widget) {
    return new DateTime($model->updated_at);
}], ['attribute' => 'status', 'value' => function ($model, $key, $index, $widget) {
    return Yii::t('igolf', $model->status);
}, 'filter' => Registration::getLocalizedPreCompetitionStatuses()], ['class' => 'kartik\\grid\\CheckboxColumn']]]);
?>

<?php 
$statuses = '<div class="btn-group"><button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">' . Yii::t('igolf', 'Change Status of Selected Registrations to ') . ' <span class="caret"></span></button><ul class="dropdown-menu" role="menu">';
foreach (Registration::getLocalizedConstants('STATUS_') as $key => $value) {
    $statuses .= '<li>' . Html::a(Yii::t('igolf', 'Change to {0}', $value), null, ['class' => 'igolf-bulk-action', 'data-status' => $key]) . '</li>';
}
$statuses .= '</ul></div>';
$buttons = '';
if ($competition) {
    $buttons = Html::a(Yii::t('igolf', 'New Registration'), ['create', 'id' => $competition->id], ['class' => 'btn btn-success']);
    $buttons .= ' ' . Html::a(Yii::t('igolf', 'Bulk Registrations'), ['bulk', 'id' => $competition->id], ['class' => 'btn btn-success']);
}
$buttons .= ' ' . Html::a(Yii::t('igolf', 'Delete Selected Registrations'), null, ['class' => 'btn btn-danger igolf-bulk-action', 'data' => ['status' => Registration::ACTION_DELETE, 'confirm-local' => Yii::t('igolf', 'Are you sure you want to delete selected registration(s)?')]]);
$buttons .= ' ' . $statuses;