<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>
                <a href="#" onclick="goBack()" class="btn btn-primary m-b-5"><span class="fa fa-arrow-left"></span> Kembali</a>
                <hr>
                <?php
                    $dj = $data_uji;
                    $array_uji = [
                        'Nomor Permintaan Uji'      => $dj['nomor_uji'], 
                        'Jenis Layanan'             => $dj['jenis_layanan'], 
                        'Registrasi Laboratorium'   => $dj['registrasi_laboratorium'], 
                        'Tangal Pukul Pengambilan'  => indo_datetime($dj['tgl_pukul_pengambilan'],'time'), 
                        'Tanggal Pukul Registrasi'  => indo_datetime($dj['tgl_pukul_registrasi'], 'time'), 
                        'Perkiraan Estimasi Selesai LHP' => indo_datetime($dj['perkiraan_estimasi_selesai_lhp'], 'time'), 
                        'Tanggal Pukul Mulai Uji'   => indo_datetime($dj['tgl_pukul_mulai_uji'], 'time'), 
                        'Tanggal Pukul Terbit LHU'  => indo_datetime($dj['tgl_pukul_terbit_lhu'], 'time'), 
                        'Tanggal Pukul Terbit LHP'  => indo_datetime($dj['tgl_pukul_terbit_lhp'], 'time'), 
                        'Tanggal Surat'             => indo_datetime($dj['tgl_surat']), 
                        'Nomor Surat'               => $dj['nomor_surat'], 
                        'Instansi/Perusahaan'       => $dj['instansi_umum'], 
                        'Alamat'                    => $dj['alamat'],
                        'Keterangan'                => $dj['keterangan'],
                        'Petugas Pengambil Sampel'  => $data[0]['petugas_pengambil_sampel'],
                    ];
                ?>
                <div class="row">
                    <?php foreach($array_uji as $key => $k): ?>
                        <?= toi_verifikasi_data_uji($key, $k); ?>
                    <?php endforeach; ?>
                </div>
            </div>
            <div class="panel panel-body">
                <div class="table-responsive">
                    <table class="table table-bordered table-hover table-striped">
                        <thead>
                            <tr class="grey">
                                <th rowspan="2" class="text-center">No.</th>
                                <th rowspan="2" class="text-center">Nomor Sampel</th>
                                <th rowspan="2" class="text-center">
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Jenis&nbsp;Sampel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </th>
                                <th rowspan="2" class="text-center">Jumlah Sampel</th>
                                <th rowspan="2" class="text-center">Kemasan</th>
                                <th rowspan="2" class="text-center">Bobot (gr)</th>
                                <th rowspan="2" class="text-center">Merek Dagang</th>
                                <th rowspan="2" class="text-center">Bentuk/Jenis</th>
                                <th colspan="3" class="text-center">Tekstur</th>
                                <th rowspan="2" class="text-center">
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Kode&nbsp;Parameter&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </th>
                                <th rowspan="2" class="text-center">Label&nbsp;Pakan</th>
                                <th rowspan="2" class="text-center">Enzym&nbsp;Fitase</th>
                                <th colspan="2" class="text-center">Kualitas</th>
                                <th rowspan="2" class="text-center">Keterangan</th>
                                <th rowspan="2" class="text-center">Kesimpulan</th>
                            </tr>
                            <tr class="grey">
                                <th>Basah</th>
                                <th>Lembab</th>
                                <th>Kering</th>
                                <th>Baik</th>
                                <th>Tidak&nbsp;Baik</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $i = 1;
                            foreach ($data as $r) { ?>
                                <tr>
                                    <td class="text-center"><?php echo $this->uri->segment(4) + $i++ ?></td>
                                    <td><?php echo $r['nomor_sampel']; ?></td>
                                    <td style="width:600px;"><?php echo $r['jenis_sampel']; ?></td>
                                    <td><?php echo count(array($r['id_sampel'])); ?></td>
                                    <td><?php echo $r['kemasan']; ?></td>
                                    <td><?php echo $r['berat_sampel']; ?></td>
                                    <td><?php echo $r['merk_dagang']; ?></td>
                                    <td><?php echo $r['bentuk_jenis']; ?></td>
                                    <td><?php echo $r['id_penanganan_sampel'] == '3' ? '√' : '-'; ?></td>
                                    <td><?php echo $r['id_penanganan_sampel'] == '2' ? '√' : '-'; ?></td>
                                    <td><?php echo $r['id_penanganan_sampel'] == '1' ? '√' : '-'; ?></td>
                                    <td style="width:600px;">
                                        <?php
                                            $xx = '';
                                            foreach(json_decode($r['jenis_pengujian']) as $jp){
                                                $xx .= "<button class='btn btn-xs btn-primary'>".$this->m_pendaftaran->get_parameter_uji($jp)['nama']."</button>, ";
                                            }
                                            $xx = substr($xx, 0, -2);
                                            echo $xx;
                                        ?>
                                    </td>
                                    <td><?= $r['label_pakan']; ?></td>
                                    <td><?= ($r['phytase'] == 1) ? 'Ya' : 'Tidak'; ?></td>
                                    <td><?php echo $r['kualitas'] === 'Baik' ? '√' : '-'; ?></td>
                                    <td><?php echo $r['kualitas'] === 'Tidak Baik' ? '√' : '-'; ?></td>
                                    <td><?php echo $r['keterangan']; ?></td>
                                    <td><?= $r['nama_klasifikasi']; ?></td>
                                </tr>
                            <?php } ?>
                            <tr>
                                <td class="text-right" colspan="3">Total:</td>
                                <td colspan="12"><?php echo count($data); ?></td>
                            </tr>
                        </tbody>
                        <tfoot>
                        </tfoot>
                    </table>
                </div>
                <div style="width: 30%; margin-top:10px;">
                    <form id="diiya"  method="post" action="<?= site_url('permintaan_uji/verifikasi/' . $id_uji . '/ya') ?>"">
                        <table class="table table-hover table-striped table-bordered">
                            <tbody align="center">
                                <tr>
                                    <td><label><b> Pilih&nbsp;Semua</b></label></td>
                                    <td><label> SDM</label></td>
                                    <td><label> Metode</label></td>
                                    <td><label> Peralatan</label></td>
                                    <td><label> Bahan&nbsp;Kimia</label></td>
                                </tr>
                                <tr>
                                    <td><input type="checkbox" id="masterCheckbox"></td>
                                    <td><input type="checkbox" class="cbku" name="kaji_ulang[]" value="sdm"></td>
                                    <td><input type="checkbox" class="cbku" name="kaji_ulang[]" value="metode"></td>
                                    <td><input type="checkbox" class="cbku" name="kaji_ulang[]" value="peralatan"></td>
                                    <td><input type="checkbox" class="cbku" name="kaji_ulang[]" value="bahan kimia"></td>
                                </tr>
                            </tbody>
                        </table>
                    </form>
                    <div style="margin-bottom: 5px;">
                        <a href="#" onclick="$('#diiya').submit()" class="btn btn-success">Verifikasi</a>
                        <!-- <?= site_url('permintaan_uji/verifikasi/' . $id_uji . '/tidak') ?>
                        <a href="#" class="btn btn-success">Tolak</a> -->
                        <button type='button' class='btn btn-primary' onclick="toi_modal_note_verifikasi(<?= $id_uji; ?>);">
                            Tolak
                        </button>
                    </div>
                </div>
            </div>
        </div>
        <!-- end panel -->
    </div>
</div>
<?= toi_modal_note_verifikasi($id_uji); ?>
<script>
    $("#masterCheckbox").click(function () {
        $(".cbku").prop("checked", $("#masterCheckbox").is(':checked'));
    });
    $(".cbku").click(function () {
        $("#masterCheckbox").prop("indeterminate", true);
    });
    $("#masterCheckbox").click();
</script>
