<?php

use yii\bootstrap\Alert;

if (Yii::$app->session->getFlash('message') != null) {
    echo Alert::widget([
        'options' => [
            'class' => 'alert-info',
        ],
        'body' => Yii::$app->session->getFlash('message'),
    ]);
}

use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;
use yii\widgets\Menu;
use yii\bootstrap\Tabs;

$this->title = 'Users';
$this->params['breadcrumbs'] = [
    'Mikrotik',
    $this->title,
];
?>
<div class="site-plugins">
    <div class="row">
        <div class="col-lg-3">
            <?php
            echo Menu::widget($menu);
            ?> 
        </div>
        <div class="col-md-9">
            <h1 style="margin-top: 0px"><?= Html::encode($this->title) ?></h1>

            <?php
            $tabs[] = ['label' => 'Users', 'content' => GridView::widget([
                    'dataProvider' => $provider['users'],
                    'id' => 'id',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info',];
                        }
                    },
                            'columns' => [
                                'name:text:Name',
                                'group:text:Group',
                                'last_logged_in:text:Last Logged In',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/system/users',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/system/users/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'Groups', 'content' => GridView::widget([
                            'dataProvider' => $provider['groups'],
                            'id' => 'id',
                            'columns' => [
                                'name:text:Name',
                                'policy:text:Policies',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/system/groups',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/system/groups/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'SSH Keys', 'content' => GridView::widget([
                            'dataProvider' => $provider['keys'],
                            'id' => 'id',
                            'columns' => [
                                'user:text:Users',
                                'key_owner:text:Owner',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{delete}',
                                    'controller' => 'mikrotik/system/keys',
                                    'header' => Html::button('Import', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/system/keys/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'SSH Private Keys', 'content' => GridView::widget([
                            'dataProvider' => $provider['private'],
                            'id' => 'id',
                            'columns' => [
                                'user:text:Users',
                                'key_owner:text:Owner',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{delete}',
                                    'controller' => 'mikrotik/system/privates',
                                    'header' => Html::button('Import', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/system/privates/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'Active Users', 'content' => GridView::widget([
                            'dataProvider' => $provider['active'],
                            'id' => 'id',
                            'columns' => [
                                'name:text:Name',
                                'when:text:At',
                                'address:text:From',
                                'via:text:Via',
                                'group:text:Group',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{delete}',
                                    'controller' => 'mikrotik/system/privates',
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    echo Tabs::widget([
                        'items' => $tabs]);
//                                                            
                    ?>



        </div>
    </div>
</div>



