<form class="form-horizontal" method="post" id="formUjiSampel">
<div class="row">

<div class="col-lg-12">
    <div class="panel panel-lime">
        <div class="panel-heading">
            <a href="<?php echo site_url('ampel/pendaftaran'); ?>" class="btn btn-primary m-b-5"><span class="fa fa-arrow-left"></span> Kembali</a>
        </div>
    </div>
</div>
  <!-- begin col-8 -->
  <div class="col-lg-6">
      <!-- begin panel -->
      <div class="panel panel-lime">
          <div class="panel-heading">
            <h3>Permintaan Uji</h3>
          </div>
          <div class="panel-body">

            <div class="bg-default">

                <input type="hidden" name="id_uji_hidden" value="<?php echo (!empty($id_sampel) ? $id_sampel : null); ?>">
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Jenis Layanan<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <select name="id_jenis_layanan" onchange="regLab(this.value);" class="form-control default-select2" required>
                            <option readonly></option>
                            <?php foreach ($jenis_layanan as $r) { ?>
                                <option value="<?php echo $r['singkatan'] ?>"><?php echo $r['nama_jenis'] ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Registrasi Laboratorium<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control" name="registrasi_laboratorium" id="registrasi_laboratorium" type="text" placeholder="Masukkan Registrasi Laboratorium" required readonly>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Tanggal Pukul Pengambilan<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control datetimepicker1" autocomplete="false" name="tgl_pukul_pengambilan" id="tgl_pukul_pengambilan" type="text" placeholder="Masukkan Tanggal Pukul Pengambilan" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Tanggal Pukul Registrasi<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control datetimepicker1" autocomplete="false" name="tgl_pukul_registrasi" id="tgl_pukul_registrasi" type="text" placeholder="Masukkan Tanggal Pukul Registrasi" required>
                    </div>
                </div>

                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Asal Instansi/Umum<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control" name="instansi_umum" id="instansi_umum" type="text" placeholder="Masukkan Asal Instansi/Umum" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Alamat<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control" name="alamat" id="alamat" type="text" placeholder="Masukkan Alamat" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Nama Pemohon<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control" name="nama_pemohon" id="nama_pemohon" type="text" placeholder="Masukkan Nama Pemohon" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Nomor Telepon<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control" name="nomor_telepon" id="nomor_telepon" type="text" placeholder="Masukkan Nomor Telepon" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Email Pemohon<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control" name="email_pemohon" id="email_pemohon" type="email" placeholder="Masukkan Email Pemohon" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Sumber Dana<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control" name="sumber_dana" id="sumber_dana" type="text" placeholder="Masukkan Sumber Dana" required>
                    </div>
                </div>
            </div>
        </div>
      </div>
  </div>

  <div class="col-lg-6">
      <!-- begin panel -->
      <div class="panel panel-lime">
          <div class="panel-heading">
          <h3 class="txt-sampel">Sampel <?php echo empty($addData) ? '1' : $addData['idn']?></h3>
          </div>
          <div class="panel-body">
          <?php $i = 0; foreach($editSampel as $r){ $i++; $x= intval($i - 1)?>
            <div id="form_sampel" class="">
            <div id="form_sampel_0">
                <!-- <h3 class="txt-sampel">Sampel <?php echo empty($r['cek']) ? $i : '1' ?></h3> -->
                <input type="hidden" name="id_sampel_hidden<?php echo empty($r['cek']) ? '['.$x.']' : '[]' ?>" value="">
                <input type="hidden" name="id_disposisi_hidden<?php echo empty($r['cek']) ? '['.$x.']' : '[]' ?>" value="">
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Asal Sampel<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control asal_sampel" name="asal_sampel[]" type="text" placeholder="Asal Sampel" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Klasifikasi<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <!-- <input class="form-control klasifikasi" name="klasifikasi[]" type="text" placeholder="Klasifikasi" required> -->
                        <select class="form-control default-select2 klasifikasi" name="klasifikasi[]" required>
                            <option></option>
                            <?php foreach ($klasifikasi as $r) { ?>
                                <option value="<?php echo $r['id_jenis']; ?>">
                                    <?php echo $r['nama_jenis']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Golongan Sampel<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <select class="form-control default-select2 id_keterangan" name="id_keterangan[]" required>
                            <option></option>
                            <?php foreach ($gol_sampel as $r) { ?>
                                <option value="<?php echo $r['id_jenis']; ?>">
                                    <?php echo $r['nama_jenis']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Jenis Sampel<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <!-- <input class="form-control id_jenis_sampel" name="id_jenis_sampel[]" type="text" placeholder="Jenis Sampel" required> -->
                        <select class="form-control default-select2 id_jenis_sampel" name="id_jenis_sampel[]" required>
                            <option></option>
                            <?php foreach ($jenis_sampel as $r) { ?>
                                <option value="<?php echo $r['id_jenis']; ?>">
                                    <?php echo $r['nama_jenis']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Kualitas<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <!-- <input class="form-control kualitas" name="kualitas[]" type="text" placeholder="Kualitas" required> -->
                        <select class="form-control default-select2 kualitas" name="kualitas[]" required>
                            <option></option>
                            <option value="Baik">Baik</option>
                            <option value="Tidak Baik">Tidak Baik</option>
                        </select>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Bentuk/Jenis<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control bentuk_jenis" name="bentuk_jenis[]" type="text" placeholder="Bentuk/Jenis" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Jenis Pengujian<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <!-- <input class="form-control jenis_pengujian" name="jenis_pengujian[]" type="text" placeholder="Jenis Pengujian" required> -->
                        <select name="jenis_pengujian[0][]" class="form-control  default-select2 jenis_pengujian" multiple="" required>
                            <option></option>
                            <?php foreach ($jenis_pengujian as $r) { ?>
                                <option value="<?php echo $r['id_jenis']; ?>">
                                    <?php echo $r['nama_jenis'] ?>
                                </option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Label Pakan<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control label_pakan" name="label_pakan[]" type="text" placeholder="Label Pakan" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Petugas Pengambil Sampel<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control petugas_pengambil_sampel" name="petugas_pengambil_sampel[]" type="text" placeholder="Petugas Pengambil Sampel" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Penanganan Sampel<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <!-- <input class="form-control id_penanganan_sampel" name="id_penanganan_sampel[]" type="text" placeholder="Masukkan Penanganan Sampel" required> -->
                        <select class="form-control default-select2 id_penanganan_sampel" name="id_penanganan_sampel[]" required>
                            <option></option>
                            <?php foreach ($penanganan_sampel as $r) { ?>
                                <option value="<?php echo $r['id_jenis']; ?>">
                                    <?php echo $r['nama_jenis']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Berat Sampel<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control berat_sampel" name="berat_sampel[]" type="text" placeholder="Masukkan Berat Sampel" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Satuan Berat<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control satuan_sampel" name="satuan_sampel[]" type="text" placeholder="Masukkan Satuan Berat" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Kemasan<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <input class="form-control kemasan" name="kemasan[]" type="text" placeholder="Masukkan Kemasan" required>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Penyimpanan Sampel Kerja<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <!-- <input class="form-control sampel_kerja" name="sampel_kerja[]" type="text" placeholder="Masukkan Penyimpanan Sampel Kerja" required> -->
                        <select class="form-control default-select2 id_sampel_kerja" name="id_sampel_kerja[]" required>
                            <option></option>
                            <?php foreach ($sampel_kerja as $r) { ?>
                                <option value="<?php echo $r['id_jenis']; ?>">
                                    <?php echo $r['nama_jenis']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label">Penyimpanan Sampel Arsip<span class="text-danger">*</span></label>
                    <div class="col-md-8">
                        <!-- <input class="form-control sampel_arsip" name="sampel_arsip[]" type="text" placeholder="Masukkan Penyimpanan Sampel Arsip" required> -->
                        <select class="form-control default-select2 id_sampel_arsip" name="id_sampel_arsip[]" required>
                            <option></option>
                            <?php foreach ($sampel_arsip as $r) { ?>
                                <option value="<?php echo $r['id_jenis']; ?>">
                                    <?php echo $r['nama_jenis']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </div>
                </div>

            </div>
            </div>
            <?php } ?>
         </div>
      </div>
  </div>

  <div class="col-lg-12">
      <!-- begin panel -->
      <div class="panel panel-lime">
          <div class="panel-heading">
                  <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>
          <div class="panel-body">

            <div class="com-md-10" style="margin-top: 5px;">
                <div class="form-group m-b-12">
                    <label class="col-md-4 col-form-label control-label"></label>
                    <div class="col-md-8">
                        <button type="button" onclick="saveData(0)" class="btn btn-md btn-success">Simpan Data</button>
                        <button type="reset" class="btn btn-md btn-warning">Reset</button>
                        <a onclick="goBack();" class="btn btn-md btn-danger">Batal</a>
                        <button type="button" onclick="saveData(<?php echo empty($addData) ? '1' : $addData['idn']?>)" class="btn btn-md btn-success">Tambah Sampel</button>
                    </div>
                </div>
            </div>

          </div>
      </div>
  </div>
  <input type="text" id="idn" name="idn">

</div>
</form>

<script>

    function saveData(x) {
        $('#idn').val(x);
        $('#formUjiSampel').submit();
    }

    function regLab(x){
        $("#registrasi_laboratorium").val('<?php echo $jumlahUji.'.'.date("m.Y") ?>'+x);
    }

    function delSampel(){
        $("#form_sampel_"+this.y).hide();
        this.y = this.x-1;
        this.y = this.y-1;
        alert(this.y);
    }
</script>
