<h2 align="center">STATISTIK PERKARA DAN REMINDER</h2>
<?php 
$jenis_pengadilan = $this->session->userdata('jenis_pengadilan');
?>
<div id='dashboard' style="margin-left: auto; margin-right:auto; margin-top:10px; width:85%;">
	<div id="usual2" class="usual" > 
		<ul>
				<?php 
				echo "<li class='tab'><a href=\"#tabs1\" id= 'tabInfo' class=\"selected\">Key Indikator Perkara</a></li>";
				echo "<li class='tab'><a href=\"#tabs2\" id= 'tabInfo'>Penambahan Perkara</a></li>";
				echo "<li class='tab'><a href=\"#tabs3\" id= 'tabInfo'>Status Perkara</a></li>";
				$namaeksekusi = 'Eksekusi';
				if($jenis_pengadilan==3)
					$namaeksekusi = 'Pengawasan Eksekusi';
				if($jenis_pengadilan==1 OR $jenis_pengadilan==2){
					echo "<li class='tab'><a href=\"#tabs4\" id= 'tabInfo'>Status Penahanan</a></li>";
				}
				if($jenis_pengadilan!=3 AND $jenis_pengadilan!=2){
					echo "<li class='tab'><a href=\"#tabs5\" id= 'tabInfo'>Status Jurnal Keuangan Perdata</a></li>";
				}
				
			?>
			
		</ul>
		<div id="tabs1">
		<div id='key_indikator' style="background:white;padding:5px;">
		<form id="form_tanggal" method="post" action='<?php echo base_url("dashboard/");?>' target="_self">
			<table width="100%" margin-left="10px" bgcolor='snow'>
		    <tr>
		        <td align='center'>
		        	<?php $curM=date('m'); ?>
                                <span class="custom-dropdown custom-dropdown--emerald" style="width:150px">
                                <?php
                                	$js='id="bulan" style="width:150px;" class="custom-dropdown__select custom-dropdown__select--white"';
                                	echo form_dropdown('bulan', $nama_bulan, $bulan_terpilih, $js);
                                ?>
                                </span>
                                 
                                        <?php 
                                        	if($tahun_perkara!=''){
                                        		if($tahun_perkara->num_rows>0){
                                        			echo '<span class="custom-dropdown custom-dropdown--emerald" style="width:100px">';
                                        			$js='id="tahun" style="width:80px;" class="custom-dropdown__select custom-dropdown__select--white"';
                                        			foreach ($tahun_perkara->result_array() as $key) {
                                        				$arr_tahun[$key['tahun']]=$key['tahun'];
                                        			}
                                        			echo form_dropdown('tahun', $arr_tahun, $tahun_terpilih, $js);
                                        			echo '</span>';
                                        		}else{
                                        			echo '<span style="font-family: Century Gothic,sans-serif;font-size: 13px;padding-left:5px;">'.date('Y').'</span>';
                                        		}
                                        	}else{
                                        		echo '<span style="font-family: Century Gothic,sans-serif;font-size: 13px;padding-left:5px;">'.date('Y').'</span>';
                                        	}
                                        ?>
                                
                                <input type="hidden" id='post_bulan' name="bulan" value="" />
								<input type="hidden" id='post_tahun' name="tahun" value="" />
		        </td><div id='green_loading'></div>
		    </tr>
			</table>
			</form>
		<div class="cssTable">
			<table id="tablePerkaraAll">
				<col  width="4%" />
		        <col  width="25%" />
		        <col  width="8%" />
		        <col  width="8%" />
		        <col  width="8%" />
		        <col  width="11%" />
		        <col  width="8%" />
		        <col  width="8%" />
		        <col  width="13%" />
		        <col  width="11%" />
		        <?php 
		        if($jenis_pengadilan==1 OR $jenis_pengadilan==3){
		        	echo '<col  width="8%" />';
		        }
		        if($jenis_pengadilan==1 OR $jenis_pengadilan==2){
		        	echo '<col  width="8%" />';
		        }?>
				<tbody>
					<tr height="50px">
						<td>No</td>
						<td>Perkara</td>
						<td>Sisa Bulan Lalu</td>
						<td>Masuk</td>
						<td>Putus</td>
						<td>Rasio Penanganan Perkara</td>
						<td>Sisa</td>
						<td>Banding</td>
						<td>Kasasi</td>
						<td>Peninjauan Kembali</td>
						<?php 
						if($jenis_pengadilan==1 OR $jenis_pengadilan==3){
							echo '<td>'.$namaeksekusi.'</td>';
						}
						if($jenis_pengadilan==1 OR $jenis_pengadilan==2){
							echo '<td>Grasi</td>';
						}
						?>
					</tr>
					<?php
						$con=1;

							if($data_keyindikator->num_rows>0){
				    			foreach ($data_keyindikator->result() as $row) {
				    				echo "<tr>";
					    				echo '<td align="center">'.$con.'</td>';
					    				echo '<td >'.$row->nama.'</td>';
					    				if($row->belum_putus!=0){
					    					$mainurl = '1/'.$row->id.'/'.$bulan_terpilih.'/'.$tahun_terpilih;
											$enc = base64_encode($this->encrypt->encode($mainurl));
					    					echo "<td align='center'><a style='color:red' href='".base_url()."perkara_dashboard/type/".$enc."'>".$row->belum_putus."</a></td>";
					    				}else {
					    					echo "<td align='center'>".'-'."</td>";
					    				}
					    				if($row->masuk!=0){
					    					$mainurl = '2/'.$row->id.'/'.$bulan_terpilih.'/'.$tahun_terpilih;
											$enc = base64_encode($this->encrypt->encode($mainurl));
					    					echo "<td align='center'><a style='color:blue' href='".base_url()."perkara_dashboard/type/".$enc."'>".$row->masuk."</a></td>";
					    				}else {
					    					echo "<td align='center'>".'-'."</td>";
					    				}
					    				if($row->putus!=0){
					    					$mainurl = '3/'.$row->id.'/'.$bulan_terpilih.'/'.$tahun_terpilih;
											$enc = base64_encode($this->encrypt->encode($mainurl));
					    					echo "<td align='center'><a style='color:blue' href='".base_url()."perkara_dashboard/type/".$enc."'>".$row->putus."</a></td>";
					    				}else {
					    					echo "<td align='center'>".'-'."</td>";
					    				}
					    				$rasio = 0;
										if($row->masuk== 0 || $row->masuk=='')
										{ 
											$rasio = $row->putus * 100;	
										}
										else
										{ 
											$rasio = ($row->putus/$row->masuk) * 100;	
										}
										$rasiox = number_format($rasio,2,',','.');
					    				echo "<td align='center'>".$rasiox." %</td>";
					    				$sisa = $row->belum_putus+$row->masuk-$row->putus;
					    				if($sisa!=0){
					    					$mainurl = '4/'.$row->id.'/'.$bulan_terpilih.'/'.$tahun_terpilih;
											$enc = base64_encode($this->encrypt->encode($mainurl));
					    					echo "<td align='center'><a style='color:red' href='".base_url()."perkara_dashboard/type/".$enc."'>".$sisa."</a></td>";
					    				}else {
					    					echo "<td align='center'>".'-'."</td>";
					    				}
					    				if($row->banding!=0){
					    					$mainurl = '5/'.$row->id.'/'.$bulan_terpilih.'/'.$tahun_terpilih;
											$enc = base64_encode($this->encrypt->encode($mainurl));
					    					echo "<td align='center'><a style='color:blue' href='".base_url()."perkara_dashboard/type/".$enc."'>".$row->banding."</a></td>";
					    				}else {
					    					echo "<td align='center'>".'-'."</td>";
					    				}
					    				if($row->kasasi!=0){
					    					$mainurl = '6/'.$row->id.'/'.$bulan_terpilih.'/'.$tahun_terpilih;
											$enc = base64_encode($this->encrypt->encode($mainurl));
					    					echo "<td align='center'><a style='color:blue' href='".base_url()."perkara_dashboard/type/".$enc."'>".$row->kasasi."</a></td>";
					    				}else {
					    					echo "<td align='center'>".'-'."</td>";
					    				}
					    				if($row->pk!=0){
					    					$mainurl = '7/'.$row->id.'/'.$bulan_terpilih.'/'.$tahun_terpilih;
											$enc = base64_encode($this->encrypt->encode($mainurl));
					    					echo "<td align='center'><a style='color:blue' href='".base_url()."perkara_dashboard/type/".$enc."'>".$row->pk."</a></td>";
					    				}else {
					    					echo "<td align='center'>".'-'."</td>";
					    				}
					    				if($jenis_pengadilan==1 OR $jenis_pengadilan==3){
						    				if($row->eksekusi!=0){
						    					$mainurl = '8/'.$row->id.'/'.$bulan_terpilih.'/'.$tahun_terpilih;
												$enc = base64_encode($this->encrypt->encode($mainurl));
						    					echo "<td align='center'><a style='color:blue' href='".base_url()."perkara_dashboard/type/".$enc."'>".$row->eksekusi."</a></td>";
						    				}else {
						    					echo "<td align='center'>".'-'."</td>";
						    				}
						    			}
						    			if($jenis_pengadilan==1 OR $jenis_pengadilan==2){
						    				if($row->grasi!=0){
						    					$mainurl = '9/'.$row->id.'/'.$bulan_terpilih.'/'.$tahun_terpilih;
												$enc = base64_encode($this->encrypt->encode($mainurl));
						    					echo "<td align='center'><a style='color:blue' href='".base_url()."perkara_dashboard/type/".$enc."'>".$row->grasi."</a></td>";
						    				}else {
						    					echo "<td align='center'>".'-'."</td>";
						    				}
						    			}
				    				echo "</tr>";
				    				$con++;
				    			}
					    	}else{
				    			echo "<tr><td colspan='9' align='center'>Data Tidak diTemukan</td></tr>";
				    		}
									
					?>
				</tbody>
			</table>
		
		</div>

		</div>
		</div>
		<br>
		<div id="tabs2"></div>
		<div id="tabs3"></div>
		<div id="tabs4"></div>
		<div id="tabs5"></div>
	</div>
