<?php 
include "../koneksi.php";
$data = mysqli_query ($koneksi, "SELECT po_tbl.PO_ID,
                                detail_po.QtyPO,
                                product.ItemDescription,
                                product.SLoc,
                                SUM(deliverytbl.QtyKirim) AS QtyKirim,
                                product.QtyUnit
                        FROM deliverytbl
                        INNER JOIN detail_po
                        ON deliverytbl.DetailPO_ID=detail_po.DetailPO_ID
                        INNER JOIN po_tbl
                        ON detail_po.PO_ID=po_tbl.PO_ID
                        INNER JOIN product
                        ON detail_po.ProductID=product.ProductID
                        WHERE po_tbl.PO_ID=$_GET[id]");
        $row = mysqli_fetch_array ($data);
        if ($_GET['qty_po'] == '') {
            $balancepo = '';
        } else {
            $totalpack = floor($_GET['qty_po']/$row['QtyUnit']);
            $balancepo = $totalpack-$row['QtyKirim'];
        }
        
?>
<table class="table table-bordered" style="width: 100%; background-color: white;">
    <tr>
        <th width="30%">Total Pack</th>
        <td width="60%"><?php echo $totalpack; ?></td>
        <td width="10"><?php echo $row['SLoc'] ?></td>
    </tr>
    <tr>
        <th width="30%">Delivery</th>
        <td width="60%"><?php echo $row['QtyKirim']; ?></td>
        <td width="10"><?php echo $row['SLoc'] ?></td>
    </tr>
    <tr>
        <th width="30%">Balance PO</th>
        <td width="60%"><?php echo $balancepo; ?></td>
        <td width="10"><?php echo $row['SLoc'] ?></td>
        <input type="hidden" id="balance_po" name="balance_po" value="<?php echo $balancepo; ?>">
    </tr>
</table>