<?php
error_reporting(0);
ob_clean();
flush();
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename="Laporan_penerimaan_fg.csv"');

$output = fopen('php://output', 'w');

?>

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Laporan Penerimaan FG</title>
</head>

<body>
    <h1>Laporan Penerimaan FG</h1>
    <table border="1" cellpadding="5" cellspacing="0">
        <thead>
            <tr>
                <th>#</th>
                <th>No Lot</th>
                <th>Sku</th>
                <th>Nama Barang</th>
                <th>Tgl Kirim</th>
                <th>Tgl Diterima</th>
            </tr>
        </thead>
        <tbody>
            <?php
            $i = 1;
            foreach ($resultlot as $l) {
                echo "<tr>";
                echo "<td>" . $i . "</td>";
                echo "<td>" . htmlspecialchars($l['kode_fg']) . "</td>";
                echo "<td>" . htmlspecialchars($l['sku']) . "</td>";
                echo "<td>" . htmlspecialchars($l['barang']) . "</td>";
                echo "<td>" . htmlspecialchars($l['tgl_kirim']) . "</td>";
                echo "<td>" . htmlspecialchars($l['tgl_scan']) . "</td>";
                echo "</tr>";
                $i++;
            }
            ?>
        </tbody>
    </table>
</body>

</html>