<page backbottom="5" backtop="0">
<page_footer>
<?php
date_default_timezone_set('Asia/Jakarta');
$bulan=$_GET['bulan'];
if($bulan=="01"){
	$tampil_bulan="Januari";
}elseif($bulan=="02"){
	$tampil_bulan="Februari";
}elseif($bulan=="03"){
	$tampil_bulan="Maret";
}elseif($bulan=="04"){
	$tampil_bulan="April";
}elseif($bulan=="05"){
	$tampil_bulan="Mei";
}elseif($bulan=="06"){
	$tampil_bulan="Juni";
}elseif($bulan=="07"){
	$tampil_bulan="Juli";
}elseif($bulan=="08"){
	$tampil_bulan="Agustus";
}elseif($bulan=="09"){
	$tampil_bulan="September";
}elseif($bulan=="10"){
	$tampil_bulan="Oktober";
}elseif($bulan=="11"){
	$tampil_bulan="November";
}elseif($bulan=="12"){
	$tampil_bulan="Desember";
}else{
	$tampil_bulan=" ";
}



?>	
	
<span style="font-size:6pt"><i>Rekap Absensi Bulan <?php echo $tampil_bulan." ".$_GET['tahun'];?>- Halaman [[page_cu]] / [[page_nb]] - Dicetak Pada Tanggal : <?php echo date("d/m/Y");?> - [ SIAbsensiPTK Ver.1Rev2 - NBApps ]</i></span>

  </page_footer>
<?php

include('class/mysql_crud.php');
$db_finger=new Database();
$db_finger->connect();
?>


<p align=center><b>DATA SCAN ABSENSI FINGERPRINT<br><?php echo strtoupper($tampil_bulan)." ".$_GET['tahun'];?></b><hr></p>

<?php

$blnsekarang="$_GET[tahun]-$_GET[bulan]";
$db_finger->select('libur','*','','left(tanggal_awal,7)="'.$blnsekarang.'"','','');
$cek_libur = $db_finger->numRows();
$indexlibur=$cek_libur-1;
$data_libur = $db_finger->getResult();
$cd=0;

//print_r($data_libur);	
$jml_hari=@cal_days_in_month(CAL_GREGORIAN, $_GET['bulan'], $_GET['tahun']);
$jmbaris1=ceil($jml_hari/2);
?>

<table border="1" cellpadding="2" cellspacing="0">
<thead>
<tr>
<th rowspan="2" width=20 align=center><span style="font-size:8pt">No.</span></th>
<th rowspan="2" width=20 align=center><span style="font-size:8pt">ID</span></th>
<th rowspan="2" width=120 align=center><span style="font-size:8pt">Nama</span></th>
<th rowspan="2" width=30 align=center><span style="font-size:8pt">Scan</span></th>
<th colspan="<?php echo $jml_hari;?>"  align=center><span style="font-size:8pt">TANGGAL</span></th>

</tr>
<tr>
<?php
for($x=1;$x<=$jml_hari;$x++){
if($x<10){
$tanggal="0".$x;
}else{
$tanggal=$x;	
}	
$d = date("l", mktime(0, 0, 0, $_GET['bulan'], $tanggal, $_GET['tahun']));
$tgl="$_GET[tahun]-$_GET[bulan]-$tanggal";
?>
<th <?php if($d=="Sunday"){echo"bgcolor=red";}elseif($cek_libur>0 and($tgl>=$data_libur[$cd]['tanggal_awal'] and $tgl<=$data_libur[$cd]['tanggal_akhir'])){echo"bgcolor=red";$cd++;  }?> width="25" align="center" height="25"><span style="font-size:8pt"><?php echo $tanggal; ?></span></th>
<?php	
}
?>

</tr>
</thead>
<tbody>

