<html lang="en">
	<script type="text/javascript" charset="utf-8" id="zm-extension" src="<?php echo base_url('assets/cetak/jquery/webrtc-patch.js'); ?>"></script>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="UTF-8">
    <title>Daftar Hadir</title>
    <link rel="stylesheet" href="<?php echo base_url('assets/cetak/cetak.css'); ?>">
	<script src="<?php echo base_url('assets/cetak/jquery/jquery-3.js'); ?>"></script>
	<script src="<?php echo base_url('assets/cetak/jquery/jquery-migrate-1.js'); ?>"></script>
	<script src="<?php echo base_url('assets/cetak/jquery/qrcode.js'); ?>"></script>
</head>
<body onload="window.print();" style="font-family: arial;width:100%; margin:0 auto;margin-top:0px; ">
<style>
	.page {
		padding: 1cm;
	}

	td {
		padding: 5px;
	}

	.upper {
		text-transform: uppercase;
	}
</style>
<?php
$tiga=$this->db->query("SELECT * from web_setting where id='1'");
foreach ($tiga->result() as $rt) {
$nama_sekolah=$rt->nama;
$namsek=$rt->nama;
$logo=$rt->logo;
$back=$rt->back;
$tapel=$rt->tapel;
$kop=$rt->kop;
$kepsek = balikin($rt->namakepsek);
$nipkepsek = $rt->nipkepsek;
$kabupaten = $rt->kabupaten;
}
$kodeabsen=$this->input->get('kodeabsen');
$mm=$this->input->get('mm3');
$yy=$this->input->get('yy3');
//$harike3=substr(hari($dd,$mm,$yy),0,3);
?>
	<div class="page">
	<center>
	 <table border="0" width="100%">
     <tr>
    <td rowspan="1" width="100" align="left"><img src="<?php echo base_url('assets/back/'.$logo.'');?>" width="80"></td>
    <td>
	<center>
	<strong class="f12">
	REKAPITULASI ABSENSI<br>
	<?php echo $nama_sekolah;?><br>
	TAHUN : <?php echo $yy;?>
	</strong>
	</center>
	<br>
 </td>
  <tr>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
  </table><br>
  <font size="3">
    <table border="0" width="100%" style="font-size: small;margin-left:0px">
	<tr height="30">
  <td height="30" width="20%">Nama Sekolah</td>
  <td height="30" width="2%">:</td>
  <td height="30" width="45%" ><?php echo $namsek; ?> </td>
  <td height="30" width="1%"></td>

  <td height="30" width="15%" style="margin-left:10px"> Bulan</td>
    <td height="30" width="2%"> : </td>
  <td height="30" width="15%"><?php echo bulan($mm); ?> <?php echo $yy; ?> </td>
  </tr>
  <tr height="30">
  <td height="30" width="20%">Nama Individu</td>
  <td height="30" width="2%">:</td>
  <td height="30" width="45%" >
<?php
$jurusan1=$this->db->query("SELECT * FROM web_siswa WHERE absen='".$kodeabsen."'");
								foreach ($jurusan1->result() as $row1) {
								echo balikin($row1->NM_PEGAWAI);
								}

