<?php

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename= Laporan_SJ.xls");
header("Content-Transfer-Encoding: binary ");

?>
<!doctype html>
<html lang="en">

<head>
    <h1>Laporan Penerimaan FG</h1>
</head>
<table border="1" rules="All">
    <thead>
        <th>#</th>
        <th>Tgl</th>
        <th>No SJ</th>
        <th>Keterangan</th>
        <th>Kota</th>
        <th>DK/LK</th>
    </thead>
    <tbody>
        <?php
        $i = 1;
        foreach ($data as $d) {
            $detail = $this->M_gudang->get_detail_sj($d['doc_sj']);
            echo "<tr>";
            echo "<td><b>" . $i . "</b></td>";
            echo "<td><b>" . $d['tgl'] . "</b></td>";
            echo "<td><b>" . $d['no_sj'] . "</b></td>";
            echo "<td><b>" . $d['keterangan'] . "</b></td>";
            echo "<td><b>" . $d['kota'] . "</b></td>";
            echo "<td><b>" . $d['dk_lk'] . "</b></td>";
            echo "</tr>";
            //echo "<tr>";
            $nmr = 1;
            foreach ($detail as $dtl) {
                echo "<tr>";
                echo "<td>&nbsp;" . $nmr . "</td>";
                echo "<td colspan='2'>" . $dtl['sku'] . "</td>";
                echo "<td colspan='2'>" . $dtl['barang'] . "</td>";
                echo "<td style='text-align: right;'>" . $dtl['qty'] . "</td>";
                echo "</tr>";
                $nmr++;
            }
            //echo "</tr>";
            $i++;
        }
        ?>
    </tbody>
</table>

</html>