<?php foreach($kontak as $kontak) :   endforeach; ?>
<?php foreach($admin_login as $user) :   endforeach; ?> 
  <!-- Content Wrapper. Contains page content -->
  <?php  $level = $user->level;
  	if($level =='manager' or $level =='admin'){
  ?> 

  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark">Dashboard  </h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Grafik</a></li>
              <li class="breadcrumb-item active">Komisi Penjualan</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        

        <div class="row">
          <!-- Left col -->
          <section class="col-lg-12 connectedSortable">
            <!-- Custom tabs (Charts with tabs)-->
            <div class="card">
              <div class="card-header">
                <h3 class="card-title">
                  <i class="fas fa-chart-pie mr-1"></i>
                  Komisi Grafik   <?php echo tahun() ?>
                </h3>
                <div class="card-tools">
                  <ul class="nav nav-pills ml-auto">
                    <li class="nav-item">
                      <a class="nav-link active" href="#revenue-bulan" data-toggle="tab">Bulan</a>
                    </li>
                    <li class="nav-item">
                      <a class="nav-link" href="#sales-tahun" data-toggle="tab">Tahun</a>
                    </li>
                  </ul>
                </div>
              </div><!-- /.card-header -->
              <div class="card-body">
                <div class="tab-content p-0">
                  <!-- Morris chart - Sales 
                   <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
                  -->
                   <script src="<?php echo base_url().'assets/js/chart.js'?>"></script>
                  <div class="chart tab-pane active" id="revenue-bulan" style="position: relative; height: 300px;">
                  	<canvas id="myChart" width="1000" height="280"></canvas>

                  	<?php
                  	foreach($grafik_bulan as $data){
                  		$merk[] = $data->tanggal;
                  		$stok[] = (float) $data->jumlah;
                  	}
                  	?>
                  	<!--Load chart js-->
                  
                   <script type="text/javascript">
                    var ctx = document.getElementById('myChart').getContext('2d');
                    var chart = new Chart(ctx, {
                      type: 'bar',
                      data: {
                        labels: [
                          <?php
                          if (count($graphik)>0) {
                            foreach ($graphik as $data) {
                              echo "'" .'tanggal '.$tanggal= $data->tanggal."',";
                            }
                          }
                          ?>
                          ],
                        datasets: [{
                          label: 'Komisi Harian',
                          backgroundColor: '#ADD8E6',
                          borderColor: '##93C3D2',
                          data: [
                            <?php
                            if (count($graphik)>0) {
                             foreach ($graphik as $data) {
                              echo $data->jumlah . ", ";
                            }
                          }
                          ?>
                          ]
                        }]
                      },
                    });

                  </script>
                                       
                  </div>
                  <div class="chart tab-pane" id="sales-tahun" style="position: relative; height: 300px;">
                      <canvas id="myChart2" width="1000" height="280"></canvas>
                  	<script type="text/javascript">
                    var ctx = document.getElementById('myChart2').getContext('2d');
                    var chart = new Chart(ctx, {
                      type: 'bar',
                      data: {
                        labels: [
                          <?php
                          if (count($graphik2)>0) {
                            foreach ($graphik2 as $data2) {
                              echo "'" .'Bulan '.bulan_cetak($data2->bulan)."',";
                            }
                          }
                          ?>
                          ],
                        datasets: [{
                          label: 'Komisi Bulanan',
                          backgroundColor: '#ADD8E6',
                          borderColor: '##93C3D2',
                          data: [
                            <?php
                            if (count($graphik2)>0) {
                             foreach ($graphik2 as $data2) {
                              echo $data2->jumlah . ", ";
                            }
                          }
                          ?>
                          ]
                        }]
                      },
                    });

                  </script>              
                  </div>  
                </div>
              </div><!-- /.card-body -->
            </div>
            <!-- /.card -->

             

             
          </section>
        </div>
      
        <!-- /.row (main row) -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
	
	<?php }  ?>