<?php ob_start();
error_reporting(0);
require("../../config/koneksi.php");
require("../../config/function.php");
require("../../config/crud.php");
session_start();


$kelas=$_GET['kelas'];
$mapel=$_GET['mapel'];
$jmpl = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM jadwal_proto WHERE kelas='$kelas' "));
$bl = date('m');
$bulane = fetch ($koneksi, 'bulan', ['bln' =>$bl]);
$user=fetch($koneksi,'pengawas',['jabatan'=>$kelas]);

?>
<!DOCTYPE html>
<html>

<head>
    <meta charset='utf-8'>

     <title>Leger Sumatif Akhir Materi_<?= $kelas ?></title>
<link rel="stylesheet" href="../../plugins/bootstrap/dist/css/bootstrap.min.css">

</head>
<?php
  
		$rapor=fetch($koneksi,'setting',['id_setting' => 1]);
	if($rapor['semester']=='1'){
{$smt="(Satu)";}
}elseif($rapor['semester']=='2'){
{$smt="(Dua)";}
}
  ?>
<body style="font-size: 12px;">
    
   
    <center>
        <h5>ASESMEN FORMATIF</h5>
		
    </center>
    <br>
    
    <div class="col-md-14">
	
        <table style="margin-left: 80px;margin-right:60px"  width="100%" >
            <tr>
                <td width="15%">Satuan Pendidikan</td>
                <td width="1%">:</td>
				<td width="40%"><?= $setting['sekolah'] ?></td>
				<td></td>
				<td width="17%">Kelas</td>
                <td width="1%">:</td>
				<td width="20%"><?= $kelas ?></td>
            </tr>
            <tr>
                <td >Alamat</td>
                <td>:</td>
				<td><?= $ms['alamat'] ?> Kec. <?= $setting['kecamatan'] ?></td>
				<td></td>
				<td>Semester</td>
                <td>:</td>
				<td> <?= $rapor['semester'] ?> <?= $smt ?></td>
            </tr>
			<tr>
                <td>Kode Mapel</td>
                <td>:</td>
				<td><?= $mapel ?></td>
				<td></td>
				<td>Tahun Pelajaran</td>
                <td>:</td>
				<td><?= $rapor['tp'] ?></td>
            </tr>
			
        </table>
       
          
        <br>
 <table style="font-size: 12px" class="table table-bordered table-sm">
  <thead>
            <tr style="text-align: center">
			<th width='2%' style="text-align: center;">No</th>
	<th>Nama Siswa</th>
	
	 <?php
			$querys = mysqli_query($koneksi,"select * from nilai_formatif WHERE mapel='$_GET[mapel]' AND kelas='$_GET[kelas]'   GROUP BY ket");
              while ($kd = mysqli_fetch_array($querys)) {
			?>
			<th width='5%' style="text-align: center;"><?= $kd['ket'] ?></th>
			  <?php } ?>
			  
	</tr>
	 </thead>	
				<?php
	       $no=0;
			$query = mysqli_query($koneksi,"select * from siswa WHERE id_kelas='$_GET[kelas]'");
              while ($siswa = mysqli_fetch_array($query)) {
				 
				  $no++;
			?>
     <tbody>
	
	         <tr>
	        <td><?= $no ?></td>
			<td><?= ucwords(strtolower($siswa['nama'])) ?></td>
			
	       <?php
			$queryxx = mysqli_query($koneksi,"select AVG(nilai) AS nkd from nilai_formatif 
			JOIN tujuan ON tujuan.tp=nilai_formatif.ket
			WHERE nilai_formatif.idsiswa='$siswa[id_siswa]' AND  nilai_formatif.mapel='$_GET[mapel]'  AND nilai_formatif.kelas='$_GET[kelas]'  GROUP  BY nilai_formatif.ket ");
              while ($nilai = mysqli_fetch_array($queryxx)) {
		 
		 
			?>
	
     	<td style="text-align: center;"><?= round($nilai['nkd'],2) ?></td>
			 <?php } ?>
			 </tr>
			
			  <?php   } ?>
	
			 </tbody>
		</table>	
		<br/>
	<table border='0' style="margin-left: 80px;width:850">
					<tr>
					
						<td>
							Mengetahui, <br/>
							Kepala PKBM <br/>
							<br/>
							<br/>
							<br/>
							
							<u><?= $setting['kepsek'] ?></u><br/>
							NIP. <?= $setting['nip'] ?>
						</td>
						<td width='400px'></td>
						<td>
							<?= $setting['kecamatan'] ?>, <?php echo date('d'); ?> <?= $bulane['ket'] ?> <?= date('Y') ?><br/>
							Wali Kelas <?= $kelas ?><br/>
							<br/>
							<br/>
							<br/>
							
							<u><?= $user['nama'] ?></u><br/>
							NIP. <?= $user['nip'] ?>
						</td>
					</tr>
				</table>
</body>

</html>
