<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;
}

//$dd=$this->input->get('dd');
$mm=$this->input->get('mm3');
$yy=$this->input->get('yy3');
$jmlhbulan=strlen($mm);
if ($jmlhbulan ==1) {
	$mm='0'.$mm;
}
//$harike3=substr(hari($dd,$mm,$yy),0,3);
$j_hari = $this->db->query("SELECT count(distinct tgl) as tes FROM web_absen WHERE date_format(tgl,'%m-%Y')='$mm-$yy'");
foreach ($j_hari->result() as $jhari) {
$jml_hari=$jhari->tes;
}
$jam_masuk=jam_to_dec('07:00:00');
$carikelas="SELECT * FROM web_kelas ORDER BY urut ASC";
$kelas = $this->db->query($carikelas);
foreach ($kelas->result() as $rs) {
	$namakelas=$rs->nama;
	$kodekelas=$rs->kode;
	$halaman=0;
	$ceksiswa = $this->db->query("SELECT * FROM web_siswa WHERE KD_JENIS_KETENAGAAN='$kodekelas' ORDER BY NM_PEGAWAI asc");
	$jumlahsiswa=$ceksiswa->num_rows();
	$jmlperhal=25;
	$mulai=0;
	$nomer=0;
	if ($jumlahsiswa >=$jmlperhal) {
	//$halaman=round($jumlahsiswa/$jmlperhal,0,PHP_ROUND_HALF_EVEN);
	$halaman=ceil($jumlahsiswa/$jmlperhal);
	//echo "iki halaman = ".$halaman;
	for ($hal=1;$hal<=$halaman;$hal++) {
	?>
	<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">
	REKAP 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%">Grup</td>
  <td height="30" width="2%">:</td>
  <td height="30" width="45%" ><?php echo $namakelas; ?> </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>
  </table>
  </font>

   <table style="border:1px solid black;border-collapse: collapse" width="100%">
	<tr bgcolor="#CCCCCC" height="40">
	<th width="5%" rowspan="2" style="font-size: small;text-align: center;border:1px solid black">No.</th>
	<th width="35%" rowspan="2" style="font-size: small;text-align: center;border:1px solid black">NAMA</th>
	<th width="30%" colspan="3" style="font-size: small;text-align: center;border:1px solid black">HADIR</th>
	<th width="30%" colspan="5" style="font-size: small;text-align: center;border:1px solid black">TIDAK HADIR</th>
	</tr>
	<tr bgcolor="#CCCCCC" height="40">
	<th width="10%" style="font-size: small;text-align: center;border:1px solid black">TP</th>
	<th width="10%" style="font-size: small;text-align: center;border:1px solid black">TL</th>
	<th width="10%" style="font-size: small;text-align: center;border:1px solid black">JML</th>
	<th width="8%"style="font-size: small;text-align: center;border:1px solid black">S</th>
	<th width="8%"style="font-size: small;text-align: center;border:1px solid black">I</th>
	<th width="8%"style="font-size: small;text-align: center;border:1px solid black">WFH</th>
  <th width="8%"style="font-size: small;text-align: center;border:1px solid black">A</th>
	<th width="8%"style="font-size: small;text-align: center;border:1px solid black">JML</th>
  </tr>
	<?php
	//$nomer=0;
	$lim=$hal*$jmlperhal;
	$siswa = $this->db->query("SELECT * FROM web_siswa WHERE KD_JENIS_KETENAGAAN='$kodekelas' ORDER BY NM_PEGAWAI asc LIMIT ".$mulai.",".$jmlperhal."");
	foreach ($siswa->result() as $rssis) {
		$nomer++;
		$namasiswa=balikin($rssis->NM_PEGAWAI);
		$kodeabsen=$rssis->absen;
		$jam_tepat=array();
		$jam_terlambat=array();
		$jam_pulang=array();
		$sakit=0;
		$ijin=0;
		$tepat=0;
		$telat=0;
		$wfh=0;
		$cek1=$this->db->query("SELECT jam,status,ket FROM web_absen WHERE nip='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy'");
		foreach ($cek1->result() as $rscek1) {
				if ($rscek1->status==1) {
					if($rscek1->ket=="tepat waktu") {
						$tepat=$tepat+1;
					} else {
						$telat=$telat+1;
					}
				} elseif ($rscek1->status==3) {
					$sakit=$sakit+1;
				} elseif ($rscek1->status==4) {
					$ijin=$ijin+1;
				} elseif ($rscek1->status==5) {
					$ijin=$ijin+1;
				} elseif ($rscek1->status==6) {
					$ijin=$ijin+1;
				} elseif ($rscek1->status==7) {
					$wfh=$wfh+1;
				} else {
					$jam_pulang[]=jam_to_dec($rscek1->jam);
				}
			}
			$ceksakit=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status='3'");
			$sakit=$sakit+($ceksakit->num_rows());
			$cekijin4=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status in ('4','5','6')");
			$ijin4=$cekijin4->num_rows();
			$ijin=$ijin+$ijin4;
			$cekijin7=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status='7'");
			$ijin7=$cekijin7->num_rows();
			$wfh=$wfh+$ijin7;
		?>
		<tr height=30px>
		<td style='font-size: small; border:1px solid black' align='center'>&nbsp;<?php echo $nomer;?>.</td>
		<td style='font-size: small;border:1px solid black'><?php echo $namasiswa;?></td>
		<td style='font-size: small;border:1px solid black' align='center'>&nbsp;<?php echo $tepat;?></td>
		<td style='font-size: small;border:1px solid black' align='center'>&nbsp;<?php echo $telat;?></td>
		<td style='border:1px solid black' align='center'>&nbsp;<b><?php echo $tepat+$telat;?></b></td>
		<td style='border:1px solid black' align='center'>&nbsp;<?php echo $sakit;?></td>
		<td style='border:1px solid black' align='center'>&nbsp;<?php echo $ijin;?></td>
		<td style='border:1px solid black' align='center'>&nbsp;<?php echo $wfh;?></td>
		<td style='border:1px solid black' align='center'>&nbsp;<b><?php echo $alpha=$jml_hari-$tepat-$telat-$sakit-$ijin-$wfh;?></b></td>
		<td style='border:1px solid black' align='center'>&nbsp;<b><?php echo $tidak=$jml_hari-$tepat-$telat;?></b></td>
		</tr>

	<?php }?>
	</table>
	</center>
</div>

	<?php
	$mulai=$mulai+$jmlperhal;
	}} else {?>
	<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">
	REKAP 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%">Grup</td>
  <td height="30" width="2%">:</td>
  <td height="30" width="45%" ><?php echo $namakelas; ?> </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>
  </table>
  </font>

  <table style="border:1px solid black;border-collapse: collapse" width="100%">
	<tr bgcolor="#CCCCCC" height="40">
	<th width="5%" rowspan="2" style="font-size: small;text-align: center;border:1px solid black">No.</th>
	<th width="35%" rowspan="2" style="font-size: small;text-align: center;border:1px solid black">NAMA</th>
	<th width="30%" colspan="3" style="font-size: small;text-align: center;border:1px solid black">HADIR</th>
	<th width="30%" colspan="5" style="font-size: small;text-align: center;border:1px solid black">TIDAK HADIR</th>
	</tr>
	<tr bgcolor="#CCCCCC" height="40">
	<th width="10%" style="font-size: small;text-align: center;border:1px solid black">TP</th>
	<th width="10%" style="font-size: small;text-align: center;border:1px solid black">TL</th>
	<th width="10%" style="font-size: small;text-align: center;border:1px solid black">JML</th>
	<th width="8%"style="font-size: small;text-align: center;border:1px solid black">S</th>
	<th width="8%"style="font-size: small;text-align: center;border:1px solid black">I</th>
	<th width="8%"style="font-size: small;text-align: center;border:1px solid black">WFH</th>
    <th width="8%"style="font-size: small;text-align: center;border:1px solid black">A</th>
	<th width="8%"style="font-size: small;text-align: center;border:1px solid black">JML</th>
  </tr>
	<?php
	//$nomer=0;
	$siswa = $this->db->query("SELECT * FROM web_siswa WHERE KD_JENIS_KETENAGAAN='$kodekelas' ORDER BY NM_PEGAWAI asc");
	foreach ($siswa->result() as $rssis) {
		$nomer++;
		$namasiswa=balikin($rssis->NM_PEGAWAI);
		$kodeabsen=$rssis->absen;
		$jam_tepat=array();
		$jam_terlambat=array();
		$jam_pulang=array();
		$sakit=0;
		$ijin=0;
		$tepat=0;
		$telat=0;
		$wfh=0;
		$cek1=$this->db->query("SELECT jam,status,ket FROM web_absen WHERE nip='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy'");
		foreach ($cek1->result() as $rscek1) {
				if ($rscek1->status==1) {
					if($rscek1->ket=="tepat waktu") {
						$tepat=$tepat+1;
					} else {
						$telat=$telat+1;
					}
				} elseif ($rscek1->status==3) {
					$sakit=$sakit+1;
				} elseif ($rscek1->status==4) {
					$ijin=$ijin+1;
				} elseif ($rscek1->status==5) {
					$ijin=$ijin+1;
				} elseif ($rscek1->status==6) {
					$ijin=$ijin+1;
				} elseif ($rscek1->status==7) {
					$wfh=$wfh+1;
				} else {
					$jam_pulang[]=jam_to_dec($rscek1->jam);
				}
			}
			$ceksakit=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status='3'");
			$sakit=$sakit+($ceksakit->num_rows());
			$cekijin4=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status in ('4','5','6')");
			$ijin4=$cekijin4->num_rows();
			$ijin=$ijin+$ijin4;
			$cekijin7=$this->db->query("SELECT * FROM web_ijin WHERE absen='$kodeabsen' AND date_format(tgl,'%m-%Y')='$mm-$yy' AND status='7'");
			$ijin7=$cekijin7->num_rows();
			$wfh=$wfh+$ijin7;
		?>
		<tr height=30px>
		<td style='font-size: small; border:1px solid black' align='center'>&nbsp;<?php echo $nomer;?>.</td>
		<td style='font-size: small;border:1px solid black'><?php echo $namasiswa;?></td>
		<td style='font-size: small;border:1px solid black' align='center'>&nbsp;<?php echo $tepat;?></td>
		<td style='font-size: small;border:1px solid black' align='center'>&nbsp;<?php echo $telat;?></td>
		<td style='border:1px solid black' align='center'>&nbsp;<b><?php echo $tepat+$telat;?></b></td>
		<td style='border:1px solid black' align='center'>&nbsp;<?php echo $sakit;?></td>
		<td style='border:1px solid black' align='center'>&nbsp;<?php echo $ijin;?></td>
		<td style='border:1px solid black' align='center'>&nbsp;<?php echo $wfh;?></td>
		<td style='border:1px solid black' align='center'>&nbsp;<b><?php echo $alpha=$jml_hari-$tepat-$telat-$sakit-$ijin-$wfh;?></b></td>
		<td style='border:1px solid black' align='center'>&nbsp;<b><?php echo $tidak=$jml_hari-$tepat-$telat;?></b></td>
		</tr>

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