<?php include "../koneksi.php"; ?>
<div class="row">
<div class="col-md-12">
	 <nav>
    <ol class="breadcrumb">
		<li class="breadcrumb-item">Pengiriman</li>
        <li class="breadcrumb-item">Table Balance PO</li>
    </ol>
</nav>
</div>
</div>
<div style="width:100%;height500px;overflow:scroll;" >
<table id="example" class="display nowrap" style="width:100%">
        <thead>
		<tr>
			<th width="25%">
				Customer
			</th>
			<th width="15%">
				Nomor PO
			</th>
			<th width="10%">
				Tanggal PO
			</th>
			<th width="20%">
				Jenis Product
			</th>
			<th width="10%">
				Quantity PO
			</th>
			<th width="10%">
				Balance PO
			</th>
			<th width="10%">
				Opsi
			</th>
		</tr>
		</thead>
		<tbody>
			<?php 
				$no = 1;
				$data = mysqli_query ($koneksi, "SELECT customer.CustomerName,
														po_tbl.No_PO,
														po_tbl.TanggalPO,
														po_tbl.PO_ID,
														product.ItemDescription,
														product.SLoc,
														detail_po.QtyPO,
														detail_po.BalancePO
												FROM detail_po
												INNER JOIN po_tbl
												ON detail_po.PO_ID=po_tbl.PO_ID
												INNER JOIN customer
												ON po_tbl.CustomerID=customer.CustomerID
												INNER JOIN product
												ON detail_po.ProductID=product.ProductID
												WHERE detail_po.BalancePO>0
												ORDER BY customer.CustomerID ASC, po_tbl.TanggalPO DESC");
				
				
				while($row = mysqli_fetch_array ($data)):
			?>
		<tr>
			<td width="25%">
				<?php echo $row['CustomerName']; ?>
			</td>
			<td width="15%">
				<?php echo $row['No_PO']; ?>
			</td>
			<td width="10%">
				<?php echo $row['TanggalPO']; ?>
			</td>
			<td width="20%">
				<?php echo $row['ItemDescription']; ?>
			</td>
			<td width="10%">
				<?php echo $row['QtyPO']; ?> 
			</td>
			<td width="10%">
				<?php echo $row['BalancePO']; ?> <?php echo $row['SLoc'] ?>
			</td>
			<td width="10%">
				<a href="po_tbl/rincianpo.php?id=<?php echo $row['PO_ID']; ?>" style="color: #00008B" data-href="po_tbl/rincianpo.php?id=<?php echo $row['PO_ID']; ?>"><i class="bi bi-clipboard-check"></i> Detail</a>
			</td>
		</tr>
			<?php endwhile; ?>
		</tbody>
	</table>
	</div>
		<!-- Modal -->
		<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
            
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Kofirmasi Hapus</h4>
                </div>
            
                <div class="modal-body">
                    <p>Apakah anda mau melanjutkan menghapus data?</p>
                    <p class="debug-url"></p>
                </div>
                
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <a class="btn btn-danger btn-ok">Delete</a>
                </div>
            </div>
        </div>
    </div>

	<script>
        $('#confirm-delete').on('show.bs.modal', function(e) {
            $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
            
        });

        $(document).ready(function () {
		$('#example').DataTable({
			scrollX: true,
		});
	});
    </script>
