<?php
    global $gAr;
    $statment=$gAr['statment'];
    $heads=$gAr['heads'];
    $ledgers=$gAr['ledgers'];
    $counters=$gAr['counters'];
    $general=$gAr['g'];
?>
<table class="table table-striped table-bordered table-hover only_show">
    <thead>
        <tr>
            <th>SN</th>
            <th>Head</th>
            <th>Counter</th>
            <th class="amount_td">In</th>
            <th class="amount_td">Out</th>
            <th class="amount_td">Balance</th>
        </tr>
    </thead> 
    <tbody>
        <?php
            $total=1;
            $balance=0;
            $totalDr=0;
            $totalCr=0;
            foreach($statment as $st){
                $totalDr+=$st['leAmountDr'];
                $totalCr+=$st['leAmountCr'];
                $balance+=$st['leAmountDr'];
                $balance-=$st['leAmountCr'];
            ?>
            <tr>
                <td><?=$total++?></td>
                <td><?php echo $heads[$ledgers[$st['lID']]['hID']]['hTitle'];?></td>
                <td><?php echo $counters[$ledgers[$st['lID']]['cnID']]['cnTitle'];?></td>
                <td class="amount_td"><?php echo $general->numberFormat($st['leAmountDr']);?></td>
                <td class="amount_td"><?php echo $general->numberFormat($st['leAmountCr']);?></td>
                <td class="amount_td"><?php echo $general->numberFormat($st['leAmountDr']-$st['leAmountCr']);?></td>
            </tr>
            <?php
            }
        ?>
        <tr>
            <td>&nbsp;</td>
            <td colspan="2"><b>Total</b></td>
            <td class="amount_td"><b><?php echo $general->numberFormat($totalDr);?></b></td>
            <td class="amount_td"><b><?php echo $general->numberFormat($totalCr);?></b></td>
            <td class="amount_td"><b><?php echo $general->numberFormat($balance);?></b></td>
        </tr>
    </tbody>
</table>