<?php

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

$this->title = 'DHCP Server';
$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' => 'DHCP Server', 'content' => GridView::widget([
                    'dataProvider' => $provider['dhcp'],
                    'rowOptions' => function($provider) {
                        if ($provider->disabled == 'true') {
                            return ['class' => 'info'];
                        }
                    },
                            'id' => 'DHCP Relay',
                            'columns' => [
                                ['attribute' => 'name',
                                    'format' => 'text',
                                    'label' => 'Name'],
                                'interface:text:Interface',
                                'relay:text:Relay',
                                'lease_time:text:Lease Time',
                                'address_pool:text:Address Pool',
                                'add_arp:text:Add ARP For Leases',
                                [
                                    'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                    //'class' => 'yii\grid\CheckboxColumn',
                                    'controller' => 'mikrotik/ip/dhcpserver/dhcpserver',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/ip/dhcpserver/dhcpserver/create') . '"']),
                                    'footer' => Html::a('<span class="btn-label">DHCP Config</span>', ['config', 'id' => $model->id], ['class' => 'btn btn-primary']),
                                ],
                            ],
                            'showFooter' => true,
                        ])
                    ];
                    $tabs[] = ['label' => 'Networks', 'content' => GridView::widget([
                            'dataProvider' => $provider['networks'],
                            'id' => 'Networks',
                            'columns' => [
                                ['attribute' => 'address',
                                    'format' => 'text',
                                    'label' => 'Address'],
                                'gateway:text:Gateway',
                                'dns_server:text:DNS Server',
                                'domain:text:Domain',
                                'wins_server:text:WINS Server',
                                'next_server:text:Next Server',
                                [
                                    'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                    //'class' => 'yii\grid\CheckboxColumn',
                                    'controller' => 'mikrotik/ip/dhcpserver/dhcpservernetwork',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/ip/dhcpserver/dhcpservernetwork/create') . '"']),
                                ],
                            ],
                            'showFooter' => false,
                        ])
                    ];
                    $tabs[] = ['label' => 'Leases', 'content' => GridView::widget([
                            'dataProvider' => $provider['leases'],
                            'rowOptions' => function($provider) {
                                if ($provider->disabled == 'true') {
                                    return ['class' => 'info'];
                                }
                            },
                                    'id' => 'Networks',
                                    'columns' => [
                                        ['attribute' => 'address',
                                            'format' => 'text',
                                            'label' => 'Address'],
                                        'mac_address:text:MAC Address',
                                        'client_id:text:Client ID',
                                        'active_address:text:Active Address',
                                        'active_mac_address:text:Active MAC Address',
                                        'expires_after:text:Expires After',
                                        'status:text:Status',
                                        [
                                            'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                            //'class' => 'yii\grid\CheckboxColumn',
                                            'controller' => 'mikrotik/ip/dhcpserver/dhcpserverleases',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/ip/dhcpserver/dhcpserverleases/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Options', 'content' => GridView::widget([
                                    'dataProvider' => $provider['options'],
                                    'id' => 'Networks',
                                    'columns' => [
                                        ['attribute' => 'name',
                                            'format' => 'text',
                                            'label' => 'Name'],
                                        'code:text:Code',
                                        'value:text:Value',
                                        [
                                            'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                            //'class' => 'yii\grid\CheckboxColumn',
                                            'controller' => 'mikrotik/ip/dhcpserver/dhcpserveroptions',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/ip/dhcpserver/dhcpserveroptions/createoption') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];
                            $tabs[] = ['label' => 'Alerts', 'content' => GridView::widget([
                                    'dataProvider' => $provider['alerts'],
                                    'rowOptions' => function($provider) {
                                        if ($provider->disabled == 'true') {
                                            return ['class' => 'info'];
                                        }
                                    },
                                            'id' => 'Alerts',
                                            'columns' => [
                                                ['attribute' => 'interface',
                                                    'format' => 'text',
                                                    'label' => 'Interface'],
                                                'alert_timeout:text:Alert Timeout',
                                                [
                                                    'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}',
                                                    //'class' => 'yii\grid\CheckboxColumn',
                                                    'controller' => 'mikrotik/ip/dhcpserver/dhcpserveralerts',
                                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                        'js:document.location.href="' . Url::toRoute('mikrotik/ip/dhcpserver/dhcpserveralerts/createalert') . '"']),
                                                ],
                                            ],
                                            'showFooter' => false,
                                        ])
                                    ];

                                    echo Tabs::widget([
                                        'items' => $tabs]);
                                    //echo Html::a('<span class="btn-label">DHCP Config</span>', ['config', 'id' => $model->id], ['class' => 'btn btn-primary']);
                                    ?>

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



