<?php

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

header("Content-Disposition: attachment; filename=Laporan_Bidang_".$nama_bidang."_perTriwulan_".$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;

		width: 100%;

	}

	table th,

	table td{

		border: 1px solid #3c3c3c;

		

	}

	table td{

		vertical-align: top;

	}

	a{

		background: blue;

		color: #fff;

		padding: 8px 10px;

		text-decoration: none;

		border-radius: 2px;

	}

	.text{

		padding: 3px 3px 3px 3px;

	}

	.number{

		padding: 3px 3px 3px 3px;

	}

	.bg-coklat{

		background-color: #993300;

		color: white;

	}

	</style>

</head>

<body>

<table>

	<thead>

		<tr>

			<th colspan="9">Penerimaan Bidang <?=$nama_bidang?> Pertriwulan Periode <?=$periode_thn?></th>

			 

		</tr>

		<tr>

			<th>No</th>

			<th>Kode Mata Anggaran</th>

			<th>Nama Kegiatan</th>

			<th>Unit Misioner</th>

			<th>Triwulan 1<br>April-Juni</th>

			<th>Triwulan 2<br>Juli-September</th>

			<th>Triwulan 3<br>Oktober-Desember</th>

			<th>Triwulan 4<br>Januari-Maret</th>

			<th>Total</th>

		</tr>	

	</thead>

	<tbody>

		<?php

		$no =1;

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

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

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

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

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

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

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

		?>

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

				<?=$no++?>

			</td>

			<td class="text">

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

			</td>

			<td class="text">

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

			</td>

			<td class="text">

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

			</td>

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

				 <?=$pen_t1?>

			</td>

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

				 <?=$pen_t2?>

			</td>

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

				 <?=$pen_t3?>

			</td>

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

				 <?=$pen_t4?>

			</td>

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

				<?=$penerimaan?>

			</td>

		</tr>

		<?php

		}

		?>

	</tbody>

	<tfoot>

		<tr>

			<td colspan="4" style="background-color: yellow;"><strong>SUB TOTAL</strong></td>

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

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

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

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

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

		</tr>

	</tfoot>

</table>

<pagebreak>

<table>

	<thead>

		<tr>

			<th colspan="9">Pengeluaran Bidang <?=$nama_bidang?> Pertriwulan Periode <?=$periode_thn?></th>

			

		</tr>

		<tr>

			<th>No</th>

			<th>Kode Mata Anggaran</th>

			<th>Nama Kegiatan</th>

			<th>Unit Misioner</th>

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

			<th>Triwulan 1<br>April-Juni</th>

			<th>Triwulan 2<br>Juli-September</th>

			<th>Triwulan 3<br>Oktober-Desember</th>

			<th>Triwulan 4<br>Januari-Maret</th>

			<th>Total</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'],2,",",".");

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

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

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

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

		?>

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

				<?=$no++?>

			</td>

			<td class="text">

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

			</td>

			<td class="text">

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

			</td>

			<td class="text">

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

			</td>

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

				 <?=$peng_t1?>

			</td>

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

				 <?=$peng_t2?>

			</td>

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

				 <?=$peng_t3?>

			</td>

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

				 <?=$peng_t4?>

			</td>

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

				<?=$pengeluaran?>

			</td>

		</tr>

		<?php

		}

		?>

	</tbody>

	<tfoot>

		<tr>

			<td colspan="4" style="background-color: yellow;"><strong>SUB TOTAL</strong></td>

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

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

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

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

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

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

		</tr>

	</tfoot> 

</table>

<!-- <?=$total_penerimaan?><br>

<?=$total_pengeluaran?> -->

</body>

</html>