<?php
	
	ini_set("max_execution_time", 0);
	header("Content-Disposition: attachment; filename=\"Rekap Pendapatan Perkelas  ". date_format(date_create($tglawal),'F Y')."-".date_format(date_create($tglakhir),'F Y').".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 Pendapatan Rawat Inap Per Kelas </h3>
		<h4 align="left">Periode : <?php echo date_format(date_create($tglawal),'F Y');?> s/d <?php echo date_format(date_create($tglakhir),'F Y');?> </h4>
		
		<table id="simple-table" class="table table-striped table-bordered table-hover">
			<thead>													
				<tr>
					<th class="center">Tanggal
					<th class="center">Jml Px</th>
					<th class="center">Kelas VIP(Rp)</th>
					<th class="center">Jml Px</th>
					<th class="center">Kelas 1(Rp)</th>
					<th class="center">Jml Px</th>
					<th class="center">Kelas 3(Rp)</th>
					<th class="center">Jml Px</th>
					<th class="center">Kelas 3(Rp)</th>
					<th class="center">Total Px</th>
					<th class="center">Total Pendapatan</th>
				</tr>
			</thead>

			<tbody>
			<?php $tpxvip=0;$tpx1=0;$tpx2=0;$tpx2=0;$tpx3=0;
				  $tpxall=0;$tvip=0;$tk1=0;$tk2=0;$tk3=0;
				  $tpendatan=0;
				foreach($result as $dtrj): 
				$tpxvip=$tpxvip + $dtrj->pxvip;
				$tpx1=$tpx1 + $dtrj->px1;
				$tpx2=$tpx2 + $dtrj->px2;
				$tpx3=$tpx3 + $dtrj->px3;
				$tpxall=$tpxall + $dtrj->jmlpx;
				
				
				$tvip=$tvip + $dtrj->bayarvip;
				$tk1=$tk1 + $dtrj->bayar1;
				$tk2=$tk2 + $dtrj->bayar2;
				$tk3=$tk3 + $dtrj->bayar3;
				
				$tpendatan=$tpendatan + $dtrj->jmlbayar;
			?>
				<tr>
					<td align="center"><?php echo tgl_id_short($dtrj->tgl_nota);?></td>
					<td align="center"><?php echo $dtrj->pxvip;?></td>
					<td align="right"><?php echo number_exc_koma($dtrj->bayarvip);?></td>
					<td align="center"><?php echo $dtrj->px1;?></td>
					<td align="right"><?php echo number_exc_koma($dtrj->bayar1);?></td>
					<td align="center"><?php echo $dtrj->px2;?></td>
					<td align="right"><?php echo number_exc_koma($dtrj->bayar2);?></td>
					<td align="center"><?php echo $dtrj->px3;?></td>
					<td align="right"><?php echo number_exc_koma($dtrj->bayar3);?></td>
					<td align="center"><?php echo $dtrj->jmlpx;?></td>
					<td align="right"><?php echo number_exc_koma($dtrj->jmlbayar);?></td>
					
				</tr>
			<?php endforeach;?>
				<tr>
					<td align="center"><strong>Total</strong></td>
					<td align="center"><strong><?php echo $tpxvip;?></strong></td>
					<td align="right"><strong><?php echo number_exc_koma($tvip);?></strong></td>
					<td align="center"><strong><?php echo $tpx1;?></strong></td>
					<td align="right"><strong><?php echo number_exc_koma($tk1);?></strong></td>
					<td align="center"><strong><?php echo $tpx2;?></strong></td>
					<td align="right"><strong><?php echo number_exc_koma($tk2);?></strong></td>
					<td align="center"><strong><?php echo $tpx3;?></strong></td>
					<td align="right"><strong><?php echo number_exc_koma($tk3);?></strong></td>
					<td align="center"><strong><?php echo $tpxall;?></strong></td>
					<td align="right"><strong><?php echo number_exc_koma($tpendatan);?></strong></td>
					
				</tr>
			</tbody>
		</table>
		
	</body>
</html>