<?php

use common\models\Store;
use slavkovrn\lightbox\LightBoxWidget;
use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\StoreSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('common', 'Stores');
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginBlock('content-header') ?>
<?= $this->title . ' ' . Html::a(Yii::t('common', 'Create Store'), ['create'], ['class' => 'btn btn-success']) ?>
<?php $this->endBlock() ?>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>

<div class="box box-success">
    <div class="box-body">
        <?= GridView::widget([
            'dataProvider' => $dataProvider,
            //'filterModel' => $searchModel,
            'columns' => [
                'id',
                'user_id:user',
                'proxy_user_id:user',
                'name',
                'code',
                'address',
                [
                    'attribute' => 'logo',
                    'format' => 'raw',
                    'value' => function ($model) {
                        $images = [               // images at popup window of prettyPhoto galary
                            1 => [
                                'src' => $model->logo,
                                'title' => '',
                            ],
                        ];
                        return $model->logo ? LightBoxWidget::widget([
                            'id' => 'cover',  // id of plugin should be unique at page
                            'class' => 'galary',    // class of plugin to define style
                            'height' => '100px',     // height of image visible in widget
                            'width' => '100px',      // width of image visible in widget
                            'images' => $images,
                        ]) : null;
                    }
                ],
                [
                    'attribute' => 'license',
                    'format' => 'raw',
                    'value' => function ($model) {
                        $images = [               // images at popup window of prettyPhoto galary
                            1 => [
                                'src' => $model->license,
                                'title' => '',
                            ],
                        ];
                        return $model->license ? LightBoxWidget::widget([
                            'id' => 'cover',  // id of plugin should be unique at page
                            'class' => 'galary',    // class of plugin to define style
                            'height' => '100px',     // height of image visible in widget
                            'width' => '100px',      // width of image visible in widget
                            'images' => $images,
                        ]) : null;
                    }
                ],
                /*[
                    'attribute' => 'photos',
                    'format' => 'raw',
                    'value' => function ($model){
                        $images = [];
                        foreach ($model->photos as $index=>$photos) {
                            $images[$index] = ['src'=>$photos, 'title'=>''];
                        }
                        return $model->photos ?  LightBoxWidget::widget([
                            'id'     =>'photos',  // id of plugin should be unique at page
                            'class'  =>'galary',    // class of plugin to define style
                            'height' =>'100px',     // height of image visible in widget
                            'width' =>'100px',      // width of image visible in widget
                            'images' => $images,
                        ]) : null;
                    }
                ],*/

                'contacts',
                'tel',
                'desc',
                'created_at:datetime',
                'updated_at:datetime',
                [
                    'attribute' => 'status',
                    'value' => function ($model) {
                        return  Store::getStatusList($model->status);
                    },
                ],


                ['class' => 'common\helpers\DiyActionColumn'],
            ],
        ]); ?>
    </div>
</div>
