Пример #1
0
use yii\grid\GridView;
use yii\grid\ActionColumn;
use yii\helpers\Html;
use app\models\Note;
use yii\widgets\Pjax;
echo $this->render('_nav', ['cur' => 'notes']);
Pjax::begin(['timeout' => 5000]);
echo Gridview::widget(['options' => ['class' => 'grid-view table-responsive'], 'dataProvider' => $noteProvider, 'filterModel' => $noteSearch, 'columns' => ['id', ['attribute' => 'name', 'value' => function ($model, $key, $index, $column) {
    return mb_strimwidth($model->name, 0, 20, '...', 'UTF-8');
}], ['attribute' => 'visibility', 'value' => function ($model, $key, $index, $column) {
    switch ($model->visibility) {
        case Note::VIS_PRIVATE:
            return 'Только себе';
        case Note::VIS_PUBLIC_UNLISTED:
            return 'По ссылке';
        case Note::VIS_PUBLIC_LISTED:
            return 'Всем';
        default:
            return '(не задано)';
    }
}], ['attribute' => 'user.name', 'label' => $noteSearch->getAttributeLabel('user.name'), 'value' => function ($model, $key, $index, $column) {
    return isset($model->user) ? mb_strimwidth($model->user->name, 0, 20, '...', 'UTF-8') : '(не задано)';
}], ['attribute' => 'created_at', 'format' => ['date', 'php:d-m-Y']], ['class' => ActionColumn::className(), 'template' => '{view} {update} {delete}', 'buttons' => ['view' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', ['note/view', 'id' => $model->id]);
}, 'update' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['note/update', 'id' => $model->id]);
}, 'delete' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['note/delete', 'id' => $model->id], ['data-method' => 'post']);
}]]]]);
Pjax::end();
Пример #2
0
?>
</h2>
        </div>
        <div class="col-sm-3" style="margin-top: 15px">
            <?php 
echo Html::a('<i class="fa glyphicon glyphicon-hand-up"></i> ' . Yii::t('app', 'PDF'), ['pdf', 'id' => $model['id']], ['class' => 'btn btn-danger', 'target' => '_blank', 'data-toggle' => 'tooltip', 'title' => Yii::t('app', 'Will open the generated PDF file in a new window')]);
?>
            <?php 
echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
            <?php 
echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
        </div>
    </div>

    <div class="row">
<?php 
$gridColumn = [['attribute' => 'id', 'hidden' => true], ['attribute' => 'patient.name', 'label' => Yii::t('app', 'Patient')], ['attribute' => 'operator.username', 'label' => Yii::t('app', 'Operator')], 'date'];
echo DetailView::widget(['model' => $model, 'attributes' => $gridColumn]);
?>
    </div>

    <div class="row">
<?php 
$gridColumnReportTest = [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'test.name', 'label' => Yii::t('app', 'Test')], ['attribute' => 'test.description', 'label' => Yii::t('app', 'Description')], 'result'];
echo Gridview::widget(['dataProvider' => $providerReportTest, 'pjax' => true, 'pjaxSettings' => ['options' => ['id' => 'kv-pjax-container']], 'panel' => ['type' => GridView::TYPE_PRIMARY, 'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-book"></i>  ' . Html::encode(Yii::t('app', 'Report Test') . ' ' . $this->title) . ' </h3>'], 'columns' => $gridColumnReportTest]);
?>
    </div>
</div>
Пример #3
0
<?php

use yii\grid\GridView;
use yii\helpers\Html;
?>

<h2>Sản phẩm</h2>
<?php 
echo Gridview::widget(['dataProvider' => $dataProvider, 'columns' => ['product_id', 'product_name']]);