index.php 1.79 KB
<?php

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

/* @var $this yii\web\View */
/* @var $searchModel common\models\BrandsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Бренды';
$this->params['breadcrumbs'][] = $this->title;
$img0 = '/storage/checkbox0.gif';
$img1 = '/storage/checkbox1.gif';
?>
<div class="brands-index">

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

    <p>
        <?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'ID',
            'BRAND',
            ['attribute' => 'if_tecdoc',
                'format' => 'raw',
                'value' => function ( $model ) use ($img0, $img1) {
                    if ($model->if_tecdoc == '1') {
                        $info = " <img src=$img1>";
                    }
                    else {
                        $info = " <img src=$img0>";
                    }
                    return $info;
                },
            ],

            ['label' => 'ОРИГИНАЛ?',
            'attribute' => 'if_oem',
                'format' => 'raw',
               'value' => function ( $model ) use ($img0, $img1) {
                   if ($model->if_oem == '1') {
                       $info = " <img src=$img1>";
                   }
                   else {
                       $info = " <img src=$img0>";
                   }
                   return $info;
               },
            ],
            ['class' => 'yii\grid\ActionColumn',
            'template' => '{update}'],
        ],
    ]); ?>

</div>