<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
?>
<div class='row'>
    <div class='col-md-12'>
        <div class='box box-solid'>
            <div class='box-header with-border'>
                <h3 class='box-title'><i class="fas fa-edit    "></i> Tugas Siswa</h3>
            </div>
            <div class='box-body'>

                <?php
                $siswa = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM siswa WHERE id_siswa='$_SESSION[id_siswa]'"));
                $mapelQ = mysqli_query($koneksi, "SELECT * FROM tugas");

                ?>
                <?php while ($mapel = mysqli_fetch_array($mapelQ)) : ?>
                    <?php
                    if ($mapel['tgl_selesai'] > 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)) : ?>
                            <div class="col-md-4">
                         <ul class="products-list product-list-in-box" >
                      <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>
								  <?php if ($mapel['tgl_mulai'] > date('Y-m-d H:i:s') and $mapel['tgl_selesai'] > date('Y-m-d H:i:s')) { ?>
                                                TUGAS BELUM MULAI
                                            <?php } elseif ($mapel['tgl_mulai'] < date('Y-m-d H:i:s') and $mapel['tgl_selesai'] > date('Y-m-d H:i:s')) { ?>
                                                <a href="?pg=lihattugas&id=<?= $mapel['id_tugas'] ?>" class="btn btn-primary btn-sm pull-right">BUKA</a>
                                            <?php } ?>
                                           
										<span class="product-description">
										  <?= $mapel['judul'] ?>
										</span>
										<p>Guru : <?= $guru['nama'] ?> | <?= $mapel['tgl_mulai'] ?>
									  </div>
									</li>
									</ul>
									<ul>
									 <li>
									<span>Dimulai <?= $mapel['tgl_mulai'] ?></span>
										</li>
									 <li>
										<span>Dimulai <?= $mapel['tgl_selesai'] ?></span>
									  </li>
									</ul>
                                       

                            </div>
                        <?php endif; ?>
                    <?php } ?>
                <?php endwhile; ?>

            </div>
        </div>
    </div>
</div>