<?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 = 'Wireless Tables';
$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' => 'Interfaces', 'content' => GridView::widget([
                    'dataProvider' => $provider['interfaces'],
                    'id' => 'interfaces',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info',];
                        }
                    },
                            'columns' => [
                                'name:text:Name',
                                'interface_type:text:Type',
                                'l2mtu:text:L2 MTU',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/wireless/interfaces',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/wireless/interfaces/create') . '"']),
                                    'footer' => Html::button('CAP', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/wireless/wireless/cap') . '"']),
                                ],
                            ],
                            'showFooter' => true,
                        ])
                    ];
                    $tabs[] = ['label' => 'WDS', 'content' => GridView::widget([
                            'dataProvider' => $provider['wds'],
                            'id' => 'interfaces',
                            'rowOptions' => function($provider) {
                                if ($provider->disabled == 'true') {
                                    return ['class' => 'info',];
                                }
                            },
                                    'columns' => [
                                        'name:text:Name',
                                        'type:text:Type',
                                        'mtu:text:MTU',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/wireless/wds',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/wireless/wds/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Access List', 'content' => GridView::widget([
                                    'dataProvider' => $provider['accesslist'],
                                    'id' => 'interfaces',
                                    'rowOptions' => function($provider) {
                                        if ($provider->disabled == 'true') {
                                            return ['class' => 'info',];
                                        }
                                    },
                                            'columns' => [
                                                'mac_address:text:MAC Address',
                                                'interface:text:Interface',
                                                'signal_range:text:Signal Strength Range',
                                                'authentication:text:Authentication',
                                                'forwarding:text:Forwarding',
                                                [
                                                    'class' => 'yii\grid\ActionColumn',
                                                    'template' => '{update} {delete}',
                                                    'controller' => 'mikrotik/wireless/accesslist',
                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                        'js:document.location.href="' . Url::toRoute('mikrotik/wireless/accesslist/create') . '"']),
                                                ],
                                            ],
                                            'showFooter' => false,
                                        ])
                                    ];


                                    $tabs[] = ['label' => 'Registration', 'content' => GridView::widget([
                                            'dataProvider' => $provider['registration'],
                                            'id' => 'interfaces',
                                            'columns' => [
                                                'radio_name:text:Radio Name',
                                                'mac_address:text:MAC Address',
                                                'interface:text:Interface',
                                                'uptime:text:Uptime',
                                                'ap:text:AP',
                                                'wds:text:WDS',
                                                'last_activity:text:Last Activity',
                                                'tx_rate:text:Tx Rate',
                                                'rx_rate:text:Rx Rate',
                                                [
                                                    'class' => 'yii\grid\ActionColumn',
                                                    'template' => '',
                                                    'controller' => 'mikrotik/wireless/wireless',
                                                ],
                                            ],
                                            'showFooter' => false,
                                        ])
                                    ];
                                    $tabs[] = ['label' => 'Connect List', 'content' => GridView::widget([
                                            'dataProvider' => $provider['connectlist'],
                                            'id' => 'interfaces',
                                            'rowOptions' => function($provider) {
                                                if ($provider->disabled == 'true') {
                                                    return ['class' => 'info',];
                                                }
                                            },
                                                    'columns' => [
                                                        'interface:text:Interface',
                                                        'mac_address:text:MAC Address',
                                                        'connect:text:Connect',
                                                        'area_prefix:text:Area Prefix',
                                                        'signal_range:text:Signal Strength Range',
                                                        'security_profile:text:Security Profile',
                                                        [
                                                            'class' => 'yii\grid\ActionColumn',
                                                            'template' => '{update} {delete}',
                                                            'controller' => 'mikrotik/wireless/connectlist',
                                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                'js:document.location.href="' . Url::toRoute('mikrotik/wireless/connectlist/create') . '"']),
                                                        ],
                                                    ],
                                                    'showFooter' => false,
                                                ])
                                            ];
                                            $tabs[] = ['label' => 'Security Profiles', 'content' => GridView::widget([
                                                    'dataProvider' => $provider['securityprofiles'],
                                                    'id' => 'interfaces',
                                                    'columns' => [
                                                        'name:text:Name',
                                                        'mode:text:Mode',
                                                        [
                                                            'class' => 'yii\grid\ActionColumn',
                                                            'template' => '{update} {delete}',
                                                            'controller' => 'mikrotik/wireless/securityprofiles',
                                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                'js:document.location.href="' . Url::toRoute('mikrotik/wireless/securityprofiles/create') . '"']),
                                                        ],
                                                    ],
                                                    'showFooter' => false,
                                                ])
                                            ];
                                            $tabs[] = ['label' => 'Channels', 'content' => GridView::widget([
                                                    'dataProvider' => $provider['channels'],
                                                    'id' => 'interfaces',
                                                    'rowOptions' => function($provider) {
                                                        if ($provider->disabled == 'true') {
                                                            return ['class' => 'info',];
                                                        }
                                                    },
                                                            'columns' => [
                                                                'list:text:List',
                                                                'name:text:Name',
                                                                'frequency:text:Frequency',
                                                                'width:text:Width',
                                                                'band:text:Band',
                                                                'extension_channel:text:Extension Channel',
                                                                [
                                                                    'class' => 'yii\grid\ActionColumn',
                                                                    'template' => '{update} {delete}',
                                                                    'controller' => 'mikrotik/wireless/channels',
                                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                        'js:document.location.href="' . Url::toRoute('mikrotik/wireless/channels/create') . '"']),
                                                                ],
                                                            ],
                                                            'showFooter' => false,
                                                        ])
                                                    ];

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



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



