<table class="table table-sm table-bordered table-striped">
    <thead>
        <th width="35px">#</th>
        <th width="100px">No Pol</th>
        <th>Merk</th>
        <th>Jenis</th>
        <th width="50px">Kapasitas</th>
        <th width="100px">Tgl STNK</th>
        <th width="80px">Opsi</th>
    </thead>
    <tbody>
        <?php
        $i = 1;
        foreach ($data as $d) {
            if (!empty($d['tgl_stnk'])) {
                try {
                    $tglStnk = new DateTime($d['tgl_stnk']);
                    $formattedTglStnk = $tglStnk->format('j M Y');
                    $bulan = array(
                        'Jan' => 'Jan',
                        'Feb' => 'Feb',
                        'Mar' => 'Mar',
                        'Apr' => 'Apr',
                        'May' => 'Mei',
                        'Jun' => 'Jun',
                        'Jul' => 'Jul',
                        'Aug' => 'Agu',
                        'Sep' => 'Sep',
                        'Oct' => 'Okt',
                        'Nov' => 'Nov',
                        'Dec' => 'Des'
                    );

                    $formattedTglStnk = str_replace(array_keys($bulan), array_values($bulan), $formattedTglStnk);
                } catch (Exception $e) {
                    $formattedTglStnk = '';
                }
            } else {
                $formattedTglStnk = '';
            }
            echo "<tr>";
            echo "<td>" . $i . "</td>";
            echo "<td>" . $d['no_pol'] . "</td>";
            echo "<td>" . $d['merk'] . "</td>";
            echo "<td>" . $d['jenis'] . "</td>";
            echo "<td>" . $d['cc'] . "&nbsp;CC</td>";
            echo "<td>" . $formattedTglStnk . "</td>";
            echo "<td>
        <button onclick='editkendaraan(" . $d['id_kendaraan'] . ",\"" . $d['no_pol'] . "\",\"" . $d['merk'] . "\",\"" . $d['jenis'] . "\"," . $d['cc'] . ",\"" . $d['tgl_stnk'] . "\")' data-bs-toggle='modal' data-bs-target='#f_edit_kendaraan' type='button' class='btn btn-warning btn-sm'>
            <i class='bi bi-pencil'></i>
        </button>
        <button onclick='hapus(" . $d['id_kendaraan'] . ",\"" . $d['no_pol'] . "\")' type='button' class='btn btn-danger btn-sm'>
            <i class='bi bi-trash'></i>
        </button>
    </td>";
            echo "</tr>";
            $i++;
        }
        ?>

    </tbody>
    <tfoot>
        <tr>
            <th colspan="7">Input data</th>
        </tr>
        <tr>
            <th width="100px" colspan="2">No Pol</th>
            <th>Merk</th>
            <th>Jenis</th>
            <th width="50px">Kapasitas</th>
            <th width="100px">Tgl STNK</th>
            <th width="80px">Opsi</th>
        </tr>
        <tr>
            <th colspan="2"><input type="text" id="no_pol" class="form-control"></th>
            <th><select id="merk" class="form-control">
                    <option value="0">- Merk kendaraan-</option>
                    <option value="Mitsubishi">Mitsubishi</option>
                    <option value="Isuzu">Isuzu</option>
                    <option value="Toyota">Toyota</option>
                    <option value="Hino">Hino</option>
                    <option value="Nissan">Nissan</option>
                    <option value="UD">UD</option>
                    <option value="Daihatsu">Daihatsu</option>
                </select></th>
            <th><select id="jenis" class="form-control">
                    <option value="0">- Jenis kendaraan-</option>
                    <option value="Pickup">Pickup</option>
                    <option value="Minibus">Minibus</option>
                    <option value="Truk">Truk</option>
                    <option value="Truk boks">Truk boks</option>
                </select>
            </th>
            <th width="50px"><input type="number" id="kapasitas" class="form-control"></th>
            <th width="50px"><input type="date" id="tgl_stnk" class="form-control"></th>
            <th><button type="button" class="btn btn-primary" onclick="simpan()">Simpan</button></th>
        </tr>
    </tfoot>
</table>