<?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;
use yii\bootstrap\Nav;

$this->title = 'CAPsMAN';
$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' => 'Interfaces', 'content' => GridView::widget([
                    'dataProvider' => $provider['interfaces'],
                    'id' => 'type',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info',];
                        }
                    },
                            'columns' => [
                                'name:text:Name',
                                'mtu:text:MTU',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/capsman/interfaces',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/capsman/interfaces/create') . '"']),
                                    'footer' => Html::button('Manager', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/capsman/capsman/manager') . '"']) . ' ' . Html::button('AAA', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/capsman/capsman/aaa') . '"']),
                                ],
                            ],
                            'showFooter' => true,
                        ])
                    ];
                    $tabs[] = ['label' => 'Provisioning', 'content' => GridView::widget([
                            'dataProvider' => $provider['provisioning'],
                            'id' => 'type',
                            'rowOptions' => function($provider) {
                                if ($provider->disabled == 'true') {
                                    return ['class' => 'info',];
                                }
                            },
                                    'columns' => [
                                        'radio_mac:text:Radio MAC',
                                        'action:text:Action',
                                        'master_configuration:text:Master Configuration',
                                        'slave_configurations:text:Slave Configuration',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/capsman/provisioning',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/capsman/provisioning/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Configurations', 'content' => GridView::widget([
                                    'dataProvider' => $provider['configuration'],
                                    'id' => 'type',
                                    'columns' => [
                                        'name:text:Name',
                                        'ssid:text:SSID',
                                        'hide_ssid:text:Hide SSID',
                                        'country:text:Country',
                                        'load_balancing_group:text:Load Balancing Group',
                                        'channel:text:Channel',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/capsman/configuration',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/capsman/configuration/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Channels', 'content' => GridView::widget([
                                    'dataProvider' => $provider['channels'],
                                    'id' => 'type',
                                    'columns' => [
                                        '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/capsman/channels',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/capsman/channels/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Datapaths', 'content' => GridView::widget([
                                    'dataProvider' => $provider['datapaths'],
                                    'id' => 'type',
                                    'columns' => [
                                        'name:text:Name',
                                        'bridge:text:Bridge',
                                        'local_forwarding:text:Local Forwarding',
                                        'client_to_client_forwarding:text:Client To Client Forwarding',
                                        'vlan_mode:text:VLAN Mode',
                                        'vlan_id:text:VLAN ID',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/capsman/datapaths',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/capsman/datapaths/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Security Cfg.', 'content' => GridView::widget([
                                    'dataProvider' => $provider['security'],
                                    'id' => 'type',
                                    'columns' => [
                                        'name:text:Name',
                                        'authentication_types:text:Authentication Type',
                                        'encryption:text:Encryption',
                                        'eap_methods:text:EAP Methods',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/capsman/security',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/capsman/security/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Access List', 'content' => GridView::widget([
                                    'dataProvider' => $provider['accesslists'],
                                    'id' => 'type',
                                    'columns' => [
                                        'mac_address:text:MAC Address',
                                        'mac_address_mask:text:MAC Mask',
                                        'interface:text:Interface',
                                        'action:text:Action',
                                        'vlan_mode:text:VLAN Mode',
                                        'vlan_id:text:VLAN ID',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/capsman/accesslist',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/capsman/accesslist/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];

                            $tabs[] = ['label' => 'Remote CAP', 'content' => GridView::widget([
                                    'dataProvider' => $provider['remote'],
                                    'id' => 'type',
                                    'columns' => [
                                        'address:text:Address',
                                        'name:text:Name',
                                        'state:text:State',
                                        'radios:text:Radios',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '',
                                            'controller' => 'mikrotik/capsman/capsman',
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Radio', 'content' => GridView::widget([
                                    'dataProvider' => $provider['radio'],
                                    'id' => 'type',
                                    'columns' => [
                                        'radio_mac:text:Radio Mac',
                                        'interface:text:Interface',
                                        'remote_cap_name:text:Remote Cap Name',
                                        'remote_cap_identity:text:Remote Cap Identity',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '',
                                            'controller' => 'mikrotik/capsman/capsman',
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Registration Table', 'content' => GridView::widget([
                                    'dataProvider' => $provider['table'],
                                    'id' => 'type',
                                    'columns' => [
                                        'interface:text:Interface',
                                        'mac_address:text:MAC Address',
                                        'uptime:text:Uptime',
                                        'rx_signal:text:RX Signal',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '',
                                            'controller' => 'mikrotik/capsman/capsman',
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            echo Tabs::widget([
                                'items' => $tabs]);
//                                                            
                            ?>




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



