<?php

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

$this->title = 'Bridge';
$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' => 'Bridge', 'content' => GridView::widget([
                    'dataProvider' => $provider['bridge'],
                    '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',
                                'l2mtu:text:L2 MTU',
                                'mac_address:text:MAC Address',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/bridge/bridge',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/bridge/bridge/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'Ports', 'content' => GridView::widget([
                            'dataProvider' => $provider['ports'],
                            'id' => 'interfaces',
                            'rowOptions' => function($provider) {
                                if ($provider->disabled == 'true') {
                                    return ['class' => 'info',];
                                }
                            },
                                    'columns' => [
                                        'interface:text:Interface',
                                        'bridge:text:Bridge',
                                        'priority:text:Priority',
                                        'path_cost:text:Path Cost',
                                        'horizon:text:Horizon',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/bridge/port',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/bridge/port/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Filters', 'content' => GridView::widget([
                                    'dataProvider' => $provider['filters'],
                                    'id' => 'interfaces',
                                    'rowOptions' => function($provider) {
                                        if ($provider->disabled == 'true') {
                                            return ['class' => 'info',];
                                        }
                                    },
                                            'columns' => [
                                                'chain:text:Chain',
                                                'in_interface:text:In. Interface',
                                                'out_interface:text:Out. Interface',
                                                'src_mac_address:text:Src. MAC Address',
                                                'dst_mac_address:text:Dst. MAC Address',
                                                [
                                                    'class' => 'yii\grid\ActionColumn',
                                                    'template' => '{update} {delete}',
                                                    'controller' => 'mikrotik/bridge/filter',
                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                        'js:document.location.href="' . Url::toRoute('mikrotik/bridge/filter/create') . '"']),
                                                    'footer' => Html::button('Reset All Counters', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                        'js:document.location.href="' . Url::toRoute('mikrotik/bridge/filter/reset') . '"']),
                                                ],
                                            ],
                                            'showFooter' => true,
                                        ])
                                    ];
                                    $tabs[] = ['label' => 'NAT', 'content' => GridView::widget([
                                            'dataProvider' => $provider['nat'],
                                            'id' => 'interfaces',
                                            'rowOptions' => function($provider) {
                                                if ($provider->disabled == 'true') {
                                                    return ['class' => 'info',];
                                                }
                                            },
                                                    'columns' => [
                                                        'chain:text:Chain',
                                                        'in_interface:text:In. Interface',
                                                        'out_interface:text:Out. Interface',
                                                        'src_mac_address:text:Src. MAC Address',
                                                        'dst_mac_address:text:Dst. MAC Address',
                                                        [
                                                            'class' => 'yii\grid\ActionColumn',
                                                            'template' => '{update} {delete}',
                                                            'controller' => 'mikrotik/bridge/nat',
                                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                'js:document.location.href="' . Url::toRoute('mikrotik/bridge/nat/create') . '"']),
                                                            'footer' => Html::button('Reset All Counters', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                'js:document.location.href="' . Url::toRoute('mikrotik/bridge/nat/reset') . '"']),
                                                        ],
                                                    ],
                                                    'showFooter' => true,
                                                ])
                                            ];
                                            $tabs[] = ['label' => 'Hosts', 'content' => GridView::widget([
                                                    'dataProvider' => $provider['hosts'],
                                                    'id' => 'interfaces',
                                                    'rowOptions' => function($provider) {
                                                        if ($provider->disabled == 'true') {
                                                            return ['class' => 'info',];
                                                        }
                                                    },
                                                            'columns' => [
                                                                'mac_address:text:MAC Address',
                                                                'on_interface:text:On. Interface',
                                                                'age:text:Age',
                                                                'bridge:text:Bridge',
                                                                [
                                                                    'class' => 'yii\grid\ActionColumn',
                                                                    'template' => '',
                                                                    'controller' => 'mikrotik/bridge/hosts',
                                                                ],
                                                            ],
                                                            'showFooter' => false,
                                                        ])
                                                    ];

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



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



