<table class="table table-sm table-bordered">
    <thead>
        <th>#</th>
        <th>Doc No</th>
        <th>TGL</th>
        <th>SKU</th>
        <th>BARANG</th>
        <th>TRANSFER</th>
        <th>PENERIMAAN</th>
        <th>SELISIH</th>
    </thead>
    <tbody>
        <?php
        $i = 1;
        $jml = 0;
        foreach ($data as $d) {
            echo "<tr>";
            echo "<td>" . $i . "</td>";
            echo "<td>" . $d['doc_tf'] . "</td>";
            echo "<td>" . $d['tgl'] . "</td>";
            echo "<td>" . $d['sku'] . "</td>";
            echo "<td>" . $d['barang'] . "</td>";
            echo "<td style='text-align: right;'>" . $d['IT'] . "</td>";
            echo "<td style='text-align: right;'>" . $d['Recv'] . "</td>";
            echo "<td style='text-align: right;'>" . $d['balance'] . "</td>";
            echo "</tr>";
            $i++;
            $jml += $d['balance'];
        }
        ?>
    </tbody>
    <tfoot>
        <td style='text-align: center;' colspan='7'><b>JUMLAH</b></td>
        <td style='text-align: right;'><b><?= $jml; ?></b></td>
    </tfoot>
</table>