<?php
if($this->session->userdata('is_logged_in')===FALSE){
            redirect('login');
}
?>
<div class="templatepopcentering" style="width:530px;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_tun_akta_banding/cetak_cabut_banding';?>">
			<table id="" style="padding:5px;width:100%" >				
			<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 style="width:200px"class="templatepopleftcol">Akta Cabut Banding<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:275px;'  name="jenisAkta" id="jenisAkta" class="custom-dropdown__select custom-dropdown__select--white">
                                <?php 
                                    if($pihakasal==1){
                                        echo '<option value="7">Akta Pencabutan Permohonan Banding Penggugat</option>';
                                        echo '<option value="8">Akta Pencabutan Permohonan Banding Kuasa Penggugat</option>';
                                    }elseif($pihakasal==2){
                                        echo '<option value="9">Akta Pencabutan Permohonan Banding Tergugat</option>';
                                        echo '<option value="10">Akta Pencabutan Permohonan Banding Kuasa Tergugat</option>';
                                    }elseif($pihakasal==3){
                                        echo '<option value="11">Akta Pencabutan Permohonan Banding Intervensi</option>';
                                        echo '<option value="12">Akta Pencabutan Permohonan Banding Kuasa Intervensi</option>';
                                    }
                                ?>
                                
                                
                            </select>
                        </span>
                    </td>
                </tr>
                <?php if($pihakasal==2){ ?>                
                <tr class="trTergugat">
                    <td class="templatepopleftcol">Nama Tergugat<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:275px;'  name="terdakwa" id="terdakwa"  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'>Pihak Tidak Secara Langsung Mengajukan Permohonan Banding</option>";
                                        }
                                    }else{
                                        echo "<option value='-1'>Pihak Tidak Secara Langsung Mengajukan Permohonan Banding</option>";
                                    }
                                ?>                                 
                            </select>
                        </span>
                    </td> 
                </tr>
                <?php } ?>
                <?php if($pihakasal==1){ ?>               
                <tr class="trPenggugat" >
                    <td class="templatepopleftcol">Nama Penggugat<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                        <select style="width:275px;"  name="terdakwa" id="terdakwa"  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."'>".$this->templatehelper->standradnaming($row->nama)."</option>";
                                            }
                                        }else{
                                            echo "<option value='-1'>Pihak Tidak Secara Langsung Mengajukan Permohonan Banding</option>";
                                        }
                                    }else{
                                        echo "<option value='-1'>Pihak Tidak Secara Langsung Mengajukan Permohonan Banding</option>";
                                    } 
                                ?>                                                                                                                            
                        </select>
                        </span>
                    </td>
                </tr>
                <?php } ?>
                <?php if($pihakasal==3){ ?>
                <tr class="tr_intervensi">
                    <td class="templatepopleftcol">Nama Intervensi<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:275px;'  name="terdakwa" id="terdakwa"  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'>Pihak Tidak Secara Langsung Mengajukan Permohonan Banding</option>";
                                        }
                                    }else{
                                        echo "<option value='-1'>Pihak Tidak Secara Langsung Mengajukan Permohonan Banding</option>";
                                    }
                                ?>                                 
                            </select>
                        </span>
                    </td> 
                </tr>
                <?php } ?>                            
                <tr class="tr_kuasa" style="display:none;">
                    <td class="templatepopleftcol">Nama Kuasa Hukum<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:275px;'  name="idpenasihat" id="idpenasihat"  class="custom-dropdown__select custom-dropdown__select--white">                                                                
                                <?php
                                if($pihakasal==1){
                                    if($listKuasaP != ''){
                                        if($listKuasaP->num_rows>0){
                                            if($listKuasaP->num_rows>1){
                                                echo '<option value="-1">Pilih Kuasa Hukum</option>';
                                            }
                                            foreach ($listKuasaP->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>";
                                    }
                                }elseif($pihakasal==2){
                                    if($listKuasaT != ''){
                                        if($listKuasaT->num_rows>0){
                                            if($listKuasaT->num_rows>1){
                                                echo '<option value="-1">Pilih Kuasa Hukum</option>';
                                            }
                                            foreach ($listKuasaT->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>";
                                    }
                                }elseif($pihakasal==3){
                                    if($listKuasaInter != ''){
                                        if($listKuasaInter->num_rows>0){
                                            if($listKuasaInter->num_rows>1){
                                                echo '<option value="-1">Pilih Kuasa Hukum</option>';
                                            }
                                            foreach ($listKuasaInter->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>                        
                <tr>
                    <td class="templatepopleftcol">Penanda Tangan Akta<font color=red>*</font></td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--emerald">
                            <select style='width:275px;'  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='".$id."'>".$this->templatehelper->standradnaming($row->namaPanitera)."</option>";
                                            }
                                        }
                                    }
                                ?>                                                                                                
                            </select>
                        </span>
                    </td> 
                </tr>
                <tr>
                    <td class="templatepopleftcol">Tanggal Surat Pencabutan<font color=red>*</font></td>                    
                    <td>                                                
                        <input id="tglsurat" name="tglsurat" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                    </td>
                </tr>
                <tr>
                    <td class="templatepopleftcol">Nomor Surat Pencabutan<font color=red>*</font></td>
                    <td>
                       <input id="nomorsurat" name="nomorsurat" type="text" class="standard-input">
                    </td> 
                </tr>
                <tr>
                    <td class="templatepopleftcol">Tanggal Pencabutan<font color=red>*</font></td>                    
                    <td>                        
                        <input id='inputrelaasbanding' name='inputrelaasbanding' class='standard-input' style="width:140px;background-color:#8;padding:5px;padding-left:10px" value="<?php echo (empty($tglcabut))? $tglcabut: $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 echo $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();

$('#tglsurat').datepicker({
            inline: true,
            showOtherMonths: true,
            dateFormat: 'dd/mm/yy',
            dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
            beforeShowDay: $.datepicker.noWeekends,
            onSelect: function(dateText, inst) {
                var date = $(this).datepicker('getDate');
                var dayOfWeek = weekday[date.getDay()];
                var error = 0;
                var message ='';
                if(dayOfWeek=='Sunday' || dayOfWeek=='Saturday'){
                    message ='Tidak Dapat Memilih diluar Hari Kerja.';
                    message_error_show_parent(message);
                    return;
                }
                error = 0;               
            }
    });

$("#jenisAkta").change(function(){
    if($(this).val()==9)
    $("tr.trTergugat").show();
    else $("tr.trTergugat").hide();
})
$("#jenisAkta").change(function(){
    if($(this).val()==7)
    $("tr.trPenggugat").show();
    else $("tr.trPenggugat").hide();
})
$("#jenisAkta").change(function(){
    if($(this).val()==8||$(this).val()==10||$(this).val()==12)
    $("tr.tr_kuasa").show();
    else $("tr.tr_kuasa").hide();
})
$("#jenisAkta").change(function(){
    if($(this).val()==11)
    $("tr.tr_intervensi").show();
    else $("tr.tr_intervensi").hide();
})

$('#frm_relaas_akta').submit(function(e) {
    var jenisAkta=$('#jenisAkta').val();
    var tglsurat=$('#tglsurat').val();
    
    var nomorsurat=$('#nomorsurat').val();
    if(nomorsurat==''){
        message_error_show('Silahkan Isi Nomor Surat Pencabutan');
        e.preventDefault();
    }
    if(tglsurat==''){
        message_error_show('Silahkan Isi Tanggal Surat Pencabutan');
        e.preventDefault();
    }
    var tglbanding=$('#inputrelaasbanding').val();
    if(tglbanding==''){
        message_error_show('Silahkan Isi Tanggal Pencabutan');
        e.preventDefault();
    }    
    if((jenisAkta==7)||(jenisAkta==9)||(jenisAkta==11)){
        var terdakwa = $('#terdakwa').val();
        if(terdakwa==-1){
            message_error_show('Silahkan Pilih Nama Pihak');
            e.preventDefault();
        }
    }
    
    if(jenisAkta==8||jenisAkta==10||jenisAkta==12){
        var penasihat = $('#idpenasihat').val();
        if(penasihat==-1){
            message_error_show('Silahkan Pilih Penasihat Hukum');
            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();
    }

});
</script>