<?php

header("Content-type: application/vnd-ms-excel");

header("Content-Disposition: attachment; filename=Laporan_jenis_kegiatan_".$periode_thn.".xls");

?>

<!DOCTYPE html>

<html>

<head>

	<title></title>

		<style type="text/css">

	body{

		font-family: sans-serif;

	}

	table{

		margin: 20px auto;

		border-collapse: collapse;

	}

	table th,

	table td{

		border: 1px solid #3c3c3c;

		height: 20px;

		

	}

	table td{

		vertical-align: top;

	}

	a{

		background: blue;

		color: #fff;

		padding: 8px 10px;

		text-decoration: none;

		border-radius: 2px;

	}

	.text{

		padding: 3px 100px 3px 3px;

	}

	.number{

		padding: 3px 3px 3px 100px;

	}

	.bg-coklat{

		background-color: #993300;

		color: white;

	}

	</style>

</head>

<body>

<table>

	<thead>

		<tr>

			<th colspan="5">Rekap Jenis Kegiatan Periode <?=$periode_thn?></th>

		</tr>

		<tr>

			<th>No</th>

			<th>Jenis Kegiatan</th>

			<th class="number">Penerimaan</th>

			<th class="number">Pengeluaran</th>

			<th>Saldo</th>

		</tr>	

	</thead>

	<tbody>

		<?php

		$no =1;

		for($i=0; $i<count($result);$i++){

			$penerimaan = $result[$i]['penerimaan'] == 0? "-" : "".number_format($result[$i]['penerimaan'],0,",","."); 

			$pengeluaran = $result[$i]['pengeluaran'] == 0? "-" : "".number_format($result[$i]['pengeluaran'],0,",",".");

			$saldo = $result[$i]['saldo'] == 0? "-" : "".number_format($result[$i]['saldo'],0,",",".");

		?>

		<tr><td style="text-align: center;">

				<?=$no++?>

			</td>

			<td class="text">

				<?=$result[$i]['nama_jenis_kegiatan']?>

			</td>

			<td style="text-align: right;">

				 <?=$penerimaan?>

			</td>

			<td style="text-align: right;">

				<?=$pengeluaran?>

			</td>

			<td style="text-align: right;">

				<?=$saldo?>

			</td>

		</tr>

		<?php

		}

		?>

	</tbody>

	<tfoot>

		<tr>

			<td colspan="2" style="background-color: yellow;"><strong>Total</strong></td>

			<td style="text-align: right;"><strong><?=number_format($total_penerimaan,0,",",".")?></strong></td>

			<td style="text-align: right;"><strong><?=number_format($total_pengeluaran,0,",",".")?></strong></td>

			<td style="text-align: right;"><strong><?=number_format($total_saldo,0,",",".")?></strong></td>

		</tr>

	</tfoot>

</table>

<table>

	<thead>

		<tr>

			<th colspan="5">Rekap Jenis Kegiatan Periode <?=$periode_thn?></th>

		</tr>

		<tr>

			<th>No</th>

			<th>Jenis Kegiatan</th>

			<th class="number">Penerimaan</th>

			<th class="number">Pengeluaran</th>

			<th>Saldo</th>

		</tr>	

	</thead>



	<tbody>

		<?php

		$no =1;

		$c = count($newArr)+2;

		for($i=2; $i<$c;$i++){

		?>

		<tr><td style="text-align: center;">

				<?=$no++?>

			</td>

			<td class="text">

				<?=$newArr[$i]['nama_jenis_kegiatan']?>

			</td>

			<td style="text-align: right;">

				 <?=number_format($newArr[$i]['penerimaan'],0,",",".")?>

			</td>

			<td style="text-align: right;">

				<?=number_format($newArr[$i]['pengeluaran'],0,",",".")?>

			</td>

			<td style="text-align: right;">

				<?=number_format($newArr[$i]['saldo'],0,",",".")?>

			</td>

		</tr>

		<?php

		}

		?>

	</tbody>

	<tfoot>

		<tr>

			<td colspan="2" style="background-color: yellow;"><strong>Total</strong></td>

			<td style="text-align: right;"><strong><?=number_format($total_penerimaan,0,",",".")?></strong></td>

			<td style="text-align: right;"><strong><?=number_format($total_pengeluaran,0,",",".")?></strong></td>

			<td style="text-align: right;"><strong><?=number_format($total_saldo,0,",",".")?></strong></td>

		</tr>

	</tfoot>

</table>

</body>

</html>