</div>
<?php //echo $this->benchmark->memory_usage();?>
<div style="padding:20px;" ></div>
<script type="text/javascript"> 

$('#bulan').change(function(){
	$('#post_bulan').val(this.value);
	ngerefresh();	
});

$('#tahun').change(function(){
  	$('#post_tahun').val(this.value);
  	ngerefresh();	
})

function ngerefresh(){
	$('#post_bulan').val($('#bulan').val());
	$('#post_tahun').val($('#tahun').val());
	$('#form_tanggal').submit();
}

$("#usual2 ul").idTabs("tabs2");
$( document ).ready(function() {
	$('a#tabInfo').click(function(event){
		if (!$(this).hasClass('loaded')){
			if($(this).attr('href')=='#tabs2'){
				openLoadingDialog();
				$('#tabs2').load('<?php echo base_url("tab_penambahan_perkara/");?>');
				$('a[href=#tabs2]').addClass('loaded');
				
			}
		}
	});
});

$("#usual2 ul").idTabs("tabs3");
$( document ).ready(function() {
	$('a#tabInfo').click(function(event){
		if (!$(this).hasClass('loaded')){
			if($(this).attr('href')=='#tabs3'){
				openLoadingDialog();
				$('#tabs3').load('<?php echo base_url("tab_status_perkara/");?>',{all:'Y'});
				$('a[href=#tabs3]').addClass('loaded');
				
			}
		}
	});
});

$("#usual2 ul").idTabs("tabs4");
$( document ).ready(function() {
	$('a#tabInfo').click(function(event){
		if (!$(this).hasClass('loaded')){
			if($(this).attr('href')=='#tabs4'){
				openLoadingDialog();
				$('#tabs4').load('<?php echo base_url("tab_status_penahanan/");?>');
				$('a[href=#tabs4]').addClass('loaded');
				
			}
		}
	});
});


$("#usual2 ul").idTabs("tabs5");
$( document ).ready(function() {
	$('a#tabInfo').click(function(event){
		if (!$(this).hasClass('loaded')){
			if($(this).attr('href')=='#tabs5'){
				openLoadingDialog();
				$('#tabs5').load('<?php echo base_url("tab_status_jurnal_keuangan/");?>');
				$('a[href=#tabs5]').addClass('loaded');
				
			}
		}
	});
});


</script>