<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
?>
<div class='row'>
    <div class='col-md-12'>
        <div class="card">
             <div class="card-header">
                <h5 class='card-title'><i class="fas fa-edit"></i> Materi Siswa</h5>
            </div>
			  <form method="post" class="form-user">		
            <div class='card-body'>          
                 <div class='row'>		   
                <?php
                $siswa = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM siswa WHERE id_siswa='$_SESSION[id_siswa]'"));
                $mapelQ = mysqli_query($koneksi, "SELECT * FROM materi");

                ?>
                <?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['id_kelas'], $datakelas) or in_array('semua', $datakelas)) :

                        ?>
						
						   	<div class="col-xl-4">
							<a href="<?= $homeurl . '/lihatmateri/' . enkripsi($mapel['id_materi']) ?>" class="btn-link">
                                <div class="card widget widget-stats">
                                    <div class="card-body">
                                        <div class="widget-stats-container d-flex">
                                            
                                            <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">
												Guru : <?= $guru['nama'] ?>
												</span>
                                                <span class="widget-stats-amount">
												 <?php
                                                    if (strlen($mapel['mapel']) > 30) {
                                                        echo substr($mapel['mapel'], 0, 30) . "...";
                                                    } else {
                                                        echo $mapel['mapel'];
                                                    }
                                                    ?>
												</span>
                                                <span class="widget-stats-title">
												 <?= $mapel['judul'] ?>
												</span>
												<span class="widget-stats-title">
											<?= $mapel['tgl_mulai'] ?>
												</span>
                                            </div>
											
                                            <div class="widget-stats-indicator widget-stats-indicator-primary align-self-start">
                                                <i class="fa fa-book"> </i> 
                                            </div>
                                        </div>
                                    </div>
                                </div>
								         </a>  
                            </div>   
                        <?php endif; ?>
                    <?php } ?>
                <?php endwhile; ?>
				                 
           </form>
            </div>
        </div>
    </div>
</div>

