如果今天被阻止,Javascript NoGray Calendar 在选择的阻止日期之后查找下一个可用日期

2022-01-11 00:00:00 calendar jquery php javascript

我正在使用 NoGray Calendar 并有以下代码:

I am using the NoGray Calendar and have the following code:

my_cal1 = new ng.Calendar({
    input: {date:'date1', month:'month1', year:'year1'},
    selected_date:new Date(),display_date:new Date(),
    dates_off:[{date:22, month:6},
    events: {
        onDateClick: function(dt) {
            this.select_date(dt);
        }
    }

但是当它与我所在的那一天是同一天时,它显示为空白.

But when it is the same day as the day I am on, it shows as blank.

我怎样才能让它显示并查找下一个可用日期从被阻止的日期之后开始?

How can I make it so it displays and looks for the next available date to start from after the blocked date please?

可以在 http://www.nogray.com/找到示例日历example.php?ID=260

我要设置的区域是 start_datedisplay_date 到下一个可用日期,所以如果我有接下来 3 天的休息日,它会显示开始的 3 天之后的下一个可用日期.

The areas that I am trying to set are the start_date and display_date to the next available date so if I had the next 3 days as days off, it would show the date as the next available date after those 3 days when it starts.

这可以通过 NoGray 软件中的功能来完成,还是我需要使用 PHP 脚本来搜索下一个可用日期并输出所需的日期?

Can this be done with the functions within the NoGray software or do I require to use a PHP script to search for the next available date and out put the required date?

推荐答案

可以使用方法is_selectable http://www.nogray.com/api/calendar/is_selectable.php 检查日期是否可选.is_selectable 返回一个数组 [true|false, 'reason'].下面是一个简单的例子

You can use the method is_selectable http://www.nogray.com/api/calendar/is_selectable.php to check if the dates are selectable or not. The is_selectable returns an array [true|false, 'reason']. Below is a quick example

my_cal1 = new ng.Calendar({
    input: {date:'date1', month:'month1', year:'year1'},
    selected_date:new Date(),
    display_date:new Date(),
    dates_off:[{date:22, month:6}], // you were messing a ] here
    events: {
        onDateClick: function(dt){
            this.select_date(dt);
        },
        // code to check if the start date is selectable
        onLoad: function(){
            var st_dt = this.get_start_date().clone();
            while(!this.is_selectable(st_dt)[0]){
                st_dt = st_dt.from_string('today + 1');
            }
            // checking if no dates are selected
            if (!ng.defined(this.get_selected_date())){
                this.select_date(st_dt);
            }
            this.set_start_date(st_dt);
        }
    }
});

相关文章