<?php
if(!isset($_GET['id'])){
$db_finger->select('ptk','*','','','pin asc','');
}else{
	$kunci=$_GET['id'];
$db_finger->select('ptk','*','','pin="'.$kunci.'"','pin asc','');	
}
$data_ptk = $db_finger->getResult();
$no=1;
foreach($data_ptk as $d_data_ptk){
$cdin=0;	
$cdout=0;
$cdjam=0;	
$db_finger->select('khusus','*','','id_ptk="'.$data_ptk['pin'].'"','');
$data_khusus=$db_finger->getResult();
$jkhusus=$db_finger->numRows();
?>
<tr>
<td rowspan="3" align=center><span style="font-size:8pt"><?php echo $no; ?></span></td>
<td rowspan="3" align=center><span style="font-size:8pt"><?php echo $d_data_ptk['pin'];?></span></td>
<td rowspan="3"><span style="font-size:8pt"><?php echo $d_data_ptk['nama'];?></span></td>
<td><span style="font-size:8pt">IN</span></td>
<?php
for($x=1;$x<=$jml_hari;$x++){
if($x<10){
$tanggal="0".$x;
}else{
$tanggal=$x;	
}
$d = date("l", mktime(0, 0, 0, $_GET['bulan'], $tanggal, $_GET['tahun']));
$tgl="$_GET[tahun]-$_GET[bulan]-$tanggal";
$cektanggal="$_GET[tahun]-$_GET[bulan]-$tanggal";
$db_finger->select('absensi_log','*',NULL,'pin="'.$d_data_ptk['pin'].'"'.'and left(scan_date,10)="'.$cektanggal.'"','scan_date asc','0,1');
$data_log=$db_finger->getResult();
$res = $db_finger->getResult(); 
$log="";
?>
<td align="center" <?php if($d=="Sunday"){echo"bgcolor=red";}elseif($cek_libur>0 and $tgl>=$data_libur[$cdin]['tanggal_awal'] and $tgl<=$data_libur[$cdin]['tanggal_akhir']){echo"bgcolor=red"; $cdin++; }else{
if(@$data_log[0]['scan_date']==0){
$log="-";
$efektif[$tanggal]=1;	
$tidak[$tanggal]=1;
$scan[$tanggal]=0;
}else{
$efektif[$tanggal]=1;
$scan[$tanggal]=1;
$tidak[$tanggal]=0;
$log=substr($data_log[0]['scan_date'],11,5);
}	
}
?>><?php $jin[$tanggal]=$log;?><span style="font-size:8pt"><?php echo $log; ?></span></td>
<?php	
}
?>
<?php
$jml_efektif=array_sum($efektif);
$jml_scan=array_sum($scan);
$jml_tidak=array_sum($tidak);
$indataefektif[$d_data_ptk['pin']]=$jml_efektif;
$indatascan[$d_data_ptk['pin']]=$jml_scan;
$indatatidak[$d_data_ptk['pin']]=$jml_tidak;

?>
</tr>



<tr bgcolor="#E5E5E5">
<td><span style="font-size:8pt">OUT</span></td>
<?php
for($x=1;$x<=$jml_hari;$x++){
if($x<10){
$tanggal="0".$x;
}else{
$tanggal=$x;	
}
$d = date("l", mktime(0, 0, 0, $_GET['bulan'], $tanggal, $_GET['tahun']));
$tgl="$_GET[tahun]-$_GET[bulan]-$tanggal";
$cektanggal="$_GET[tahun]-$_GET[bulan]-$tanggal";
$db_finger->select('absensi_log','*',NULL,'pin="'.$d_data_ptk['pin'].'"'.'and left(scan_date,10)="'.$cektanggal.'"','scan_date desc','');
$data_log=$db_finger->getResult();
$jm_log=$db_finger->numRows();
$res = $db_finger->getResult(); 
$log="";
?>
<td align="center" <?php if($d=="Sunday"){echo"bgcolor=red";}elseif($cek_libur>0 and $tgl>=$data_libur[$cdout]['tanggal_awal'] and $tgl<=$data_libur[$cdout]['tanggal_akhir']){echo"bgcolor=red"; $cdout++; }else{
if(@$data_log[0]['scan_date']==0 or $jm_log<=1){
$log="-";
$efektif[$tanggal]=1;	
$tidak[$tanggal]=1;
$scan[$tanggal]=0;
}else{
$efektif[$tanggal]=1;
$scan[$tanggal]=1;
$tidak[$tanggal]=0;
$log=substr($data_log[0]['scan_date'],11,5);
}	
}
?>><?php $jout[$tanggal]=$log;?><span style="font-size:8pt"><?php echo $log;?></span></td>
<?php	
}
?>
<?php
$jml_efektif=array_sum($efektif);
$jml_scan=array_sum($scan);
$jml_tidak=array_sum($tidak);
$outdataefektif[$d_data_ptk['pin']]=$jml_efektif;
$outdatascan[$d_data_ptk['pin']]=$jml_scan;
$outdatatidak[$d_data_ptk['pin']]=$jml_tidak;

?>
</tr>


<tr bgcolor="#CCCCCC">
<td><span style="font-size:8pt">Jam Kerja</span></td>
<?php
for($x=1;$x<=$jml_hari;$x++){
if($x<10){
$tanggal="0".$x;
}else{
$tanggal=$x;	
}
$d = date("l", mktime(0, 0, 0, $_GET['bulan'], $tanggal, $_GET['tahun']));
$tgl="$_GET[tahun]-$_GET[bulan]-$tanggal";
$cektanggal="$_GET[tahun]-$_GET[bulan]-$tanggal";
$db_finger->select('absensi_log','*',NULL,'pin="'.$d_data_ptk['pin'].'"'.'and left(scan_date,10)="'.$cektanggal.'"','scan_date desc','');
$data_log=$db_finger->getResult();
$jm_log=$db_finger->numRows();
$res = $db_finger->getResult(); 
$log="";





?>
<td align="center" 
<?php if($d=="Sunday"){
	echo"bgcolor=red";
	}
	elseif($cek_libur>0 and $tgl>=$data_libur[$cdjam]['tanggal_awal'] and $tgl<=$data_libur[$cdjam]['tanggal_akhir']){
		echo"bgcolor=red"; 
		$cdjam++;
		
	}else{
		
	echo"bgcolor=#ffffff";


	}
?>><span style="font-size:8pt"><?php if($jout[$tanggal]==""){echo"";}else{
if($jin[$tanggal]=="-" and $jout[$tanggal]=="-"){
$time1 = '00:00';
$time2 = '00:00';	
}elseif($jin[$tanggal]!="-" and $jout[$tanggal]=="-"){
$time1 = '07:00';
$time2 = '10:00';	
}else{	
$time1 = $jin[$tanggal];
$time2 = $jout[$tanggal];
}
$time1_unix = strtotime(date('Y-m-d').' '.$time1.':00');
$time2_unix = strtotime(date('Y-m-d').' '.$time2.':00');
$begin_day_unix = strtotime(date('Y-m-d').' 00:00:00');
$jumlah_time = date('H:i', ($time2_unix - ($time1_unix - $begin_day_unix)));
$ex_jam=explode(":",$jumlah_time);
$jam[]=$ex_jam[0];
$menit[]=$ex_jam[1];


echo $jumlah_time; }?></span></td>
<?php	
}
?>
</tr>

<?php
$jm_menit=array_sum($menit);
$jumlahjammenit=$jm_menit/60;
$jm_jammenit=explode(".",$jumlahjammenit);
$jumlah_jam=array_sum($jam)+$jm_jammenit[0];
$jumlah_menit=ceil(("0.".$jm_jammenit[1])*60);
$jam_kerja=$jumlah_jam.":".$jumlah_menit;
$jumlahjamkerja[$d_data_ptk['pin']]=$jam_kerja;
//echo $jam_kerja;
unset($jam);
unset($menit);
?>



<?php
$no++;}

