<?php
$canEditPemeriksaanPersiapan=false;
$canEditPemeriksaanPersiapan=$this->authorization->HasRuleHakimPanitera($idperkara);
?>
<div style="font-size:14px;">
<table id='infoPerkara' style="font-size:14px; width:100%; " border="0">
	<col width="30%">
	<col width="">
	<col width="95%">
	<tbody>
		<tr>
			<td style="width:15%;" id="first-child">Tanggal Penetapan Pemeriksaan Pendahuluan</td>
			<td style="width:85%;"><?php echo $tanggalPenetapanPersiapan; ?></td>
			<?php
			if($canEditPemeriksaanPersiapan){
			?>			
			<td align="right">[<a href="#" onClick="popup_form('<?php echo base_url('edit_pemeriksaan_persiapan/'.$enc);?>')">Edit Penetapan Pemeriksaan Persiapan</a>]
			[<a href="#" onClick="popup_form('<?php echo base_url('hapus_pemeriksaan_persiapan/'.$enc);?>')"><font color='red'><b>Hapus Pemeriksaan Persiapan</b></font></a>]</td>				
			<?php } ?>
		</tr>
		<tr>
			<td id="first-child">Cetak Dokumen Penetapan</td>
			<td colspan="2">	
			<?php
			if($canEditPemeriksaanPersiapan){
			?>										
				<a href="<?php echo base_url("c_template_tun/cetak_penetapan_persiapan_tun/".$enc."/3");?>">										                    	
	            	<img src="<?php echo base_url();?>resources/img/nm_icon_doc.gif">
	            </a>
	        <?php } ?>
			</td>			
		</tr>
		<tr>
			<td id="first-child">Tanggal Pemeriksaan Persiapan</td>
			<td colspan="2">
				<div class="cssTable" style="margin-top:5px;">
    			<table id="tableinfo">
    				<tr>
    					<td style="width:30px">No</td>
		                <td style="width:140px">Tanggal</td>
		                <td style="width:250px">Agenda</td>
		                <td style="width:50px">Pukul</td>
		                <td style="width:180px">Status Kehadiran & Upload BAS</td>
		                <td style="width:200px">Cetak Dokumen</td>
    					<td style="50px"></td>
    				</tr>
    				<?php
    				$a = 0;
    				$jumlahProses = $persiapanProses->num_rows();
    				foreach($persiapanProses->result() as $row){$a++;
    					$encPersiapanProses = base64_encode($this->encrypt->encode($row->id));
    					$enc = base64_encode($this->encrypt->encode($row->perkara_id));
    					if($row->dihadiri_oleh==1){
    						$dihadiri = 'Semua Pihak';
    					}elseif($row->dihadiri_oleh==2){
    						$dihadiri = 'Pihak Penggugat Saja';
    					}elseif($row->dihadiri_oleh==3){
    						$dihadiri = 'Pihak Tergugat Saja';
    					}elseif($row->dihadiri_oleh==4){
    						$dihadiri = 'Para Pihak Tidak Hadir';
    					}else{
    						$dihadiri ='';
    					}
       					echo "<tr>";
	    					echo "<td align='center'>".$a."</td>";
			                echo "<td>".$this->tanggalhelper->convertDayDate($row->tanggal_musyawarah)."</td>";
			                echo "<td>".$row->agenda_musyawarah."</td>";
			                echo "<td align='center'>".substr($row->waktu_musyawarah,0,5)."</td>";
			                echo "<td>".$dihadiri."<br>";
			                		$baseurl=$row->edoc_persiapan_proses;
			                		if (($baseurl) and (file_exists($baseurl))){
	    	    	                    echo "<br><a target='_new' href=$baseurl>Unduh Dokumen BAS</a>";
	    	    	                }else{
	    	    	                    echo "<br><span style='color:red;font-weight:bold'>Dokumen Belum Ada</span>";
	    	    	                }
	    	    	                echo '<br><a href="#" onClick="popup_form(\''.base_url("fileupload/".$enc."/persiapan_proses/".$encPersiapanProses."/".$a).'\')" class="btn btn-default btn-sm"><i class="fa fa-file-word-o"></i> Unggah BAS</a>';
			                echo "</td>";
			                echo "<td align='center'>";			                
							if($canEditPemeriksaanPersiapan){
							?>
					            <span class="custom-dropdown custom-dropdown--emerald">
	                                <select onchange="pilih_cetak(this)" style="width:150px;z-index:99999" class="custom-dropdown__select custom-dropdown__select--white">
	                                    <option>Cetak Relas</option>
	                                    <option value="<?php echo base_url("c_template_tun/popup_pilihan_pihak_pp/".$enc."/".$encPersiapanProses."/1");?>">Relaas Panggilan Pengugat</option>
	                                    <option value="<?php echo base_url("c_template_tun/popup_pilihan_pihak_pp/".$enc."/".$encPersiapanProses."/2");?>">Relaas Panggilan Tergugat</option>	                                    
	                                </select>
			                    </span>
								<span class="custom-dropdown custom-dropdown--emerald">
	                                <select style="width:150px;z-index:99999" class="custom-dropdown__select custom-dropdown__select--white">
									 <option>Pilih Blanko BAP</option>
										<option onClick=cetakBAP1('<?php echo $enc;?>');>BAP Pemeriksaan Persiapan</option>
										<option onClick=cetakBAP2('<?php echo $enc;?>');>BAP Pemeriksaan Persiapan Tunda</option>                                   
	                                </select>
			                    </span>
			                 <?php
			                }
			                echo "</td>";
			                echo "<td align='center'>";
	    					if($jumlahProses==1 && $canEditPemeriksaanPersiapan){
	    					?>
		    					<a href="#" onClick="popup_form('<?php echo base_url('edit_pemeriksaan_proses/'.$enc.'/'.$encPersiapanProses);?>')">Edit</a>|
		    					<a href="#" onClick="popup_form('<?php echo base_url('tunda_pemeriksaan_proses/'.$enc.'/'.$encPersiapanProses);?>')">Tunda</a>
	    					<?php
	    					} else {
	    						if($row->urutan==$lastUrutan && $canEditPemeriksaanPersiapan){
	    						?>
	    							<a href="#" onClick="popup_form('<?php echo base_url('edit_pemeriksaan_proses/'.$enc.'/'.$encPersiapanProses);?>')">Edit</a>|
	    							<a href="#" onClick="popup_form('<?php echo base_url('tunda_pemeriksaan_proses/'.$enc.'/'.$encPersiapanProses);?>')">Tunda</a>
	    						<?php
	    						}
	    					
	    					}

	    					echo "</td>";
	    				echo "</tr>";
    				}
    				?>

    			</table>
				

			</td>
		</tr>

		<tr>
			<td id="first-child">Petitum</td>
			<td colspan="2"><?php echo $prositaPetitum; ?></td>
		</tr>
		
		<tr>
			<td style="width:15%;" id="first-child">E-Doc Gugatan Perbaikan</td>
			<td style="width:85%;">
				<?php
				$baseurl=$petitumDokumen;
                if (($baseurl) and (file_exists($baseurl))){
                    echo "<a target='_new' href=$baseurl>Unduh Dokumen</a>";
                }else{
                    echo "<span style='color:red;font-weight:bold'>Dokumen Belum Ada</span>";
                }
				?>
			</td>
			<?php
			if($canEditPemeriksaanPersiapan){ ?>
				<td style='text-align:right'>
				[ <a href="#" onClick="popup_form('<?php echo base_url("fileupload/".$enc."/persiapan");?>')">Edit E-Doc</a> ]				
				</td>
	  <?php }
			?>
		</tr>
	</tbody>
</table>
</div>
<script type="text/javascript">
	function pilih_cetak(ele){
		if (ele.value!=1) {
			popup_form(ele.value);
			$(ele).val('1');
		}
	}
	function cetakBAP1(){
	window.open('<?php echo base_url("c_template_tun/cetak_penetapan_persiapan_tun/")."/".$enc."/5/";?>','_self');
	}
	function cetakBAP2(){
	window.open('<?php echo base_url("c_template_tun/cetak_penetapan_persiapan_tun/")."/".$enc."/6/";?>','_self');
	}
	
    closeLoading();
</script>
