<?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: 2px;background-color: white;">			
    <form id="frm_relaas_akta" class="templatepopform" method="post" action="<?php echo base_url().'c_template_mil_akta_banding_pidana/cetak_cabut_banding';?>">
			<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("Untuk",$judul);
                        $jnsperkara=$template->jnsperkara;
                    }
                }
                    echo strtoupper($judul[0]."<br/>Perkara ".$jnsperkara);
            ?>
            </td></tr>
                <tr>
                    <td class="templatepopleftcol">Akta Cabut Banding<font color=red>*</font></td>
                    <td>
                        <input type="hidden" id="pihakasal" name = 'pihakasal' value="<?php echo $pihakasal; ?>">
                        <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($jenisAkta==2 AND $pihakasal==2){                                        
                                        echo '<option value="1">Akta Pencabutan Banding (Terdakwa)</option>';
                                    }elseif($jenisAkta==2 AND $pihakasal==1){
                                        echo '<option value="2">Akta Pencabutan Banding (Oditur)</option>';
                                    }else{
                                        echo '<option value="-1">Pilih Jenis Akta</option>';
                                    }
                                ?>  
                            </select>
                        </span>
                    </td>
                </tr>

                <?php if($pihakasal==1){ ?>
                <tr class="tr_terdakwa">
                    <td class="templatepopleftcol">Nama Terdakwa<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="idterdakwa" id="idterdakwa"  class="custom-dropdown__select custom-dropdown__select--white">
                                <?php                                
                                    if($listAllTerdakwa != ''){
                                        if($listAllTerdakwa->num_rows>0){
                                            if($listAllTerdakwa->num_rows>1){
                                                echo '<option value="-1">Pilih Nama Terdakwa</option>';
                                            }foreach ($listAllTerdakwa->result() as $row) {
                                                $IDPihak = base64_encode($this->encrypt->encode($row->IDPihak));
                                                echo "<option value='".$IDPihak."' atttgl='".$this->templatehelper->convertKeTglDatepicker($row->tglPemberitahuan)."'>".$this->templatehelper->standradnaming($row->nama)."</option>";                                                    
                                            }
                                        }else{
                                            echo "<option value='-1'>Terdakwa Tidak Langsung Mengajukan Permohonan Banding</option>";
                                        }
                                    }else{
                                        echo "<option value='-1'>Terdakwa Tidak Langsung Mengajukan Permohonan Banding</option>";
                                    }
                                ?>                                 
                            </select>
                        </span>
                    </td> 
                </tr> 
                <?php } ?> 
                <?php if($pihakasal==2){ ?>  
                <tr class="tr_terdakwa">
                    <td class="templatepopleftcol">Nama Terdakwa<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="idterdakwa" id="idterdakwa"  class="custom-dropdown__select custom-dropdown__select--white">
                                <?php                                
                                    if($listTerdakwa != ''){
                                        if($listTerdakwa->num_rows>0){
                                            if($listTerdakwa->num_rows>1){
                                                echo '<option value="-1">Pilih Nama Terdakwa</option>';
                                            }foreach ($listTerdakwa->result() as $row) {
                                                $IDPihak = base64_encode($this->encrypt->encode($row->IDPihak));
                                                echo "<option value='".$IDPihak."' atttgl='".$this->templatehelper->convertKeTglDatepicker($row->tglPemberitahuan)."'>".$this->templatehelper->standradnaming($row->nama)."</option>";                                                    
                                            }
                                        }else{
                                            echo "<option value='-1'>Terdakwa Tidak Mengajukan Permohonan Banding</option>";
                                        }
                                    }else{
                                        echo "<option value='-1'>Terdakwa Tidak Mengajukan Permohonan Banding</option>";
                                    }
                                ?>                                 
                            </select>
                        </span>
                    </td> 
                </tr>
                <?php } ?> 
                <tr class="tr_kuasa" style="display:none;">
                    <td class="templatepopleftcol">Penasihat Hukum<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="idpenasihat" id="idpenasihat"  class="custom-dropdown__select custom-dropdown__select--white">
                                <?php                                
                                if($listKuasa != ''){
                                    if($listKuasa->num_rows>0){
                                        if($listKuasa->num_rows>1){
                                            echo '<option value="-1">Pilih Kuasa Hukum</option>';
                                        }
                                        foreach ($listKuasa->result() as $row) {
                                            $IDPihak = base64_encode($this->encrypt->encode($row->IDPihak));
                                                echo "<option value='".$IDPihak."' atttgl='".$this->templatehelper->convertKeTglDatepicker($row->tglPemberitahuan)."'>".$this->templatehelper->standradnaming($row->nama)."</option>";
                                        }                                        
                                    }else{
                                        echo "<option value='-1'>Mohon Mengisikan Kuasa Hukum Terlebih Dahulu</option>";
                                    }
                                }else{
                                    echo "<option value='-1'>ohon Mengisikan Kuasa Hukum Terlebih Dahulu</option>";
                                }
                                ?>                                  
                            </select>
                        </span>
                    </td> 
                </tr>
                <?php 
                    if($pihakasal==1){
                        echo '<tr>';
                        echo '<td class="templatepopleftcol">Penuntut Umum<font color=red>*</font></td>';
                        echo '<td>';
                            echo '<span class="custom-dropdown custom-dropdown--emerald">';
                            echo '<select style="width:250px;"  name="idpenuntut" id="idpenuntut"  class="custom-dropdown__select custom-dropdown__select--white">';
                                    ?>
                                    <?php                                
                                        if($listPenuntut != ''){
                                            if($listPenuntut->num_rows>0){
                                                if($listPenuntut->num_rows>1){
                                                    echo '<option value="-1">Pilih Nama Penuntut Umum</option>';
                                                }foreach ($listPenuntut->result() as $row) {
                                                    $IDPihak = base64_encode($this->encrypt->encode($row->IDPihak));
                                                    echo "<option value='".$IDPihak."' atttgl='".$this->templatehelper->convertKeTglDatepicker($row->tglPemberitahuan)."'>".$this->templatehelper->standradnaming($row->nama)."</option>";
                                                }
                                            }else{
                                                echo "<option value='-1'>Mohon Mengisikan Penuntut Umum Terlebih Dahulu</option>";
                                            }
                                        }else{
                                            echo "<option value='-1'>ohon Mengisikan Penuntut Umum Terlebih Dahulu</option>";
                                        }                                                                                                                             
                            echo '</select>';
                            echo '</span>';
                        echo '</td>';
                    echo '</tr>';
                    }
                ?>
                <tr class="trPermintaan" style="display:none;">
                    <td class="templatepopleftcol">Cabut Melalui<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="bandingMelalui" id="bandingMelalui"  class="custom-dropdown__select custom-dropdown__select--white">
                                <option value='-1'>Pilih Cabut Melalui</option>
                                <option value='1'>Kalapas</option>
                                <option value='2'>Karutan</option>                                                                                                
                            </select>
                        </span>
                    </td> 
                </tr>                
                <tr>
                    <td class="templatepopleftcol">Penanda Tangan Akta<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:250px;'  name="penandaT" id="penandaT"  class="custom-dropdown__select custom-dropdown__select--white">
                                <?php                                
                                    if($listPembuatAkta != ''){
                                        if($listPembuatAkta->num_rows>0){
                                            foreach ($listPembuatAkta->result() as $row) {
                                                $id = base64_encode($this->encrypt->encode($row->id));
                                                echo "<option value='".$row->id."'>".$this->templatehelper->standradnaming($row->namaPanitera)."</option>";
                                            }
                                        }
                                    }
                                ?>                                                                                                
                            </select>
                        </span>
                    </td> 
                </tr>              

              <tr>
                    <td class="templatepopleftcol">Tanggal Cabut<font color=red>*</font></td>                    
                    <td>                        
                        <input style="background-color:#8;padding:5px;" value="<?php echo $tglcabutindo;?>" disabled>
                    </td>
                </tr>                       
  

                <tr>
					<td colspan="2" style="background:white;" align="center">
                        <input type="hidden" id="enc" name = 'enc' value="<?php echo $enc; ?>"> 
                        <input type="hidden" id="tglcabut" name = 'tglcabut' value="<?php echo $tglcabut; ?>">                       
                        <input type="hidden" id="tglbanding" name = 'tglbanding' value="<?php print_r($tglbanding); ?>">
						<input type="button" id="kembali" value="Kembali" class="btn">
						<input type="submit" id="print_btn" value="Cetak" class="btn">
					</td>
				</tr>
            </table>
		</div>
    </div>
