<?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 = 'OSPF';
$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' => 'Interfaces', 'content' => GridView::widget([
                    'dataProvider' => $provider['interfaces'],
                    'id' => 'interfaces',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info',];
                        }
                    },
                            'columns' => [
                                'interface:text:Interface',
                                'cost:text:Cost',
                                'priority:text:Priority',
                                'authentication:text:Authentication',
                                'network_type:text:Network Type',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/routing/ospf/interfaces',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/routing/ospf/interfaces/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'Instances', 'content' => GridView::widget([
                            'dataProvider' => $provider['instances'],
                            'id' => 'interfaces',
                            'rowOptions' => function($provider) {
                                if ($provider->disabled == 'true') {
                                    return ['class' => 'info',];
                                }
                            },
                                    'columns' => [
                                        'name:text:Name',
                                        'router_id:text:Router ID',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/routing/ospf/instances',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/routing/ospf/instances/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Networks', 'content' => GridView::widget([
                                    'dataProvider' => $provider['networks'],
                                    'id' => 'interfaces',
                                    'rowOptions' => function($provider) {
                                        if ($provider->disabled == 'true') {
                                            return ['class' => 'info',];
                                        }
                                    },
                                            'columns' => [
                                                'network:text:Network',
                                                'area:text:Area',
                                                [
                                                    'class' => 'yii\grid\ActionColumn',
                                                    'template' => '{update} {delete}',
                                                    'controller' => 'mikrotik/routing/ospf/networks',
                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                        'js:document.location.href="' . Url::toRoute('mikrotik/routing/ospf/networks/create') . '"']),
                                                ],
                                            ],
                                            'showFooter' => false,
                                        ])
                                    ];
                                    $tabs[] = ['label' => 'Areas', 'content' => GridView::widget([
                                            'dataProvider' => $provider['areas'],
                                            'id' => 'interfaces',
                                            'rowOptions' => function($provider) {
                                                if ($provider->disabled == 'true') {
                                                    return ['class' => 'info',];
                                                }
                                            },
                                                    'columns' => [
                                                        'name:text:Area Name',
                                                        'instance:text:Instance',
                                                        'area_id:text:Area ID',
                                                        'type:text:Type',
                                                        'default_cost:text:Default Cost',
                                                        [
                                                            'class' => 'yii\grid\ActionColumn',
                                                            'template' => '{update} {delete}',
                                                            'controller' => 'mikrotik/routing/ospf/areas',
                                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                'js:document.location.href="' . Url::toRoute('mikrotik/routing/ospf/areas/create') . '"']),
                                                        ],
                                                    ],
                                                    'showFooter' => false,
                                                ])
                                            ];
                                            $tabs[] = ['label' => 'Area Ranges', 'content' => GridView::widget([
                                                    'dataProvider' => $provider['ranges'],
                                                    'id' => 'interfaces',
                                                    'rowOptions' => function($provider) {
                                                        if ($provider->disabled == 'true') {
                                                            return ['class' => 'info',];
                                                        }
                                                    },
                                                            'columns' => [
                                                                'area:text:Area',
                                                                'range:text:Range',
                                                                'cost:text:Cost',
                                                                'advertise:text:Advertise',
                                                                [
                                                                    'class' => 'yii\grid\ActionColumn',
                                                                    'template' => '{update} {delete}',
                                                                    'controller' => 'mikrotik/routing/ospf/ranges',
                                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                        'js:document.location.href="' . Url::toRoute('mikrotik/routing/ospf/ranges/create') . '"']),
                                                                ],
                                                            ],
                                                            'showFooter' => false,
                                                        ])
                                                    ];
                                                    $tabs[] = ['label' => 'Virtual Links', 'content' => GridView::widget([
                                                            'dataProvider' => $provider['links'],
                                                            'id' => 'interfaces',
                                                            'rowOptions' => function($provider) {
                                                                if ($provider->disabled == 'true') {
                                                                    return ['class' => 'info',];
                                                                }
                                                            },
                                                                    'columns' => [
                                                                        'neighbor_id:text:Neighbor ID',
                                                                        'transit_area:text:Transit Area',
                                                                        'authentication:text:Authentication',
                                                                        [
                                                                            'class' => 'yii\grid\ActionColumn',
                                                                            'template' => '{update} {delete}',
                                                                            'controller' => 'mikrotik/routing/ospf/links',
                                                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                                'js:document.location.href="' . Url::toRoute('mikrotik/routing/ospf/links/create') . '"']),
                                                                        ],
                                                                    ],
                                                                    'showFooter' => false,
                                                                ])
                                                            ];
                                                            $tabs[] = ['label' => 'Neighbors', 'content' => GridView::widget([
                                                                    'dataProvider' => $provider['neighbors'],
                                                                    'id' => 'interfaces',
                                                                    'columns' => [
                                                                        'interface:text:Interface',
                                                                        'router_id:text:Router ID',
                                                                        'address:text:Address',
                                                                        'state_changes:text:State Changes',
                                                                        'state:text:State',
                                                                        [
                                                                            'class' => 'yii\grid\ActionColumn',
                                                                            'template' => '',
                                                                            'controller' => 'mikrotik/routing/ospf/ospf',
                                                                        ],
                                                                    ],
                                                                    'showFooter' => false,
                                                                ])
                                                            ];
                                                            $tabs[] = ['label' => 'NBMA Neighbors', 'content' => GridView::widget([
                                                                    'dataProvider' => $provider['nbma'],
                                                                    'id' => 'interfaces',
                                                                    'rowOptions' => function($provider) {
                                                                        if ($provider->disabled == 'true') {
                                                                            return ['class' => 'info',];
                                                                        }
                                                                    },
                                                                            'columns' => [
                                                                                'instance:text:Instance',
                                                                                'address:text:Address',
                                                                                'poll_interval:text:Poll Interval',
                                                                                'priority:text:Priority',
                                                                                [
                                                                                    'class' => 'yii\grid\ActionColumn',
                                                                                    'template' => '{update} {delete}',
                                                                                    'controller' => 'mikrotik/routing/ospf/nbma',
                                                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                                        'js:document.location.href="' . Url::toRoute('mikrotik/routing/ospf/nbma/create') . '"']),
                                                                                ],
                                                                            ],
                                                                            'showFooter' => false,
                                                                        ])
                                                                    ];
                                                                    $tabs[] = ['label' => 'Sham Links', 'content' => GridView::widget([
                                                                            'dataProvider' => $provider['sham'],
                                                                            'id' => 'interfaces',
                                                                            'rowOptions' => function($provider) {
                                                                                if ($provider->disabled == 'true') {
                                                                                    return ['class' => 'info',];
                                                                                }
                                                                            },
                                                                                    'columns' => [
                                                                                        'src_address:text:Src. Address',
                                                                                        'dst_address:text:Dst. Address',
                                                                                        'cost:text:Cost',
                                                                                        'area:text:Area',
                                                                                        [
                                                                                            'class' => 'yii\grid\ActionColumn',
                                                                                            'template' => '{update} {delete}',
                                                                                            'controller' => 'mikrotik/routing/ospf/sham',
                                                                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                                                'js:document.location.href="' . Url::toRoute('mikrotik/routing/ospf/sham/create') . '"']),
                                                                                        ],
                                                                                    ],
                                                                                    'showFooter' => false,
                                                                                ])
                                                                            ];
                                                                            $tabs[] = ['label' => 'LSA', 'content' => GridView::widget([
                                                                                    'dataProvider' => $provider['lsa'],
                                                                                    'id' => 'interfaces',
                                                                                    'columns' => [
                                                                                        'instance:text:Instance',
                                                                                        'area:text:Area',
                                                                                        'type:text:Type',
                                                                                        'id:text:ID',
                                                                                        'originator:text:Originator',
                                                                                        'sequence_number:text:Sequence Number',
                                                                                        'age:text:Age',
                                                                                        [
                                                                                            'class' => 'yii\grid\ActionColumn',
                                                                                            'template' => '',
                                                                                            'controller' => 'mikrotik/routing/ospf/ospf',
                                                                                        ],
                                                                                    ],
                                                                                    'showFooter' => false,
                                                                                ])
                                                                            ];
                                                                            $tabs[] = ['label' => 'Routes', 'content' => GridView::widget([
                                                                                    'dataProvider' => $provider['routes'],
                                                                                    'id' => 'interfaces',
                                                                                    'columns' => [
                                                                                        'instance:text:Instance',
                                                                                        'area:text:Area',
                                                                                        'dst_address:text:Dst. Address',
                                                                                        'gateway:text:Gateway',
                                                                                        'interface:text:Interface',
                                                                                        'cost:text:Cost',
                                                                                        'state:text:State',
                                                                                        [
                                                                                            'class' => 'yii\grid\ActionColumn',
                                                                                            'template' => '',
                                                                                            'controller' => 'mikrotik/routing/ospf/ospf',
                                                                                        ],
                                                                                    ],
                                                                                    'showFooter' => false,
                                                                                ])
                                                                            ];
                                                                            $tabs[] = ['label' => 'AS Border Routers', 'content' => GridView::widget([
                                                                                    'dataProvider' => $provider['borderrouters'],
                                                                                    'id' => 'interfaces',
                                                                                    'columns' => [
                                                                                        'instance:text:Instance',
                                                                                        'router_id:text:Router ID',
                                                                                        'gateway:text:Gateway',
                                                                                        'interface:text:Interface',
                                                                                        'cost:text:Cost',
                                                                                        'state:text:State',
                                                                                        [
                                                                                            'class' => 'yii\grid\ActionColumn',
                                                                                            'template' => '',
                                                                                            'controller' => 'mikrotik/routing/ospf/ospf',
                                                                                        ],
                                                                                    ],
                                                                                    'showFooter' => false,
                                                                                ])
                                                                            ];
                                                                            $tabs[] = ['label' => 'Area Border Routers', 'content' => GridView::widget([
                                                                                    'dataProvider' => $provider['arearouters'],
                                                                                    'id' => 'interfaces',
                                                                                    'columns' => [
                                                                                        'instance:text:Instance',
                                                                                        'area:text:Area',
                                                                                        'router_id:text:Router ID',
                                                                                        'gateway:text:Gateway',
                                                                                        'interface:text:Interface',
                                                                                        'cost:text:Cost',
                                                                                        'state:text:State',
                                                                                        [
                                                                                            'class' => 'yii\grid\ActionColumn',
                                                                                            'template' => '',
                                                                                            'controller' => 'mikrotik/routing/ospf/ospf',
                                                                                        ],
                                                                                    ],
                                                                                    'showFooter' => false,
                                                                                ])
                                                                            ];
                                                                            echo Tabs::widget([
                                                                                'items' => $tabs]);
                                                                            ?>



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



