<?php
	require("../../config/koneksi.php");
	require("../../config/function.php");
	require("../../config/crud.php");
	require("../../config/dis.php");
	
	(isset($_SESSION['id_user'])) ? $id_user = $_SESSION['id_user'] : $id_user = 0;
	($id_user==0) ? header('location:login.php'):null;
	$idjadwal = $_GET['idj'];
	
	$mapel=mysqli_fetch_array(mysqli_query($koneksi, "select * from jadwal_mapel where id_jadwal='$idjadwal'"));
	$user = fetch($koneksi, 'users',array('id_user'=>$mapel['guru']));
	$bl=date('m');
    $bulane = fetch ($koneksi, 'bulan', ['bln' =>$bl]);
	?>

	
<link rel='stylesheet' href='<?= $homeurl ?>/dist/css/cetak.min.css'>
<link rel='stylesheet' href='../../dist/css/bootstrap.min.css' />
<style type="text/css">
	@font-face {
		font-family: 'tulisan_keren';
		src: url('../../dist/fonts/poppins/Poppins-Light.ttf');
	}

	body {
		font-family: 'tulisan_keren';
		line-height: 1.42857143;
		color: #000;
		width: 100%;
		height: 100%;
		margin: 0;
		padding: 0;
		background-color: #FAFAFA;
		font-size: 13px;
	}

	.footer {
		position: absolute;
		bottom: 1.5cm;
		left: 1.5cm;
		right: 1.5cm;
		width: auto;
		height: 30px
	}

	* {
		box-sizing: border-box;
		-moz-box-sizing: border-box;
	}

	@page {
		size: A4;
		margin: 10mm;
	}

	@media print {

		html,
		body {
			width: 210mm;
			height: 297mm;
		}

		.page {
			margin: 10mm;
			border: initial;
			border-radius: initial;
			width: initial;
			min-height: initial;
			box-shadow: initial;
			background: initial;
			page-break-after: always;
		}

		.footer {
			bottom: .7cm;
			left: .7cm;
			right: .7cm
		}
	}
</style>
<div style='background:#fff; width:97%; margin:0 auto; height:90%;'>
            <table width='100%'>
                <tr>
                    <td width='100'><img src='<?= $homeurl . '/' . $setting['logo'] ?>' width='70'></td>
                    <td style="text-align:center">
                        <strong class='f12'>
                            <?= strtoupper($setting['header']) ?><br>
							  KABUPATEN / KOTA <?= strtoupper($setting['kabupaten']) ?><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>REKAPITULASI ABSENSI MATA PELAJARAN</h4></center>
		<br>
 
    <table width="100%">
	
            <tr>
                 <td width='100px'>Mapel</td>
                <td width='10px'>:</td>
                <td><?= $mapel['mapel'] ?></td>
				<td width='200px'></td>
				<td width='100px'>Bulan</td>
                <td width='10px'>:</td>
                <td><?= $bulane['ket'] ?> <?= date('Y') ?></td>
            </tr>
			
                <tr>
                <td width='100px'>Kelas</td>
                <td width='10px'>:</td>
                <td><?= $mapel['kelas'] ?></td>
				<td width='200px'></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 height='40px'>
                    <th width="10px">No.</th>					
                    <th width="10%">NIS</th>             
                    <th>Nama Lengkap<br> </th>
                     <?php
					$qu = mysqli_query($koneksi, "select * from absen_mapel WHERE idjadwal='$idjadwal' AND blth='$bl' GROUP BY tanggal");                            
                       while ($ab = mysqli_fetch_array($qu)) {  
                     	$tanggale = date('d',strtotime($ab['tanggal']));			   
                           ?>
			          <th><?= $tanggale ?></th>
					   <?php } ?>
                    <th>Catatan</th>
                </tr>
			                <?php
					
							$no = 0;
                              $query = mysqli_query($koneksi, "select * from absen_mapel WHERE idjadwal='$idjadwal' AND blth='$bl' GROUP BY idsiswa");                            
                                while ($absen = mysqli_fetch_array($query)) {
							    $siswa = fetch($koneksi,'siswa',['id_siswa'=>$absen['idsiswa']]); 
							      		
                                      $no++;                         
                                        ?>
			
			 <tr>
                            <td style="text-align:center;width:15">&nbsp;<?= $no ?>.</td>
                            <td style="text-align:center">&nbsp;<?= $siswa['nis'] ?></td>
                            <td>&nbsp;<?= $siswa['nama'] ?></td>
							
							 <?php
                              $queryQ = mysqli_query($koneksi, "select * from absen_mapel WHERE idjadwal='$idjadwal' AND idsiswa='$siswa[id_siswa]' AND blth='$bl' GROUP BY tanggal");                            
                                while ($absenQ = mysqli_fetch_array($queryQ)) {
							    	                     
                                        ?>
                            <td style="text-align:center">&nbsp;<?= $absenQ['ket'] ?></td>
							<?php } ?>
                            <td>&nbsp;</td>
							
							<?php } ?>
                        </tr>
						    
								
            </table>
			
    
	<table width='100%'>
					<tr>
					<td width='50px'></td>
						<td>
							Mengetahui, <br/>
							Kepala Sekolah <br/>
							<br/>
							<br/>
							<br/>
							
							<u><?= $setting['kepsek'] ?></u><br/>
							NIP. <?= $setting['nip'] ?>
						</td>
						<td width='300px'></td>
						<td>
							<?= $setting['kecamatan'] ?>, <?php echo date("t",time());; ?> <?= $bulane['ket'] ?> <?= date('Y') ?><br/>
							Guru Mata Pelajaran<br/>
							<br/>
							<br/>
							<br/>
							
							<u><?= $user['nama'] ?></u><br/>
							NIP. <?= $user['nip'] ?>
						</td>
					</tr>
				</table>
</div>