<?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_stok_harian.xls");
header("Content-Transfer-Encoding: binary ");
?>
<html>

<head>
    <h2>LAPORAN STOK HARIAN</h2>
    <h4>Periode Stok: <?= date('d F Y', strtotime($tgl)); ?></h4>
    <h4>Tgl Cetak : <?= date('d F Y', strtotime($cetak)); ?></h4>
</head>
<table rules="all" border="1">
    <thead>
        <tr>
            <th>SKU</th>
            <th>Barang</th>
            <?php foreach ($pivot_data['gudang'] as $gudang): ?>
                <th><?php echo $gudang; ?></th>
            <?php endforeach; ?>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($pivot_data['barang'] as $index => $barang): ?>
            <tr>
                <td><?php echo $pivot_data['sku'][$index]; ?></td>
                <td><?php echo $barang; ?></td>
                <?php foreach ($pivot_data['stok'][$index] as $stok): ?>
                    <td><?php echo $stok; ?></td>
                <?php endforeach; ?>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>

</html>