<?php
	
	ini_set("max_execution_time", 0);
	header("Content-Disposition: attachment; filename=\"Pendapatan ".$keter." Per Dokter  ". tgl_id_short($tglawal)."-".tgl_id_short($tglakhir).".xls\"");
	header("Content-type: application/vnd.ms-excel");    
	?>
	<h3 align="center">Pendapatan <?php echo $keterl;?> Per Dokter </h3>
	<h4 align="center">Periode : <?php echo tgl_id($tglawal);?> s/d <?php echo tgl_id($tglakhir);?> </h4>
<table border="1" align="center">
	<thead>
		<tr>
			<th rowspan="2" style="background-color:#8c0023;color:#ffffff;" class="center">No</th>
			<th rowspan="2" style="background-color:#8c0023;color:#ffffff;" class="center">Dokter</th>
			<th colspan="2" style="background-color:#8c0023;color:#ffffff;" class="center">Pasien Umum</th>
			<th colspan="4" style="background-color:#8c0023;color:#ffffff;" class="center">Pasien BPJS</th>
			<th colspan="4" style="background-color:#8c0023;color:#ffffff;" class="center">Asuransi Lainnya</th>
			<th rowspan="2"	style="background-color:#8c0023;color:#ffffff;" class="center">Total Px </th>
			<th rowspan="2"	style="background-color:#8c0023;color:#ffffff;" class="center">Jumlah </th>
		</tr>
		<tr>
			<th style="background-color:#8c0023;color:#ffffff;" class="center" width="">Jml Px</th>
			<th style="background-color:#8c0023;color:#ffffff;" class="center" width="">Sub Total</th>
			<th style="background-color:#8c0023;color:#ffffff;" class="center" width="">Jml Px</th>
			<th style="background-color:#8c0023;color:#ffffff;" class="center" width="">Sub Total</th>
			<th style="background-color:#8c0023;color:#ffffff;" class="center" width="">Px Ekses</th>
			<th style="background-color:#8c0023;color:#ffffff;" class="center" width="">Total Ekses</th>
			<th style="background-color:#8c0023;color:#ffffff;" class="center" width="">Jml Px</th>
			<th style="background-color:#8c0023;color:#ffffff;" class="center" width="">Sub Total</th>
			<th style="background-color:#8c0023;color:#ffffff;" class="center" width="">Px Ekses</th>
			<th style="background-color:#8c0023;color:#ffffff;" class="center" width="">Total Ekses</th>
		</tr>
		
	</thead>

	<tbody>
	<?php $tpxumum=0;$tpxbpjs=0;$tpxlainya=0;$tpxbpjex=0;$tpxlainex=0;
		  $tpxall=0;$tumum=0;$tbpjs=0;$tlainya=0;$tbpjsexe=0;$tlainyaexe=0;
		  $tpendatan=0;$no=1;
	foreach($result as $dtrj): 
		$tpxumum=$tpxumum + $dtrj->px_umum;
		$tpxbpjs=$tpxbpjs + $dtrj->px_bpjs;
		$tpxlainya=$tpxlainya + $dtrj->px_lainnya;
		$tpxall=$tpxall + $dtrj->px_jml;
		$tpxbpjex=$tpxbpjex + $dtrj->px_exesbpjs;
		$tpxlainex=$tpxlainex + $dtrj->px_exesas;

		$tumum=$tumum + $dtrj->umum;
		$tbpjs=$tbpjs + $dtrj->bpjs;
		$tlainya=$tlainya + $dtrj->lainnya;
		$tpendatan=$tpendatan + $dtrj->subtotal;
		$tbpjsexe=$tbpjsexe + $dtrj->exes_bpjs;
		$tlainyaexe=$tlainyaexe + $dtrj->exes_lainnya;
		
		if($dtrj->kd_dokter=='-'){
			$namadok='Non Dokter';
		}else{
			$namadok=$dtrj->nm_dokter;
		}
		/* if($_POST['sts']=='1'){
			$tglnya=$dtrj->tgl_registrasi;
		}else{
			$tglnya=$dtrj->tgl_nota;
		} */
	?>
		<tr>
			<td><?php echo $no;?></td>			
			<td><?php echo $namadok;?></td>			
			<td><?php echo $dtrj->px_umum;?></td>			
			<td><?php echo number_exc_koma($dtrj->umum);?></td>	
			<td><?php echo $dtrj->px_bpjs;?></td>
			<td><?php echo number_exc_koma($dtrj->bpjs);?></td>
			<td><?php echo $dtrj->px_exesbpjs;?></td>
			<td><?php echo number_exc_koma($dtrj->exes_bpjs);?></td>
			<td><?php echo $dtrj->px_lainnya;?></td>
			<td><?php echo number_exc_koma($dtrj->lainnya);?></td>
			<td><?php echo $dtrj->px_exesas;?></td>
			<td><?php echo number_exc_koma($dtrj->exes_lainnya);?></td>
			<td><?php echo $dtrj->px_jml;?></td>
			<td><?php echo number_exc_koma($dtrj->subtotal);?></td>			
		</tr>
	<?php $no++; endforeach;?>
		<tr>
			<td colspan="2" align="center"><strong>Total</strong></td>	
			<td><?php echo $tpxumum;?></td>
			<td><strong><?php echo number_exc_koma($tumum);?></strong></td>
			<td><?php echo $tpxbpjs;?></td>			
			<td><strong><?php echo number_exc_koma($tbpjs);?></strong></td>			
			<td><?php echo $tpxbpjex;?></td>			
			<td><strong><?php echo number_exc_koma($tbpjsexe);?></strong></td>
			<td><?php echo $tpxlainya;?></td>
			<td><strong><?php echo number_exc_koma($tlainya);?></strong></td>
			<td><?php echo $tpxlainex;?></td>
			<td><strong><?php echo number_exc_koma($tlainyaexe);?></strong></td>
			<td><?php echo $tpxall;?></td>
			<td><strong><?php echo number_exc_koma($tpendatan);?></strong></td>
			
		</tr>
	</tbody>
</table>