<?php
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use nota\assets\AppAsset;
use common\widgets\Alert;
use yii\helpers\Url;
use nota\models\Member;
use nota\models\Kodeakses;
use nota\models\Usermember;
use nota\models\Kalender;
use nota\models\Cluster;
use nota\models\SessionnotaUser;
use nota\models\Pembayaran;
use yii\helpers\BaseInflector;
use yii\helpers\ArrayHelper;
use yii\bootstrap\ActiveForm;
?>
<aside class="main-sidebar sidebar-dark-primary elevation-4">
	<!-- Brand Logo -->
	<a href="https://cpanel-1.rrlbg.com" class="brand-link">
		<!-- <img src="<?= Yii::$app->request->BaseUrl; ?>/dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image " style=""> -->
		<span class="brand-text font-weight-light">NOTAPANEL </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">
				<!-- <img src="<?= Yii::$app->request->BaseUrl; ?>/images/user.png" class="img-circle elevation-2" alt="User Image"> -->
			</div>
			<div class="info">
				<a href="#" class="d-block">Halo, <?= \Yii::$app->user->identity->vNama; ?> </a>
				<p style="color: grey"><?= \Yii::$app->user->identity->eType; ?></p>
			</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">
			<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
				<?php
                if (Yii::$app->user->isGuest) {
	            } else {
					if(Yii::$app->user->identity->id){
						$user = Usermember::find()->where(['id'=>Yii::$app->user->identity->id])->one();
						$cluster = Cluster::find()->select(['*'])->where(['eDeleted'=>'Tidak'])->where(['idCluster'=>$user->idCluster])->one();

						$pembayaran = Pembayaran::find()
							        // ->where(['vKode' => $id])
							        ->where(['idCluster'=>$cluster->idCluster])->andWhere(['eDeleted'=>'Tidak'])->orderBy(['iId' => SORT_DESC])
							        ->one();


						
						if($cluster->vIPL=='' || $cluster->vMisiVisi==''){
							echo '
								<li><a class="" href="'.Url::to(['admin/dashboard']).'"><i class="fa fa-circle-o text-red"></i> HOME</a></li>
								<li><a class="" href="'.Url::to(['admin/cluster', 'slug' => $user->idCluster]).'"><i class="fa fa-circle-o text-red"></i> DATA PERUMAHAN</a></li>';
						}else{
							if($pembayaran->dateFinish < date('Y-m-d h:m:s')){
								// echo date('Y-m-d h:m:s');
								echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['admin/dashboard']).'"><i class="nav-icon fas fa-tachometer-alt"></i> <p>Dashboard</p></a></li>';
								// echo $create =  Html::a('<i class="glyphicon glyphicon-plus"></i> PESAN ', ['create-inv'], ['class' => 'btn btn-success']);
								echo '<li class="nav-header">Data Akun</li>';
								echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['admin/invoice']).'"><i class="nav-icon fas fa-file"></i> <p>Invoice</p></a></li>';										
							}else{
								if($user->eType=='ADMIN' || $user->eType=='BENDAHARA' || $user->eType=='KASIR'){
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['admin/dashboard']).'"><i class="nav-icon fas fa-tachometer-alt"></i> <p>Dashboard</p></a></li>';
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['nota/create']).'"><i class="nav-icon fas fa-edit"></i> <p>Buat Transaksi <span class="right badge badge-danger">New</span></p></a></li>';
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['nota/index']).'"><i class="nav-icon fas fa-table"></i> <p>Transaksi</p></a></li>';
									if($user->eType=='ADMIN' || $user->eType=='BENDAHARA' || $user->eType=='SUPERVISOR'){
										// echo '<li class="nav-header">Laporan</li>';
										echo '<li class="nav-item">
									            <a href="#" class="nav-link">
									              <i class="nav-icon fas fa-book"></i>
									              <p>
									                Laporan
									                <i class="fas fa-angle-left right"></i>
									              </p>
									            </a>
									            <ul class="nav nav-treeview">
									              <li class="nav-item">
									                <a class="nav-link" href="'.Url::to(['kasir-shift/dashboard']).'"><i class="nav-icon fas fa-table"></i> <p>Laporan Kasir</p></a>
									              </li>
									              <li class="nav-item">
									                <a class="nav-link" href="'.Url::to(['kasir-shift/laporan-harian']).'"><i class="nav-icon fas fa-table"></i> <p>Laporan Harian</p></a>
									              </li>
									              <li class="nav-item">
									                <a class="nav-link" href="'.Url::to(['kasir-shift/laporan-bulanan']).'"><i class="nav-icon fas fa-table"></i> <p>Laporan BUlanan</p></a>
									              </li>
									              <li class="nav-item">
									                <a class="nav-link" href="'.Url::to(['kasir-shift/margin-bulanan']).'"><i class="nav-icon fas fa-table"></i> <p>Laporan Margin</p></a>
									              </li>
									              <li class="nav-item">
									                <a class="nav-link" href="'.Url::to(['kasir-shift/perbandingan-bulanan']).'"><i class="nav-icon fas fa-table"></i> <p>Growth Omset</p></a>
									              </li>
									            </ul>
									        </li>';
									}										
									echo '<li class="nav-header">Data Akun</li>';
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['setting/toko', 'slug' => $user->idCluster]).'"><i class="nav-icon fas fa-home"></i> <p>Pengaturan Toko</p></a></li>';
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['admin/invoice']).'"><i class="nav-icon fas fa-file"></i> <p>Invoice</p></a></li>';									
									echo '<li class="nav-header">Master Data</li>';
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['barang/index']).'"><i class="nav-icon fas fa-th"></i> <p>Produk</p></a></li>';
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['barang/stock']).'"><i class="nav-icon fas fa-th"></i> <p>Stok</p></a></li>';

								}else{
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['admin/dashboard']).'"><i class="nav-icon fas fa-tachometer-alt"></i> <p>Dashboard</p></a></li>';
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['admin/dashboard']).'"><i class="nav-icon fas fa-edit"></i> <p>Buat Transaksi <span class="right badge badge-danger">New</span></p></a></li>';
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['admin/dashboard']).'"><i class="nav-icon fas fa-table"></i> <p>Transaksi</p></a></li>';
									echo '<li class="nav-header">Data Akun</li>';
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['admin/invoice']).'"><i class="nav-icon fas fa-file"></i> <p>Invoice</p></a></li>';
									echo '<li class="nav-header">Master Data</li>';
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['admin/dashboard']).'"><i class="nav-icon fas fa-th"></i> <p>Produk</p></a></li>';
									echo '<li class="nav-item"><a class="nav-link" href="'.Url::to(['admin/dashboard']).'"><i class="nav-icon fas fa-th"></i> <p>Stok</p></a></li>';
								}
							}
								
						}
							
							
					} 
				}
                ?>
                <?php
				$shift = \nota\models\KasirShift::getActiveShift();
				?>

				<?php if (!$shift): ?>
				    <?= Html::a(
				        'Buka Kasir',
				        ['/kasir-shift/buka'],
				        ['class' => 'btn btn-success']
				    ) ?>
				<?php else: ?>
				    <?= Html::a(
				        'Tutup Kasir',
				        ['/kasir-shift/tutup', 'id' => $shift->id],
				        ['class' => 'btn btn-danger']
				    ) ?>
				<?php endif; ?>

	          <!-- <li class="nav-item">
	            <a href="pages/widgets.html" class="nav-link">
	              <i class="nav-icon fas fa-edit"></i>
	              <p>
	                Buat Transaksi
	                <span class="right badge badge-danger">New</span>
	              </p>
	            </a>
	          </li>
	          
	          <li class="nav-header">REPORT</li>
	          <li class="nav-item">
	            <a href="iframe.html" class="nav-link">
	              <i class="nav-icon fas fa-table"></i>
	              <p>Transaksi</p>
	            </a>
	          </li>

	          <li class="nav-item">
	            <a href="#" class="nav-link">
	              <i class="nav-icon fas fa-book"></i>
	              <p>
	                Kasir
	                <i class="fas fa-angle-left right"></i>
	              </p>
	            </a>
	            <ul class="nav nav-treeview">
	              <li class="nav-item">
	                <a href="pages/examples/invoice.html" class="nav-link">
	                  <i class="far fa-circle nav-icon"></i>
	                  <p>Buka Shift</p>
	                </a>
	              </li>
	              <li class="nav-item">
	                <a href="pages/examples/profile.html" class="nav-link">
	                  <i class="far fa-circle nav-icon"></i>
	                  <p>Tutup Shift</p>
	                </a>
	              </li>
	              <li class="nav-item">
	                <a href="pages/examples/profile.html" class="nav-link">
	                  <i class="far fa-circle nav-icon"></i>
	                  <p>Laporan Shift</p>
	                </a>
	              </li>
	              </ul>
	              </li> -->             
	          </ul>
	      </ul>
		</nav>
		<!-- /.sidebar-menu -->
	</div>
	<!-- /.sidebar -->
</aside>