<?php
$list_uraian = array(
	array('nama'=>'Sisa Awal','key' =>0,'nominal' => 0),
	array('nama'=>'Panjar Perkara','key' =>1,'nominal' => 0),
	array('nama'=>'PNBP','key' =>11,'nominal' => 0),
	array('nama'=>'Alat Tulis Kantor','key' =>12,'nominal' => 0),
	array('nama'=>'Panggilan','key' =>4,'nominal' => 0),
	array('nama'=>'Sita','key' =>5,'nominal' => 0),
	array('nama'=>'Sumpah','key' =>9,'nominal' => 0),
	array('nama'=>'Pemeriksaan Setempat','key' =>7,'nominal' => 0),
	array('nama'=>'Pemberitahuan','key' =>6,'nominal' => 0),
	array('nama'=>'Pengiriman','key' =>3,'nominal' => 0),
	array('nama'=>'Materai','key' =>8,'nominal' => 0),
	array('nama'=>'Penerjemah','key' =>10,'nominal' => 0),
	array('nama'=>'Hak-Hak Kepaniteraan','key' =>13,'nominal' => 0),
	array('nama'=>'Lain-lain','key' =>14,'nominal' => 0),
	array('nama'=>'Sisa Panjar','key' =>2,'nominal' => 0)
);

$data = array();
for ($i=0; $i < 15; $i++) { $data[$i] = 0;}
$input = 0;
$output = 0;
if($laporan!=''){
	if($laporan->num_rows>0){
		$i=0;
		foreach ($laporan->result() as $row) {
			$data[$row->kategori_id] = $row->nominal;
			if($row->jenis_transaksi==1){
				$input = $input+$row->masuk_lampau;
			}elseif($row->jenis_transaksi==-1){
				$output = $output+$row->masuk_lampau;
			}
		}
	}
}

$sisaawal = $input-$output;
if ($period>$period_saldo_awal){
	$data[0] = $sisaawal+$saldo_awal;
}else{
	$data[0] = $saldo_awal;
}
?>
<style type="text/css">
#view_laporan tr td,#view_laporan tr th{
	font-size:9.0pt;
}
</style>
<div style="padding:5px;min-width:800px;">
<div style="padding:20px;"></div>
<button class="btn btnExcel" style="width:150px;text-align:center;">Export Excel</button></div>
<table id="view_laporan" class="cetakExcel" border="0" cellpadding="2" cellspacing="0" style="margin:10px;min-width:800px;">
	<tbody>
		<tr>
			<td align="center" colspan="12" style="text-align: center;border:0px;border-top:0;font-size:14px;border-right:0px;">LAPORAN KEUANGAN PERKARA PERDATA UMUM</td>

		</tr>
		<tr>
			<td align="center" colspan="12" style="text-align: center;border:0px;font-size:14px;border-right:0px;"><?php echo $nama_pn;?></td>

		</tr>
		<tr>
			<td align="center" colspan="12" style="text-align: center;border:0px;font-size:14px;border-bottom:1px solid #000000;border-right:0px;">Bulan <?php echo fetch_montd($bulan);?> <?php echo $tahun;?></td>

		</tr>
	</tbody>
	<tbody>
		<tr>
			<th rowspan="1" colspan="1">NO</th>
			<th rowspan="1" colspan="1">URAIAN</th>
			<th rowspan="1" colspan="1">PENERIMAAN</th>
			<th rowspan="1" colspan="1">PENGELUARAN</th>
		</tr>
		<tr>
			<th>1</th>
			<th>2</th>
			<th>3</th>
			<th>4</th>
		</tr>
		<tr>
		<?php
		for ($i=1; $i<=4 ; $i++) { 
			echo "<td style='padding:10px;'></td>";
		}
		?>
		</tr>
		<?php
			$i = 1;
			$in = 0;
			$out = 0;
			foreach ($list_uraian as $key) {
				echo "<tr>";
					echo "<td style='text-align:center;'>".$i."</td>";
					echo "<td>".$key['nama']."</td>";
					if($key['key']==0 OR $key['key']==1){
						echo "<td style='text-align:right;'>".number_format($data[$key['key']], 0, ',', '.')."</td>";
						echo "<td style='text-align:right;'></td>";
						$in = $in+$data[$key['key']];
					}else{
						echo "<td style='text-align:right;'></td>";
						echo "<td style='text-align:right;'>".number_format($data[$key['key']], 0, ',', '.')."</td>";
						$out = $out+$data[$key['key']];
					}
				echo "</tr>";
				$i++;
			}
			echo "<tr>";			
				echo "<td colspan='2' style='text-align:center;'>Jumlah</td>";
				echo "<td style='text-align:right;'>".number_format($in, 0, ',', '.')."</td>";
				echo "<td style='text-align:right;'>".number_format($out, 0, ',', '.')."</td>";
			echo "</tr>";
			echo "<tr>";			
				echo "<td colspan='2' style='text-align:center;'>Saldo Akhir</td>";
				echo "<td colspan='2' style='text-align:right;'>".number_format($in-$out, 0, ',', '.')."</td>";
			echo "</tr>";
		?>	
	</tbody>
</table>
</div>
<div style="padding:15px;"></div>
<script src="resources/js/jquery.table2excel.js"></script>
<script>
$(function() {
	$(".btnExcel").click(function(){
		$(".cetakExcel").table2excel({
			exclude: ".noExl",
			name: "Excel Document Name",
			filename: "Cetak Excel"
		});
	});
});
</script>