<div style="font-size:14px;">
	<table id='infoPerkara' style="font-size:14px;width:100%;">
		<col width="15%">
		<col width="85%">
		<tbody>
			<?php
			$can_manage_intervensi=$this->authorization->HasRuleManageIntervensi($this->encrypt->decode(base64_decode($enc))); 
			if ($can_manage_intervensi){ ?>
			<tr>
				<td colspan="3">
					[<a href="#" onClick="popup_form('<?php echo base_url("add_pihak_ketiga/".$enc."/add");?>')">Tambah Pihak Intervensi</a>]
					<hr class="thick-line" style="clear:both;">
				</td>
				
			</tr>
			<?php
			}
			$pihak_id_intervensi = '';
			if($para_pihak!=''){
				if($para_pihak->num_rows>0){
					$jmlIntervensi = $para_pihak->num_rows;
					$i=1;
					foreach ($para_pihak->result() as $row) {
						echo '<div style="font-size:14px;">
							<table id="infoPerkara" style="font-size:14px;width:100%;">
								<col width="15%">
								<col width="85%">
								<tbody>';
						if ($can_manage_intervensi){
							echo '<tr>';
								$idpihak = base64_encode($this->encrypt->encode($row->pihak_id));
								$enc_id = base64_encode($this->encrypt->encode($row->id));
								echo '<td colspan="2" style="cursor:pointer;vertical-align:top;">[<a href="#" onClick="popup_form(\''.base_url('add_pihak_ketiga/'.$enc.'/edit/'.$idpihak).'/urt/'.$row->urutan.'/'.$enc_id.'\')">EDIT DATA</a>]</td>';
							echo '</tr>';
						}
						$pihak_id_intervensi = $row->pihak_id;
						echo '<tr>';
							echo '<td id="first-child">Nama</td>';
							echo '<td>'.$row->nama.'</td>';
						echo '</tr>';
						echo '<tr>';
							echo '<td id="first-child">Alamat</td>';
							echo '<td>'.$row->alamat.'</td>';
						echo '</tr>'; 
						if($idalurperkara='9'){  
						 	if($row->tergabung_ke_pihak==1){
						 		$pihak = 'Penggugat II';
						 	}elseif($row->tergabung_ke_pihak==2){
						 		$pihak = 'Tergugat II';
						 	}elseif($row->tergabung_ke_pihak==3){
						 		$pihak = 'Penggugat';
						 	}else{
						 		$pihak = '<font color="red">ERROR</font>';
							}
						}
						if($idalurperkara!='9'){
							if($row->tergabung_ke_pihak==1){
								$pihak = 'Penggugat '.$this->templatehelper->converToAngkaRomawi($penggugatke);
							}elseif($row->tergabung_ke_pihak==2){
								$pihak = 'Tergugat '.$this->templatehelper->converToAngkaRomawi($tergugatke);
							}elseif($row->tergabung_ke_pihak==3){
								$pihak = 'Sendiri - Penggugat';
							}else{
								$pihak = '<font color="red">ERROR</font>';
							}
							$penggugatke++;
							$tergugatke++;
						}
						echo '<tr>';
							echo '<td id="first-child">Tergabung Ke Pihak</td>';
							echo '<td>'.$pihak.' Intervensi ';
							if($jmlIntervensi>1){
								echo $this->templatehelper->converToAngkaRomawi($row->urutan);
							}
							echo '</td>';
						echo '</tr>';
						if($this->session->userdata('jenis_pengadilan')==1 OR $this->session->userdata('jenis_pengadilan')==4){
						echo '<tr>';
							echo '<td id="first-child">Jenis Intervensi</td>';
							echo '<td>'.$row->jenis_intervensi_nama.'</td>';
						echo '</tr>';
						}						
						echo '<tr>';
							echo '<td id="first-child">Tanggal Ijin Intervensi</td>';
							echo '<td>'.$this->tanggalhelper->convertDayDate($row->tanggal_izin_intervensi).'</td>';
						echo '</tr>';						
						echo '<tr>';
							echo '<td id="first-child">Kuasa Hukum</td>';
							echo '<td>';
								echo '<table id="infoPerkara" style="font-size:14px;width:100%;">';
									echo '<tbody>';
						if ($pengacara_pihak_ketiga!=''){
							if($pengacara_pihak_ketiga->num_rows>0){
								$ada_pengacara=false;
								foreach ($pengacara_pihak_ketiga->result() as $baris) {
									if ($baris->pihak_id==$pihak_id_intervensi){
										$ada_pengacara=true;
										break;
									}
								}
								if ($ada_pengacara){
										echo '<tr>';
											echo '<table class="cssTable" id="infoPerkara" style="font-size:14px;width:100%;">';
												echo '<col width="5%">';
												echo '<col width="40%">';
												echo '<col width="45%">';
												if($can_manage_intervensi)
													echo '<col width="10%">';
												echo '<tbody>';
													echo '<tr>';
														echo '<td>No</td>';
														echo '<td>Nama</td>';
														echo '<td>Alamat</td>';
														if($can_manage_intervensi)
															echo '<td></td>';
													echo '</tr>';
													$j=1;
													foreach ($pengacara_pihak_ketiga->result() as $baris) {
														if ($row->pihak_id==$baris->pihak_id){
															echo "<tr>";
																echo "<td align='center'>".$j."</td>";																
																echo "<td>".$baris->nama."</td>";
																echo "<td>".$baris->alamat."</td>";
																
																$idpihakpengacara = base64_encode($this->encrypt->encode($baris->pengacara_id));
																$enc_id = base64_encode($this->encrypt->encode($baris->id));
																if($can_manage_intervensi){
																	echo '<td align="center" style="cursor:pointer;">';
																		echo '<a href="#" onClick="popup_form(\''.base_url('add_pengacara_pihak_ketiga/'.$enc.'/edit/'.$idpihakpengacara).'/urt/'.$baris->urutan.'/'.$enc_id.'\')">[Detil]</a>';
																	echo '</td>';
																}
																
															echo "</tr>";
															$j++;
														}
													}
												echo '</tbody>
												</table>
											</tr>';
								}
							}
							if($can_manage_intervensi){
							?>							
												<td style="background:#fff;text-align:left" colspan="4">
													<a href="#" onClick="popup_form('<?php echo base_url("add_pengacara_pihak_ketiga/".$enc."/add");?>')">[ Tambah Kuasa Hukum Pihak Intervensi ]</a>
												</td>			
												<?php
							}
									echo 	'</tbody>
										 </table>
										</td>
									</tbody>
							</table>';		
						}																								
						$i++;

						echo '<table id="infoPerkara" style="font-size:14px;width:100%;">';
							echo '<col width="15%">';
							echo '<col width="85%">';
							echo '<tbody>';
								echo '<tr>';
									echo '<td style="background-color:#A3DBA8;padding:5px;" colspan="2">Data Petitum</td>';
           
           						echo '</tr>';
           					echo '</tbody>';
           				echo '</table>';
           				echo '<table id="infoPerkara" style="font-size:14px;width:100%;">';
							echo '<col width="15%">';
							echo '<col width="85%">';
							echo '<tbody>';
								echo '<tr>';
									echo '<td id="first-child">Isi Petitum Intervensi</td>';
									echo '<td>'.$row->isi_petitum.'</td>';
								echo '</tr>';
								if ($can_manage_intervensi){
									echo '<tr>';
									echo '<td colspan="3">[<a href="#" onClick="popup_form(\''.base_url("add_intervensi_petitum/".$enc.'/'.$idpihak).'\')">EDIT ISI PETITUM</a>]</td></td>';
									echo '</tr>';
								}
							echo '</tbody>';
						echo '</table>';
						echo  '<hr class="thick-line" style="clear:both;">';
					}
				}
			}
			?>
		</tbody>
	</table>
</div>
<script type="text/javascript">
closeLoading();
</script>