<?php
if($this->session->userdata('is_logged_in')===FALSE){
            redirect('login');
}
?>
<div class="templatepopcentering" >
    <div style="border: 1px solid #ffffff;">
        <div id='pop' style="padding:5px;">
        <form id="frm_pen_penolakan_perpanajangan_thnn" name="frm_pen_penolakan_perpanajangan_thnn" class="templatepopform" target="_self" method="POST" action="<?php echo base_url().'c_template_penetapan/cetak_penetapan_penolakan_perpanjangan_tahanan';?>">
            <table style="padding:5px;width:100%">
                <tr><td colspan="2" class="templatepoptitle">
                <?php 
                     foreach ($template->result() as $template){
                        echo strtoupper($template->namatemplate."<br/>Perkara ".$template->jnsperkara);
                    }
               ?>
                </td></tr>
                    <tr>
                        <td class="templatepopleftcol">Tanggal Penetapan<font color="red">*</font>
						</td>
                                <td style="padding-left:3px;">
                                <input id="tgl_penetapan" name="tgl_penetapan" value="<?php echo date('d/m/Y');?>" class="datepicker" maxlength="10" placeholder="tgl/bln/tahun">
                        </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="ditetapkanoleh" id="ditetapkanoleh" class="custom-dropdown__select custom-dropdown__select--white">
                                    <option value='1'><?php echo $this->templatehelper->standradnaming("Ketua :: ".$penandatangan->row(0)->KetuaPNNama);?></option>
                                    <option value='2'><?php echo $this->templatehelper->standradnaming("Wakil Ketua :: ".$penandatangan->row(0)->WakilKetuaPNNama);?></option>
                                    <?php 
                                    if($plhKetua!=NULL){
                                        echo '<option value="5">'.$this->templatehelper->standradnaming("Plh Ketua :: ".$penandatangan->row(0)->PlhKetua).'</option>';
                                    } 
                                    if($pltKetua!=NULL){
                                        echo '<option value="7">'.$this->templatehelper->standradnaming("Plt Ketua :: ".$penandatangan->row(0)->PltKetua).'</option>';
                                    } 
                                    ?>
                                </select>
                            </span>
                        </td> 
                    </tr>
                        <td colspan="2" style="background:white;padding-top:15px;padding-bottom:15px;" align="center">
							<input type="hidden" id="curr_date" name="curr_date" value="<?php echo $curr_date;?>">
							<input type="hidden" id="tglPendaftaran" name="tglPendaftaran" value="<?php echo $tglPendaftaran;?>">
                            <input type="hidden" id="enc" name="enc" value="<?php echo $enc;?>">
                            <input type="hidden" id="enctahan" name="enctahan" value="<?php echo $enctahan;?>">
                            <input type="hidden" id="encpihak" name="encpihak" value="<?php echo $encpihak;?>">
                            <input type="hidden" id="jnstmp" name="jnstmp" value="<?php echo $jnstmp;?>">
                            <input type="button" id="kembali" value="Kembali" class="btn">
							<input type="submit" id="simpan_btn" value="Cetak" class="btn btn-danger">
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
$('#kembali').closingFormWin();
$('.datepicker').ValidateDateInput();
        $('#tgl_penetapan').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 ='';
                var tmp = $(this).val().split("/");
                var tmp2 = $('#curr_date').val().split("/");
				var tmp3 = $('#tglPendaftaran').val().split("-");

                if(dayOfWeek=='Sunday' || dayOfWeek=='Saturday'){
                    message ='Tidak Dapat Memilih diluar Hari Kerja.';
                    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 Atau Tepat Pada Tanggal Pendaftaran';
                    error = 1
                }

                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");
                }
            }
        });
</script>