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

<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/pengajuan') ?>" class="btn btn-primary m-b-5"><span class="fa fa-arrow-left"></span> Kembali</a>
            </div>
            <div class="panel panel-body table-responsive">
                <table class="table table-bordered table-hover table-striped table-td-valign-middle">
                	<thead>
                		<tr>
	                		<th rowspan="2" class="text-center">No.</th>
	                		<th rowspan="2" class="text-center">Aksi</th>
	                		<th rowspan="2" class="text-center">Nomor Sampel</th>
	                		<th colspan="7" class="text-center">Hasil Pengujian (%)</th>
	                	</tr>
	                	<tr>
	                		<th class="text-center">Air</th>
	                		<th class="text-center">Abu</th>
	                		<th class="text-center">Protein&nbsp;Kasar</th>
	                		<th class="text-center">Lemak&nbsp;Kasar</th>
	                		<th class="text-center">Serat&nbsp;Kasar</th>
	                		<th class="text-center">Kalsium</th>
	                		<th class="text-center">Fosfor</th>
	                	</tr>
                	</thead>
                	<tbody>
						<form method="post" action="<?php echo site_url("sampel/pengajuan/save_uji_sampel") ?>">
                		<?php $z = 0; foreach ($data as $r) { ?>
                		<tr> <?php $z++; ?>
                			<td rowspan="4" class="text-center"><?php echo $z; ?></td>
                			<?php //if(empty($status)) { ?>
                			<td rowspan="2" class="text-center">
                				<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" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(70px, 32px, 0px);">
	                                  <li>
	                                    <a href="<?php echo site_url('sampel/pengajuan/uji_air') ?>">Uji Sampel</a>
	                                  </li>
									  <?php if(empty($this->input->get('create_edit'))){ ?>
										<li>
										<a href="<?php echo site_url('sampel/pengajuan/mulai_uji_sampel?id_uji='.$this->input->get('id_uji').'&status='.$this->input->get('status').'&create_edit=1') ?>">Edit</a>
										</li>
									  <?php } ?>
									  <?php if(!empty($this->input->get('create_edit'))){ ?>
									  <li>
										<button class="btn btn-link" type="submit">Simpan</button>
	                                    <!-- <a href="#" onclick="save_uji_sampel(<?php echo $r['nomor_sampel'];?>)">Simpan</a> -->
	                                  </li>
									  <?php } ?>
	                              </ul>
	                            </div>
                			</td>
                            <?php //} ?>
                            <td class="text-center">
							  <?php $pk = strlen($r['nomor_sampel']);
                                if($pk == 3) $idsm = '0'.$r['nomor_sampel'];
                                else if($pk == 2) $idsm = '00'.$r['nomor_sampel'];
                                else if($pk == 1) $idsm = '000'.$r['nomor_sampel'];

                                echo $idsm;
                              ?>
							</td>

							<input type="hidden" name="id_uji" value="<?php echo $this->input->get('id_uji') ?>">
							<input type="hidden" name="status" value="<?php echo $this->input->get('status') ?>">
							<input type="hidden" name="id_sampel[]" value="<?php echo $r['nomor_sampel'] ?>">

						    <?php if(empty($this->input->get('create_edit'))){ ?>
								<td class="text-center"><?php echo $r['l_air']?></td>
								<td class="text-center"><?php echo $r['l_abu']?></td>
								<td class="text-center"><?php echo $r['l_protein_kasar']?></td>
								<td class="text-center"><?php echo $r['l_lemak_kasar']?></td>
								<td class="text-center"><?php echo $r['l_serat_kasar']?></td>
								<td class="text-center"><?php echo $r['l_kalsium']?></td>
								<td class="text-center"><?php echo $r['l_fosfor']?></td>
							<?php } ?>


							<?php if(!empty($this->input->get('create_edit'))){ ?>
                            <td><input value="<?php echo $r['air'] ?>" id="uji_air<?php echo $r['nomor_sampel'] ?>" class="width-td" type="" name="air[]"></td>
                            <td><input value="<?php echo $r['abu'] ?>" id="uji_abu<?php echo $r['nomor_sampel'] ?>" class="width-td" type="" name="abu[]"></td>
                            <td><input value="<?php echo $r['protein_kasar'] ?>" id="uji_protein_kasar<?php echo $r['nomor_sampel'] ?>" class="width-td" type="" name="protein_kasar[]"></td>
                            <td><input value="<?php echo $r['lemak_kasar'] ?>" id="uji_lemak_kasar<?php echo $r['nomor_sampel'] ?>" class="width-td" type="" name="lemak_kasar[]"></td>
                            <td><input value="<?php echo $r['serat_kasar'] ?>" id="uji_serat_kasar<?php echo $r['nomor_sampel'] ?>" class="width-td" type="" name="serat_kasar[]"></td>
                            <td><input value="<?php echo $r['kalsium'] ?>" id="uji_kalsium<?php echo $r['nomor_sampel'] ?>" class="width-td" type="" name="kalsium[]"></td>
                            <td><input value="<?php echo $r['fosfor'] ?>" id="uji_fosfor<?php echo $r['nomor_sampel'] ?>" class="width-td" type="" name="fosfor[]"></td>
							<?php } ?>
                		</tr>
                		<tr>
                			<th class="text-center">Metode</th>

							<td><?php echo $this->m_master->getMetodeUji(1)[0]['detail']; ?></td>
                			<td><?php echo $this->m_master->getMetodeUji(2)[0]['detail']; ?></td>
                			<td><?php echo $this->m_master->getMetodeUji(3)[0]['detail']; ?></td>
                			<td><?php echo $this->m_master->getMetodeUji(5)[0]['detail']; ?></td>
                			<td><?php echo $this->m_master->getMetodeUji(6)[0]['detail']; ?></td>
                			<td><?php echo $this->m_master->getMetodeUji(7)[0]['detail']; ?></td>
                			<td><?php echo $this->m_master->getMetodeUji(9)[0]['detail']; ?></td>

                			<!-- <td><textarea style="width: 100%;"></textarea></td>
                			<td><textarea style="width: 100%;"></textarea></td>
                			<td><textarea style="width: 100%;"></textarea></td>
                			<td><textarea style="width: 100%;"></textarea></td>
                			<td><textarea style="width: 100%;"></textarea></td>
                			<td><textarea style="width: 100%;"></textarea></td>
                			<td><textarea style="width: 100%;"></textarea></td> -->
                		</tr>
                		<tr>
                			<th class="text-center" colspan="2">Tanggal&nbsp;Mulai&nbsp;Pengujian</th>

							<?php if(empty($this->input->get('create_edit'))){ ?>
								<td class="text-center"><?php echo strpos($r['mulai_uji_air'], '000') === false ? $r['mulai_uji_air'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['mulai_uji_abu'], '000') === false ? $r['mulai_uji_abu'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['mulai_uji_protein_kasar'], '000') === false ? $r['mulai_uji_protein_kasar'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['mulai_uji_lemak_kasar'], '000') === false ? $r['mulai_uji_lemak_kasar'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['mulai_uji_serat_kasar'], '000') === false ? $r['mulai_uji_serat_kasar'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['mulai_uji_kalsium'], '000') === false ? $r['mulai_uji_kalsium'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['mulai_uji_fosfor'], '000') === false ? $r['mulai_uji_fosfor'] : ''?></td>
							<?php } ?>

							<?php if(!empty($this->input->get('create_edit'))){ ?>
								<td><input value="<?php echo strpos($r['mulai_uji_air'], '000') === false ? $r['mulai_uji_air'] : '' ?>" id="mulai_uji_air<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="mulai_uji_air[]"></td>
								<td><input value="<?php echo strpos($r['mulai_uji_abu'], '000') === false ? $r['mulai_uji_abu'] : '' ?>" id="mulai_uji_abu<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="mulai_uji_abu[]"></td>
								<td><input value="<?php echo strpos($r['mulai_uji_protein_kasar'], '000') === false ? $r['mulai_uji_protein_kasar'] : '' ?>" id="mulai_uji_protein_kasar<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="mulai_uji_protein_kasar[]"></td>
								<td><input value="<?php echo strpos($r['mulai_uji_lemak_kasar'], '000') === false ? $r['mulai_uji_lemak_kasar'] : '' ?>" id="mulai_uji_lemak_kasar<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="mulai_uji_lemak_kasar[]"></td>
								<td><input value="<?php echo strpos($r['mulai_uji_serat_kasar'], '000') === false ? $r['mulai_uji_serat_kasar'] : '' ?>" id="mulai_uji_serat_kasar<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="mulai_uji_serat_kasar[]"></td>
								<td><input value="<?php echo strpos($r['mulai_uji_kalsium'], '000') === false ? $r['mulai_uji_kalsium'] : '' ?>" id="mulai_uji_kalsium<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="mulai_uji_kalsium[]"></td>
								<td><input value="<?php echo strpos($r['mulai_uji_fosfor'], '000') === false ? $r['mulai_uji_fosfor'] : '' ?>" id="mulai_uji_fosfor<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="mulai_uji_fosfor[]"></td>
							<?php } ?>
                		</tr>
                		<tr>
                			<th class="text-center" colspan="2">Tanggal&nbsp;Selesai&nbsp;Pengujian</th>

							<?php if(empty($this->input->get('create_edit'))){ ?>
								<td class="text-center"><?php echo strpos($r['selesai_uji_air'], '000') === false ? $r['selesai_uji_air'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['selesai_uji_abu'], '000') === false ? $r['selesai_uji_abu'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['selesai_uji_protein_kasar'], '000') === false ? $r['selesai_uji_protein_kasar'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['selesai_uji_lemak_kasar'], '000') === false ? $r['selesai_uji_lemak_kasar'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['selesai_uji_serat_kasar'], '000') === false ? $r['selesai_uji_serat_kasar'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['selesai_uji_kalsium'], '000') === false ? $r['selesai_uji_kalsium'] : ''?></td>
								<td class="text-center"><?php echo strpos($r['selesai_uji_fosfor'], '000') === false ? $r['selesai_uji_fosfor'] : ''?></td>
							<?php } ?>

							<?php if(!empty($this->input->get('create_edit'))){ ?>
								<td><input value="<?php echo strpos($r['selesai_uji_air'], '000') === false ? $r['selesai_uji_air'] : '' ?>" id="selesai_uji_air<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="selesai_uji_air[]"></td>
								<td><input value="<?php echo strpos($r['selesai_uji_abu'], '000') === false ? $r['selesai_uji_abu'] : '' ?>" id="selesai_uji_abu<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="selesai_uji_abu[]"></td>
								<td><input value="<?php echo strpos($r['selesai_uji_protein_kasar'], '000') === false ? $r['selesai_uji_protein_kasar'] : '' ?>" id="selesai_uji_protein_kasar<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" nauji_protein_kasar[]"></td>
								<td><input value="<?php echo strpos($r['selesai_uji_lemak_kasar'], '000') === false ? $r['selesai_uji_lemak_kasar'] : '' ?>" id="selesai_uji_lemak_kasar<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text<" name="selesai_uji_lemak_kasar[]"></td>
								<td><input value="<?php echo strpos($r['selesai_uji_serat_kasar'], '000') === false ? $r['selesai_uji_serat_kasar'] : '' ?>" id="selesai_uji_serat_kasar<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="selesai_uji_serat_kasar[]"></td>
								<td><input value="<?php echo strpos($r['selesai_uji_kalsium'], '000') === false ? $r['selesai_uji_kalsium'] : '' ?>" id="selesai_uji_kalsium<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="selesai_uji_kalsium[]"></td>
								<td><input value="<?php echo strpos($r['selesai_uji_fosfor'], '000') === false ? $r['selesai_uji_fosfor'] : '' ?>" id="selesai_uji_fosfor<?php echo $r['nomor_sampel'] ?>" class="width-td datepicker-default" type="text" name="selesai_uji_fosfor[]"></td>
							<?php } ?>
                		</tr>
                		<tr>
                			<td class="" colspan="10" height="5px;"></td>
                		</tr>


                		<?php } ?>
						</form>
                	</tbody>
                	<tfoot>

                	</tfoot>
                </table>
            </div>
			<div class="panel panel-footer">
            <?php if($this->input->get('status') === '8'){ ?>
							<a href="<?php echo site_url('sampel/pengajuan/siapkan_sampel?id_uji='.$id_uji.'&status=9') ?>" class="btn btn-primary btn-md">ACC LHU</a>
						<?php } ?>
            </div>

        </div>
        <!-- end panel -->
    </div>
</div>

<div class="modal fade" id="modal-alert" style="display: none;" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div class="alert alert-danger m-b-0">
                    <p><b>Peringatan:</b> Apakah anda yakin akan membatalkan penyiapan sampel ini?</p>
                </div>
            </div>
            <div class="modal-footer">
                <a href="<?php //echo site_url('sampel/pengajuan/siapkan_sampel?id_uji='.$id_uji.'&status=0') ?>" class="btn width-100 btn-sm btn-primary">Ya</a>
                <a href="javascript:;" class="btn width-100 btn-sm btn-danger" data-dismiss="modal">Tidak</a>
            </div>
        </div>
    </div>
</div>

<script>

</script>
