<?php
include "koneksi.php";
if (!isset($_SESSION["UserID"])) {
	header("location:login.php?p=3");
}


?>
<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="style.css">
<html>

<head>
	<title> PT. MULTI HIDRACHROME BALIKPAPAN </title>
	<link rel="icon" type="image/png" href="images/mhb.jpeg">
			<?php
			include "part/menu2.php";
			?>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<?php
	include "part/jss.php";
	?>

</head>

<body>

	<div style="width:1280px; height:220px" class="container" >

		
			<div class="alert alert-info" style='background-color:#F8F8FF' href="#">
            <div style="display: block; margin-left: auto; margin-right: auto; width: 1000px;  height:100px;"><img style="width: 1000px;  height:180px;" src="images/hd.jpg"></div>
            <div>
                <center>
                    <h1>PT. MULTI HIDRACHROM BALIKPAPAN</h1>
                </center>
            </div>
            <div>
                <center>
                    <h4 >PROFESIONAL INFORMATION SYSTEM</h4>
                </center>
            </div>
        </div>




			<div class="alert alert-info" style="background-color;" align='center' >
				<h3>Histori Pengambil Cuti</h3>
				<?php
				if (isset($_GET["p"])) {
					$p = $_GET["p"];
					if ($p == "1") {
				?>
						<div class="alert alert-primary">
							Data Karyawan berhasil ditambah!
						</div>
					<?php
					} else if ($p == "2") {
					?>
						<div class="alert alert-primary">
							Data Karyawan berhasil diupdate!
						</div>
					<?php
					} else if ($p == "3") {
					?>
						<div class="alert alert-primary">
							Data Karyawan berhasil dipecat!
						</div>
				<?php
					}
				}
				?>
				<table class="table table-bordered">
					<thead>
						<tr>
							<th>
								NIK 
							</th>
							<th>
								NAMA KARYAWAN
							</th>
							<th>
								JABATAN 
							</th>
							<th>
								DEPARTEMEN 
							</th>
							<th>
								STATUS 
							</th>
							<th>
								TANGGAL MASUK KEMBALI
							</th>
							<th>
								ALAMAT CUTI 
							</th>
							<th>
								SISA CUTI TAHUNAN 
							</th>
							<th>
								JENIS CUTI 
							</th>
							<th>
								PILIHAN 
							</th>
						</tr>
					</thead>
					<tbody>
						<?php
						$q = "SELECT ck.id AS id, ck.alamat AS alamat, ck.sisa_cuti AS sisa_cuti, ck.tanggal_awal_cuti AS tanggal_awal_cuti, ck.tanggal_akhir_cuti AS tanggal_akhir_cuti, ck.tanggal_pengajuan_cuti AS tanggal_pengajuan_cuti, ck.alasan_cuti AS alasan_cuti, ck.tanggal_lapor_cuti AS tanggal_lapor_cuti, ck.id_jenis_cuti AS id_jenis_cuti,
                                      dk.nik AS nik, dk.nama_karyawan AS nama_karyawan, dk.jabatan AS jabatan, dk.departement AS departement, dk.status_kepegawaian AS status_kepegawaian, dk.asal_penerimaan AS asal_penerimaan, dk.sisa_cuti_tahun AS sisa_cuti_tahun
									  
						      FROM cuti_karyawan ck INNER JOIN data_karyawan dk ON ck.id_data_karyawan = dk.id
							  WHERE ck.status = 0
							  ORDER BY ck.id";
						
						//$q = "SELECT * FROM cuti_karyawan  ORDER BY id DESC";
						$res = mysqli_query($conn, $q);
						while ($row = mysqli_fetch_array($res)) {
						?>
							<tr>
								<td>
									<?php
									
									echo $row["nik"];
									//$bs = $row["id_data_karyawan"];
									//$s = "SELECT * FROM data_karyawan WHERE id='$bs'";
									
									?>
								</td>
								<td>
									<?php
									echo $row["nama_karyawan"];
									?>
								</td>
								<td>
									<?php
									echo $row["jabatan"];
									?>
									
								</td>
								<td>
									<?php
									echo $row["departement"];
									//$tanggalmasuk = $row["tanggal_masuk"];
									
									//date_default_timezone_set('Asia/Jakarta');
                                    //$awal = date_create($tanggalmasuk);
                                    //$akhir = date_create('');
                                    //$diff = date_diff($akhir,$awal);

                                    //echo '('.$diff->y . ' tahun-';
                                    //echo $diff->m . ' bulan-';
                                    //echo $diff->d . ' hari)';
									?>
								</td>
								<td>
									<?php
									echo $row["status_kepegawaian"];
									?>
								</td>
								<td>
									<?php
									echo $row["tanggal_akhir_cuti"];
									?>
								</td>
								<td>
									<?php
									echo $row["alamat"];
									?>
								</td>
								<td>
									<?php
									echo $row["sisa_cuti"];
									?>
								</td>
									<td>
									<?php
									$s = "SELECT * FROM jenis_cuti WHERE id=" .$row['id_jenis_cuti'];
                                    $resi = mysqli_query($conn,$s);
                                    $rowi = mysqli_fetch_array($resi);
									echo $rowi["nama"];
									?>
								</td>
								</td>

								<td>
									<a href="cutiPDF.php?id=<?php echo $row["id"]; ?>">PRINT PDF</a>
								</td>
							</tr>
						<?php
						}
						?>
					</tbody>
				</table>

			</div>

    <script>
    $(document).ready(function()
	{
		 $('.table-bordered').DataTable();
	});
    </script>
	<center><h5 class="form-signin">Copyright &copy; <a href="#" data-toggle="modal" data-target="#contact">SatrioPringgondani</a></h5></center>  
</body>

</html>