<?php
$jnsmed=$this->encrypt->decode(base64_decode($encmed));
?>
<div class="centering" style="width:1000px;margin-top: 1%;">
<div id='popup_edit_hasil_mediasi' style="border: 1px solid #ffffff;">
    <div class="detil" style="padding: 2px;background-color: white;">
		<form id="frm_mediasi" class="removeformbottomspace" method="post" action="<?php echo base_url().'tab_mediasi_c/update_hasil_mediasi';?>">
			<table id="tableDetilPerkara" style="font-size:14px;">
				<col class="first_col"  width="20%">
				<col class="second_col" width="80%">
                    <tbody>
						<tr>
							<td colspan="2" style="padding:4px;background:white;font-size:16px;color:#111;" align="center"><strong>Edit Data Hasil <?php echo $jnsmed;?></strong></td>
						</tr>
                        <tr>
                            <td>Tgl Hasil Mediasi</td>
                            <td id="tgl_kesepakatan_mediasi" style="padding:0px;padding-left:5px;">
                            <?php 
                            if(!empty($keputusan_mediasi)){
                                echo $this->tanggalhelper->convertDayDate($keputusan_mediasi);
                                echo " (Sesuai Tanggal Jadwal Mediasi Terakhir)";
                                ?>
                            <input type="hidden" id="tgl_hasil_mediasi" name="tgl_hasil_mediasi" value="<?php echo $keputusan_mediasi;?>">
                            <?php
                            } ?>
                            </td>
                        </tr>
                        <tr>
                            <td>Tgl Laporan Mediator<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_laporan_mediator" name="tgl_laporan_mediator" value="<?php echo (!empty($tgl_laporan_mediator) ? $this->tanggalhelper->convertToInputDate($tgl_laporan_mediator) : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                            </td>
                        </tr>
                        <tr>
                            <td>Hasil Mediasi<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <span class="custom-dropdown custom-dropdown--emerald" style="200px">
                                    <select style="width:200px" name="hasil_mediasi" id="hasil_mediasi" class="custom-dropdown__select custom-dropdown__select--white" >
                                        <?php
                                        $nilai = '';
                                        if(!empty($hasil_mediasi)){
                                            if($hasil_mediasi=='Y'){
                                                $hasil_mediasi='Y1';
                                            }
                                            $nilai = $hasil_mediasi;
                                        }
                                        ?>
                                        <option value=''>Pilih Hasil Mediasi</option>
                                        <option value='Y1' <?php echo ($nilai=='Y1')? 'selected':'' ?>  >Berhasil Dengan Akta Perdamaian</option>
                                        <option value='Y2' <?php echo ($nilai=='Y2')? 'selected':'' ?>  >Berhasil Dengan Pencabutan</option>
                                        <option value='S' <?php echo ($nilai=='S')? 'selected':'' ?>  >Berhasil Sebagian</option>
                                        <option value='T' <?php echo ($nilai=='T')? 'selected':''; ?>  >Tidak Berhasil</option>                                       
                                        <option value='D' <?php echo ($nilai=='D')? 'selected':''; ?>  >Tidak Dapat Dilaksanakan</option>
                                    </select>
                                </span>
                            </td>
                        </tr>                       
                        <tr id='tr_tgl_kesepakatan' style="display:none" >
                            <td>Tgl Kesepakatan Perdamaian<font color="red">*</font></td>
                            <td style="padding:0px;padding-left:5px;">
                                <input id="tgl_kesepakatan" name="tgl_kesepakatan" value="<?php echo (!empty($tgl_kesepakatan_perdamaian) ? $this->tanggalhelper->convertToInputDate($tgl_kesepakatan_perdamaian) : '');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                            </td>
                        </tr>
                        <tr id='isi_kesepakatan' style="display:none" >
                            <td valign="top" style="vertical-align:top">Isi Kesepakatan Perdamaian<font color="red">*</font></td>
                            <td style="background:white;" id="isi_kesepakatan_text">
                                <?php echo $this->ckeditor->editor("isi_kesepakatan_perdamaian",$isi_kesepakatan_perdamaian);?>
                            </td>
                        </tr>                        
                        <tr>
                            <td>Keterangan</td>
                            <td style="padding:0px;padding-left:5px;">
                                <textarea id="keterangan" name="keterangan" class="standard-input" style="resize: none;margin: 0px; width: 98%; height: 60px;"><?php echo (!empty($keterangan)?$keterangan:'');?></textarea>
                            </td>
                        </tr>
						<tr>
                            <td colspan="2" class="buttongroup">
							<input type="hidden" name="enc" id="enc" value="<?php echo $enc; ?>">
							<input type="hidden" id="curr_date" name="curr_date" value="<?php echo $tgl_sekarang;?>">
                            <input type="hidden" id="mediasi_id" name="mediasi_id" value="<?php echo base64_encode($this->encrypt->encode($mediasi_id));?>">
                            <input type="hidden" id="dimulasi_mediasi" name="dimulasi_mediasi" value="<?php echo $tgl_mediasi;?>">
                            <input type="hidden" id="urutan" name="urutan" value="<?php echo $urutan;?>">
							<input type="button" id='close_form_mediasi' value="Kembali" class="btn">
                            <?php
                            if(!empty($tgl_laporan_mediator)){
                                echo '<input type="button" id="hapus" value="Hapus" style="text-decoration:none" class="del_btn">';
                            }
                            ?>
                            <input type="submit" id="simpan_btn" value="Simpan" class="btn">
                        	</td>
                        </tr>
					</tbody>
			</table>
		</form>
	</div>
</div>
<script type="text/javascript">
$('#frm_mediasi').SubmitHandling({
    refresh:'1',
    setRefresh:1,
    divRef:'#konten',
    clicked:1,
    btnClicked:'#close_form_mediasi',
    whenStatus:1,
	isCKEdit:1,
	tdID:'isi_kesepakatan_text',
	textID:'isi_kesepakatan_perdamaian',
    next_step:1
});
$('#hapus').ButtonClickHandling({
    refresh:'1',
    setRefresh:1,
    divRef:'#konten',
    clicked:1,
    btnClicked:'#close_form_mediasi',
    whenStatus:1,
    actions:'<?php echo base_url()?>tab_mediasi_c/hapus_hasil_mediasi/',
    formName:'#frm_mediasi',
    actionName:'Hapus Data'
});
<?php 
if($this->session->userdata('jenis_pengadilan')==1){
?>
    $('#close_form_mediasi').click(function(){
        window.open("<?php echo base_url('perkara_detil/'.$enc.'/6');?>","_self");    
    });          
<?php
}else if($this->session->userdata('jenis_pengadilan')==4){
?>
    $('#close_form_mediasi').click(function(){
        window.open("<?php echo base_url('perkara_detil_agama/'.$enc.'/6');?>","_self");    
    });           
<?php
}else{
?>
    $('#close_form_mediasi').closingFormWin();
<?php
}
?>
var hasil_mediasi='<?php echo $hasil_mediasi;?>';
if(hasil_mediasi==="Y1"||hasil_mediasi==="Y2"||hasil_mediasi==="S"){
    $('#tr_tgl_kesepakatan').show();
    $('#isi_kesepakatan').show();   
};


$("#hasil_mediasi").change(function(){
    if($(this).val()=='Y1'||$(this).val()=='Y2'||$(this).val()=='S'){
        $('.centering').css({'width':'1000px'});
        $('.first_col').css({'width':'20%'});
        $('.second_col').css({'width':'80%'});
    }else{
        $('.centering').css({'width':'600px'});
        $('.first_col').css({'width':'30%'});
        $('.second_col').css({'width':'70%'});
    }

    switch($(this).val()){
        case "Y1":               
                $('#tr_tgl_kesepakatan').show();
                $('#isi_kesepakatan').show();
        break;
        case "Y2":
                $('#tr_tgl_kesepakatan').show();
                $('#isi_kesepakatan').show();               
        break;
        case "S":                
                $('#tr_tgl_kesepakatan').show();
                $('#isi_kesepakatan').show();
        break;
        case "T":
                $('#tr_tgl_kesepakatan').hide();
                $('#isi_kesepakatan').hide();               
        break;
        case "D":
                $('#tr_tgl_kesepakatan').hide();
                $('#isi_kesepakatan').hide();               
        break;
        case "":
                $('#tr_tgl_kesepakatan').hide();
                $('#isi_kesepakatan').hide();               
        break;
    }
});
$('#tgl_laporan_mediator').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 error = 0;
                
                var tmp = $(this).val().split("/");
                var tmp2 = $('#curr_date').val().split("/");
                var tgl_hasil_mediasi = $('#tgl_hasil_mediasi').val();
                var tmp3 = tgl_hasil_mediasi.split("-");

                if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() > new Date(tmp2[2]+"-"+tmp2[1]+"-"+tmp2[0]+"T00:00:00").getTime())){
                    message = 'Tidak Dapat Memilih Melebihi Hari ini. Sekarang Tanggal '+$('#curr_date').val();
                    $('#tgl_laporan_mediator').val('');
                    error = 1
                    
                }
                if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() < new Date(tmp3[0]+"-"+tmp3[1]+"-"+tmp3[2]+"T00:00:00").getTime())){
                    message = 'Tidak Dapat Memilih Tanggal Sebelum Tanggal Hasil Mediasi';
                    $('#tgl_laporan_mediator').val('');
                    error = 1
                    
                }

                if(error==1){
                    message_error_show(message);
                    $(this).css("background-color", "red");
                }else{
                    $(this).css("background-color", "#dedbdb");
                }
                error = 0;
            }
        });
$('#tgl_kesepakatan').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 error = 0;
                
                var tmp = $(this).val().split("/");
                var tmp2 = $('#curr_date').val().split("/");
                if((new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]+"T00:00:00").getTime() > new Date(tmp2[2]+"-"+tmp2[1]+"-"+tmp2[0]+"T00:00:00").getTime())){
                    message = 'Tidak Dapat Memilih Melebihi Hari ini. Sekarang Tanggal '+$('#curr_date').val();
                    error = 1
                }

                if(error==1){
                    message_error_show(message);
                    $(this).css("background-color", "red");
                }else{
                    $(this).css("background-color", "#dedbdb");
                }
                error = 0;
            }
        });

$('.datepicker').ValidateDateInput();
$(document).ready(function() {
    if($('#hasil_mediasi').val()=='Y1'||$('#hasil_mediasi').val()=='Y2'||$('#hasil_mediasi').val()=='S'){
        $('.centering').css({'width':'1000px'});
        $('.first_col').css({'width':'20%'});
        $('.second_col').css({'width':'80%'});
    }else{
        $('.centering').css({'width':'600px'});
        $('.first_col').css({'width':'30%'});
        $('.second_col').css({'width':'70%'});
    }
});
</script>
