<?php 
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$namafile.".xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<!DOCTYPE html>
<html>
<head>
	<title>Table Waktu</title>
	<meta charset="UTF-8">
</head>
<body>
	<table border="1">
		<thead>
			<tr>
			 <th>Berita Acara</th>
			 <th>Nomor Sample</th>
			 <th>Type</th>
			 <th>Status</th>
			 <th>PPIC</th>
			 <th>LAB</th>
			 <th>Pengirim</th>
			 <th>Jam Masuk Security</th>
			 <th>Jam Masuk Timbangan</th>
			 <th>Waktu Timbangan</th>
			 <th>Jam Masuk PPIC</th>
			 <th>Waktu Ambil Sample</th>
			 <th>Jam Input QA</th>
			 <th>Jam Selesai QA</th>
			 <th>Waktu Analisa</th>
			 <th>Jam Keluar Timbangan</th>
			 <th>Waktu Bongkar</th>
			</tr>
		</thead>
		<tbody>
	<?php foreach($all_data as $row) {
	 $this->db2 = $this->load->database('default2', TRUE);
	 $this->db4 = $this->load->database('default4', TRUE);
	 $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();
	 $mystring = $row->id_sample;
	 $findme   = 'R';
	 $pos = strpos($mystring, $findme);
	 $status_resample = ($pos == TRUE ? 'Resample' : '');
	 $waktu_masuk = $this->fungsi->selisihWaktu($rowRLIS->jam_input_security, $rowTIS->datetime_in);
	 $waktu_ambil_sample = $this->fungsi->selisihWaktu($rowTIS->datetime_in, $row->adddate);
	 $waktu_analisa = $this->fungsi->selisihWaktu($row->adddate, $row->waktu_approve_qa);
	 $waktu_bongkar = $this->fungsi->selisihWaktu($row->waktu_approve_qa, $rowTIS->datetime_out);
	?>
			 <tr>
			 	<td><?php echo $row->idba ?></td>
			 	<td><?php echo $row->id_sample ?></td>
			 	<td><?php echo $rowRLIS->type ?></td>
			 	<td><?php echo $status_resample ?></td>
			 	<td><?php echo $row->id_sample_ppic ?></td>
			 	<td><?php echo $row->id_sample_lab ?></td>
			 	<td><?php echo $rowCIS->nama_sup ?></td>
			 	<td><?php echo $this->fungsi->formatWaktu24($rowRLIS->jam_input_security) ?></td>
			 	<td><?php echo $this->fungsi->formatWaktu24($rowTIS->datetime_in) ?></td>
			 	<td><?php echo $waktu_masuk ?></td>
			 	<td><?php echo $this->fungsi->formatWaktu24($row->adddate) ?></td>
			 	<td><?php echo $waktu_ambil_sample ?></td>
			 	<td><?php echo $this->fungsi->formatWaktu24($row->waktu_periksa_qa) ?></td>
			 	<td><?php echo $this->fungsi->formatWaktu24($row->waktu_approve_qa) ?></td>
			 	<td><?php echo $waktu_analisa ?></td>
			 	<td><?php echo $this->fungsi->formatWaktu24($rowTIS->datetime_out) ?></td>
			 	<td><?php echo $waktu_bongkar ?></td>
			 </tr>
			<?php } ?>
		</tbody>
	</table>
</body>
</html>