<div class="table-responsive">
    <table class="table table-bordered" style="width:100%;">
        <thead>
            <tr>
                <th style="vertical-align:middle; text-align:center;">Buyer</th>
                <th style="vertical-align:middle; text-align:center;">Received</th>
                <th style="vertical-align:middle; text-align:center;">Delivered</th>
                <th style="vertical-align:middle; text-align:center;">Total Stock</th>
            </tr>
        </thead>
        <tbody>
            <?php
            if ($listdata->num_rows() > 0) {
                foreach ($listdata->result_array() as $row) {
            ?>
                <tr>
                    <td><?=$row['buyer_name']?></td>
                    <td style="text-align:right;"><?=number_format($row['received'],2,'.',',')?></td>
                    <td style="text-align:right;"><?=number_format($row['delivered'],2,'.',',')?></td>
                    <td style="text-align:right;"><?=number_format($row['total'],2,'.',',')?></td>
                </tr>
            <?php } ?>
            <?php } else { ?>
                <tr>
                    <td colspan="4"><i>Data not found</i></td>
                </tr>
            <?php } ?>                
        </tbody>
        <tfoot>
            <?php
                foreach ($listtotal->result_array() as $row_t) {
            ?>
                <tr>
                    <th>Total</th>
                    <th style="text-align:right;"><?=number_format($row_t['total_received'],2,'.',',')?></th>
                    <th style="text-align:right;"><?=number_format($row_t['total_delivered'],2,'.',',')?></th>
                    <th style="text-align:right;"><?=number_format($row_t['grand_total'],2,'.',',')?></th>
                </tr>
            <?php } ?>      
        </tfoot>
    </table>
</div>