<?php

use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Menu;
use yii\helpers\Html;

$messages_count = \app\models\Messages::find()->where(['user_id' => Yii::$app->user->id, 'status' => '0'])->count();
$messages_counter = $messages_count > 0 ? ('</span><span class="notification">' . $messages_count . '</span>') : '';

$items = [];

if(Yii::$app->user->can('admin') ) {
    $items[] = ['label' => Yii::t('app', 'Одиниці виміру'), 'url' => ['/units']];
    $items[] = ['label' => Yii::t('app', 'Users'), 'url' => '/user/admin'];
    $items[] = ['label' => Yii::t('app', 'Categories ID'), 'url' => '/category'];
    $items[] = ['label' => Yii::t('app', 'EventLog ID'), 'url' => '/eventlog'];
}
if (!Yii::$app->user->isGuest){
    $items[] = ['label' => Yii::t('app','Profile'),'url' => '/settings/profile'];
    $items[] = ['label' => Yii::t('app', 'Change password'), 'url' => '/settings/account'];
    $items[] = ['label' => Yii::t('app', 'Subscriptions'), 'url' => ['/subscriptions/index']];
    $items[] =  ['label' => Yii::t('user', 'Logout')."\n\n\n(".Yii::$app->user->identity->username.")",  'url' => '/site/logout'];
}


echo Menu::widget([
    'items' => [
        ['label' => Yii::t('app','Home'),
            'url' => ['/site/index'],
            'template' => '<a href="/"><span class="glyphicon glyphicon-home hidden-md hidden-lg" aria-hidden="true"></span><span class="hidden-sm hidden-xs">{label}</span></a></li>',

        ],
        ['label' => Yii::t('app','UserManual ID'),
            'url' => ['services/index'],
            //'options'=>['class'=>'dropdown'],
            'template' => '<a class="drpdwn-link" href="#"><span class="glyphicon glyphicon-briefcase hidden-md hidden-lg" aria-hidden="true"></span><span class="hidden-sm hidden-xs">{label}</span></a>',
            'items' => [
                ['label' => Yii::t('app','Керівництва'),'url' => '/manual.pdf', 'linkOptions' => ['target' => '_blank']],
                ['label' => Yii::t('app', 'Rules'),'url' => ['/downloads-files/rules']],
                ['label' => Yii::t('app','Examples'),'url' => ['/downloads-files/examples']],
                ['label' => Yii::t('app','Анкета (для юридичних осіб)'),'url' => '/Анкета (для юридичних осіб).doc', 'linkOptions' => ['target' => '_blank']],
                ['label' => Yii::t('app','Згода на обробку персональних даних (для фізичних осіб)'),'url' => '/Згода на обробку персональних даних (для фізичних осіб).doc', 'linkOptions' => ['target' => '_blank']],
                ['label' => Yii::t('app','Reglament'),'url' => ['/downloads-files/reglament']],

            ],
            'submenuTemplate' => "<ul class='drpdwn-menu purple-back' >{items}</ul>",
            //'visible' => !Yii::$app->user->isGuest,
        ],

        [
            //'template' => '<img src="/css/dist/images/epsilon-logo.jpg" class="logo img-responsive hidden-sm hidden-xs">',
        ],
        ['label' => Yii::t('app','Publishing ID'),
            'url' => ['/publishing'],
            'template' => '<a href="{url}"><span class="glyphicon glyphicon-usd hidden-md hidden-lg" aria-hidden="true"></span><span class="hidden-sm hidden-xs">Публікації</span></a>',
            'items' => [
                ['label' => Yii::t('app','pMakeBidding ID'),'url' => ['/publishing/','PublishingSearch' => ['lot_num','userName','lotName','endBidding','status' =>0]], 'linkOptions' => ['target' => '_blank']],
                ['label' => Yii::t('app','pWaitAuction ID'),'url' => ['/publishing/','PublishingSearch' => ['lot_num','userName','lotName','endBidding','status' =>1]], 'linkOptions' => ['target' => '_blank']],
                ['label' => Yii::t('app','pMakeAuction ID'),'url' => ['/publishing/','PublishingSearch' => ['lot_num','userName','lotName','endBidding','status' =>2]], 'linkOptions' => ['target' => '_blank']],
                ['label' => Yii::t('app','pMakeFinal ID'),'url' => ['/publishing/','PublishingSearch' => ['lot_num','userName','lotName','endBidding','status' =>3]], 'linkOptions' => ['target' => '_blank']],
                ['label' => Yii::t('app','pEndTorg ID'),'url' => ['/publishing/','PublishingSearch' => ['lot_num','userName','lotName','endBidding','status' =>4]], 'linkOptions' => ['target' => '_blank']],

            ],
            'submenuTemplate' => "<ul class='drpdwn-menu purple-back' >{items}</ul>",

        ],
        ['label' => Yii::t('app','SignIn'),
            'url' => ['/user/login'],
            'template' => '<a href="{url}"><span class="glyphicon glyphicon-log-in hidden-md hidden-lg" aria-hidden="true"></span><span class="hidden-sm hidden-xs">{label}</span></a>',
            'visible' => Yii::$app->user->isGuest],
        [
            'label' => Yii::t('app','Cabinet'),
            'url' => Yii::$app->user->can('org') ? ['/cabinet'] : ['/cabinet'],
            'template' => '<a href="{url}"><span class="glyphicon glyphicon-log-in hidden-md hidden-lg" aria-hidden="true"></span><span class="hidden-sm hidden-xs">{label}</span></a>',
            'visible' => !Yii::$app->user->isGuest,
        ],
        [
            'label'=> '(044) 228-29-14',
            'options'=>['class'=>'contacts'],
            'template' => '<a href="#"> <span class="glyphicon glyphicon-earphone" aria-hidden="true"></span><span class="hidden-xs">{label}</span></a>',
            'visible' => Yii::$app->user->isGuest,
        ],
        [
            'label' => Yii::t('app','Messages'),
            'template' => '<a href="{url}" title="{label}"><span class="glyphicon glyphicon-inbox" aria-hidden="true">' . $messages_counter . '</a>',
            'url' => ['/messages/index'],
            'visible' => !Yii::$app->user->isGuest,
        ],
        [
            'label' => Yii::t('app','Profile'),
            //'template' => '<a class="drpdwn-link" href="#"><span class="glyphicon glyphicon-briefcase hidden-md hidden-lg" aria-hidden="true"></span><span class="hidden-sm hidden-xs">{label}</span></a>',
            'template' => '<a href="#"><span class="hidden-sm hidden-xs"></span><span class="glyphicon glyphicon-user " aria-hidden="true"></span></a>',
            'items' => $items,
            'submenuTemplate' => "<ul class='drpdwn-menu drpdwn-menu-right purple-back' >{items}</ul>",
            'visible' => !Yii::$app->user->isGuest,
        ],

    ],
    'options' => [
        'class' => 'row',
    ],
    'encodeLabels' =>'false',
]);
