<?php
if (@count($arrmetode)>1) {
    $colspan='colspan="'.count($arrmetode).'"';
} else {
    $colspan='';
}
?>
<!-- Table with stripped rows -->
<table class="table table-bordered" id="tabelku">
<thead>
<tr>
    <th scope="col" width="2%" rowspan="2">No.</th>
    <th scope="col" rowspan="2">Tanggal</th>
    <th scope="col" <?php echo $colspan ?>>Metode Pembayaran</th>
    <th scope="col" rowspan="2">Jumlah</th>
</tr>
<tr>
    <?php
    if (@$arrmetode) {
        foreach ($arrmetode as $key => $value) {
            ?>
            <th><?php echo $value ?></th>
            <?php
        }
    } else {
        ?>
        <th></th>
        <?php
    }
    ?>
</tr>
</thead>
<tbody>
<?php
$no=1;
$total=0;
if (@$arrtanggal) {
    foreach ($arrtanggal as $key => $value) {
        ?>
        <tr>
            <td><?php echo $no ?></td>
            <td><?php echo date('d-m-Y',strtotime($value)) ?></td>
            <?php
            if (@$arrmetode) {
                $jum=0;
                foreach ($arrmetode as $keygen => $val) {
                    $jumlah=@array_sum($arrjumlah[$val][$value]);
                    ?>
                    <td><?php echo number_format($jumlah,0,',','.') ?></td>
                    <?php
                    $jum=$jumlah+$jum;
                }
            } else {
                ?>
                <td></td>
                <?php
                $jum=0;
            }
            ?>
            <td><?php echo number_format($jum,0,',','.') ?></td>
        </tr>
        <?php
        $no++;
    }
}
?>
</tbody>
<tfoot>
<tr>
    <th colspan="2">Total</th>
    <?php
    $jum=0;
    if (@$arrmetode) {
        foreach ($arrmetode as $key => $value) {
            $total=@array_sum($arrtotal[$value]);
            ?>
            <th><?php echo number_format($total,0,',','.') ?></th>
            <?php
            $jum=$jum+$total;
        }
    } else {
        ?>
        <th></th>
        <?php
    }
    ?>
    <th><?php echo number_format($jum,0,',','.') ?></th>
</tr>
</tfoot>
</table>