?>
</td>
  <td height="30" width="1%"></td>

  <td height="30" width="15%" style="margin-left:10px"> Waktu Cetak</td>
    <td height="30" width="2%"> : </td>
  <td height="30" width="15%"><?php echo date("d M Y H:m:s"); ?></td>
  </tr>

  </table>
  </font>

	<table style="border:1px solid black;border-collapse: collapse" width="100%">
  <tr bgcolor="#CCCCCC" height="40">
  <th width="15%" style="font-size: small;text-align: center;border:1px solid black">TANGGAL</th>
  <th width="15%" style="font-size: small;text-align: center;border:1px solid black">HARI</th>
  <th width="15%" style="font-size: small;text-align: center;border:1px solid black">STATUS</th>
  <th width="15%"style="font-size: small;text-align: center;border:1px solid black">DATANG</th>
  <th width="15%" style="font-size: small;text-align: center;border:1px solid black">PULANG</th>
  <th width="15%" style="font-size: small;text-align: center;border:1px solid black">KETERANGAN</th>
  </tr>
	<?php
	$j=$this->db->query("SELECT COUNT(*) as tes FROM web_siswa WHERE 1");
	foreach ($j->result() as $rsj) {
	$jml_peg=$rsj->tes;
	}
	$jam_masuk=jam_to_dec('07:00:00');
	$tot_hari=jml_hari($mm,$yy);
	for ($i=1;$i<=$tot_hari;$i++) {
	$aa=str_pad($i,2,'0',STR_PAD_LEFT);
	?>
	<tr height=30px>
	<td style='font-size: small; border:1px solid black' align='center'>&nbsp;<?php echo $tg="$aa-$mm-$yy";?></td>
	<td style='font-size: small; border:1px solid black'>&nbsp;<?php echo $hari=hari($i,$mm,$yy);?></td>
	<?php
									$skrg="$yy-$mm-$aa";
									$cek1=$this->db->query("SELECT status,jam,ket FROM web_absen WHERE tgl='$skrg' AND nip='$kodeabsen' AND status=1");
									$hasilcek1=$cek1->num_rows();
									$jamcek1='';
									$jamcek2='';
									$ketcek1='';
									$harike3=substr(hari($aa,$mm,$yy),0,3);
									$siswa = $this->db->query("SELECT * FROM web_siswa WHERE absen='$kodeabsen' ORDER BY NM_PEGAWAI asc");
									foreach ($siswa->result() as $rssis) {
										$cekhari=$rssis->$harike3;
									}
									//cekliburan
									$cekijin=$this->db->query("SELECT * FROM web_ijin WHERE tgl='$skrg' AND absen='$kodeabsen'");
									$hasilijin=$cekijin->num_rows();
									$ceklibur=$this->db->query("SELECT * FROM web_libur WHERE tgl='$skrg'");
									$hasillibur=$ceklibur->num_rows();
									if ($hasillibur ==0) {
										if ($cekhari==6){
											$kehadiran='LIBUR SEKOLAH';
										} elseif ($hasilijin != 0){
											foreach ($cekijin->result() as $rsijin) {
												$hijin=$rsijin->status;
												$ketcek1=$rsijin->ket;
												$cekst=$this->db->query("SELECT * FROM web_status WHERE kd_jenis='".$hijin."'");
												foreach ($cekst->result() as $rsst) {
													$kehadiran=$rsst->status;
												}
											}
										} else {
											if ($hasilcek1 !=0) {

												$kehadiran='<b>HADIR</b>';
												$cek2=$this->db->query("SELECT status,jam,ket FROM web_absen WHERE tgl='$skrg' AND nip='$kodeabsen' AND status=2");
												foreach ($cek2->result() as $rscek2) {
													$jamcek2=$rscek2->jam;
												}
												foreach ($cek1->result() as $rscek1) {
													$jamcek1=$rscek1->jam;
													$ketcek1=$rscek1->ket;
												}
											} else {
												$cek3=$this->db->query("SELECT status,jam,ket FROM web_absen WHERE tgl='$skrg' AND nip='$kodeabsen' AND status>=3");
												$hasilcek3=$cek3->num_rows();
												//echo "SELECT status,jam,ket FROM web_absen WHERE tgl='$skrg' AND nip='$kodeabsen' AND status>=3"."<br>";
												if ($hasilcek3 !=0) {
													foreach ($cek3->result() as $rscek3) {
													$status3=$rscek3->status;
													$ketcek1=$rscek3->ket;
													}
													$cekst=$this->db->query("SELECT * FROM web_status WHERE kd_jenis='".$status3."'");
													foreach ($cekst->result() as $rsst) {
														$statusku=$rsst->status;
													}
													$kehadiran='<b>'.strtoupper($statusku).'</b>';
												} else {
													$kehadiran='TIDAK HADIR';
												}
											}
										}
									} else {
										$kehadiran='LIBUR NASIONAL';
										foreach ($ceklibur->result() as $rslibur) {
											$ketcek1=$rslibur->ket;
										}
									}
									?>

	<td style='font-size: small; border:1px solid black'>&nbsp; <?php echo $kehadiran;?> </td>
	<td style='font-size: small; border:1px solid black' align='center'>&nbsp;<?php echo $jamcek1;?></td>
	<td style='font-size: small; border:1px solid black' align='center'>&nbsp;<?php echo $jamcek2;?></td>
	<td style='font-size: small; border:1px solid black'>&nbsp;<?php echo $ketcek1;?></td>

	</tr>
	<?php }?>
	</table>
	</center>
</div>
</body>
</html>
