<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($method)) { ?>
	            	<?php echo menu_parameter($jenis_uji, false, null, $role_analis) ?>
					<div style="margin-top: 5px;">
		            	<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>
					</div>
				
					<a style="margin-top:5px;" href="<?php echo site_url('sampel/analis/batch/'.$jenis_uji); ?>" class="btn btn-info btn-sm">
						Batch
					</a>
				<?php }else{ ?>
					<?php if(empty($kontrol_sampel)) { ?>
						<a href="<?php echo site_url('sampel/analis/batch/'.$jenis_uji); ?>" class="btn btn-primary">
							Kembali
						</a>
					<?php }else { ?>
						<a href="<?php echo site_url('sampel/analis/kontrol_sampel/'.$jenis_uji.'?nomor_batch='.$this->input->get('nomor_batch').'&method=kontrol_sampel'); ?>" class="btn btn-primary">
							Kembali
						</a>
					<?php } ?>
					<br>
					<br>
					<span style="font-size:20px;">Nomor Batch: <?php echo $this->input->get('nomor_batch') ?></span>
				<?php } ?>

				<hr id="hr1">

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

            	<form id="form_edit_analis" method="post">

					<?php if(!empty($method) && $method == 'batch_sampel') { ?>
	            		<button style="margin-bottom: 3px;" id="hapus_analis" type="button" class="btn btn-warning btn-sm" onclick="onHapus()">Hapus</button>
					<?php } ?>

					<?php if(!empty($method) && $method == 'batch_sampel') { ?>
            			<button style="margin-bottom: 3px;" id="edit_analis" type="button" class="btn btn-primary btn-sm" onclick="onEdit()"><?php echo !empty($method) ? ($method == 'batch_sampel' ? 'Edit Batch' : (!empty($kontrol_sampel) ? 'Tambah Sampel ke Batch '. $this->input->get('nomor_batch') : 'Buat Kontrol Sampel')) : 'Buat 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 } ?>

            		<!-- Trigger the modal with a button -->

					<!-- 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;" class="mulai_uji" onchange="klik_tgl('nomor_batch2');" type="date" id="nomor_batch2" name="nomor_batch2" value="">
								<input class="form-control text-center" id="c_nomor_batch2" placeholder="Kode Tanggal Nomor Batch"  readonly>
							</div>
					      </div>
					      <div class="modal-footer">
					      	<button style="margin-bottom: 3px;" id="" type="button" class="btn btn-primary btn-sm" onclick="onEdit()"><?php echo !empty($method) ? ($method == 'batch_sampel' ? 'Edit Batch' : (!empty($kontrol_sampel) ? 'Tambah Sampel ke Batch '. $this->input->get('nomor_batch') : 'Buat Kontrol Sampel')) : 'Buat Batch';?></button>
					        <button type="button" class="btn btn-default" data-dismiss="modal">Keluar</button>
					      </div>
					    </div>

					  </div>
					</div>

					<?php if(empty($method)) {?>
						<input type="hidden" value="edit" name="method">
					<?php } else{?>
						<input type="hidden" value="<?php echo $method; ?>" name="method">
						<input type="hidden" value="<?php echo $this->input->get('nomor_batch') ?>" name="nomor_batch">
						<?php if(!empty($kontrol_sampel)){ ?>
							<input type="hidden" value="<?php echo $kontrol_sampel; ?>" name="kontrol_sampel">
						<?php } ?>
					<?php } ?>

					<?php if(!empty($method) && $method != 'kontrol_sampel') { ?>
						<?php if(in_array($jenis_uji, array('ca', 'af', 'ur', 'fosfor'))) { ?>
							<?php 
								$jam_mulai = strpos($data[0]['mulai_uji'], '00:00:00') == false ? date('H', strtotime($data[0]['mulai_uji'])) : date('H'); 
								$menit_mulai = strpos($data[0]['mulai_uji'], '00:00:00') == false ? date('H', strtotime($data[0]['mulai_uji'])) : date('i');
								$jam_selesai = strpos($data[0]['selesai_uji'], '00:00:00') == false ? date('H', strtotime($data[0]['selesai_uji'])) : date('H'); 
								$menit_selesai = strpos($data[0]['selesai_uji'], '00:00:00') == false ? date('H', strtotime($data[0]['selesai_uji'])) : date('i');
							?>
							<table class=" table table1">
								<tr>
									<th>Terbitan/Revisi</th>
									<td>:</td>
									<td><?php echo $data[0]['terbitan_revisi_ke'] ?></td>

									<th>Tanggal Revisi</th>
									<td>:</td>
									<td><?php echo toi_date03($data[0]['tanggal_revisi']); ?></td>

									<th style="width:100px;"></th>
								</tr>
								<tr>
									<th>Tanggal Terbitan</th>
									<td>:</td>
									<td><?php echo toi_date03($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><?php echo toi_date03($data[0]['mulai_uji']); ?></td>

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

									<th></th>
								</tr>
								<tr>
									
									<th>Pukul Mulai Pengujian</th>
									<td>:</td>
									<td>
										<?php echo date('H:i', strtotime($data[0]['mulai_uji'])) ?>
									</td>

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

									<th></th>
								</tr>

								<tr>
									<th>Pukul Selesai Pengujian</th>
									<td>:</td>
									<td><?php echo date('H:i', strtotime($data[0]['selesai_uji'])) ?></td>
									
									<th>Metode Uji</th>
									<th>:</th>
									<td><?php 
										if($jenis_uji == 'af'){
											echo ': Agra Quant Total Aflatoxin Test Kit';
										}else{
											echo "AOAC 2012 Bab 4 Butir 4.8.02 Metode 968.08";
										}
									?>
									</td>

									<td></td>
								</tr>
							</table>
						<?php }else { ?>
							<table class="table bg-inverse">
								<tr>
									<th>Suhu (ᵒC)</th>
									<td>:</td>
									<th> <?php echo empty($data[0]) ? '' : $data[0]['suhu']; ?></th>

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

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

									<th>Tanggal Terbitan</th>
									<td>:</td>
									<th><?php echo empty($data[0]) || is_null($data[0]['tanggal_terbitan']) ? '' : set_indo_date_from_timestemp($data[0]['tanggal_terbitan'].' 00:00:00'); ?></th>

									<th style="width:300px;"></th>
								</tr>
								<tr>
									<?php if($jenis_uji != 'kalsium') { ?>
										<th>Alat Uji</th>
										<td>:</td>
										<th> <?php echo empty($data[0]) ? '' : $data[0]['alat_uji']; ?></th>
									<?php } else { ?>
										<th>Metode Uji</th>
										<td>:</td>
										<th>
											AOAC 2012 Bab 4 Butir 4.8.03 Metode 927.02 
										</th>
									<?php } ?>

									<th>Tanggal Revisi</th>
									<td>:</td>
									<th><?php echo empty($data[0]) || is_null($data[0]['tanggal_revisi']) ? '' : set_indo_date_from_timestemp($data[0]['tanggal_revisi'].' 00:00:00'); ?></th>

									<th style="width:300px;"></th>
								</tr>
							</table>
						<?php } ?>
					<?php } ?>

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

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