简体   繁体   中英

Disable Specific Date

So I want to Disable Specific date in Months, This is my Function in Controller called "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);
    }

I want to make ,when the month is still on the 1st to 15th, the 16th to the end of the month is disabled, but if it's already on the 16th, the 1st to 15th is disabled. how to make this happend?

If you want to limit days in date field of the Front end (extjs), you can use setDisabledDates method of the Date Field.

Ex: To disable the 5th and 6th of October, use: datefield.setDisabledDates(["10/05/2003", "10/06/2003"])

For more detail, view the link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM