<?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>
		<?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" align='center' >
					<h3>AGING SCHEDULE</h3>
					<h5>menampilkan aging schedule</h5>
					<?php
					if (isset($_GET["p"])) 
					{
						$p = $_GET["p"];
						if ($p == "1") 
						{
						?>
						<div class="alert alert-primary">
							KARYAWAN MUTASI DISETUJUI!
						</div>
						<?php
						} 
						else if ($p == "3") 
						{
						?>
							<div class="alert alert-danger">
								KARYAWAN KARYAWAN GAGAL DIUSULKAN MUTASI!
							</div>
						<?php
						}
					}
					?>
					<?php
					$z = 1;
					?>
					<table class="table table-bordered">
						<thead>
							<tr>
							    <th>
									NO 
								</th>
								<th>
									KODE
								</th>
								<th>
									NAMA
								</th>
								<th>
									NO INVOICE
								</th>
								<th>
									TGL INVOICE
								</th>
								<th>
									TGL. JT
								</th>
								<th>
									BLM JT
								</th>
								<th>
									CASH
								</th>
								<th>
									30 - 60
								</th>
								<th>
									61 - 90
								</th>
								<th>
									> 90
								</th>
								<th>
									OVER DUE
								</th>
								<th>
									TOTAL
								</th>
							</tr>
						</thead>
						<tbody>
							<?php
							$status = '1';
							$q = "SELECT * FROM invoice";
							$res = mysqli_query($conn, $q);
							while ($row = mysqli_fetch_assoc($res)) {
							?>
								<tr>
									<td>
									     <?php
									         echo $z;
									         $z = $z + 1;
											 //echo $row["id"];
									     ?>
								    </td>
									<td>
										<?php
										echo $row["id_kode_suplier"];
										?>
									</td>
									<td>
										<?php
										$aba = $row["id_kode_suplier"];
										$aS = "SELECT * FROM data_suplier WHERE kode_suplier = '$aba'";
										$resi = mysqli_query($conn,$aS);
										while ($rowi = mysqli_fetch_assoc($resi))
										{
											echo $rowi["nama_suplier"];
										}
										?>
									</td>
									
									<td>
										<?php
										echo $row["no_invoice"];
										?>
									</td>
									<td>
										<?php
										echo $row["tanggal_invoice"];
										?>
									</td>
									<td>
										<?php
										$aba = $row["id_kode_suplier"];
										$aS = "SELECT * FROM data_suplier WHERE kode_suplier = '$aba'";
										$resi = mysqli_query($conn,$aS);
										while ($rowi = mysqli_fetch_assoc($resi))
										{
											//echo '+'.$rowi["top"].' days///';
											//echo 'tanggal invoice'.$row["tanggal_invoice"].'////';
										
										$tgl_invoice = $row["tanggal_invoice"];
									    $top = '+'.$rowi["top"].' days';
										}
										$tgl1 = $tgl_invoice;// pendefinisian tanggal yang akan dikurang
                                        $tgl2 = date('d-M-Y', strtotime($top, strtotime($tgl1))); //operasi penjumlahan tanggal sebanyak 6 hari
                                        echo $tgl2;
										//echo $top;
										?>
									</td>
									<td>
										<?php
										echo $row["jumlah"];
										?>
									</td>
									<td>
										<?php
										if ($row["jenis_pembayaran"] == '1')
										{
											echo $row["jumlah"];
										}
										else
										{
											echo '-';
										}
										?>
									</td>
									<td>
										<?php
										;
										?>
									</td>
									<td>
										<?php
									
										?>
									</td>
										<td>
										<?php
										
										?>
									</td>
										<td>
										<?php
										
										?>
									</td>
										<td>
										<?php
										
										?>
									</td>
							

									</td>
								</tr>
							<?php
							}
							?>
						</tbody>
					</table>

				</div>

		<center><h5 class="form-signin">Copyright &copy; <a href="#" data-toggle="modal" data-target="#contact">SatrioPringgondani</a></h5></center>  
	</body>
</html>

<script>
$(document).ready(function()
{
	 $('.table-bordered').DataTable();
});
</script>