<div class="centering" style="width:500px;margin-top: 5%;">
    <div id='form_verzet' style="border: 1px solid #ffffff;">
		<div class="detil" style="padding: 2px;background-color: white;">
            <div>
                <form id="frm_akta_cerai" method="post" action="<?php echo base_url().'tab_ikrar_akta_cerai_c/validateInputAktaCerai';?>">
				<table id="tableDetilPerkara" style="font-size:14px;">
                		<col width="45%">
                        <col width="55%">
                        <tbody>
                            <tr>
                                <td colspan="2" style="background:white;border:0px;font-size: 20px;color: #648C03;" align="center">Data Akta Cerai</td>
                            </tr>
                            <tr>
                                <td id="first-child">Nomor Akta Cerai</td>
                                <td>
                                    <strong><label id='nomer_ac' ><?php echo $nomor_ac;?></label></strong>
                                    <input class='standard-input' type="text" maxlength='25' id="nomor_ac" name="nomor_ac" value="<?php echo $nomor_ac;?>">
                                </td>                
                           </tr>
                            <tr>
                                <td id="first-child">Tanggal Akta Cerai</td>
                                <td>
                                    <span>
                                        <input id="tgl_akta_cerai" name="tgl_akta_cerai" value="<?php echo $this->tanggalhelper->convertToInputDate($tanggal_akta_cerai);?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td id="first-child">Nomor Seri Akta Cerai</td>
                                <td>
                                    <span>
                                        <input class='standard-input' type="text" maxlength='25' id="no_seri_akta_cerai" name="no_seri_akta_cerai" value="<?php echo $no_seri_akta_cerai;?>">
                                    </span>
                                </td>                
                            </tr>
                            <tr>
                                <td id="first-child">Jenis Cerai</td>
                                <td>                                    
                                    <input class='standard-input' type="text"  value="<?php echo $jenis_perkara;?>" disabled>                                                       
                                </td>
                            </tr>
                            <tr>
                                <td id="first-child">Qobla/Ba'da</td>
                                <td>
                                    <span class="custom-dropdown custom-dropdown--emerald" style='width:245px;'>
                                        <select name="qobla" id="qobla" style='width:245px;' class="custom-dropdown__select custom-dropdown__select--white">
                                            <option value=-1 <?php echo $qobla==-1?'selected':'';?> >Pilih Salah Satu</option>
                                            <option value=0 <?php echo $qobla==0?'selected':'';?> >Qobla Duhul</option>
                                            <option value=1 <?php echo $qobla==1?'selected':'';?> >Ba'da Duhul</option>
                                        </select>
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td id="first-child">Faktor Perceraian</td>
                                <td>
                                    <input class='standard-input' type="text" id="faktor_penyebab" name="faktor_penyebab" value="<?php echo $this->templatehelper->standradnaming($faktor_penyebab);?>" disabled>                                                       
                                </td>                
                            </tr>
                            
                            <tr>
                                <td id="first-child">Keadaan Istri</td>
                                <td>
                                    <input class='standard-input' type="text" id="keadaan_istri" name="keadaan_istri" value="<?php echo (!empty($keadaan_istri)?$keadaan_istri:''); ?>" disabled>                                                       
                                </td>
                                              
                            </tr>
                            <tr>
                                <td id="first-child">Perceraian Ke</td>
                                <td>
                                    <span>
                                        <input type="number" id="perceraian_ke" name="perceraian_ke" min="1" value="<?php echo $perceraian_ke;?>">
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td id="first-child">Tanggal Penyerahan Akta Cerai</td>
                                <td>
                                    <span>
                                        <input id="tgl_penyerahan_akta_cerai" name="tgl_penyerahan_akta_cerai" value="<?php echo $this->tanggalhelper->convertToInputDate($tgl_penyerahan_akta_cerai);?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="background:white;padding:2px;">
                                    <input type="hidden" id="enc" name="enc" value="<?php echo $enc;?>">
                                    <input type="hidden" id="enc_ac" name="enc_ac" value="<?php echo $enc_ac;?>">
                                    <!-- <input type="hidden" id="nomor_ac" name="nomor_ac" value="<?php echo $nomor_ac;?>"> -->
                                    <input type="hidden" id="curr_date" value="<?php echo $current_date;?>">
                                    <input type="hidden" id="jenis_perkara" name="jenis_perkara" value="<?php echo $jenis_perkara?>">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="background:white;" align="center">
                                    <input type="button" id='close_form_add_akta_cerai' value="Kembali" class="btn">
                                    <?php
                                    if(!empty($tanggal_akta_cerai)){
                                        echo '<input type="submit" id="hapus" value="Hapus" class="del_btn" onclick="return false;">';
                                    }
                                    ?>
                                    <input id="simpan" class="btn" type="submit" value="Simpan">
                                </td>
                            </tr>
                        </tbody>
                	</table>               	
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    function baca() {
        var no = '<?php echo $nomor_ac;?>';    
        if(no=='Auto Generate (pilih tanggal akta cerai)'){
            $('#nomer_ac').show();
            $('#nomor_ac').hide(); 
        } else{
            $('#nomer_ac').hide();
            $('#nomor_ac').show(); 
        }
    }
    window.onload = baca();
    $('.datepicker').ValidateDateInput();
    $('#frm_akta_cerai').SubmitHandling({
        refresh:'1',
        setRefresh:1,
        divRef:'#konten',
        clicked:1,
        btnClicked:'#close_form_add_akta_cerai',
        whenStatus:1,
        isCKEdit:0,
        
    });
    $('#hapus').ButtonClickHandling({
        refresh:'1',
        setRefresh:1,
        divRef:'#konten',
        clicked:1,
        btnClicked:'#close_form_add_akta_cerai',
        whenStatus:1,
        actions:'<?php echo base_url("tab_ikrar_akta_cerai_c/validateDeleteAktaCerai");?>',
        formName:'#frm_akta_cerai',
        actionName:'Hapus Data Akta Cerai'
    });
    $('#close_form_add_akta_cerai').closingFormWin();
    
    $('#tgl_akta_cerai').datepicker({
        beforeShowDay: $.datepicker.noWeekends,
        inline: true,
        showOtherMonths: true,
        dateFormat: 'dd/mm/yy',
        dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
        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");
                $.ajax({
                    type: 'POST',
                    url: "<?php echo base_url().'tab_ikrar_akta_cerai_c/get_no_urut_akta_cerai';?>",
                    data: {tanggal:$(this).val()},
                    success: function (data) {
                        temp=data.split('/');
                        $('#enc_ac').val(temp[0]);
                        $('#nomer_ac').text(data); 
                        $('#nomor_ac').val(data);
                        $('#nomer_ac').hide();
                        $('#nomor_ac').show(); 
                    }
                })
            }
            error = 0;
        }
    });
    $('#tgl_penyerahan_akta_cerai').datepicker({
        beforeShowDay: $.datepicker.noWeekends,
        inline: true,
        showOtherMonths: true,
        dateFormat: 'dd/mm/yy',
        dayNamesMin: ['Ming', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
        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;
        }
    });
    
</script>