<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;
}
$semester=$this->input->get('semester');
if ($semester == 1){
	$keterangan ="Gasal";
	$awalbln=7;
	$akhirbln=12;
} elseif ($semester == 2){
	$keterangan ="Genap";
	$awalbln=1;
	$akhirbln=6;
}
//$mm=$this->input->get('mm2');
$yy=$this->input->get('yy2');
//$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 SEMESTER<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 $keterangan; ?> <?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="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">TEPAT</th>
  <th width="15%"style="font-size: small;text-align: center;border:1px solid black">TERLAMBAT</th>
  <th width="15%" style="font-size: small;text-align: center;border:1px solid black">TIDAK HADIR</th>
  <th width="15%" style="font-size: small;text-align: center;border:1px solid black">RATA-RATA MASUK</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;
	}
	for ($j=$awalbln;$j<=$akhirbln;$j++) {
		$mm=$j;
	$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 $i."-".$mm."-".$yy;?></td>
	<td style='font-size: small; border:1px solid black'>&nbsp;<?php echo $hari=hari($i,$mm,$yy);?></td>
	<td style='font-size: small; border:1px solid black' align='center'>&nbsp; <?
	$jam_tepat=array();
	$jam_terlambat=array();
	$jam_pulang=array();

	$res=$this->db->query("SELECT jam,status FROM web_absen WHERE tgl='$yy-$mm-$aa'");
	  foreach ($res->result() as $ros) {
		 if ($ros->status==1) {
			$cek=jam_to_dec($ros->jam);
			  if ($cek>$jam_masuk) $jam_terlambat[]=jam_to_dec($ros->jam);
				else $jam_tepat[]=jam_to_dec($ros->jam);
		 } else   $jam_pulang[]=jam_to_dec($ros->jam);
	  }
	  echo $tepat=sizeof($jam_tepat);
	  $jml_masuk=sizeof($jam_tepat)+sizeof($jam_terlambat);
	?> </td>
	<td style='font-size: small; border:1px solid black' align='center'>&nbsp;<?php echo $telat=sizeof($jam_terlambat)?></td>
	<td style='font-size: small; border:1px solid black' align='center'>&nbsp;<?php echo $tidak=(!$jml_masuk) ? "-": $jml_peg-$jml_masuk;?></td>
	<td style='font-size: small; border:1px solid black' align='center'>&nbsp; <?php
	if ($jml_masuk) {
	  $a=@ceil((array_sum($jam_tepat)+array_sum($jam_terlambat))/(sizeof($jam_tepat)+sizeof($jam_terlambat)));
	  echo $jam1=dec_to_jam($a);
	} else echo $jam1='-';
	?></td>

	</tr>
	<?php
} }

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