<?php
	  $id = $_SESSION['id'];
	  $user = $this->dashboard_model->user_login($id);
      $informasi = $this->dashboard_model->admin();
      $tp = $this->dashboard_model->tp();
      $geldesk = $this->dashboard_model->gelombang();
      $informasi_penguji = $this->dashboard_model->penguji();
	  $sekolah = $this->dashboard_model->sekolah();
	  $menu = $this->dashboard_model->menu_psswd();      
?>

<?php if($this->session->userdata('level')=="Administrator" or ($this->session->userdata('level')=="Operator")) { ?>
<section class="content">
    <div class="container-fluid">
        <!-- Small boxes (Stat box) -->
    <div class="row">
    <?php if($this->session->userdata('level')=="Administrator" or ($this->session->userdata('level')=="Operator")) { ?>
    <div class="callout callout-info">
	    <h3>Selamat Datang <strong><span class="text-blue"><?php echo $user->nama ?></span></strong> di Sistem PPDB <?php echo $sekolah->pengaturan_value ?> - TP. <?php echo $tp->tp ?><small> [ <span class="text-red"><?php echo $geldesk->gelombang ?></span> ]</small></h3>
	        <p><strong><?php echo $informasi->info ?>.</strong></p>
	        <!-- <?php if($menu->pengaturan_value == 1) { ?>
		        <a href="<?php echo base_url('akun') ?>" class="btn btn-warning btn-sm">
		        <i class  = "fa fa-edit"></i>GANTI PASSWORD</a>
	        <?php } ?> -->
    </div>    
    <?php } ?>
    <div class="col-lg-3 col-6">
                <!-- small box -->
                <div class="small-box bg-info">
                    <div class="inner">
                        <h3><?php echo $this->dashboard_model->pendaftar()->total; ?></h3>
                        <p>Total - [ Gel. 1 : <b><?php echo $this->dashboard_model->gel1()->total; ?></b>
                            & Gel. 2 : <b><?php echo $this->dashboard_model->gel2()->total; ?></b> ]
                        </p>

                    </div>
                    <div class="icon">
                        <i class="nav-icon fas fa-users"></i>
                    </div>
                    <a href="form-pendaftaran" class="small-box-footer">PENDAFTARAN <i class="fas fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-6">
                <!-- small box -->
                <div class="small-box bg-success">
                    <div class="inner">
                        <h3><?php echo $this->dashboard_model->otkp()->total; ?></h3>
                        <p>Pendaftar MPLB</p>
                    </div>
                    <div class="icon">
                        <i class="fas fa-user-clock"></i>
                    </div>
                    <a href="otkp" class="small-box-footer">MPLB <i class="fas fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-6">
                <!-- small box -->
                <div class="small-box bg-warning">
                    <div class="inner">
                        <h3><?php echo $this->dashboard_model->tkj()->total; ?></h3>
                        <p>Pendaftar TJKT</p>
                    </div>
                    <div class="icon">
                        <i class="fas fa-users-cog"></i>
                    </div>
                    <a href="tkj" class="small-box-footer">TJKT <i class="fas fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-6">
                <!-- small box -->
                <div class="small-box bg-danger">
                    <div class="inner">
                        <h3><?php echo $this->dashboard_model->animasi()->total; ?></h3>
                        <p>Pendaftar ANIMASI</p>
                    </div>
                    <div class="icon">
                        <i class="fas fa-users-cog"></i>
                    </div>
                    <a href="animasi" class="small-box-footer">ANIMASI <i class="fas fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-6">
                <!-- small box -->
                <div class="small-box bg-info">
                    <div class="inner">
                        <h3><?php echo $this->dashboard_model->kuliner()->total; ?></h3>
                        <p>Pendaftar KULINER</p>
                    </div>
                    <div class="icon">
                        <i class="fas fa-users-cog"></i>
                    </div>
                    <a href="kuliner" class="small-box-footer">KULINER <i class="fas fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-6">
                <!-- small box -->
                <div class="small-box bg-success">
                    <div class="inner">
                        <h3><?php echo $this->dashboard_model->nilai()->total; ?></h3>
                        <p>BTQ & Wawancara</p>
                    </div>
                    <div class="icon">
                        <i class="fas fa-chalkboard-teacher"></i>
                    </div>
                    <a href="nilai" class="small-box-footer">BTQ & WAWANCARA <i class="fas fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <div class="col-lg-3 col-6">
                <!-- small box -->
                <div class="small-box bg-warning">
                    <div class="inner">
                        <h3><?php echo $this->dashboard_model->lulus()->total; ?></h3>
                        <p>Calon Siswa LULUS TES</p>
                    </div>
                    <div class="icon">
                        <i class="fas fa-users-cog"></i>
                    </div>
                    <a href="lulustes" class="small-box-footer">LULUS TES <i class="fas fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-6">
                <!-- small box -->
                <div class="small-box bg-danger">
                    <div class="inner">
                        <h3><?php echo $this->dashboard_model->belumlulus()->total; ?></h3>
                        <p>Calon Siswa BELUM LULUS TES</p>
                    </div>
                    <div class="icon">
                        <i class="fas fa-users-cog"></i>
                    </div>
                    <a href="belumlulustes" class="small-box-footer">BELUM LULUS TES <i class="fas fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <!-- ./col -->


            <div class="col-12 col-sm-6 col-md-3">
                <div class="info-box">
                    <span class="info-box-icon bg-warning elevation-1"><i class="fas fa-edit"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">Penyerahan Berkas</span>
                        <span class="info-box-number">
                            <?php echo $this->dashboard_model->formulir()->total; ?>
                        </span>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
            <!-- /.col -->
            <div class="col-12 col-sm-6 col-md-3">
                <div class="info-box mb-3">
                    <span class="info-box-icon bg-danger elevation-1"><i class="fas fa-shopping-cart"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">Invoice</span>
                        <span class="info-box-number"><?php echo $this->dashboard_model->invoice()->total; ?></span>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
            <!-- /.col -->

            <!-- fix for small devices only -->
            <div class="clearfix hidden-md-up"></div>

            <div class="col-12 col-sm-6 col-md-3">
                <div class="info-box mb-3">
                    <span class="info-box-icon bg-success elevation-1"><i class="fas fa-thumbs-up"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">Salin Slip</span>
                        <span class="info-box-number"><?php echo $this->dashboard_model->registrasi()->total; ?></span>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
            <!-- /.col -->
            <div class="col-12 col-sm-6 col-md-3">
                <div class="info-box mb-3">
                    <span class="info-box-icon bg-info elevation-1"><i class="fa fa-lock"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">Pengguna</span>
                        <span class="info-box-number">
                            <?php echo $this->dashboard_model->user()->total; ?>
                            <small>User</small>
                        </span>
                    </div>
                </div>
                <!-- /.info-box -->
            </div>
            <!-- /.col -->
        </div>
        <!--Grafik Pendaftaran-->
        <?php if($this->session->userdata('level')=="Administrator" or ($this->session->userdata('level')=="Operator")) { ?>
        <div class="col-md-12">
            <hr>
            <h5>Statistik Pendaftaran Terakhir</h5>
            <hr>
            <!-- Styles -->
            <style>
            #chartdiv {
                width: 100%;
                height: 500px;
            }
            </style>

            <!-- Resources -->
            <script src="https://www.amcharts.com/lib/4/core.js"></script>
            <script src="https://www.amcharts.com/lib/4/charts.js"></script>
            <script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>

            <!-- Chart code -->
            <script>
            am4core.ready(function() {

                // Themes begin
                am4core.useTheme(am4themes_animated);
                // Themes end

                // Create chart instance
                var chart = am4core.create("chartdiv", am4charts.XYChart);
                chart.paddingRight = 20;

                // Add data
                chart.data = [
                    <?php 
$pendaftaran = $this->dashboard_model->pendaftaran();
foreach($pendaftaran as $pendaftaran) {
?> {
                        "year": "<?php echo date('d-m-Y',strtotime($pendaftaran->tgl_trans)) ?>",
                        "value": <?php echo $pendaftaran->total; ?>
                    },
                    <?php } ?>
                ];

                // Create axes
                var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
                categoryAxis.dataFields.category = "year";
                categoryAxis.renderer.minGridDistance = 50;
                categoryAxis.renderer.grid.template.location = 0.5;
                categoryAxis.startLocation = 0.5;
                categoryAxis.endLocation = 0.5;

                // Pre zoom
                chart.events.on("datavalidated", function() {
                    categoryAxis.zoomToIndexes(Math.round(chart.data.length * 0.4), Math.round(chart
                        .data.length * 0.55));
                });

                // Create value axis
                var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
                valueAxis.baseValue = 0;

                // Create series
                var series = chart.series.push(new am4charts.LineSeries());
                series.dataFields.valueY = "value";
                series.dataFields.categoryX = "year";
                series.strokeWidth = 2;
                series.tensionX = 0.77;

                var range = valueAxis.createSeriesRange(series);
                range.value = 0;
                range.endValue = 1000;
                range.contents.stroke = am4core.color("#FF0000");
                range.contents.fill = range.contents.stroke;

                // Add scrollbar
                var scrollbarX = new am4charts.XYChartScrollbar();
                scrollbarX.series.push(series);
                chart.scrollbarX = scrollbarX;

                chart.cursor = new am4charts.XYCursor();

            }); // end am4core.ready()
            </script>

            <!-- HTML -->
            <div id="chartdiv"></div>


        </div>
    </div>
    <!-- /.row -->
    <?php } ?>
    <?php } ?>

    <!--Khusus Penguji-->
    <?php if($this->session->userdata('level')=="Penguji") { ?>     
    <div class="callout callout-info">
    <h3>Selamat Datang <strong><?php echo $user->nama ?></strong> di Sistem PPDB <?php echo $sekolah->pengaturan_value ?>.</h3>
        <p><strong><?php echo $informasi_penguji->info ?>.</strong></p>
    </div>    
    <div class="col-lg-3 col-6">    
        <!-- small box -->
        <div class="small-box bg-danger">
            <div class="inner">
                <h3><?php echo $this->dashboard_model->nilai()->total; ?></h3>
                <p>BTQ & Wawancara</p>
            </div>
            <div class="icon">
                <i class="ion ion-bag"></i>
            </div>
            <a href="nilai" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
        </div>
    </div>
    <?php } ?>

    <!--Khusus Peserta-->
    <?php if($this->session->userdata('level')=="Peserta") { ?>
    <?php
      $id = $_SESSION['userid'];
      $peserta = $this->dashboard_model->user2($id);
      $menu = $this->user_model->menu_pengumuman();
      $this->load->view('dashboard/info',$peserta);
    ?>
    <div class="row">
	<?php if($menu->pengaturan_value == 1) { ?>	
    <div class="col-lg-3 col-6">    
        <!-- small box -->
        <div class="small-box bg-info">
            <div class="inner">
                <h4><b>PENGUMUMAN</b></h4>
                <p>Hasil Tes Akademik & BTQ</p>
            </div>
            <div class="icon">
                <i class="nav-icon fas fa-laptop"></i>
            </div>
            <a href="pengumuman" class="small-box-footer">Klik Disini <i class="fas fa-arrow-circle-right"></i></a>
        </div>
    </div>
    <?php } ?>
    <div class="col-lg-3 col-6">
        <!-- small box -->
        <div class="small-box bg-success">
            <div class="inner">
                 <h4><b>BIODATA</b></h4>
                <p>No. Pendaftaran : <?php echo $id; ?></p>
            </div>
            <div class="icon">
                <i class="nav-icon fas fa-user"></i>
            </div>
            <a href="biodata" class="small-box-footer">Klik Disini <i class="fas fa-arrow-circle-right"></i></a>
        </div>
    </div>
    <!-- ./col -->
    <div class="col-lg-3 col-6">
        <!-- small box -->
        <div class="small-box bg-danger">
            <div class="inner">
                <h4><b>BERKAS</b></h4>
                <p>Berkas Yang Sudah Diserahkan</p>
            </div>
            <div class="icon">
                <i class="nav-icon fas fa-edit"></i>
            </div>
            <a href="berkas" class="small-box-footer">Klik Disini <i class="fas fa-arrow-circle-right"></i></a>
        </div>
    </div>
     <!-- ./col -->
     <div class="col-lg-3 col-6">
        <!-- small box -->
        <div class="small-box bg-warning">
            <div class="inner">
                <h4><b>REGISTRASI</b></h4>
                <p>Pembayaran Registrasi PPDB</p>
            </div>
            <div class="icon">
                <i class="fas fa-check-double"></i>
            </div>
            <a href="lap_registrasi" class="small-box-footer">Klik Disini <i class="fas fa-arrow-circle-right"></i></a>
        </div>
    </div>
    </div>
    <!-- ./col -->
    <?php } ?>