?>
</tbody>
</table>
<BR><BR><BR>
<table border=1 cellpadding=0 cellspacing=1>
<tr>
<th width=15 align=center>No.</th>
<th>Tanggal Awal</th>
<th>Tanggal Akhir</th>
<th>Keterangan</th>
</tr>
<?php
$db_finger->select('libur','*','','left(tanggal_awal,7)="'.$blnsekarang.'" and keterangan<>""','','');
$dl=$db_finger->getResult();
$nomor=1;
foreach($dl as $d_data_libur){
	
	?>
	
	
<tr>
<td width=15 align=center><?php echo $nomor;?></td>
<td><?php echo $d_data_libur['tanggal_awal'];?></td>
<td><?php echo $d_data_libur['tanggal_akhir'];?></td>
<td><?php echo $d_data_libur['keterangan'];?></td>
</tr>

<?php	
$nomor++;
}
?>
</table>


</page>




<page backbottom="5" backtop="0" orientation="P">
<page_footer>
<?php
date_default_timezone_set('Asia/Jakarta');
$bulan=$_GET['bulan'];
if($bulan=="01"){
	$tampil_bulan="Januari";
}elseif($bulan=="02"){
	$tampil_bulan="Februari";
}elseif($bulan=="03"){
	$tampil_bulan="Maret";
}elseif($bulan=="04"){
	$tampil_bulan="April";
}elseif($bulan=="05"){
	$tampil_bulan="Mei";
}elseif($bulan=="06"){
	$tampil_bulan="Juni";
}elseif($bulan=="07"){
	$tampil_bulan="Juli";
}elseif($bulan=="08"){
	$tampil_bulan="Agustus";
}elseif($bulan=="09"){
	$tampil_bulan="September";
}elseif($bulan=="10"){
	$tampil_bulan="Oktober";
}elseif($bulan=="11"){
	$tampil_bulan="November";
}elseif($bulan=="12"){
	$tampil_bulan="Desember";
}else{
	$tampil_bulan=" ";
}



?>	
	
	
<span style="font-size:6pt"><i>Rekap Absensi Bulan <?php echo $tampil_bulan." ".$_GET['tahun'];?>- Halaman [[page_cu]] / [[page_nb]] - Dicetak Pada Tanggal : <?php echo date("d/m/Y");?> - [ SIAbsensiPTK Ver.1Rev2 - NBApps ]</i></span>
	
    
  </page_footer>
<?php

