<?php

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

$this->title = 'Traffic Eng';
$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' => 'Interface', 'content' => GridView::widget([
                    'dataProvider' => $provider['interface'],
                    'id' => 'interfaces',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info',];
                        }
                    },
                            'columns' => [
                                'interface:text:Interface',
                                'bandwidth:text:Bandwidth',
                                'te_metric:text:TE Metric',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/mpls/traffic/interfacestraffic',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/mpls/traffic/interfacestraffic/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'Tunnel Path', 'content' => GridView::widget([
                            'dataProvider' => $provider['tunnel'],
                            'id' => 'interfaces',
                            'rowOptions' => function($provider) {
                                if ($provider->disabled == 'true') {
                                    return ['class' => 'info',];
                                }
                            },
                                    'columns' => [
                                        'name:text:Name',
                                        'use_cspf:text:Use CSPF',
                                        'hops:text:Hops',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/mpls/traffic/tunnel',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/mpls/traffic/tunnel/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Path State', 'content' => GridView::widget([
                                    'dataProvider' => $provider['path'],
                                    'id' => 'interfaces',
                                    'columns' => [
                                        'src:text:Src.',
                                        'dst:text:Dst.',
                                        'bandwidth:text:Bandwidth',
                                        'out_interface:text:Out Interface',
                                        'out_next_hop:text:Out Next Hop',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '',
                                            'controller' => 'mikrotik/mpls/traffic/traffic',
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Resv. State', 'content' => GridView::widget([
                                    'dataProvider' => $provider['resv'],
                                    'id' => 'interfaces',
                                    'columns' => [
                                        'src:text:Src.',
                                        'dst:text:Dst.',
                                        'bandwidth:text:Bandwidth',
                                        'label:text:Label',
                                        'interface:text:Interface',
                                        'next_hop:text:Next Hop',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '',
                                            'controller' => 'mikrotik/mpls/traffic/traffic',
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Traffic Eng Interface', 'content' => GridView::widget([
                                    'dataProvider' => $provider['traffic'],
                                    'id' => 'interfaces',
                                    'rowOptions' => function($provider) {
                                        if ($provider->disabled == 'true') {
                                            return ['class' => 'info',];
                                        }
                                    },
                                            'columns' => [
                                                'name:text:Name.',
                                                'type:text:Type',
                                                [
                                                    'class' => 'yii\grid\ActionColumn',
                                                    'template' => '{update} {delete}',
                                                    'controller' => 'mikrotik/mpls/traffic/trafficeng',
                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                        'js:document.location.href="' . Url::toRoute('mikrotik/mpls/traffic/trafficeng/create') . '"']),
                                                ],
                                            ],
                                            'showFooter' => false,
                                        ])
                                    ];
                                    echo Tabs::widget([
                                        'items' => $tabs]);
                                    ?>



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



