<form method="post" action="" id="form_filter_cari">
    <?php
        $array_filter = [
            'nomor_uji'=>'Nomor Permintaan Uji',
            'instansi_umum'=>'Instansi/Umum',
            'status'=>'Status Disposisi',
            'jenis_layanan'=>'Jenis Layanan'
        ];
    ?>
    
    <div class="row">
        <div class="col-md-2 text-right"><h3 class="text-white">Pencarian</h3></div>
        <div class="col-md-10"></div>
        <?php foreach($array_filter as $key => $k) : ?>
            <div class="col-md-2 text-right">
                <label><?= $k; ?></label>
            </div>
            <?php if(in_array($key, ['nomor_uji', 'instansi_umum'])) : ?>
                <div class="col-md-4 mb-2">
                    <div class="col-md-10">
                        <input class="form-control" value="<?php echo !empty($filter) ? $filter[$key] : ''; ?>" name="<?= $key; ?>" placeholder="Masukkan <?= $k; ?>">
                    </div>
                </div>
            <?php else : ?>
                <div class="col-md-4 mb-2">
                    <div class="col-md-10">
                        <select class="form-control select2" name="<?= $key; ?>">
                            <option></option>
                            <?php foreach($data_filter[$key] as $row => $r) : ?>
                                <?php
                                    $nama = $r['nama'];
                                    if($key == 'status'){
                                        $nama .= ' ['.$r['detail'].']';
                                    }
                                ?>
                                <option value="<?= $r['nama']; ?>" <?= (!empty($filter) && $r['nama'] == $filter[$key]) ? 'selected' : ''; ?>><?= $nama; ?></option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                </div>
            <?php endif; ?>
        <?php endforeach; ?>
    </div>
    <div class="row mb-2">
        <div class="col-md-2"></div>
        <div class="col-md-4">
            <div class="col-md-10">
                <input type="hidden" name="filter_cari" value="1">
                <button class="btn btn-primary btn-sm" type="button" onclick="onfilter_cari();">Cari</button>
                <a href="<?php echo site_url('permintaan_uji'); ?>" class="btn btn-danger btn-sm">Reset</a>
            </div>
        </div>
    </div>
    <input class="form-control" type="hidden" name="filter_cari" value="1">
</form>

<script>
  function onfilter_cari() {
    $("#form_filter_cari").submit();
  }
</script>
