<style type="text/css">
  .width-td{width: 100px;}

  .table1 > thead > tr > th {
     vertical-align: middle;
     text-align: left;
  }
  .table1 > tbody > tr > td {
     vertical-align: middle;
     text-align: left;
  }

</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>
				</div>

				<!-- ---------------------------------------------------------------------- -->
				<?php if(empty($kontrol_sampel)) : ?>
					<div class="row">
						<div>
							<?= select_parameter($jenis_uji); ?>
						</div>
						<div style="margin-left:4px;">
							<button class="btn btn-primary" id="bt_cari1" onclick="cari1();">
								<span class="fa fa-search"></span> Pencarian
							</button>
							<button class="btn btn-primary" id="bt_cari2" onclick="cari2();">
								<span class="fa fa-search"></span> Pencarian
							</button>
						
							<a href="<?= site_url('batch_list/'.$jenis_uji); ?>" class="btn btn-warning">
								Batch
							</a>
						</div>
					</div>
				<?php else : ?>
					<a href="<?= site_url('kontrol_sampel_list/'.$jenis_uji.'/'.$nomor_batch); ?>" class="btn btn-primary">
						Kembali
					</a>
					<a class="btn btn-warning" href="<?= base_url('edit_batch_uji/'.$jenis_uji.'/'.$nomor_batch.'/'.$kontrol_sampel); ?>">
						Edit Batch
					</a>
				<?php endif; ?>
				
				<hr>
				<!-- ------------------------------------------------------------------------- -->

				<?php $this->load->view('uji_analis/form_filter', true); ?>

				<form id="form_edit_analis" method="post">
					<?php if(!empty($kontrol_sampel)) : ?>
                        <input type="hidden" name="nomor_batch" value="<?= $nomor_batch; ?>">
                        <input type="hidden" name="kontrol_sampel" value="<?= $kontrol_sampel; ?>">
						<button style="margin-bottom: 3px;" id="hapus_analis" type="button" class="btn btn-warning btn-sm" onclick="onHapus()">
							Hapus
						</button>
						<!-- <button style="margin-bottom: 3px;" id="edit_analis" type="button" class="btn btn-primary btn-sm" onclick="onEdit()">
							Edit Batch
						</button> -->
					<?php else : ?>
						<button type="button" id="edit_analis" class="btn btn-info btn-sm" data-toggle="modal" data-target="#myModal">
							Buat Batch
						</button>
					<?php endif;?>
					
					<!-- Modal -->
					<div id="myModal" class="modal fade" role="dialog">
						<div class="modal-dialog modal-sm">

						<!-- Modal content-->
						<div class="modal-content">
							<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal">&times;</button>
							<h4 class="modal-title">Masukkan Kode Tanggal Nomor Batch</h4>
							</div>
							<div class="modal-body">
							<div style="width:400px; margin-left:15%;" class="input-group">
								<input style="width:50px;" onchange="klik_tgl('tgl_batch');" type="date" id="tgl_batch" name="tgl_batch" value="">
								<input class="form-control text-center" id="c_tgl_batch" placeholder="Kode Tanggal Nomor Batch"  readonly>
							</div>
							</div>
							<div class="modal-footer">
							<button style="margin-bottom: 3px;" type="button" onclick="onEdit();" class="btn btn-primary btn-sm">Buat Batch</button>
							<button type="button" class="btn btn-default" data-dismiss="modal">Keluar</button>
							</div>
						</div>

						</div>
					</div>

					<?php if(!empty($kontrol_sampel) && count($data) > 0) : ?>
						<?php if(in_array($jenis_uji, ['ca', 'af', 'ur', 'fosfor'])) : ?>
							<table class=" table table1">
                                <tr>
									<th>Nomor Bagian</th>
									<td>:</td>
									<td><?= $data[0]['nomor_bagian'] ?></td>

									<th>Halaman</th>
									<td>:</td>
									<td><?= $data[0]['halaman']; ?></td>

									<th style="width:100px;"></th>
								</tr>
								<tr>
									<th>Terbitan/Revisi</th>
									<td>:</td>
									<td><?= $data[0]['terbitan_revisi_ke'] ?></td>

									<th>Tanggal Revisi</th>
									<td>:</td>
									<?php if($data[0]['tanggal_revisi'] == 0) : ?>
                                        <th>-</th>
                                    <?php else : ?>
                                        <th><?= get_str_date2($data[0]['tanggal_revisi']); ?></th>
                                    <?php endif; ?>

									<th style="width:100px;"></th>
								</tr>
								<tr>
									<th>Tanggal Terbitan</th>
									<td>:</td>
									<td><?= get_str_date2($data[0]['tanggal_terbitan']); ?></td>
									<th></th> <th></th> <th></th>
									<th style="width:100px;"></th>
								</tr>
								<tr>
									<th>Tanggal Pengujian</th>
									<td>:</td>
									<td><?= get_str_date2($data[0]['mulai_uji']); ?></td>

									<th>Suhu (ᵒC)</th>
									<td>:</td>
									<td><?= $data[0]['suhu'] ?></td>

									<th></th>
								</tr>
								<tr>
									
									<th>Pukul Mulai Pengujian</th>
									<td>:</td>
									<td>
										<?= get_str_time($data[0]['mulai_uji']); ?>
									</td>

									<th>RH (%)</th>
									<td>:</td>
									<th><?= $data[0]['rh'] ?></th>

									<th></th>
								</tr>

								<tr>
									<th>Pukul Selesai Pengujian</th>
									<td>:</td>
									<td><?= get_str_time($data[0]['selesai_uji']); ?></td>
									
									<th>Metode Uji</th>
									<th>:</th>
									<td><?= $data[0]['metode_uji'] ?></td>

									<td></td>
								</tr>
							</table>
						<?php else : ?>
							<table class="table">
                                <tr>
									<th>Nomor Bagian</th>
									<td>:</td>
									<td><?= $data[0]['nomor_bagian'] ?></td>

									<th>Halaman</th>
									<td>:</td>
									<td><?= $data[0]['halaman']; ?></td>

									<th style="width:100px;"></th>
								</tr>
								<tr>
									<th>Suhu (ᵒC)</th>
									<td>:</td>
									<th> <?= empty($data[0]) ? '' : $data[0]['suhu']; ?></th>

									<th>Terbitan/Revisi</th>
									<td>:</td>
									<th> <?= empty($data[0]) ? '' : $data[0]['terbitan_revisi_ke']; ?></th>

									<th style="width:300px;"></th>
								</tr>
								<tr>
									<th>RH (%)</th>
									<td>:</td>
									<th> <?= empty($data[0]) ? '' : $data[0]['rh']; ?></th>

									<th>Tanggal Terbitan</th>
									<td>:</td>
									<th><?= get_str_date2($data[0]['tanggal_terbitan']); ?></th>

									<th style="width:300px;"></th>
								</tr>
								<tr>
                                    <th>Metode Uji</th>
                                    <td>:</td>
                                    <th>
                                        <?= $data[0]['metode_uji'] ?>
                                    </th>

									<th>Tanggal Revisi</th>
									<td>:</td>
                                    <?php if($data[0]['tanggal_revisi'] == 0) : ?>
                                        <th>-</th>
                                    <?php else : ?>
                                        <th><?= get_str_date2($data[0]['tanggal_revisi']); ?></th>
                                    <?php endif; ?>

									<th style="width:300px;"></th>
								</tr>
                                <?php if(!in_array($jenis_uji, ['fosfor', 'ca', 'af', 'ur', 'kalsium', 'lemak_kasar', 'protein_kasar', 'andf', 'serat_kasar'])) : ?>
                                    <tr>
                                        <th>Alat Uji</th>
                                        <td>:</td>
                                        <th>
                                            <?php
                                                $str_alat = '';
                                                $alat = ($data[0]['alat_uji']) ? json_decode($data[0]['alat_uji']) : '';
                                                if($alat != ''){
                                                    foreach($alat as $a){
                                                        $str_alat .= $this->m_analis->get_alat_uji_by_id($a)['nama_alat'].', ';
                                                    }
                                                }
                                                $str_alat = substr($str_alat, 0, -2);
                                                echo $str_alat;
                                            ?>
                                        </th>

                                        <th>Nama Analis</th>
                                        <td>:</td>
                                        <td><?= $data[0]['nama_analis']; ?></td>
                                        <th style="width:300px;"></th>
                                    </tr>
                                <?php endif; ?>
							</table>
						<?php endif; ?>
					<?php endif; ?>

        		</div>
    		<div class="panel panel-body table-responsive">

          <!-- CONTENT table-->
    <!-- </div> -->