</div>

<script type="text/javascript">
$('#kembali').closingFormWin();

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

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

$('#frm_relaas_akta').submit(function(e) {
    var jenisAkta = $('#jenisAkta').val();

    if(jenisAkta==1 && $(pihakasal==2)){    
        var terdakwa = $('#idterdakwa').val();
        if(terdakwa==-1 || terdakwa==''){
            message_error_show('Silahkan Pilih Nama Terdakwa Yang Melakukan Banding');
            e.preventDefault();
        }
    } 
    
    if(jenisAkta==2 && $(pihakasal==1)){
        var penuntut = $('#idpenuntut').val();
        if(penuntut==-1){
            message_error_show('Silahkan Pilih Oditur Yang Mengajukan Banding');
             e.preventDefault();
        }
    }   
        var penandaT = $('#penandaT').val();
    if(penandaT==-1){
        message_error_show('Silahkan Pilih Pembuat Akta Cabut Banding');
        e.preventDefault();
    }
    if(jenisAkta==-1){
        message_error_show('Silahkan Pilih Jenis Akta Cabut Banding');
        e.preventDefault();
    }

    var tglcabut = $('#tglcabut').val();
    if(tglcabut==''){
        message_error_show('Tanggal Cabut Masih Kosong');
        e.preventDefault();
    }
});
</script>