//include('class/mysql_crud.php');
//$db_finger=new Database();
//$db_finger->connect();
?>
<p align=center><b>REKAP ABSENSI FINGERPRINT<br><?php echo strtoupper($tampil_bulan)." ".$_GET['tahun'];?></b><hr></p>
<?php

$blnsekarang="$_GET[tahun]-$_GET[bulan]";
$db_finger->select('libur','*','','left(tanggal_awal,7)="'.$blnsekarang.'"','','');
$cek_libur = $db_finger->numRows();
$indexlibur=$cek_libur-1;
$data_libur = $db_finger->getResult();
$cd=0;

//print_r($data_libur);	
$jml_hari=@cal_days_in_month(CAL_GREGORIAN, $_GET['bulan'], $_GET['tahun']);
$jmbaris1=ceil($jml_hari/2);
?>
<table border="1" cellpadding="2" cellspacing="0">
<thead>
<tr>
<th width=30 height=20 align=center><span style="font-size:8pt">No.</span></th>
<th width=30 align=center><span style="font-size:8pt">ID</span></th>
<th width=200 align=center><span style="font-size:8pt">Nama</span></th>
<th width=40 align=center><span style="font-size:8pt">Scan</span></th>

<th width=60 align=center><span style="font-size:8pt">Jumlah Hari Efektif</span></th>
<th align=center  width=70 ><span style="font-size:8pt">Jumlah Scan</span></th>
<th align=center width=70 ><span style="font-size:8pt">Jumlah Tidak Scan</span></th>
<th align=center width=70 ><span style="font-size:8pt">Persentase</span></th>
<th align=center width=70 ><span style="font-size:8pt">Jumlah Jam Kerja</span></th>
<th align=center width=70 ><span style="font-size:8pt">Validasi</span></th>
</tr>
</thead>
<tbody>

<?php

if(!isset($_GET['id'])){
$db_finger->select('ptk','*','','','pin asc','');
}else{
	$kunci=$_GET['id'];
$db_finger->select('ptk','*','','pin="'.$kunci.'"','pin asc','');	
}
$data_ptk = $db_finger->getResult();
$no=1;
foreach($data_ptk as $d_data_ptk){
$cdin=0;	
$cdout=0;	
$db_finger->select('khusus','*','','id_ptk="'.$d_data_ptk['pin'].'"','');
$data_khusus=$db_finger->getResult();
$jkhusus=$db_finger->numRows();
?>
<?php $jml_persenout=ceil($outdatascan[$d_data_ptk['pin']]/$outdataefektif[$d_data_ptk['pin']]*100); ?>
<tr>
<td rowspan="2" align=center ><span style="font-size:8pt"><?php echo $no; ?></span></td>
<td rowspan="2" align=center ><span style="font-size:8pt"><?php echo $d_data_ptk['pin'];?></span></td>
<td rowspan="2"><span style="font-size:8pt"><?php echo $d_data_ptk['nama'];?></span></td>
<td><span style="font-size:8pt">IN</span></td>
<td align=center ><span style="font-size:8pt"><?php echo $indataefektif[$d_data_ptk['pin']]; ?></span></td>
<td align=center ><span style="font-size:8pt"><?php echo $indatascan[$d_data_ptk['pin']]; ?></span></td>
<td align=center ><span style="font-size:8pt"><?php echo $indatatidak[$d_data_ptk['pin']]; ?></span></td>
<td align=center ><span style="font-size:8pt"><?php $jml_persen=ceil($indatascan[$d_data_ptk['pin']]/$indataefektif[$d_data_ptk['pin']]*100); echo "$jml_persen %"; ?></span></td>
<td rowspan="2" align=center><?php echo $jumlahjamkerja[$d_data_ptk['pin']];?></td>
<td rowspan="2" align=center><qrcode value="<?php echo $d_data_ptk['pin']."-".$d_data_ptk['nama']."-".$jml_persen."-".$jml_persenout."-".$jumlahjamkerja[$d_data_ptk['pin']]; ?>" ec="H" style="width: 15mm; background-color: white; color: black;"></qrcode></td>
</tr>
<tr bgcolor="#E5E5E5">
<td><span style="font-size:8pt">OUT</span></td>
<td align=center ><span style="font-size:8pt"><?php echo $outdataefektif[$d_data_ptk['pin']]; ?></span></td>
<td align=center ><span style="font-size:8pt"><?php echo $outdatascan[$d_data_ptk['pin']]; ?></span></td>
<td align=center ><span style="font-size:8pt"><?php echo $outdatatidak[$d_data_ptk['pin']]; ?></span></td>
<td align=center ><span style="font-size:8pt"><?php $jml_persen=ceil($outdatascan[$d_data_ptk['pin']]/$outdataefektif[$d_data_ptk['pin']]*100); echo "$jml_persen %"; ?></span></td>
</tr>
<?php
$no++;}

?>
</tbody>
</table>

</page>
