停用特定日期

问题描述

所以我想禁用特定月份的日期,这是我在控制器中的函数“ jurnal.PHP

function jurnal_harian_form() {
        setlocale(LC_ALL,"US");
        echo "<h3 id='title'>Jurnal Harian :: Daftar SKP :: Form Jurnal Harian</h3>";
        $_GET['nip'] = ($_SESSION['NIP']);
        $data_profil_pegawai = $this->jurnal_mdl->get_data_statistik_Jabatan();
        $harilibur = $this->jurnal_mdl->GetHariLibur();
        $currentYear = date("Y");
        $currentDay = date("d");
        $month = strftime("%B");
        $min =  date('Y-m-d',strtotime("$month $currentYear + 14 days"));
        $Now =  date('Y-m-d');

        $r =0;
        for ($i=1; $i < 6 ; $i++) { 
            $gg = date('Y-m-d',strtotime("$i $month $currentYear"));
            $issun = date('w',strtotime("$gg"));
            if ($issun == '6' || $issun == '0') {
                $min =  date('Y-m-d',strtotime("$min +1 days"));
                $r++;
            } 
            
        }

        $hasilmin = '';
        $hasilmax = '';
        if($Now >= $min){
            $hasilmin = date('Y-m-d',strtotime("first day of $month $currentYear"));
            if ($r == 1) {
                $hasilmax = date('Y-m-d',strtotime("$month $currentYear +1 month +6 days"));
            } elseif($r == 2) {
                $hasilmax = date('Y-m-d',strtotime("$month $currentYear  +14 days"));
            }else{
                $hasilmax = date('Y-m-d',strtotime("$month $currentYear +1 month +5 days"));
            }  
        }else if($Now == $min){
            $hasilmin = date('Y-m-d',strtotime("$month $currentYear +5 days"));
            } elseif($r == 2) {
                $hasilmax = date('Y-m-d',strtotime("$month $currentYear +6 days"));
            }else{
                $hasilmax = date('Y-m-d',strtotime("$month $currentYear +4 days"));
            }
        }else{
            $hasilmin = date('Y-m-d',strtotime("first day of $month $currentYear "));
            if ($r == 1) {
                $hasilmax = date('Y-m-d',strtotime("$month $currentYear +5 days"));
            } 
            elseif($r == 2 && $currentDay <= 15) {
                $hasilmax = date('Y-m-d',strtotime("$month $currentYear +14 days"));
            }
            elseif($r == 2 && $currentDay >= 15) {
                $hasilmax = date('Y-m-d',strtotime("$Now +14 days"));
            }
            else{
                $hasilmax = date('Y-m-d',strtotime("$month $currentYear +4 days"));
            } 
        }
       
        $data = array(
            "html_store" => $this->get_store_form_tambah_jurnal(),"pegawai"    => $data_profil_pegawai,"harilibur"  => $harilibur,"minvalue"   => $hasilmin,"maxvalue"   => $hasilmax
        );
        $this->load->view('jurnal/grid_jurnal_harian2',$data);
    }

我想制作,当月份仍在1号到15号时,则禁用该月的16号到月末,但是如果已经在16号,则禁用1号到15号。如何做到这一点?

解决方法

如果要在前端(extjs)的日期字段中限制天数,可以使用日期字段的setDisabledDates方法。

例如:要禁用10月5日和6日,请使用:datefield.setDisabledDates(["10/05/2003","10/06/2003"])

有关更多详细信息,请查看link

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...