<?php

use yii\bootstrap\Alert;

if (Yii::$app->session->getFlash('message') != null) {
    echo Alert::widget([
        'options' => [
            'class' => 'alert-info',
        ],
        'body' => Yii::$app->session->getFlash('message'),
    ]);
}

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

$this->title = 'Certificates';
$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
            $tabs[] = ['label' => 'Certificates', 'content' => GridView::widget([
                    'dataProvider' => $provider['cert'],
                    'id' => 'id',
                    'rowOptions' => function($provider) {
                        if (($provider->issued != 'true') && ( $provider->private_key != 'true') && ( $provider->trusted != 'true')) {
                            return ['class' => 'info',];
                        }
                    },
                            'columns' => [
                                'name:text:Name',
                                'common_name:text:Common Name',
                                'key_size:text:Key Size',
                                'days_valid:text:Days Valid',
                                'trusted:text:Trusted',
                                'ca:text:CA',
                                [
                                    'class' => 'yii\grid\ActionColumn',
                                    'template' => '{update} {delete}',
                                    'controller' => 'mikrotik/system/certificates',
                                    'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/system/certificates/create') . '"']),
                                    'footer' => Html::button('Import', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                        'js:document.location.href="' . Url::toRoute('mikrotik/system/certificates/import') . '"']),
                                ],
                            ],
                            'showFooter' => true,
                        ])
                    ];
                    $tabs[] = ['label' => 'SCEP Servers', 'content' => GridView::widget([
                            'dataProvider' => $provider['scep'],
                            'id' => 'id',
                            'rowOptions' => function($provider) {
                                if (($provider->disabled == 'true')) {
                                    return ['class' => 'info',];
                                }
                            },
                                    'columns' => [
                                        'ca_cert:text:CA Certificate',
                                        'next_ca_cert:text:Next CA Certificate',
                                        'path:text:Path',
                                        'days_valid:text:Days Valid',
                                        [
                                            'class' => 'yii\grid\ActionColumn',
                                            'template' => '{update} {delete}',
                                            'controller' => 'mikrotik/system/scep',
                                            'header' => Html::button('Add', ['class' => 'btn btn-primary', 'name' => 'add-button', 'onclick' =>
                                                'js:document.location.href="' . Url::toRoute('mikrotik/system/scep/create') . '"']),
                                        ],
                                    ],
                                    'showFooter' => false,
                                ])
                            ];


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



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



