<?php

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

$this->title = 'Mesh';
$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
            //var_dump($provider);
            $tabs[] = ['label' => 'Mesh', 'content' => GridView::widget([
                    'dataProvider' => $provider['mesh'],
                    'id' => 'interfaces',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info',];
                        }
                        if ($provider->running == 'false') {
                            return ['class' => 'danger',];
                        }
                    },
                            'columns' => [
                                'name:text:Name',
                                'type:text:Type',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/mesh/mesh',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/mesh/mesh/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'Ports', 'content' => GridView::widget([
                            'dataProvider' => $provider['port'],
                            'id' => 'interfaces',
                            'rowOptions' => function($provider) {
                                if ($provider->disabled == 'true') {
                                    return ['class' => 'info',];
                                }
                            },
                                    'columns' => [
                                        'interface:text:Interface',
                                        'mesh:text:Mesh',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/mesh/port',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/mesh/port/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'FDB', 'content' => GridView::widget([
                                    'dataProvider' => $provider['fdb'],
                                    'id' => 'interfaces',
                                    'columns' => [
                                        'mesh:text:Mesh',
                                        'type:text:Type',
                                        'mac_address:text:MAC Address',
                                        'on_interface:text:On Interface',
                                        'lifetime:text:Lifetime',
                                        'age:text:Age',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '',
                                            'controller' => 'mikrotik/mesh/mesh',
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];

                            echo Tabs::widget([
                                'items' => $tabs]);
                            ?>



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



