<!-- Table with stripped rows -->
<table class="table table-hover" id="tabelkeranjang">
<thead>
<tr>
    <th scope="col">Kode Barang</th>
    <th scope="col">Barcode</th>
    <th scope="col">Nama Barang</th>
    <th scope="col">Kategori</th>
    <th scope="col">Jumlah Penjualan</th>
    <th scope="col">Total Harga Jual</th>
    <th scope="col">Total Harga Beli</th>
    <th scope="col">Total Keuntungan</th>
</tr>
</thead>
<tbody>
<?php
$totjum=0;
$totjual=0;
$totbeli=0;
$totuntung=0;
foreach ($databarang as $hasil) {
    $untung=$hasil->jual-$hasil->beli;
    ?>
    <tr>
        <td><?php echo $hasil->kode_barang ?></td>
        <td><?php echo $hasil->barcode ?></td>
        <td><?php echo $hasil->barang ?></td>
        <td><?php echo $hasil->kategori ?></td>
        <td><?php echo $hasil->jumlah ?></td>
        <td><?php echo number_format($hasil->jual,0,',','.') ?></td>
        <td><?php echo number_format($hasil->beli,0,',','.') ?></td>
        <td><?php echo number_format($untung,0,',','.') ?></td>
    </tr>
    <?php
    $totjum=$hasil->jumlah+$totjum;
    $totjual=$hasil->jual+$totjual;
    $totbeli=$hasil->beli+$totbeli;
    $totuntung=$untung+$totuntung;
}
?>
</tbody>
<tfoot>
<tr>
    <th scope="col" colspan="4">Total</th>
    <th scope="col"><?php echo $totjum ?></th>
    <th scope="col"><?php echo number_format($totjual,0,',','.') ?></th>
    <th scope="col"><?php echo number_format($totbeli,0,',','.') ?></th>
    <th scope="col"><?php echo number_format($totuntung,0,',','.') ?></th>
</tr>
</tfoot>
</table>
<!-- End Table with stripped rows -->