<?php
	include "koneksi.php";
	//$jenis_cuti=mysqli_real_escape_string($conn,$_POST["jenis_cuti"]);
	//$id=mysqli_real_escape_string($conn,$_GET["id"]);
	//$tanggalmasuk=$_POST["tanggalmasuk"];
	//$tanggalhariini=$_POST["tanggalhariini"];
	

$q = "SELECT * FROM data_karyawan"; 
$res = mysqli_query($conn, $q);
while ($row = mysqli_fetch_array($res))
{
	$id=$row["id"];
	$tanggallahir=$row["tanggal_lahir"];
	$tanggalhariini=date('m-d');
	//$tanggal
	
	echo "id : " . $id . "</br>";
	echo "jeniscuti : " . $tanggallahir . "</br>";
	//echo "tanggal hari ini : " .$tanggalhariini . "</br>";
	
	
	//echo $row['tanggal_akhir_cuti'];
	if ($tanggallahir <== $tanggalhariini)
    {
		
	    //echo 'tanggal sama';
	    //header("location:tes.php?p=2");
        $qStatus="UPDATE data_karyawan SET sisa_cuti_tahun = '12' WHERE id = $id ";
		$update = mysqli_query($conn, $qStatus);
			//echo "query : " . $q;
			if (! $update)
			{
				echo "gagal  update";
				//header("location:batascuti.php?p=2");
			}
			else if ($update)
			{
				mysqli_query($conn,$qStatus);
				echo "cutinya sudah habis. berhasil update";
				//header("location:batascuti.php?p=1");
			}
         
         //echo $q;
    }
    else
    {
	    echo 'Belum habis masa cutinya' . "</br>";
	    //header("location:tes.php?p=3");
    }
	echo "</br>";
}





//echo 'tanggal hari ini dari sebelah =';
//echo $tanggalhariini.'......';
//echo 'tanggal hari masuk =';
//echo $tanggalmasuk.'.......';













	////$q="UPDATE merk_sparepart SET nama='$nama' WHERE id='$id'";
	////mysqli_query($conn,$q);
	////header("location:merksparepart.php?p=1");
	
	//// if (empty($nama))
	//// {
	//// 	//header("location:updategajikaryawan.php?p=1&id=".$id);
	//// }
	//// else
	//// {
		//$q="SELECT * FROM jenis_cuti WHERE id=$id"; 
		//$res=mysqli_query($conn,$q);
		//echo "query : " .$q;
		
		//if ($res)
		{
			////$q="INSERT INTO kendaraan (nama,id_merkMotor) VALUES ('$nama','$id')";
			//$q="UPDATE jenis_cuti SET batas_cuti='$batas_cuti' WHERE id=$id";
			////$update = $conn->query($q);
			//$update = mysqli_query($conn, $q);
			//echo "query : " . $q;
			//if (! $update)
			{
				//echo "gagal  update";
				//header("location:batascuti.php?p=2");
			}
			//else if ($update)
			{
				
				//echo "berhasil update";
				//header("location:batascuti.php?p=1");
			}
			////header("location:updategajikaryawan.php?p=2");
		}
		//else
		{
			//echo "gagal update ";
		}
		
	////}
?>