<?php

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

$this->title = 'MPLS';
$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' => 'LDP Interface', 'content' => GridView::widget([
                    'dataProvider' => $provider['ldpint'],
                    'id' => 'interfaces',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info',];
                        }
                    },
                            'columns' => [
                                'interface:text:Interface',
                                'hello_interval:text:Hello Interval',
                                'hold_time:text:Hold TIme',
                                'transport_address:text:Transport Address',
                                'accept_dynamic_neighbors:text:Accept Dynamic Neighbors',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/mpls/mpls/ldpinterface',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/mpls/mpls/ldpinterface/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'LDP Neighbor', 'content' => GridView::widget([
                            'dataProvider' => $provider['ldpneighbor'],
                            'id' => 'interfaces',
                            'rowOptions' => function($provider) {
                                if ($provider->disabled == 'true') {
                                    return ['class' => 'info',];
                                }
                            },
                                    'columns' => [
                                        'transport:text:Transport',
                                        'send_targeted:text:Send Targeted',
                                        'peer:text:Peer',
                                        'local_transport:text:Local Transport',
                                        'addresses:text:Addresses',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/mpls/mpls/ldpneighbor',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/mpls/mpls/ldpneighbor/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Accept Filter', 'content' => GridView::widget([
                                    'dataProvider' => $provider['ldpfilter'],
                                    'id' => 'interfaces',
                                    'rowOptions' => function($provider) {
                                        if ($provider->disabled == 'true') {
                                            return ['class' => 'info',];
                                        }
                                    },
                                            'columns' => [
                                                'prefix:text:Prefix',
                                                'neighbor:text:Neighbor',
                                                'accept:text:Accept',
                                                [
                                                    'class' => 'yii\grid\ActionColumn',
                                                    'template' => '{update} {delete}',
                                                    'controller' => 'mikrotik/mpls/mpls/ldpfilter',
                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                        'js:document.location.href="' . Url::toRoute('mikrotik/mpls/mpls/ldpfilter/create') . '"']),
                                                ],
                                            ],
                                            'showFooter' => false,
                                        ])
                                    ];
                                    $tabs[] = ['label' => 'Advertise Filter', 'content' => GridView::widget([
                                            'dataProvider' => $provider['advertise'],
                                            'id' => 'interfaces',
                                            'rowOptions' => function($provider) {
                                                if ($provider->disabled == 'true') {
                                                    return ['class' => 'info',];
                                                }
                                            },
                                                    'columns' => [
                                                        'prefix:text:Prefix',
                                                        'neighbor:text:Neighbor',
                                                        'advertise:text:Advertise',
                                                        [
                                                            'class' => 'yii\grid\ActionColumn',
                                                            'template' => '{update} {delete}',
                                                            'controller' => 'mikrotik/mpls/mpls/advertise',
                                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                'js:document.location.href="' . Url::toRoute('mikrotik/mpls/mpls/advertise/create') . '"']),
                                                        ],
                                                    ],
                                                    'showFooter' => false,
                                                ])
                                            ];
                                            $tabs[] = ['label' => 'Forwarding Table', 'content' => GridView::widget([
                                                    'dataProvider' => $provider['forwarding'],
                                                    'id' => 'interfaces',
                                                    'columns' => [
                                                        'in_label:text:In Label',
                                                        'out_labels:text:Out Labels',
                                                        'destination:text:Destination',
                                                        'interface:text:Interface',
                                                        'nexthop:text:Nexthop',
                                                        [
                                                            'class' => 'yii\grid\ActionColumn',
                                                            'template' => '',
                                                            'controller' => 'mikrotik/mpls/mpls/advertise',
                                                        ],
                                                    ],
                                                    'showFooter' => false,
                                                ])
                                            ];
                                            $tabs[] = ['label' => 'MPLS Interface', 'content' => GridView::widget([
                                                    'dataProvider' => $provider['interface'],
                                                    'id' => 'interfaces',
                                                    'columns' => [
                                                        'interface:text:Interface',
                                                        'mpls_mtu:text:MPLS MTU',
                                                        [
                                                            'class' => 'yii\grid\ActionColumn',
                                                            'template' => '{update} {delete}',
                                                            'controller' => 'mikrotik/mpls/mpls/mplsinterface',
                                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                'js:document.location.href="' . Url::toRoute('mikrotik/mpls/mpls/mplsinterface/create') . '"']),
                                                        ],
                                                    ],
                                                    'showFooter' => false,
                                                ])
                                            ];
                                            $tabs[] = ['label' => 'Local Bindings', 'content' => GridView::widget([
                                                    'dataProvider' => $provider['local'],
                                                    'id' => 'interfaces',
                                                    'columns' => [
                                                        'dst_address:text:Dst. Address',
                                                        'label:text:Label',
                                                        [
                                                            'class' => 'yii\grid\ActionColumn',
                                                            'template' => '{update} {delete}',
                                                            'controller' => 'mikrotik/mpls/mpls/localbinding',
                                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                'js:document.location.href="' . Url::toRoute('mikrotik/mpls/mpls/localbinding/create') . '"']),
                                                        ],
                                                    ],
                                                    'showFooter' => false,
                                                ])
                                            ];
                                            $tabs[] = ['label' => 'Remote Bindings', 'content' => GridView::widget([
                                                    'dataProvider' => $provider['remote'],
                                                    'id' => 'interfaces',
                                                    'columns' => [
                                                        'dst_address:text:Dst. Address',
                                                        'label:text:Label',
                                                        'nexthop:text:Nexthop',
                                                        [
                                                            'class' => 'yii\grid\ActionColumn',
                                                            'template' => '{update} {delete}',
                                                            'controller' => 'mikrotik/mpls/mpls/remotebinding',
                                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                'js:document.location.href="' . Url::toRoute('mikrotik/mpls/mpls/remotebinding/create') . '"']),
                                                        ],
                                                    ],
                                                    'showFooter' => false,
                                                ])
                                            ];

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



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



