<?php	
	ini_set("max_execution_time", 0);
	header("Content-Disposition: attachment; filename=\"Rekap Transfer Pasien IGD ".$tglawal." sd ".$tglakhir.".xls\"");
	header("Content-type: application/vnd.ms-excel");  
?>	
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>RS Insan Permata</title>
		<meta name="author" content="mbelink21" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
	</head>

	<body>
		<h3 align="left">Rekap Transfer Pasien IGD </h3>
		<h4 align="left">Periode : <?php echo tgl_id($tglawal);?> s/d <?php echo tgl_id($tglakhir);?> </h4>
		
		<table border="1">
			<thead>
				<tr>
					<th>No</th>
					<th>No Rawat</th>
					<th>No RM</th>
					<th>Nama</th>
					<th class="hidden-480">Tgl Registrasi</th>
					<th class="hidden-480">Jam Registrasi</th>
					<th class="hidden-480">Tgl Pindah</th>
					<th class="hidden-480">Jam Pindah</th>
					<th class="hidden-480">Rentang Waktu</th>
					<th class="hidden-480">Asal Ruang</th>
					<th class="hidden-480">Tujuan</th>
				</tr>
			</thead>

			<tbody>
			<?php $no=1;
			date_default_timezone_set('Asia/Jakarta');								
			foreach($result as $dtk){ 
				$tglreg=strtotime($dtk->tanggal_reg);
				$tglpind=strtotime($dtk->tanggal_pindah);
				
				$diff=$tglpind - $tglreg;
				
				if($diff < 0){
					$mentx=abs(floor($diff/60));
					$jamx=floor(abs($diff)/(60*60));
					$menitx=abs($diff) - $jamx * (60 * 60);
					if($mentx==0){
						$ment= $mentx;
					}else{
						$ment= $mentx * -1;
					}
					if($jamx==0){
						$jam= $jamx;
					}else{
						$jam= $jamx * -1;
					}
					if($menitx==0){
						$menit= $menitx;
					}else{
						$menit= $menitx * -1;
					}
					
				}else{
					$ment=floor($diff/60);
					$jam=floor($diff/(60*60));
					$menit=$diff - $jam * (60 * 60);
				}
				
			if($jam==0){
				$waktu= floor($menit/60).' Menit';
			}else{
				$waktu=$jam.' jam  '.floor($menit/60).' Menit';
			}
			
			?>
				<tr>
					<td><?php echo $no;?></td>
					<td><?php echo $dtk->no_rawat;?></td>
					<td class=""><?php echo $dtk->no_rkm_medis;?></td>
					<td class=""><?php echo $dtk->nm_pasien;?></td>
					<td class="hidden-480"><?php echo $dtk->tgl_registrasi;?></td>
					<td class="hidden-480"><?php echo $dtk->jam_reg;?></td>
					<td class="hidden-480"><?php echo $dtk->tgl_pindah;?></td>
					<td class="hidden-480"><?php echo $dtk->jam_pindah;?></td>
					<td class="hidden-480"><?php echo $waktu;//$jam.' jam  '.floor($menit/60).' Menit';?></td>
					<td class="hidden-480"><?php echo strtoupper($dtk->asal_ruang);?></td>
					<td class="hidden-480"><?php echo strtoupper($dtk->ruang_selanjutnya);?></td>
				</tr>
			<?php $no++; } ?>
				
			</tbody>
		</table>
		
	</body>
</html>