<table class="table table-sm table-bordered">
    <thead>
        <tr>
            <th>#</th>
            <th width="50px">Sku</th>
            <th>Nama Barang</th>
            <th width="50px">Tanggal</th>
            <th width="70px">Shift</th>
            <th>No Mesin</th>
            <th width="80px">Jml FG</th>
            <th width="50px">Barcode</th>
            <th>Tranfer ke gudang</th>
            <th>Doc Number</th>
            <th>Gudang</th>
        </tr>
    </thead>
    <tbody>
        <?php
        $i = 1;
        foreach ($resultlot as $l) {
            $doc_tf = $this->db->get_where('tb_tf_note', ['id_produksi' => $l['id']])->result_array();
            echo "<tr>";
            echo "<td>" . $i . "</td>";
            echo "<td>" . $l['sku'] . "</td>";
            echo "<td>" . $l['barang'] . "</td>";
            echo "<td>" . $l['tanggal'] . "</td>";
            echo "<td>" . $l['shift'] . "</td>";
            echo "<td>" . $l['mesin'] . "</td>";
            echo "<td>" . $l['nomor'] . "</td>";
            if ($l['cari_gudang'] == 0) {
                echo "<td></td>";
            } else {
                if ($l['sts_cetak'] == 0) {
                    echo "<td><button type='button' class='btn btn-warning btn-sm' onclick='cetaklot(" . $l['id'] . ",\"" . $l['sku'] . "\"," . $l['nomor'] . ")'><i class='bi bi-receipt-cutoff'></i></button></td>";
                } else {
                    if ($l['sts_cetak'] == 1) {
                        echo "<td style='text-align: center;'><i class='bi bi-printer' onclick='msg(" . $l['id'] . ")'></i>&nbsp;" . $l['id'] . "</td>";
                    }
                }
            }
            if ($l['cari_gudang'] == 0) {
                if ($akses['dml'] == 1) {
                    echo '<td><div class="btn-group" role="group" aria-label="Basic outlined example">';
                    echo "<button data-bs-toggle='modal' data-bs-target='#f_update_lot' onclick='edit_lot(" . $l['id'] . ",\"" . $l['sku'] . "\"," . $l['shift'] . "," . $l['kd_mesin'] . ")' type='button' class='btn btn-outline-primary btn-sm'><i class='bi bi-pencil'></i></button>";
                    echo "<button onclick='lot_number(" . $l['id'] . ",\"" . $l['sku'] . "\")' type='button' class='btn btn-outline-danger btn-sm'><i class='bi bi-badge-vo'></i></button>";
                    echo "<button onclick='tflot(" . $l['id'] . ",\"" . $l['sku'] . "\"," . $l['nomor'] . ")' type='button' class='btn btn-outline-primary btn-sm'><i class='bi bi-box-arrow-right'></i></button>";
                    echo '</div></td>';
                    echo "<td></td>";
                } else {
                    echo "<td></td>";
                }
            } else {
                echo '<td>' . $l['tgl_transfer'] . '<br><div class="btn-group" role="group" aria-label="Basic outlined example">';
                echo "<button data-toggle='tooltip' title='Void LOT' onclick='lot_number_gudang(" . $l['id'] . ",\"" . $l['sku'] . "\")' type='button' class='btn btn-outline-danger btn-sm'><i class='bi bi-badge-vo'></i></button>";
                echo '</div></td>';
                if ($l['doc_tf'] > 0) {
                    echo "<td>";
                    foreach ($doc_tf as $d) {
                        echo $d['doc_no'] . "<br>";
                    }
                    echo "</td>";
                } else {
                    echo "<td></td>";
                }
            }
            echo "<td>" . $l['gudang'] . "</td>";
            echo "</tr>";
            if (!isset($l['keterangan']) or $l['keterangan'] == '') {
            } else {
                echo "<tr>";
                echo "<td colspan='10'><span class='badge bg-info'><i class='bi bi-chat-left-text'></i>&nbsp;Pesan</span>&nbsp;" . $l['keterangan'] . "</td>";
                echo "</tr>";
            }
            $i++;
        }
        ?>
    </tbody>
    <?php
    if ($akses['dml'] == 1) {
    ?>
        <tfoot>
            <tr>
                <th colspan="11">Input data nomor lot FG</th>
            </tr>
            <tr>
                <th colspan="3">SKU</th>
                <th>Tgl</th>
                <th>Shift</th>
                <th>Mesin</th>
                <th>Jml FG</th>
                <th colspan="4"></th>
            </tr>
            <tr>
                <th colspan="3"><select class="form-control" id="brglot">
                        <?php
                        foreach ($brglot as $b) {
                            echo "<option value='" . $b['sku'] . "'>" . $b['barang'] . "</option>";
                        }
                        ?>
                    </select></th>
                <th><input type="date" id="tgllot" class="form-control"></th>
                <th><select class="form-control" id="shiftlot">
                        <option value="1">Shift 1</option>
                        <option value="2">Shift 2</option>
                        <option value="3">Shift 3</option>
                        <option value="4">Shift 4</option>
                        <option value="5">Shift 5</option>
                    </select></th>
                <th><select class="form-control" id="mesinlot">
                        <?php
                        foreach ($resultmesin as $m) {
                            echo "<option value='" . $m['kd_mesin'] . "'>" . $m['mesin'] . "</option>";
                        }
                        ?>
                    </select></th>
                <th><input type="number" id="qtylot" class="form-control"></th>
                <th colspan="4"><button type="button" onclick="simpanlot()" class="btn btn-primary btn-sm">simpan</button></th>
            </tr>
        </tfoot>
    <?php
    }
    ?>
</table>