<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
 $siswa = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM siswa WHERE id_siswa='$_SESSION[id_siswa]'"));
?>
<div class='row'>
    <div class='col-md-7'>
        <div class='box box-solid'>
            <div class='box-header with-border'>
                <h3 class='box-title'>Materi Belajar</h3>
            </div>
            <div class="box-body">
                  <ul class="products-list product-list-in-box" >
                <?php
               
                $mapelQ = mysqli_query($koneksi, "SELECT * FROM materi ORDER BY id_materi DESC LIMIT 5");

                ?>
                <?php while ($mapel = mysqli_fetch_array($mapelQ)) : ?>
                    <?php
                    if ($mapel['tgl_mulai'] < date('Y-m-d H:i:s')) {
                        $datakelas = unserialize($mapel['kelas']);
                        $guru = fetch($koneksi, 'users', ['id_user' => $mapel['id_guru']]);
                    ?>
                        <?php if (in_array($siswa['kelas'], $datakelas) or in_array('semua', $datakelas)) : ?>

                    <li class="item">
                      <div class="product-img">
                        <img src="images/user.png" alt="Product Image">
                      </div>
                      <div class="product-info">
                        <a href="#" class="product-title" style="font-size: 20px">
						
						 <?php
                           if (strlen($mapel['mapel']) > 30) {
                             echo substr($mapel['mapel'], 0, 30) . "...";
                                   } else {
                             echo $mapel['mapel'];
                                  }
                                   ?>
								   </a>
						<a href="?pg=lihatmateri&id=<?= $mapel['id_materi'] ?>" class="btn btn-primary btn-sm pull-right">BUKA</a>
                        <span class="product-description">
                          <?= $mapel['judul'] ?>
                        </span>
						<p>Guru : <?= $guru['nama'] ?> | <?= $mapel['tgl_mulai'] ?>
                      </div>
                    </li>
                   
                        <?php endif; ?>
                    <?php } ?>
                <?php endwhile; ?>
					</ul>
                </div>
               
            </div>
        </div>
    
	<div class='col-md-5'>
        <div class='box box-solid'>
            <div class='box-header with-border'>
                <h3 class='box-title'>ABSENSI <?= strtoupper($siswa['nama']); ?></h3>
            </div>
            <div class="box-body">
                  <ul class="products-list product-list-in-box" >
                <?php
               
                $abs = mysqli_query($koneksi, "SELECT * FROM absen_daring ORDER BY id DESC LIMIT 5");
                
                ?>
                <?php while ($absen = mysqli_fetch_array($abs)) : ?>
                    <?php
                     $map = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM materi WHERE id_materi='$absen[materi]'"));
                    ?>
                    <li class="item">
                      <div class="product-img">
                        <img src="images/user.png" alt="Product Image">
                      </div>
                      <div class="product-info">
                        <a href="#" class="product-title" style="font-size: 20px">
						
						 <?php
                           if (strlen($map['mapel']) > 30) {
                             echo substr($mapel['map'], 0, 30) . "...";
                                   } else {
                             echo $map['mapel'];
                                  }
                                   ?>
								   </a>
						<a href="#" class="btn btn-default btn-sm pull-right">HADIR</a>
                        <span class="product-description">
                          <?= $siswa['nama'] ?>
                        </span>
						<p><?= $absen['waktu'] ?>
                      </div>
                    </li>
                   
                <?php endwhile; ?>
					</ul>
                </div>
			</div>
        </div>
    </div>
</div>