<?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 = 'RIP';
$this->params['breadcrumbs'] = [
    'Mikrotik',
    'Routing',
    $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' => 'Interface', 'content' => GridView::widget([
                    'dataProvider' => $provider['interface'],
                    'id' => 'interfaces',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info',];
                        }
                    },
                            'columns' => [
                                'interface:text:Interface',
                                'receive:text:Receive',
                                'send:text:Send',
                                'authentication:text:Authentication',
                                'key_chain:text:Key Chain',
                                'passive:text:Passive',
                                'in_prefix_list:text:In Prefix List',
                                'out_prefix_list:text:Out Prefix List',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/routing/rip/interfaces',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/routing/rip/interfaces/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'Networks', 'content' => GridView::widget([
                            'dataProvider' => $provider['net'],
                            'id' => 'interfaces',
                            'rowOptions' => function($provider) {
                                if ($provider->disabled == 'true') {
                                    return ['class' => 'info',];
                                }
                            },
                                    'columns' => [
                                        'network:text:Network',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/routing/rip/network',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/routing/rip/network/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Keys', 'content' => GridView::widget([
                                    'dataProvider' => $provider['key'],
                                    'id' => 'interfaces',
                                    'columns' => [
                                        'chain:text:Key Chain',
                                        'key_id:text:Key ID',
                                        'key:text:Key',
                                        'from_date:text:From',
                                        'to_date:text:To',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/routing/rip/keys',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/routing/rip/keys/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Neighbours', 'content' => GridView::widget([
                                    'dataProvider' => $provider['neighbor'],
                                    'id' => 'interfaces',
                                    'rowOptions' => function($provider) {
                                        if ($provider->disabled == 'true') {
                                            return ['class' => 'info',];
                                        }
                                    },
                                            'columns' => [
                                                'address:text:Address',
                                                [
                                                    'class' => 'yii\grid\ActionColumn',
                                                    'template' => '{update} {delete}',
                                                    'controller' => 'mikrotik/routing/rip/neighbor',
                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                        'js:document.location.href="' . Url::toRoute('mikrotik/routing/rip/neighbor/create') . '"']),
                                                ],
                                            ],
                                            'showFooter' => false,
                                        ])
                                    ];
                                    $tabs[] = ['label' => 'Routes', 'content' => GridView::widget([
                                            'dataProvider' => $provider['route'],
                                            'id' => 'interfaces',
                                            'columns' => [
                                                'dst_address:text:Dst. Address',
                                                'gateway:text:Gateway',
                                                'from:text:From',
                                                'metric:text:Metric',
                                                'timeout:text:Timeout',
                                                [
                                                    'class' => 'yii\grid\ActionColumn',
                                                    'template' => '',
                                                    'controller' => 'mikrotik/routing/rip/rip',
                                                ],
                                            ],
                                            'showFooter' => false,
                                        ])
                                    ];
                                    echo Tabs::widget([
                                        'items' => $tabs]);
                                    echo Html::a('<spanclass="btn-label">RIP Settings</span>', ['settings'], ['class' => 'btn btn-primary']);
                                    ?>



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



