<?php
require("../../config/koneksi.php");
require("../../config/function.php");
require("../../config/crud.php");

?>  
<?php
				$query = mysqli_query($koneksi, "SELECT * FROM absensi WHERE tanggal='$tanggal' ORDER BY id DESC LIMIT 10"); 
				$cek = mysqli_num_rows($query);
				if ($cek >= 1) {
				while ($data = mysqli_fetch_array($query)) :
				$peg = fetch($koneksi,'users',['id_user'=>$data['idpeg']]);
				 $siswa = fetch($koneksi,'siswa',['id_siswa'=>$data['idsiswa']]);
				 if($data['ket']=='H'){$info='Hadir';} if($data['ket']=='S'){$info='Sakit';} 
				 if($data['ket']=='I'){$info='Izin';} if($data['ket']=='A'){$info='Alpha';}
				$no++;
                ?>

							   <div class="widget-payment-request-container">
                                            <div class="widget-payment-request-author">
                                                <div class="avatar m-r-sm">
												<?php if($data['level']=='siswa'): ?>
												<?php if($siswa['foto']==''){ ?>
                                                    <img src="../images/user.png" alt="">
												<?php }else{ ?>
													 <img src="../images/fotosiswa/<?= $siswa['foto'] ?>" alt="">
												<?php } ?>
												<?php else: ?>
												<?php if($peg['foto']==''){ ?>
                                                    <img src="../images/user.png" alt="">
												<?php }else{ ?>
													 <img src="../images/fotoguru/<?= $peg['foto'] ?>" alt="">
												<?php } ?>
												<?php endif; ?>
												
                                                </div>
                                                <div class="widget-payment-request-author-info">
												<?php if($data['level']=='siswa'): ?>
                                                    <span class="widget-payment-request-author-name"><?= $siswa['nama'] ?> <h5 class="kanan"><span class="badge badge-secondary">Kelas <?= $siswa['kelas'] ?></span></h5></span>
                                                    <?php else: ?>
													 <span class="widget-payment-request-author-name"><?= $peg['nama'] ?> <h5 class="kanan"><span class="badge badge-secondary"><?= strtoupper($peg['level']); ?> </span></h5></span>
													<?php endif; ?>
													<span class="widget-payment-request-author-about">JAM ABSEN <?= $data['masuk']; ?> <h5><span class="badge badge-dark"><?= $info ?></span></h5>
													
													</span>
														<?php if($data['level']=='siswa'): ?>
                                                <button class="btn btn-primary pull-right" type="button" disabled>
												<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
												<?= $data['mesin'] ?>
											</button>
											 <?php else: ?>
											 <button class="btn btn-success pull-right" type="button" disabled>
												<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
												<?= $data['mesin'] ?>
											</button>
											 <?php endif; ?>
												</div>
											
                                            </div>
											
                                        <h5><span class="badge badge-secondary"><?= $data['keterangan']; ?></span></h5>
												<?php endwhile; ?>
				                               <?php }else{ ?>
												 <button class="btn btn-light" type="button" disabled>
										<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
										Tidak ada aktifitas...
									</button>
												 <?php } ?>
												 
												 
												 
												 
						