<?php ob_start();

require("../../config/koneksi.php");
require("../../config/function.php");
require("../../config/crud.php");
	(isset($_SESSION['id_user'])) ? $id_user = $_SESSION['id_user'] : $id_user = 0;
	($id_user==0) ? header('location:login.php'):null;
	$mapel = $_GET['m'];
	$kelas = $_GET['k'];
	$tanggal = $_GET['t'];
	$bulan = date('m',strtotime($tanggal));
    $bulane = fetch ($koneksi, 'bulan', ['bln' =>$bulan]);
	$guru = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM users WHERE id_user='$_GET[g]'"));
	?>

<!DOCTYPE html>
<html>

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

    <title>NILAI HARIAN <?= $mapel ?> <?= $kelas ?></title>

<link rel='stylesheet' href='../../vendor/css/cetak.min.css'>
<link rel='stylesheet' href='../../vendor/css/bootstrap.min.css' />
</head>
<style>
@page { margin: 80px; }
body { margin: 20px; }
</style>
<body style="font-size: 13px;">	


<div style='background:#fff; width:97%; margin:0 auto; height:90%;'>
            <table width='100%'>
                <tr>
                    <td width='100'><img src='../../images/<?= $setting['logo'] ?>' width='70'></td>
                    <td style="text-align:center">
                        <strong class='f12'>
                        <?= strtoupper($setting['header']) ?><br>
                     <?= strtoupper($setting['sekolah']) ?><br>
					 <small>Alamat :  <?= $setting['alamat'] ?> Kec. <?= $setting['kecamatan'] ?> Kab.  <?= $setting['kabupaten'] ?> Email :  <?= $setting['email'] ?></small>
                        </strong>
                    </td>
                    
                </tr>
            </table>
			 <hr style="margin:1px">
		 <hr style="margin:2px">
   <br>
		
		<center><h4>NILAI HARIAN <?= $mapel ?></h4></center>
		<br>
 
    <table width="100%">
	
            <tr>
			<td width="10%"></td>
                 <td width='100px'>Sekolah</td>
                <td width='10px'>:</td>
                <td><?= $setting['sekolah'] ?></td>
				<td width="70%"></td>
				<td width='100px'>Bulan</td>
                <td width='10px'>:</td>
                <td><?= $bulane['ket'] ?> <?= date('Y') ?></td>
            </tr>
			
                <tr>
				<td width="10%"></td>
                <td width='100px'>Kelas</td>
                <td width='10px'>:</td>
                <td><?= $kelas ?></td>
				<td ></td>
				 <td width='100px'>Smt - TP</td>
                <td width='10px'>:</td>
                <td><?= $setting['semester'] ?> - <?= $setting['tp'] ?></td>
				</tr>
				
			
    </table>

     <br>
	 
		 <table class='it-grid it-cetak' width='100%'>       
              <tr>
                <th width="3%" class="text-center">NO</th>             
                <th width="10%" class="text-center">N I S</th>													                                                  
                <th width="35%" class="text-center">NAMA SISWA</th>
				 <th width="5%" class="text-center">JK</th>	
	            <th width="10%" class="text-center">NILAI</th>
				
            </tr>
              <?php
			  $tahun = date('Y');
				$query = mysqli_query($koneksi, "SELECT * FROM nilai_harian WHERE tanggal='$tanggal' and kelas='$kelas' and mapel='$mapel'"); 						
	           while ($data = mysqli_fetch_array($query)) :	
									
			$siswa = fetch($koneksi,'siswa',['id_siswa'=>$data['idsiswa']]);
			$no++;
			?>
			
		<tr>
                 <td class="text-center"><?= $no; ?></td>
                 <td class="text-center"><?= $siswa['nis'] ?></td>
                  <td><?= $siswa['nama'] ?></td>
				   <td class="text-center"><?= $siswa['jk'] ?></td>
				<td class="text-center"><?= $data['nilai'] ?></td>
				
                  </tr>
			  <?php endwhile; ?>
                    
								
            </table>
			
    <br>
	
	<table width='100%'>
					<tr>
					<td width="5%"></td>
					<td width='50px'></td>
						<td>
							Mengetahui, <br/>
							
					Kepala Sekolah
					<br/>
							<br/>
							<br/>
							<br/>
							
							<u><?= $setting['kepsek'] ?></u><br/>
							NIP. <?= $setting['nip'] ?>
						</td>
						<td width='40%'></td>
						<td width="5%"></td>
						<td>
							<?= ucwords(strtolower($setting['kecamatan'])); ?>, <?php echo date("d",strtotime($tanggal)); ?> <?= $bulane['ket'] ?> <?= date('Y') ?><br/>
							Guru Pengampu<br/>
							<br/>
							<br/>
							<br/>
							
							<u><?= $guru['nama'] ?></u><br/>
							NIP. <?= $guru['nip'] ?>.
						</td>
					</tr>
				</table>
</div>
</body>

</html>
<?php

$html = ob_get_clean();
require_once '../../vendor/vendors/autoload.php';

use Dompdf\Dompdf;

$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'Potrait');
$dompdf->render();
$dompdf->stream("Rekap Honor GTT Bulan ". $bulan . ".pdf", array("Attachment" => false));
exit(0);
?>