<form id="f_panji" name="f_panji" Action="" method="">
    <table class="table table-sm table-bordered">
        <thead>
            <tr class="table-warning">
                <th colspan="2">No. ITO</th>
                <th colspan="7"><input type="text" id='docno' name='docno' class="form-control"></th>
            </tr>
            <tr class="table-warning">
                <th>#</th>
                <th>SKU</th>
                <th>BARANG</th>
                <th>Tanggal</th>
                <th>Gudang</th>
                <th>Jml Lot</th>
                <th>Jml Kirim</th>
                <th>Kirim</th>
                <th>Selisih</th>
            </tr>
        </thead>
        <tbody>
            <?php
            $i = 1;
            foreach ($data as $d) {
                echo "<tr>";
                echo "<td><input type='hidden' id='id_kirim[]' name='id_kirim[]' value='" . $d['id'] . "'>" . $i . "</td>";
                echo "<td>" . $d['sku'] . "</td>";
                echo "<td>" . $d['barang'] . "</td>";
                echo "<td>" . $d['tgl'] . "</td>";
                echo "<td>" . $d['gudang'] . "</td>";
                echo "<td>" . $d['qty_lot'] . "</td>";
                echo "<td>" . $d['jml_note'] . "</td>";
                echo "<td><input type='number' id='jml_kirim[]' name='jml_kirim[]' class='form-control form-control-sm'></td>";
                echo "<td>" . $d['blc'] . "<input type='hidden' id='blc[]' name='blc[]' value='" . $d['blc'] . "'></td>";

                echo "</tr>";
                $i++;
            }
            ?>
        </tbody>
        <tfoot>
            <td colspan="9"><button type="submit" class="btn btn-primary" style="float:right;">Simpan</button></td>
        </tfoot>
    </table>
</form>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
    $(document).ready(function() {
        $('form[name="f_panji"]').on('submit', function(event) {
            event.preventDefault();
            var formData = new FormData(this);
            var docno = $("#docno").val()
            if (docno == '') {
                pesan('Nomor ITO Mohon diisi', 'error');
            } else {
                $.ajax({
                    url: '<?= base_url('Produksi/simpan_tf_kirim'); ?>',
                    type: 'POST',
                    data: formData,
                    processData: false,
                    contentType: false,
                    success: function(response) {
                        tampildata();
                        //log                        
                        var strTable = 'tb_tf_note';
                        var keterangan = 'Telah mentransfer barang dengan nomor ITO ' + docno;
                        $.ajax({
                            url: "<?= base_url('Pengaturan/log'); ?>",
                            type: 'POST',
                            cache: false,
                            data: {
                                strTable: strTable,
                                keterangan: keterangan
                            },
                            success: function() {}
                        });
                    },
                    error: function(xhr, status, error) {
                        alert('Terjadi kesalahan: ' + error);
                    }
                });
            }
        });
    });
</script>