簡體   English   中英

禁用特定日期

[英]Disable Specific Date

所以我想以月為單位禁用特定日期,這是我在控制器中名為“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("first day of $month $currentYear"));
            if ($r == 1) {
                $hasilmax = 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"])

欲知更多詳情,請查看鏈接

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM