<?php

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

$this->title = 'Switch';
$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' => 'Switch', 'content' => GridView::widget([
                    'dataProvider' => $provider['switch'],
                    'id' => 'interfaces',
                    'columns' => [
                        'name:text:Name',
                        'type:text:Type',
                        'mirror_source:text:Mirror Source',
                        'mirror_target:text:Mirror Target',
                        [
                            'class' => 'yii\grid\ActionColumn',
                            'template' => '{update}',
                            'controller' => 'mikrotik/switchm/switchm',
                        ],
                    ],
                    'showFooter' => false,
                ])
            ];
            $tabs[] = ['label' => 'Port', 'content' => GridView::widget([
                    'dataProvider' => $provider['port'],
                    'id' => 'interfaces',
                    'columns' => [
                        'name:text:Name',
                        'switch:text:Switch',
                        'vlan_mode:text:VLAN Mode',
                        'vlan_header:text:VLAN Header',
                        'default_vlan_id:text:Default VLAN ID',
                        [
                            'class' => 'yii\grid\ActionColumn',
                            'template' => '',
                            'controller' => 'mikrotik/switchm/switchm',
                        ],
                    ],
                    'showFooter' => false,
                ])
            ];
            $tabs[] = ['label' => 'Hosts', 'content' => GridView::widget([
                    'dataProvider' => $provider['host'],
                    'id' => 'interfaces',
                    'columns' => [
                        'switch:text:Switch',
                        'mac_address:text:MAC Address',
                        'ports:text:Ports',
                        'drop:text:Drop',
                        'mirror:text:Mirror',
                        [
                            'class' => 'yii\grid\ActionColumn',
                            'template' => '{update} {delete}',
                            'controller' => 'mikrotik/switchm/host',
                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                'js:document.location.href="' . Url::toRoute('mikrotik/switchm/host/create') . '"']),
                        ],
                    ],
                    'showFooter' => false,
                ])
            ];

            $tabs[] = ['label' => 'VLAN', 'content' => GridView::widget([
                    'dataProvider' => $provider['vlan'],
                    'id' => 'interfaces',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info',];
                        }
                    },
                            'columns' => [
                                'switch:text:Switch',
                                'vlan_id:text:VLAN ID',
                                'ports:text:Ports',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/switchm/vlan',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/switchm/vlan/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                     $tabs[] = ['label' => 'Rule', 'content' => GridView::widget([
                    'dataProvider' => $provider['rule'],
                    'id' => 'interfaces',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info',];
                        }
                    },
                            'columns' => [
                                'switch:text:Switch',
                                'ports:text:Ports',
                                'src_mac_address:text:Src. MAC Address',
                                'dst_mac_address:text:Dst. MAC Address',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/switchm/rule',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/switchm/rule/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
//                            $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>



