<?php
  $this->load->view('includes/header.php');
  echo '<font id="breadcrumb" class="title">'.$menu_path.'</font>';
  echo '<br>';
  /* Display system message */
  $this->fungsi->disp_sys_msg();
  echo validation_errors('<p class="field_error">', '</p>');
?>

<table border width="100%">
	<tr>
		<td colspan="14">Geo Collect</td>
	</tr>
	<tr>
		<td colspan="14"><?php echo date('d-M-y') ?></td>
	</tr>
	<tr>
		<th>No</th>
		<th>Source</th>
		<th>Volume SJ</th>
		<th>Volume PPIC</th>
		<th>Status</th>
		<th>No BA</th>
		<th>Jam Masuk</th>
		<th>Jam Keluar</th>
		<th>FA</th>
		<th>Residu</th>
		<th>Sedimen</th>
		<th>Density 15&deg;</th>
		<th>WC</th>
		<th>Fuel</th>
	</tr>
	<?php
		$no = 1;
		$total_sj = 0;
		$total_ppic = 0;
		foreach($t_qa as $row):
		$rowCIS = $this->db2->get_where('berita_acara', array('id_ba' => $row->idba))->row();
		$rowRLIS = $this->db->get_where('berita_acara', array('id_ba' => $row->idba))->row();
		$rowTIS = $this->db4->get_where('tr_timbangan', array('noref' => $row->idba))->row();
		$jam_keluar = ($rowTIS->datetime_out != '0000-00-00 00:00:00' ? $this->fungsi->formatWaktu24($rowTIS->datetime_out) : '-');
		$status = ($row->status == '' ? 'DITEST LAB' : $row->status);
		if(strpos($row->id_sample, 'R') !== false)
		{} else
		{
			$total_sj = $total_sj + $rowCIS->vol_coll;
			$total_ppic = $total_ppic + $rowCIS->vol_ppic;
		}
		// $volume_sj = ($rowRLIS->resample == '0' ? $this->fungsi->format_idr($rowCIS->vol_coll) : 'RESAMPLE');
		// $volume_ppic = ($rowRLIS->resample == '0' ? $this->fungsi->format_idr($rowCIS->vol_ppic) : 'RESAMPLE');
		$volume_sj = (strpos($row->id_sample, 'R') !== false ? 'RESAMPLE' : $this->fungsi->format_idr($rowCIS->vol_coll));
		$volume_ppic = (strpos($row->id_sample, 'R') !== false ? 'RESAMPLE' : $this->fungsi->format_idr($rowCIS->vol_ppic));
	?>
	<tr>
		<td><?php echo $no++ ?></td>
		<td><?php echo $rowRLIS->nama_sup ?></td>
		<td><?php echo $volume_sj ?></td>
		<td><?php echo $volume_ppic ?></td>
		<td><?php echo $status ?></td>
		<td><?php echo $row->idba ?></td>
		<td><?php echo $this->fungsi->formatWaktu24($rowRLIS->jam_input_security) ?></td>
		<td><?php echo $jam_keluar ?></td>
		<td><?php echo $row->qctbk ?></td>
		<td><?php echo $row->qcresidu ?></td>
		<td><?php echo $row->qcresidub ?></td>
		<td><?php echo $row->qckg ?></td>
		<td><?php echo $row->qcair ?></td>
		<td><?php echo $row->qcbakar ?></td>
	</tr>
	<?php endforeach; ?>
	<tr>
		<th colspan="2" align="right">TOTAL</th>
		<td><?php echo $this->fungsi->format_idr($total_sj) ?></td>
		<td colspan="11"><?php echo $this->fungsi->format_idr($total_ppic) ?></td>
	</tr>
</table>

<table>
	<tr>
		<td>TOTAL PENERIMAAN H-1</td>
		<td>:</td>
		<td><?php echo $this->fungsi->format_idr($this->fungsi->totalUOmin1()) ?> Liter</td>
	</tr>
	<tr>
		<td>TOTAL PENERIMAAN BY MONTH</td>
		<td>:</td>
		<td><?php echo $this->fungsi->format_idr($this->fungsi->totalUOmonth()) ?> Liter</td>
	</tr>
</table>

<?php
  if(!empty($link))
  {
  	echo '<p id="bottom_link">';
  	foreach($link as $links)
  	{
  		echo $links . ' ';
  	}
  	echo '</p>';
  }
  $this->load->view('includes/footer.php');
?>