<html>
<head>
<title>Cetak - Laporan Absensi Siswa</title>
<link rel="stylesheet" href="bootstrap/css/printer.css">
</head>
<body>
<?php 
session_start();
error_reporting(0);
include "config/koneksi.php";
include "config/fungsi_indotgl.php";


   
	$d = mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM kelas_siswa where idKelas='$_GET[id]' "));
    $m = mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM rb_mata_pelajaran where kode_pelajaran='$_GET[kd]'"));
		$n = mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM rb_jadwal_pelajaran where kodejdwl='$_GET[jdwl]'"));
    echo "<div class='col-md-12'>
              <div class='box box-info'>
                <div class='box-header with-border'>
                  <h3 align='center'>Rekap Data Absensi Siswa </b></h3> 
				</div>
              <div class='table-responsive'>

              <div class='col-md-12'>
            
                    <input type='hidden' name='id' value='$s[idKelas]'>
					 <h4 class='box-title'>Nama Kelas :</th>               <td>$d[nmKelas]</h4>
                     <h4 class='box-title'>Mata Pelajaran :</th>           <td>$m[namamatapelajaran]</h4>
                 
              </div>

              <form method='POST' class='form-horizontal' action='' enctype='multipart/form-data'>
                <div class='col-md-12'>
               <table border='1' class='table table-bordered table-striped'>
                      <thead>
                      <tr>
                        <th>No</th>
                        <th>NIPD</th>
                        <th style='width:240px'>Nama Siswa</th>
                        <th>Pertemuan</th>
                        <th>Hadir</th>
                        <th>Sakit</th>
                        <th>Izin</th>
                        <th>Alpa</th>
                        <th style='width:240px'><center>% Kehadiran</center></th>
                      </tr>
                    </thead>
                    <tbody>";
                    
                    $no = 1;
                    $tampil = mysqli_query($conn,"SELECT * FROM siswa a where a.idKelas='$_GET[id]' AND idSiswa='$_SESSION[idsa]'ORDER BY a.idSiswa");
                    while($r=mysqli_fetch_array($tampil)){
                    $total = mysqli_num_rows(mysqli_query($conn,"SELECT * FROM `rb_absensi_siswa` where kodejdwl='$_GET[jdwl]' GROUP BY tanggal"));
                    $hadir = mysqli_num_rows(mysqli_query($conn,"SELECT * FROM `rb_absensi_siswa` where kodejdwl='$_GET[jdwl]' AND nisn='$r[nisnSiswa]'  AND kode_kehadiran='H'"));
                    $sakit = mysqli_num_rows(mysqli_query($conn,"SELECT * FROM `rb_absensi_siswa` where kodejdwl='$_GET[jdwl]' AND nisn='$r[nisnSiswa]' AND kode_kehadiran='S'"));
                    $izin = mysqli_num_rows(mysqli_query($conn,"SELECT * FROM `rb_absensi_siswa` where kodejdwl='$_GET[jdwl]' AND nisn='$r[nisnSiswa]' AND kode_kehadiran='I'"));
                    $alpa = mysqli_num_rows(mysqli_query($conn,"SELECT * FROM `rb_absensi_siswa` where kodejdwl='$_GET[jdwl]' AND nisn='$r[nisnSiswa]' AND kode_kehadiran='A'"));
                    $persen = $hadir/($total)*100;
                    echo "<tr bgcolor=$warna>
                            <td>$no</td>
                            <td>$r[nisnSiswa]</td>
                            <td>$r[nmSiswa]</td>
                          
                            <td align=center>$total</td>
                            <td align=center>$hadir</td>
                            <td align=center>$sakit</td>
                            <td align=center>$izin</td>
                            <td align=center>$alpa</td>
                            <td align=right>".number_format($persen, 2)." %</td>";
                    echo "</tr>";
                      $no++;
                      }

                    echo "</tbody>
                  </table>
                </div>
              </div>
            </div>";
?>



<table width="100%">
<tr>
	<td align="center"></td>
	<td align="center" width="400px">
		Banyuwangi, <?php echo tgl_raport(date("Y-m-d")); ?>
		
	</td>
</tr>
</table>
</body>
<script>
	window.print()
</script>
</html>