<?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\widgets\Menu;
use yii\widgets\ActiveForm;

$this->title = 'Web Proxy Direct';
$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 $form = ActiveForm::begin(['id' => 'form-proxy']); ?>
                <?= $form->field($model, 'src_address')->label('Src. Address'); ?>
                <?= $form->field($model, 'dst_address')->label('Dst. Address'); ?>
                <?= $form->field($model, 'dst_port')->label('Dst. Port'); ?>
                <?= $form->field($model, 'local_port')->label('Local Port'); ?>
                <?= $form->field($model, 'dst_host')->label('Dst. Host'); ?>
                <?= $form->field($model, 'path')->label('Path'); ?>
                <?=
                $form->field($model, 'method')->dropDownList(['' => '', 'any' => 'any',
                    'connect' => 'connect',
                    'delete' => 'delete',
                    'get' => 'get',
                    'head' => 'head',
                    'options' => 'options',
                    'post' => 'post',
                    'put' => 'put',
                    'trace' => 'trace',
                ]);
                ?>
                <?=
                $form->field($model, 'action')->dropDownList(['allow' => 'allow',
                    'deny' => 'deny',
                ]);
                ?>
                <?php
                if ($action == 'update') {
                    if ($model->disabled == 'true') {
                        $action_e = 'enable';
                    } else {
                        $action_e = 'disable';
                    }
                    echo Html::submitButton('Update', ['class' => 'btn btn-primary', 'name' => 'create-button']);
                    echo ' ';
                    echo Html::a('<span class="btn-label">' . ucfirst($action_e) . '</span>', [$action_e, 'id' => $model->id], ['class' => 'btn btn-primary']);
                } else {
                    echo Html::submitButton('Create', ['class' => 'btn btn-primary', 'name' => 'create-button']);
                }
                ?>
        </div>
        <?php ActiveForm::end(); ?> 
    </div>
</div>
</div>