<div>&nbsp;</div>
<table class="table table-hover table-bordered" id="tabelstok" style="width: 100%;">
<thead>
<tr>
    <th scope="col" width="2%">No.</th>
    <th scope="col">Tanggal</th>
    <th scope="col">Kode Barang</th>
    <th scope="col">Nama Barang</th>
    <th scope="col">Selisih SO</th>
</tr>
</thead>
<tbody>
<?php
$no=1;
foreach ($databarang as $hasil) {
    $totalsistem=$hasil->harga_beli*$hasil->stok;
    $totalnyata=$hasil->harga_beli*$hasil->stok_nyata;
    $selisih=$totalnyata-$totalsistem;
    ?>
    <tr>
        <td><?php echo $no ?></td>
        <td><?php echo date('d-m-Y',strtotime($hasil->tanggal)) ?></td>
        <td><?php echo $hasil->kode_barang ?></td>
        <td><?php echo $hasil->barang ?></td>
        <td><?php echo number_format($selisih,0,',','.') ?></td>
    </tr>
    <?php
    $no++;
}
?>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
    $("#tabelstok").DataTable({
        "processing":true,
        "responsive":true,
        "paging": true
    });
});
</script>