<style type="text/css">
    .table > thead > tr > th {
	    vertical-align: middle;
	    text-align: center;
    }
</style>
<div class="row">
    <!-- begin col-8 -->
    <div class="col-sm-12">
        <!-- begin panel -->
        <div class="panel panel-grey">
            <div class="panel-heading">
        		<div class="panel-heading-btn">
                  <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-grey" data-click="panel-expand"><i class="fa fa-expand"></i></a>
                  <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-grey" data-click="panel-remove"><i class="fa fa-times"></i></a>
              </div>

              <hr>

            </div>
            <div class="panel panel-body table-responsive">
                <form method="post" action="<?= site_url('sampel/pengajuan/simpan_penyiapan_sampel'); ?>">
                    <div class="row mb-3" style="font-weight: bold;">
                        <div class="col-sm-2 text-right">Tanggal Penyiapan :</div>
                        <div class="col-sm-10"><?= toi_date_input('tanggal_penyiapan[]', $data[0]['tanggal_penyiapan']); ?></div>
                        <div class="col-sm-2 text-right">Jenis Layanan :</div>
                        <div class="col-sm-10"><?= $data[0]['nama_layanan']; ?></div>
                        <div class="col-sm-2 text-right">Jenis Sampel :</div>
                        <div class="col-sm-10">
                            <?php $jenis_sampel = ['aktif', 'pasif', 'khusus']; ?>
                            <select class="" name="jenis_sampel[]">
                                <option readonly>Pilih salah satu</option>
                                <?php foreach($jenis_sampel as $js) : ?>
                                    <option <?= (isset($data[0]) && $data[0]['jenis_sampel'] == $js)?'selected':''; ?> value="<?= $js; ?>">
                                        <?= ucwords($js); ?>
                                    </option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                        <div class="col-sm-2 mt-3">
                            <button type="submit" class="btn btn-primary">Simpan Penyiapan Sampel</button>
                        </div>
                    </div>
                    <table class="table table-bordered table-hover table-striped">
                        <thead class="text-midle">
                            <tr class="grey">
                                <th rowspan="3" class="text-center">No.</th>
                                <th colspan="2" class="text-center">Waktu</th>
                                <th rowspan="3" class="text-center">Nomor Sampel</th>
                                <th rowspan="3" class="text-center">Bentuk/Jenis Sampel</th>
                                <th colspan="4" class="text-center">Kondisi Sampel</th>
                                <th colspan="5" class="text-center">Jenis Sampel</th>
                                <th rowspan="3" class="text-center">Jenis Grinder</th>
                                <th rowspan="3" class="text-center">Keterangan</th>
                            </tr>
                            <tr class="grey">
                                <th rowspan="2" class="text-center">Pukul&nbsp;Mulai</th>
                                <th rowspan="2" class="text-center">Pukul&nbsp;Selesai</th>
                                <th rowspan="2" class="text-center">Cair</th>
                                <th colspan="3" class="text-center">Padat</th>
                                <th colspan="3" class="text-center">Arsip</th>
                                <th colspan="2" class="text-center">Kerja</th>
                            </tr>
                            <tr class="grey">
                                <th class="text-center">Basah</th>
                                <th class="text-center">Lembab</th>
                                <th class="text-center">Kering</th>
                                <th class="text-center">Cair</th>
                                <th class="text-center">Tanpa Dioven</th>
                                <th class="text-center">Dioven</th>
                                <th class="text-center">Selain Uji Aflatoksin</th>
                                <th class="text-center">Uji Aflatoksin</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $i = 1; foreach ($data as $rkey => $r) { ?>
                            <input type='hidden' name="id_sampel[]" value="<?= $r['id_sampel']; ?>">
                            
                            <tr>
                                <td class="text-center"><?= $this->uri->segment(4) + $i++ ?></td>
                                <td><?= toi_time_input('pukul_mulai[]', strtotime($r['pukul_mulai']), false, 100); ?></td>
                                <td><?= toi_time_input('pukul_selesai[]', strtotime($r['pukul_selesai']), false, 100); ?></td>
                                <td><input class="text-center" name="nomor_sampel[]" value="<?= $r['nomor_sampel'] ?>"></td>
                                <td><input class="text-center" name="bentuk_jenis[]" value="<?= $r['bentuk_jenis']; ?>"></td>
                                
                                <?php foreach($bentuk_sampel as $bkey => $bs) : ?>
                                    <td class="text-center"><input type="radio" <?= ($r['id_bentuk_sampel'] == $bs['id']) ? 'checked' : ''; ?> name="id_bentuk_sampel[<?= $rkey; ?>]" value="<?= $bs['id']; ?>">
                                <?php endforeach; ?>
                                <?php foreach($penanganan_arsip as $bkey => $bs) : ?>
                                    <td class="text-center"><input type="checkbox" <?= (strpos($r['id_penanganan_arsip'], $bs['id']) != false) ? 'checked' : ''; ?> name="id_penanganan_arsip[<?= $rkey; ?>][]" value="<?= $bs['id']; ?>">
                                <?php endforeach; ?>
                                <?php foreach($penanganan_kerja as $bkey => $bs) : ?>
                                    <td class="text-center"><input type="checkbox" <?= (strpos($r['id_penanganan_kerja'], $bs['id']) != false) ? 'checked' : ''; ?> name="id_penanganan_kerja[<?= $rkey; ?>]" value="<?= $bs['id']; ?>">
                                <?php endforeach; ?>

                                <td class="text-center">
                                    <select style="width:99%;" name="id_grinder[]">
                                        <option readonly>Pilih salah satu</option>
                                        <?php foreach($grinder as $g) : ?>
                                            <option <?= ($r['id_grinder'] == $g['id']) ? 'selected' : ''; ?> value="<?= $g['id']; ?>"><?= $g['nama']; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                    <input class="text-center mt-1" placeholder="Grinder baru" name="grinder_baru[]">
                                </td>
                                <td><input class="text-center" name="keterangan[]" value="<?= $r['keterangan']; ?>"></td>
                            </tr>
                            <?php } ?>
                        </tbody>
                        <tfoot>

                        </tfoot>
                    </table>
                </form>
            </div>
        </div>
        <!-- end panel -->
    </div>
</div>

