<?php

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

$this->title = 'Firewall';
$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' => 'Filter Rules', 'content' => GridView::widget([
                    'dataProvider' => $provider['filter'],
                    'id' => 'Filter Rules',
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info'];
                        }
                    },
                            'columns' => [

//                        ['attribute' => 'ranges',
//                            'format' => 'text',
//                            'label' => 'Addresses'],
                                'action:text:Action',
                                'chain:text:Chain',
                                'src_address:text:SRC. Address',
                                'dst_address:text:DST. Address',
                                'protocol:text:Protocol',
                                'src_port:text:SRC.Port',
                                'dst_port:text:DST.Port',
                                'in_interface:text:In Interface',
                                'out_interface:text:Out Interface',
                                [
                                    'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                    //'class' => 'yii\grid\CheckboxColumn',
                                    'controller' => 'mikrotik/ip/firewall/filter',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/ip/firewall/filter/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'NAT', 'content' => GridView::widget([
                            'dataProvider' => $provider['nat'],
                            'id' => 'Filter Rules',
                            'rowOptions' => function($provider) {
                                if ($provider->disabled == 'true') {
                                    return ['class' => 'info'];
                                }
                            },
                                    'columns' => [
                                        'action:text:Action',
                                        'chain:text:Chain',
                                        'src_address:text:SRC. Address',
                                        'dst_address:text:DST. Address',
                                        'protocol:text:Protocol',
                                        'src_port:text:SRC.Port',
                                        'dst_port:text:DST.Port',
                                        'in_interface:text:In Interface',
                                        'out_interface:text:Out Interface',
                                        [
                                            'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                            //'class' => 'yii\grid\CheckboxColumn',
                                            'controller' => 'mikrotik/ip/firewall/nat',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/ip/firewall/nat/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];


                            $tabs[] = ['label' => 'Mangle', 'content' => GridView::widget([
                                    'dataProvider' => $provider['mangle'],
                                    'id' => 'Filter Rules',
                                    'rowOptions' => function($provider) {
                                        if ($provider->disabled == 'true') {
                                            return ['class' => 'info'];
                                        }
                                    },
                                            'columns' => [

                                                'action:text:Action',
                                                'chain:text:Chain',
                                                'src_address:text:SRC. Address',
                                                'dst_address:text:DST. Address',
                                                'protocol:text:Protocol',
                                                'src_port:text:SRC.Port',
                                                'dst_port:text:DST.Port',
                                                'in_interface:text:In Interface',
                                                'out_interface:text:Out Interface',
                                                [
                                                    'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                                    //'class' => 'yii\grid\CheckboxColumn',
                                                    'controller' => 'mikrotik/ip/firewall/mangle',
                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                        'js:document.location.href="' . Url::toRoute('mikrotik/ip/firewall/mangle/create') . '"']),
                                                ],
                                            ],
                                            'showFooter' => false,
                                        ])
                                    ];
                                    $tabs[] = ['label' => 'Service Ports', 'content' => GridView::widget([
                                            'dataProvider' => $provider['service'],
                                            'id' => 'Filter Rules',
                                            'rowOptions' => function($provider) {
                                                if ($provider->disabled == 'true') {
                                                    return ['class' => 'info'];
                                                }
                                            },
                                                    'columns' => [

                                                        'name:text:Name',
                                                        'ports:text:Ports',
                                                        [
                                                            'class' => 'yii\grid\ActionColumn', 'template' => '{update}',
                                                            //'class' => 'yii\grid\CheckboxColumn',
                                                            'controller' => 'mikrotik/ip/firewall/serviceports',
                                                        ],
                                                    ],
                                                    'showFooter' => false,
                                                ])
                                            ];
                                            $tabs[] = ['label' => 'Connections', 'content' => GridView::widget([
                                                    'dataProvider' => $provider['con'],
                                                    'id' => 'Filter Rules',
                                                    'columns' => [
                                                        'src_address:text:Src. Address',
                                                        'dst_address:text:Dst. Address',
                                                        'protocol:text:Protocol',
                                                        'timeout:text:Timeout',
                                                        'orig_packets:text:Orig. Rate',
                                                        'repl_packets:text:Repl. Rate',
                                                        'orig_bytes:text:Orig. Bytes',
                                                        'repl_bytes:text:Repl. Bytes',
                                                        [
                                                            'class' => 'yii\grid\ActionColumn', 'template' => '{delete}',
                                                            //'class' => 'yii\grid\CheckboxColumn',
                                                            'controller' => 'mikrotik/ip/firewall/connections',
                                                        ],
                                                    ],
                                                    'showFooter' => false,
                                                ])
                                            ];
                                            $tabs[] = ['label' => 'Address lists', 'content' => GridView::widget([
                                                    'dataProvider' => $provider['address'],
                                                    'id' => 'Filter Rules',
                                                    'rowOptions' => function($provider) {
                                                        if ($provider->disabled == 'true') {
                                                            return ['class' => 'info'];
                                                        }
                                                    },
                                                            'columns' => [

                                                                'list:text:Name',
                                                                'address:text:Address',
                                                                'timeout:text:timeout',
                                                                [
                                                                    'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                                                    //'class' => 'yii\grid\CheckboxColumn',
                                                                    'controller' => 'mikrotik/ip/firewall/addresslists',
                                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                        'js:document.location.href="' . Url::toRoute('mikrotik/ip/firewall/addresslists/create') . '"']),
                                                                ],
                                                            ],
                                                            'showFooter' => false,
                                                        ])
                                                    ];
                                                    $tabs[] = ['label' => 'Layer 7 Protocols', 'content' => GridView::widget([
                                                            'dataProvider' => $provider['layer7protocols'],
                                                            'id' => 'Filter Rules',
                                                            'columns' => [

                                                                'name:text:Name',
                                                                'regexp:text:Regexp',
                                                                [
                                                                    'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                                                    //'class' => 'yii\grid\CheckboxColumn',
                                                                    'controller' => 'mikrotik/ip/firewall/layer7protocols',
                                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                                        'js:document.location.href="' . Url::toRoute('mikrotik/ip/firewall/layer7protocols/create') . '"']),
                                                                ],
                                                            ],
                                                            'showFooter' => false,
                                                        ])
                                                    ];
                                                    echo Tabs::widget([
                                                        'items' => $tabs]);
                                                    ?>

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



