<?php
if($this->session->userdata('is_logged_in')===FALSE){
            redirect('login');
}
?>
<div class="templatepopcentering" style="width:500px;margin-top: 1%;">
<div id='pop' style="border: 1px solid #ffffff;">
    <div class="detil" style="padding: 4px;background-color: white;"> 
        <form id="frm_akta_cabut_pk" style="padding: 4px;background:white;margin:0;" method="post" action="<?php echo base_url().'c_template_akta_cabut_pk/cetak_akta_cabut_pk';?>">            
            <table id="" style="padding:5px;"> 
            <tr><td colspan="2" class="templatepoptitle">
            <?php 
                $i=0;
                foreach ($template->result() as $template)
                {
                    if ($i=='0')
                    {
                        $judul=$template->namatemplate;
                        $judul=explode("Oleh",$judul);
                        $jnsperkara=$template->jnsperkara;
                    }
                }
                    echo strtoupper($judul[0]."<br/>Perkara ".$jnsperkara);
            ?>
            </td></tr>
            <tr>
                <td class="templatepopleftcol">Pihak Pemohon PK</td>
                <td style="font-size:13px; padding-left:10px">
                    <?php 
                    if($info != ''){
                        if($info->num_rows>0){
                            foreach ($info->result() as $row) {                                
                                echo $this->templatehelper->standradnaming($row->pihak_nama);
                                //echo "Diwakili oleh: <b>".$this->templatehelper->standradnaming($row->diwakili)."</b></br>";
                                }
                            }
                        }
                    ?>
                </td>
            </tr> 
            <tr>
                <td class="templatepopleftcol">Pilih Jenis Akta<font color=red>*</font></td>
                    <td style="">
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="jenisAkta" id="jenisAkta" class="custom-dropdown__select custom-dropdown__select--white">
                                <?php
                                    if($pihakasal==2){
                                        echo "<option value='-1'>Pilih Jenis Akta Pencabutan</option>";
                                        echo "<option value='1'>Akta Pencabutan Peninjauan Kembali Oleh Terpidana</option>";
                                        echo "<option value='2'>Akta Pencabutan Peninjauan Kembali Oleh Ahli Waris</option>";
                                        echo "<option value='3'>Akta Pencabutan Peninjauan Kembali Oleh Kuasa Hukum Terpidana</option>";
                                    }elseif($pihakasal==1){
                                        echo "<option value='4'>Akta Pencabutan Peninjauan Kembali Oleh Penuntut Umum</option>";
                                    }    
                                ?>    
                            </select>
                        </span>
                </td> 
            </tr>
            <tr class="row_terdakwa" style="display:none;">
                <td class="templatepopleftcol">Pemohon Peninjauan Kembali<font color=red>*</font></td>
                    <td style="">
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="terdakwa" id="terdakwa" class="custom-dropdown__select custom-dropdown__select--white">                                
                                <?php 
                                    if($info_DataTerdakwa != ''){
                                        if($info_DataTerdakwa->num_rows>0){
                                            if($info_DataTerdakwa->num_rows>1){
                                                echo "<option value='-1'>Pilih Terdakwa</option>";
                                            }foreach ($info_DataTerdakwa->result() as $row) {
                                                $pihak_id = base64_encode($this->encrypt->encode($row->pihak_id));
                                                echo "<option value='".$pihak_id."'>".$this->templatehelper->standradnaming($row->pihak_nama).'/ tanggal Permohonan: '.$this->templatehelper->convertKeTglIndo($row->tglPemohonPK)."</option>";
                                            }
                                        }else{
                                            echo "<option value='-1'>Data Terdakwa Tidak Ada</option>";
                                        }
                                    }else{
                                        echo "<option value='-1'>Data Terdakwa Tidak Ada</option>";
                                    }
                                ?>
                            </select>
                    </span>
                </td> 
            </tr>
            <tr class="row_ph" style="display:none;">
                <td class="templatepopleftcol">Pilih Penasihat Hukum<font color=red>*</font></td>
                    <td style="">
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="ph" id="ph" class="custom-dropdown__select custom-dropdown__select--white">                                
                                <?php 
                                    if($info_DataPH_PK != ''){
                                        if($info_DataPH_PK->num_rows>0){
                                            if($info_DataPH_PK->num_rows>1){
                                                echo "<option value='-1'>Pilih Penasihat Hukum</option>";
                                            }foreach ($info_DataPH_PK->result() as $row) {
                                                $pengacara_id = base64_encode($this->encrypt->encode($row->pengacara_id));
                                                echo "<option value='".$pengacara_id."'>".$this->templatehelper->standradnaming($row->namaPengacara).' mewakili '.$this->templatehelper->standradnaming($row->pihak_nama)."</option>";
                                            }
                                        }else{
                                            echo "<option value='-1'>Data Penasihat Hukum Tidak Ada</option>";
                                        }
                                    }else{
                                        echo "<option value='-1'>Data Penasihat Hukum Tidak Ada</option>";
                                    }
                                ?>
                            </select>
                    </span>
                </td> 
            </tr>
            <tr class="row_jpu" >
                <td class="templatepopleftcol">Pilih Penuntut Umum<font color=red>*</font></td>
                    <td style="">
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="jpu" id="jpu" class="custom-dropdown__select custom-dropdown__select--white">                                
                                <?php 
                                    if($info_dataDataJaksaPK != ''){
                                        if($info_dataDataJaksaPK->num_rows>0){
                                            if($info_dataDataJaksaPK->num_rows>1){
                                                echo "<option value='-1'>Pilih Jaksa Penuntut Umum</option>";
                                            }foreach ($info_dataDataJaksaPK->result() as $row) {
                                                $pihak_id = base64_encode($this->encrypt->encode($row->pihak_id));
                                                echo "<option value='".$pihak_id."'>".$this->templatehelper->standradnaming($row->nama).' / '.$row->pekerjaan."</option>";
                                            }
                                        }else{
                                            echo "<option value='-1'>Data Jaksa Penuntut Umum Tidak Ada</option>";
                                        }
                                    }else{
                                        echo "<option value='-1'>Data Jaksa Penuntut Umum Tidak Ada</option>";
                                    }
                                ?>
                            </select>
                    </span>
                </td> 
            </tr>            
            <tr>
                <td class="templatepopleftcol">Pembuat Penetapan<font color=red>*</font></td>
                    <td style="">
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="pembuat" id="pembuat" class="custom-dropdown__select custom-dropdown__select--white">
                                <?php 
                                    if($info_penadatangan != ''){
                                        if($info_penadatangan->num_rows>0){
                                            foreach ($info_penadatangan->result() as $row) {
                                                $id = base64_encode($this->encrypt->encode($row->id));
                                                echo "<option value='".$id."'>".$row->pejabat.' - '.$this->templatehelper->standradnaming($row->pw)."</option>";
                                            }
                                        }
                                    }
                                ?>
                            </select>
                    </span>
                </td> 
            </tr>
            <tr>
                <td class="templatepopleftcol">Terhadap Putusan<font color=red>*</font></td>
                    <td style="">
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="putusan" id="putusan" class="custom-dropdown__select custom-dropdown__select--white">                                
                                <?php 
                                    if($dataPutusan != ''){
                                        if($dataPutusan->num_rows>0){
                                            if($dataPutusan->num_rows>1){
                                                echo "<option value='-1'>Silakan Pilih Terhadap Putusan</option>";
                                            }foreach ($dataPutusan->result() as $row) {
                                                $idPut = base64_encode($this->encrypt->encode($row->idPut));
                                                echo "<option value='".$idPut."'>&nbsp;". $row->tahapan ."&nbsp;Nomor: ". $row->nomorPerkara .".&nbsp  Tgl Putus : ".$this->templatehelper->convertKeTglIndo($row->tglPutus) ." </option>";
                                            }
                                        }else{
                                            echo "<option value='-1'>Data Putusan Tidak Ada</option>";
                                        }
                                    }else{
                                        echo "<option value='-1'>Data Putusan Tidak Ada</option>";
                                    }
                                ?>
                            </select>
                        </span>
                </td> 
            </tr>
                <tr>
                    <td colspan="2" style="background:white;" align="center">
                        <input type="hidden" id="enc" name = 'enc' value="<?php echo $enc; ?>">
                        <input type="button" id="kembali" value="Kembali" class="btn">
                        <input type="submit" id="print_btn" value="Cetak" class="btn">
                    </td>
                </tr>
            </table>
