<?php
/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\grid\GridView;

$this->title = Yii::t('app', 'BiddingBegin ID');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="lots-index">

    <div class="panel panel-primary">
        <div class="panel-heading"><span class="glyphicon glyphicon-flag"></span><strong> <?= Html::encode($this->title) ?></strong></div>
        <div class="panel-body">

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

                    'name',

                    [
                        'attribute' => 'lot_id',
                        'header'    =>  Yii::t('app','Lots ID'),
                        'value' =>  function($model)
                        {
                            $sql = Yii::$app->db->createCommand("SELECT id, name from lots WHERE aukname=:name");
                            $sql->bindValues([':name' => $model->name]);
                            $result = $sql->queryAll();

                            $arr = array();
                            foreach ($result as $key=>$value)
                            {
                                $arr[] = $value['name'].", ";
                            }
                            return implode(",",$arr);

                        }
                    ],
                    //'date_start',
                    //'date_stop',

                    [
                        'class' => 'yii\grid\ActionColumn',
                        'template' => '{view}',
                        'buttons' => [
                            'view' => function ($url,$model,$key) {
                                return Html::a('', '/auctions/index?AuctionsSearch[name]='.$model->name,['class' => 'glyphicon glyphicon-eye-open']);
                            },
                        ],
                    ],
                ],
            ]);
            ?>
        </div></div>
