<?php

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

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

$this->title = Yii::t('app', 'Admin Menus');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="admin-menu-index box box-primary">

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

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'showFooter' => true,
        'layout' => "<div class='box-header with-border admin_grid_action'>
                        <div class='action_link'>"
                            .Html::a(Yii::t('app', 'Create Admin Menu'), ['create'], ['class' => 'btn btn-success btn-flat']).
                        "</div>
                        <div class='pull-right'>
                            {pager}
                        </div>
                    </div>
                    <div class='box-body no-padding table-responsive'>
                        {items}
                    </div>
                    <div class='box-footer admin_grid_action'>
                        <div class='action_link'>"
                            .Html::a(Yii::t('app', 'Create Admin Menu'), ['create'], ['class' => 'btn btn-success btn-flat']).
                        "</div>
                        <div class='pull-right'>
                            {pager}
                        </div>
                    </div>",
        'columns' => [
            ['class' => 'yii\grid\ActionColumn'],
            'admin_menu_id',
            'name',
            'path',
            'param',
            [
                'format' => 'raw',
                'filter' => [
                    '1'=>'Отображаются',
                    '0'=>'Скрытые',
                ],
                'value' => function($data){
                    if($data->status){
                        $status_img = '<i style="color: #008000" class="glyphicon glyphicon-ok"></i>';
                    } else {
                        $status_img = '<i style="color: red" class="glyphicon glyphicon-remove"></i>';
                    }
                    return $status_img;
                },
                'attribute'=>'status',
            ],
            [
                'attribute' =>  'parentt',
                'content' =>
                    function($model, $key, $index, $column) {
                    if($model->parent->admin_menu_id) {
                        return $model->parent->name;
                    } else {
                        return '<i class="small">'.Yii::t('app', 'Корневой элемент').'</i>';
                    }
                }
            ],
            [
                'format' => 'raw',
                'filter' => [
                    '1'=>'Отображаются',
                    '0'=>'Скрытые',
                ],
                'value' => function($data){
                    if($data->hide_min){
                        $status_img = '<i style="color: #008000" class="glyphicon glyphicon-ok"></i>';
                    } else {
                        $status_img = '<i style="color: red" class="glyphicon glyphicon-remove"></i>';
                    }
                    return $status_img;
                },
                'attribute'=>'hide_min',
            ],
        ],
    ]); ?>

</div>
