<?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;
	$idu = $_GET['idu'];
	
	$user = fetch($koneksi, 'users',array('id_user'=>$idu));
	$bl=date('m');
    $bulane = fetch ($koneksi, 'bulan', ['bln' =>$bl]);
	?>

	
<link rel='stylesheet' href='../../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>RINCIAN ABSENSI PEGAWAI</h4></center>
		<br>
 
    <table width="100%">
	
            <tr>
                 <td width='100px'>Nama</td>
                <td width='10px'>:</td>
                <td><?= $user['nama'] ?></td>
				<td width='200px'></td>
				<td width='150px'>Bulan</td>
                <td width='10px'>:</td>
                <td><?= $bulane['ket'] ?> <?= date('Y') ?></td>
            </tr>
			
                <tr>
                <td width='100px'>Semester</td>
                <td width='10px'>:</td>
                <td><?= $setting['semester'] ?></td>
				<td width='200px'></td>
				 <td width='150px'>Tahun Pelajaran</td>
                <td width='10px'>:</td>
                <td> <?= $setting['tp'] ?></td>
				</tr>
				
			
    </table>

     <br>
	 
		 <table class='it-grid it-cetak' width='100%'>       
              <tr height='40px'>
                    <th width="5p%">No.</th>					
                    <th width="15%">Tangggal</th>
					 <th width="15%">Jam Absen</th>
                    <th width="10%">Kehadiran</th>
					<th >Keterangan</th>
                    <th width="20%">Paraf</th>
                   </tr>
			              
			
			         
                             <?php
					$bulan= date('m');
					$tahun=date('Y');
					$blth=date('m');
                	$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
					<?php 
					$absen = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM absensi WHERE idguru='$idu' AND blth='$bulan' GROUP BY tanggal")); 
					$tg=date('d',strtotime($absen['tanggal']));
					$tanggale=date('m-Y',strtotime($absen['tanggal']));
					?>
                   <?php
					$date1 = date("D",strtotime("$tahun-$bulan-$i"));
					?>
					<tr>
                    <td  style="text-align:center">
                    <?php if($date1=='Sun')	{ ?>				
					<b style="color:red"><?= $i ?></b>
					<?php }else{ ?>
					<?= $i ?>
					<?php } ?>
					 <?php if($tg==$i)	{ ?>
					<td style="text-align:center"><?= $i ?>-<?= $tanggale ?></td>
						<td style="text-align:center"><?= $absen['jam_masuk'] ?></td>
					<td style="text-align:center"><?= $absen['ket'] ?></td>
				    <td></td>
					<td></td>
					<?php }else{ ?>
					<td style="text-align:center"><?= $i ?>-<?= date('m') ?>-<?= date('Y') ?></td>
					<td></td>
					<td style="text-align:center">X</td>
					<td style="text-align:center;color:red">Libur / Tidak ada Jadwal</td>
					<td></td>
					 <?php } ?>
					</tr>
                        <?php } ?>
						    
								
            </table>
			
			<br>
			<table width='100%'>
					<tr>
					<td width='50px'></td>
						<td>
							 <br/>
							<br/>
							<br/>
							<br/>
							<br/>
							
							<br/>
							
						</td>
						<td width='475px'></td>
						<td>
							<?= $setting['kecamatan'] ?>, <?php echo date("t",time());; ?> <?= $bulane['ket'] ?> <?= date('Y') ?><br/>
							Kepala Sekolah<br/>
							<br/>
							<br/>
							<br/>
							
							<u><?= $setting['kepsek'] ?></u><br/>
							NIP. <?= $setting['nip'] ?>
						</td>
					</tr>
				</table>
</div>