<div class="row">
    <!-- begin col-8 -->
    <div class="col-lg-12">
        <!-- begin panel -->
        <div class="panel panel-lime">
            <div class="panel-heading">
            </div>
            <div class="panel-body">
                <div class="col-sm-8">
                    <form class="form-horizontal" method="post" name="" action="">
                        <input type="hidden" name="id_sampel" value="<?php echo (!empty($id_sampel) ? $id_sampel : null); ?>">
                        <div class="form-group m-b-11">
                            <label class="col-md-4 col-form-label control-label">Nomor Permintaan Uji</label>
                            <div class="col-md-7">
                                <input class="form-control" name="nomor_permintaan_uji" type="text" placeholder="Nomor Permintaan Uji" value="<?php echo $this->input->post('nomor_permintaan_uji') ?>">
                            </div>
                        </div>
                        <div class="form-group m-b-11">
                            <label class="col-md-4 col-form-label control-label">Registrasi Laboratorium</label>
                            <div class="col-md-7">
                                <input class="form-control" name="registrasi_laboratorium" type="text" placeholder="Registrasi Laboratorium" value="<?php echo $this->input->post('registrasi_laboratorium') ?>">
                            </div>
                        </div>

                        <div class="form-group m-b-11">
                            <label class="col-md-4 col-form-label control-label"></label>
                            <div class="col-md-7">
                                <button type="submit" class="btn btn-md btn-success">Cari</button>
                                <a href="<?php echo site_url('sampel/pendaftaran') ?>" class="btn btn-danger">Reset</a>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <!-- begin col-8 -->
    <div class="col-sm-12">
        <!-- begin panel -->
        <div class="panel panel-lime">
            <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="<?php echo site_url('sampel/pendaftaran/create_edit'); ?>" class="btn btn-primary">Tambah Data</a>
            </div>
            <div class="panel panel-body table-responsive">
                <table class="table table-bordered table-hover table-striped table-td-valign-middle data-tables">
                    <thead>
                    <tr class="lime">
                    <th rowspan="2" class="text-center">No</th>
                    <th rowspan="2" class="text-center">Aksi</th>
                    <th rowspan="2" class="text-center">Status Sampel</th>
                    <th rowspan="2" class="text-center">Jenis Pelayanan</th>
                    <th rowspan="2" class="text-center">Nomor Permintaan&nbsp;Uji</th>
                    <th rowspan="2" class="text-center">Registrasi Laboratorium</th>
                    <th rowspan="2" class="text-center">Tanggal/Pukul Pengembilan</th>
                    <th rowspan="2" class="text-center">Tanggal/Pukul Registrasi</th>
                    <th rowspan="2" class="text-center">Perkiraan&nbsp;Estimasi Selesai&nbsp;LHP</th>
                    <th rowspan="2" class="text-center">Tanggal/Pukul Mulai&nbsp;Uji</th>
                    <th rowspan="2" class="text-center">Tanggal/Pukul Terbit&nbsp;LHU</th>
                    <th rowspan="2" class="text-center">Tanggal/Pukul Terbit&nbsp;LHP</th>
                    <th rowspan="2" class="text-center">Tanggal dan Nomor&nbsp;Surat</th>
                    <th rowspan="2" class="text-center">Instansi/Perusahaan/Umum,&nbsp;Alamat, dan&nbsp;Nomor&nbsp;Telepon</th>
                    <th rowspan="2" class="text-center">Asal&nbsp;Sampel</th>
                    <th rowspan="2" class="text-center">Nomor Sampel</th>
                    <th rowspan="2" class="text-center">Jenis&nbsp;Sampel</th>
                    <th colspan="3"></th>
                    <th colspan="2" class="text-center">Kualitas</th>
                    <th rowspan="2" class="text-center">Bentuk Jenis</th>
                    <th rowspan="2" class="text-center">Jenis Pengujian</th>
                    <th rowspan="2" class="text-center">Label Pakan</th>
                    <th rowspan="2" class="text-center">Petugas Pengambil&nbsp;Sampel</th>
                    <th rowspan="2" class="text-center">Keterangan</th>
                    <th rowspan="2" class="text-center">Klasifikasi</th>
                    </tr>
                    <tr class="lime">
                        <th class="text-center">Basah</th>
                        <th class="text-center">Lembab</th>
                        <th class="text-center">Kering</th>
                        <th class="text-center">Baik</th>
                        <th class="text-center">Tidak Baik</th>
                    </tr>
                    </thead>
                    <tbody>
                        <?php
                        $z = 1;
                        foreach ($data as $r) {
                            ?>
                            <tr>
                                <?php
                                $sample = $this->m_pendaftaran->getSampel($r['id_uji']);
                                $tr = false;
                                ?>
                                <td <?php echo 'rowspan="' . count($sample) . '"' ?>><?php echo $this->uri->segment(3) + $z++ ?></td>
                                <td <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                    <div class="btn-group m-b-5 m-r-5">
                                        <a href="javascript:;" class="btn btn-success">Aksi</a>
                                        <a href="javascript:;" data-toggle="dropdown" class="btn btn-success dropdown-toggle" aria-expanded="false">
                                            <span class="caret"></span>
                                        </a>
                                        <ul class="dropdown-menu pull-right" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(70px, 32px, 0px);">
                                            <li><a href="<?php echo site_url('sampel/pendaftaran/detail'); ?>">Detail</a></li>
                                            <!-- <li><a href="<?php echo site_url('sampel/pendaftaran/create_edit?id_uji='.$r['id_uji']); ?>">Edit</a></li> -->
                                            <?php if(in_array($r['id_status'], array('1','2')) 
                                                && in_array($idGroup, array('1','2'))) { ?>
                                                <li><a href="<?php echo site_url('sampel/pendaftaran/verifikasi?id_uji='.$r['id_uji']) ?>">Verifikasi</a></li>
                                            <?php } ?>
                                            <?php if(in_array($r['id_status'], array('1')) 
                                                && in_array($idGroup, array('1','4'))){ ?>
                                                <li><a href="<?php echo site_url('sampel/pendaftaran/ajukan_sampel?id_uji='.$r['id_uji'].'&status=2') ?>">Ajukan Sampel</a></li>
                                            <?php } ?>
                                            <?php if(!in_array($r['id_status'], array('1','2'))) { ?>
                                                <li><a href="https://view.officeapps.live.com/op/view.aspx?src=<?php echo base_url(); ?>/template/NPPS.xlsx">Download NPPS</a></li>
                                                <li><a href="https://view.officeapps.live.com/op/view.aspx?src=<?php echo base_url(); ?>/template/TTPP.xlsx">Download TTPP</a></li>
                                            <?php } ?>
                                        </ul>
                                    </div>
                                </td>
                                <td class="text-center" <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                    <?php echo str_replace('Status', '', $r['status_sampel']).'<br>['.str_replace(' ','&nbsp;',$r['detail_status']).']' ?>
                                    <?PHP echo  $r['id_status'] === '14' ? '<br>['.str_replace(' ', '&nbsp;',strtoupper(str_replace('|', ', ', $r['kaji_ulang_permintaan']))).']' : '';?>
                                </td>
                                <td <?php echo 'rowspan="' . count($sample) . '"' ?>><?php echo $r['jenis_layanan'] ?></td>
                                <td class="text-center" <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                  <?php $pk = strlen($r['id_uji']);
                                    if($pk == 3) $idsm = '0'.$r['id_uji']; 
                                    else if($pk == 2) $idsm = '00'.$r['id_uji'];
                                    else if($pk == 1) $idsm = '000'.$r['id_uji'];

                                    echo $idsm;
                                  ?>
                                </td>
                                <td <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                    <?php echo $r['registrasi_laboratorium'] ?>
                                </td>
                                <td class="text-center" <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                    <?php echo $r['tgl_pukul_pengambilan'] ?>
                                </td>
                                <td class="text-center" <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                    <?php echo $r['tgl_pukul_registrasi'] ?>
                                </td>
                                <td class="text-center" <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                <?php echo !isset($r['perkiraan_estimasi_selesai_php']) || strpos($r['perkiraan_estimasi_selesai_php'],'000') !== false ? '-' : $r['perkiraan_estimasi_selesai_php'] ?>
                                </td>
                                <td class="text-center" <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                    <?php echo !isset($r['tgl_pukul_mulai_uji']) || strpos($r['tgl_pukul_mulai_uji'],'000') !== false ? '-' : $r['tgl_pukul_mulai_uji'] ?>
                                </td>
                                <td class="text-center" <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                    <?php echo !isset($r['tgl_pukul_terbit_lhu']) || strpos($r['tgl_pukul_terbit_lhu'],'000') !== false ? '-' : $r['tgl_pukul_terbit_lhu'] ?>
                                </td>
                                <td class="text-center" <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                    <?php echo !isset($r['tgl_pukul_terbit_lhp']) || strpos($r['tgl_pukul_terbit_lhp'],'000') !== false ? '-' : $r['tgl_pukul_terbit_lhp'] ?>
                                </td>
                                <td class="text-center" <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                    <?php echo !isset($r['tgl_surat']) || strpos($r['tgl_surat'],'000') !== false ? '-' : $r['tgl_surat'] ?>
                                    <?php echo !isset($r["nomor_surat"]) || $r["nomor_surat"] === '0' ? '<br>-' : "<br>" . $r["nomor_surat"] ?>
                                </td>
                                <td class="text-center" <?php echo 'rowspan="' . count($sample) . '"' ?>>
                                    <?php echo $r['instansi_umum'] . "<br>" . $r["alamat"] . "<br>" . $r["nomor_telepon"] . "<br>" . $r["email_pemohon"] . "<br>" . $r["nama_pemohon"] . "<br>" . $r["sumber_dana"]?>
                                </td>
                                <?php foreach ($sample as $s) { ?>
                                    <?php if ($tr) { ?>
                                    <tr>
                                    <?php }$tr = true ?>
                                    <td><?php echo $s['asal_sampel'] ?></td>
                                    <td class="text-center">
                                      <?php $pk = strlen($s['id_sampel']);
                                        if($pk == 3) $idsm = '0'.$s['id_sampel']; 
                                        else if($pk == 2) $idsm = '00'.$s['id_sampel'];
                                        else if($pk == 1) $idsm = '000'.$s['id_sampel'];

                                        echo $idsm;
                                      ?>
                                    </td>
                                    <td><?php //echo $s['bahan_sampel'] ?></td>
                                    <td><?php echo $s['id_jenis_sampel']==1?'√':'-' ?></td>
                                    <td><?php echo $s['id_jenis_sampel']==2?'√':'-' ?></td>
                                    <td><?php echo $s['id_jenis_sampel']==3?'√':'-' ?></td>
                                    <td><?php echo $s['kualitas']=='Baik'?'√':'-' ?></td>
                                    <td><?php echo $s['kualitas']=='Tidak Baik'?'√':'-' ?></td>
                                    <td><?php echo $s['bentuk_jenis'] ?></td>
                                    <td>
                                    <!-- <?php 
                                        $prUji = explode('|',$s['jenis_pengujian']);
                                        $x = count($prUji);
                                        for($i=0; $i < $x; $i++){
                                            if (isset($prUji[$i]) && $prUji[$i] !== '') 
                                                echo $this->m_master->getParameterUji($prUji[$i]).', ';
                                        }
                                    ?> -->
                                    </td>
                                    <td><?php echo $s['label_pakan'] ?></td>
                                    <td><?php echo $s['petugas_pengambil_sampel'] ?></td>
                                    <td><?php echo $s['keterangan'] ?></td>
                                    <td><?php echo $s['nama_kesimpulan'] ?></td>
                                </tr>
                            <?php } ?>
                        <?php } ?> 
                    </tbody>
                </table>
            </div>
            <div class="row">
                <div class="col-sm-12" style="margin-top: 10px;">
                    <?php if ($link_paging) { ?> 
                        <ul class="pagination pagination-sm no-margin">
                            <?php echo $link_paging; ?> 
                        </ul>
                    <?php } ?>
                </div>
            </div>
        </div>
        <!-- end panel -->
    </div>
</div>


<div class="modal fade" id="modal-alert" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">Peringatan pengajuan</h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-danger m-b-0" id="peringatan">
                    <p><b>Konfirmasi:</b> Apakah anda akan mengajukan Sampel ini?</p>
                </div>
                <div id="ditolak">
                    <input type="checkbox" name="kaji_ulang[]">
                </div>
            </div>
            <div class="modal-footer">
                <a href="javascript:;" class="btn width-100 btn-success" data-dismiss="modal">Ya</a>
                <a onclick="ditolak();" class="btn width-100 btn-danger">Tidak</a>
            </div>
        </div>
    </div>
</div>
