<?php
/**
 * Created by PhpStorm.
 * User: NeiroN
 * Date: 15.09.2015
 * Time: 10:03
 */
use yii\widgets\Menu;

/** @var dektrium\user\models\User $user */
$user = Yii::$app->user->identity;
//$networksVisible = count(Yii::$app->authClientCollection->clients) > 0;

?>

<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">
            <?= $user->username ?>
        </h3>
    </div>

    <div class="panel-body">
        <ul class="nav nav-pills" role="tablist">
            <li role="presentation">
                <a href="/messages/index?id=<?php echo $user->id; ?>">
                    <?php echo Yii::t('app', 'Messages ID'); ?>
                    <span class="badge">
                        <?php
                            $count = \app\models\Messages::find()
                                ->select(['COUNT(*) AS cnt'])
                                ->where('user_id ='.$user->id)
                                ->one();
                        echo $count['cnt'];
                        ?>
                    </span></a></li>
        </ul>
        <?php
        if (Yii::$app->user->can('org') || Yii::$app->user->can('admin'))
        {
            $items = [
                //['label' => Yii::t('app', 'Messages ID'),  'url' => ['/messages/index?id='.$user->id]],
                ['label' => Yii::t('user', 'Profile'),  'url' => ['settings/profile']],
                ['label' => Yii::t('app', 'Bidding ID'),  'url' => ['/bidding/index?id='.$user->id]],
                ['label' => Yii::t('app', 'Auction ID'),  'url' => ['/auctions/index?id='.$user->id]],
                ['label' => Yii::t('app', 'Reports ID'),  'url' => ['/client/view?id='.$user->id]],
                ['label' => Yii::t('app', 'YouLots ID'),  'url' => ['/lots/index?id='.$user->id]],
                ['label' => Yii::t('user', 'Logout'),  'url' => ['/site/logout']],
            ];
        }
        else
        {
            $items = [
                //['label' => Yii::t('app', 'Messages ID'),  'url' => ['/messages/index?id='.$user->id]],
                ['label' => Yii::t('user', 'Profile'),  'url' => ['/client/view?id='.$user->id]],
                ['label' => Yii::t('app', 'Auction ID'),  'url' => ['/auctions/index?id='.$user->id]],
                ['label' => Yii::t('app', 'Reports ID'),  'url' => ['/client/view?id='.$user->id]],
                ['label' => Yii::t('user', 'Logout'),  'url' => ['/site/logout']],
            ];
        }
        ?>
        <?= Menu::widget([
            'options' => [
                'class' => 'nav nav-pills nav-stacked',
            ],
            'items' => $items,
        ])
        ?>
    </div>
</div>