</form>
</div>
</div>
<script type="text/javascript">
$('#kembali').closingFormWin();

$("tr.row_terdakwa").hide();
$("tr.row_ph").hide();
$("tr.row_jpu").hide();

$("#jenisAkta").change(function(){
    if(($(this).val()==1)||($(this).val()==2))
    $("tr.row_terdakwa").show();
    else $("tr.row_terdakwa").hide();
})

$("#jenisAkta").change(function(){
    if(($(this).val()==3))
    $("tr.row_ph").show();
    else $("tr.row_ph").hide();
})
$("#jenisAkta").change(function(){
    if(($(this).val()==4))
    $("tr.row_jpu").show();
    else $("tr.row_jpu").hide();
})


$('#frm_akta_cabut_pk').submit(function(e) {
    var jenisAkta = $('#jenisAkta').attr('value');    
    var pembuat = $('#pembuat').val();
    if(pembuat == -1){
        message_error_show('Silahkan Pilih Pejabat Pembuat AKTA');
        e.preventDefault();
    }
    var putusan = $('#putusan').val();
    if(putusan == -1){
        message_error_show('Silahkan Pilih Tahapan Putusan');
        e.preventDefault();
    }

    if((jenisAkta==1)){
        var terdakwa = $('#terdakwa').attr('value');
        if(terdakwa == -1){
            message_error_show('Silahkan Pilih terdakwa');
            e.preventDefault();
        }
    }

    if((jenisAkta==2)){
        var terdakwa = $('#terdakwa').attr('value');
        if(terdakwa == -1){
            message_error_show('Silahkan Pilih terdakwa');
            e.preventDefault();
        }
    }

    if((jenisAkta==3)){
        var ph = $('#ph').attr('value');
        if(ph == -1){
            message_error_show('Silahkan Pilih Penasihat Hukum');
            e.preventDefault();
        }
    }
    if(jenisAkta==-1){
        message_error_show('Silahkan Pilih Jenis Akta Pencabutan Peninjauan Kembali');
        e.preventDefault();
    }
        
});
</script>