<?php
use yii\helpers\Html;
$profile = Yii::$app->user->identity->profile;
	$photo = "/images/users/".Yii::$app->user->id."_sm.jpg";
	if( !file_exists( Yii::getAlias('@webroot').$photo ) ){
			$photo = "";
	}
?>
<aside class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <a href="/control/" class="brand-link">
        <img src="/img/icon-180x180.png" alt="Amitel Logo" class="brand-image img-circle elevation-3" style="opacity: .8">
        <span class="brand-text font-weight-light">Amitel admin 3</span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">
        <!-- Sidebar user panel (optional) -->
        <div class="user-panel mt-3 pb-3 mb-3 d-flex">
            <div class="image">
                <?=Html::img($photo, [
                    'class' => 'img-circle elevation-2',
                    'alt' => $profile->user->username,
                ])?>
            </div>
            <div class="info">
                <a href="#" class="d-block"><?=$profile->name?></a>
            </div>
        </div>

        <!-- SidebarSearch Form -->
        <!-- href be escaped -->
        <!-- <div class="form-inline">
            <div class="input-group" data-widget="sidebar-search">
                <input class="form-control form-control-sidebar" type="search" placeholder="Search" aria-label="Search">
                <div class="input-group-append">
                    <button class="btn btn-sidebar">
                        <i class="fas fa-search fa-fw"></i>
                    </button>
                </div>
            </div>
        </div> -->

        <!-- Sidebar Menu -->
        <nav class="mt-2 nav-flat">
            <?php
            echo \hail812\adminlte\widgets\Menu::widget([
				'options' => ['Class' => 'nav nav-pills nav-sidebar nav-child-indent flex-column'],
                'items' => [
                    ['label' => 'Login', 'url' => ['site/login'], 'icon' => 'sign-in-alt', 'visible' => Yii::$app->user->isGuest],
                    [
						'label' => 'Комментарии',
						'url' => ['/control/comments/index'],
						'icon' => 'comments',
						'badge' => '<span class="right badge badge-danger">'.\manager\models\Comments::find()->andWhere(['visible'=>"N"])->count().'</span>',
                        'items' => [
                            ['label' => 'rss', 'url' => ['/control/comments/rss'], 'iconStyle' => 'fa', 'iconClassAdded'=>'','icon' => 'wrench'],

                        ]
                    ],

                ],
            ]);
            ?>
        </nav>
        <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
</aside>
<script>
	var url = String(window.location);
	$('ul.nav-sidebar a').filter(function() {
	//	console.log(url+'-'+this.href.indexOf('kd')+':'+url.indexOf("design"));
	if( this.href.indexOf('design') >= 0 && ( url.indexOf("kd") >= 0 || url.indexOf("nh") >= 0 || url.indexOf("top-slider") >= 0 ) ) return true;
	if( this.href.indexOf('tags') >= 0 && ( url.indexOf("tagsfilter") >= 0  ) ) return true;
	if( this.href.indexOf('comments') >= 0 && ( url.indexOf("comments-filter") >= 0  ) ) return true;
	if( this.href.indexOf('stats') >= 0 && ( url.indexOf("analytics") >= 0  ) ) return true;

     return this.href == url;
}).parent().addClass('menu-open');
</script>
