<meta http-equiv="content-type" content="text/plain; charset=UTF-8"/>
<div style="padding:5px;min-width:1700px">
<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;">
	<tbody>
		<tr>
			<td align="center" colspan="22" style="text-align: center;border:0px;border-top:0;font-size:14px;border-right:0px;"><?php echo $perkara_nama;?></td>
		</tr>
		<tr>
			<td align="center" colspan="22" style="text-align: center;border:0px;font-size:14px;border-right:0px;"><?php echo $nama_pn;?></td>
		</tr>
		<tr>
			<td align="center" colspan="22" 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>
  <tr>
    <th height="41" width="46">No.</th>
    <th width="228">Klasifikasi    Perkara</th>
    <th width="81">Sisa Awal</th>
    <th width="64">Masuk</th>
    <th width="64">Putus</th>
    <th width="102">Dikembalikan</th>
    <th width="80">Sisa Akhir</th>
    <th width="88">Biaya Perkara</th>
    <th width="94">Denda</th>
  </tr>
    <tr>
    <?php for ($a=1; $a<=9;$a++){
        echo "<th style='width:20px;'>".$a."</th>";
          }
    ?>
    </tr>

    <tr>
    <?php for ($a=1; $a<=9;$a++){
        echo "<td style='width:20px;'></td>";
          }
    ?>
    </tr>

	<?php
	if($laporan!=''){
		if($laporan->num_rows>0){
			$i=0;
			$tot_sisa=0;
			$tot_masuk=0;
			$tot_putus=0;
			$tot_dikembalikan=0;
			$tot_sisa_akhir=0;
			$tot_biaya=0;
			$tot_denda=0;

			foreach ($laporan->result() as $row) {	
				$i++;
				echo "<tr>";
					echo "<td style='width:20px;'>".$i."</td>";
					echo "<td>".$row->nama."</td>";
					echo "<td style ='text-align:center'>".$row->sisa."</td>";
					echo "<td style ='text-align:center'>".$row->masuk."</td>";
					echo "<td style ='text-align:center'>".$row->putus."</td>";
					echo "<td style ='text-align:center'>".$row->dikembalikan."</td>";
					echo "<td style ='text-align:center'>".$row->sisa_akhir."</td>";					
					echo "<td style ='text-align:center'>".number_format($row->biaya, 0, ',', '.')."</td>";
					echo "<td style ='text-align:center'>".number_format($row->denda, 0, ',', '.')."</td>";
				echo "</tr>";

			$tot_sisa=$tot_sisa+$row->sisa;
			$tot_masuk=$tot_masuk+$row->masuk;
			$tot_putus=$tot_putus+$row->putus;
			$tot_dikembalikan=$tot_dikembalikan+$row->dikembalikan;
			$tot_sisa_akhir=$tot_masuk+$tot_sisa-$tot_putus-$tot_dikembalikan;
			$tot_denda=$tot_denda+$row->denda;
			$tot_biaya=$tot_biaya+$row->biaya;
				
			}
			echo "<td colspan='2' style ='text-align:center ;font-weight:bold'>Total</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$tot_sisa."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$tot_masuk."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$tot_putus."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$tot_dikembalikan."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".$tot_sisa_akhir."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".number_format($tot_biaya, 0, ',', '.')."</td>";
			echo "<td style ='text-align:center ;font-weight:bold'>".number_format($tot_denda, 0, ',', '.')."</td>";

		}
	}

	

	?>
</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>