<?php

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

$this->title = 'Route list';
$this->params['breadcrumbs'] = [
    'Mikrotik',
    'IP',
    $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
            //echo $model->name;
            $tabs[] = ['label' => 'Routes', 'content' => GridView::widget([
                    'dataProvider' => $provider['routes'],
                    'id' => 'Filter Rules',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info',];
                        }
                    },
                            'columns' => [
                                'dst_address:text:Dst. Address',
                                'gateway_status:text:Gateway',
                                'distance:text:Distance',
                                'routing_mark:text:Routing Mark',
                                'pref_src:text:Pref. Source',
                                [
                                    'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                    //'class' => 'yii\grid\CheckboxColumn',
                                    'controller' => 'mikrotik/ip/routes/routes',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/ip/routes/routes/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'Nexthops', 'content' => GridView::widget([
                            'dataProvider' => $provider['next'],
                            'id' => 'Filter Rules',
                            'columns' => [
                                'address:text:Address',
                                'gw_state:text:Gateway State',
                                'forwarding_nexthop:text:Forwarding Nexthop',
                                'interface:text:Interface',
                                'scope:text:Scope',
                                'check_gateway:text:Check Gateway',
                                [
                                    'class' => 'yii\grid\ActionColumn', 'template' => '',
                                    //'class' => 'yii\grid\CheckboxColumn',
                                    'controller' => 'mikrotik/ip/routes/routes',
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'Rules', 'content' => GridView::widget([
                            'dataProvider' => $provider['rules'],
                            'id' => 'Filter Rules',
                            'rowOptions' => function($provider) {
                                if ($provider->disabled == 'true') {
                                    return ['class' => 'info',];
                                }
                            },
                                    'columns' => [
                                        'src_address:text:Src. Address',
                                        'dst_address:text:Dst. Address',
                                        'routing_mark:text:Routing Mark',
                                        'interface:text:Interface',
                                        'action:text:Action',
                                        'table:text:Table',
                                        [
                                            'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                            //'class' => 'yii\grid\CheckboxColumn',
                                            'controller' => 'mikrotik/ip/routes/rules',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/ip/routes/rules/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'VRF', 'content' => GridView::widget([
                                    'dataProvider' => $provider['vrf'],
                                    'id' => 'Filter Rules',
                                    'rowOptions' => function($provider) {
                                        if ($provider->disabled == 'true') {
                                            return ['class' => 'info',];
                                        }
                                    },
                                            'columns' => [
                                                'routing_mark:text:Routing Mark',
                                                'interfaces:text:Interfaces',
                                                'route_distinguisher:text: Route Distinguisher',
                                                [
                                                    'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                                    //'class' => 'yii\grid\CheckboxColumn',
                                                    'controller' => 'mikrotik/ip/routes/vrf',
                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                        'js:document.location.href="' . Url::toRoute('mikrotik/ip/routes/vrf/create') . '"']),
                                                ],
                                            ],
                                            'showFooter' => false,
                                        ])
                                    ];
                                    echo Tabs::widget([
                                        'items' => $tabs]);
                                    ?>

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



