Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript datetimepicker中的约会释放/锁定控制_Javascript_Php_Jquery_Datetimepicker - Fatal编程技术网

Javascript datetimepicker中的约会释放/锁定控制

Javascript datetimepicker中的约会释放/锁定控制,javascript,php,jquery,datetimepicker,Javascript,Php,Jquery,Datetimepicker,我使用xdsoft datetimepicker作为我的框架来编程预约系统。我的基本想法是从sql数据库获取所有配置参数和约会,到目前为止,它工作得很好,但问题仍然是灵活性,例如,如果我只想为特定的一天允许特定的时间,它总是应用于所有的天,而不仅仅是特定的一天。如果我想禁用特定的时间,它总是被禁用的所有天以及。到目前为止,我配置的是用PHP计算所有内容,并直接在datetimepicker ini中回显所有选项。这是我的密码: <?php echo' <script>

我使用xdsoft datetimepicker作为我的框架来编程预约系统。我的基本想法是从sql数据库获取所有配置参数和约会,到目前为止,它工作得很好,但问题仍然是灵活性,例如,如果我只想为特定的一天允许特定的时间,它总是应用于所有的天,而不仅仅是特定的一天。如果我想禁用特定的时间,它总是被禁用的所有天以及。到目前为止,我配置的是用PHP计算所有内容,并直接在datetimepicker ini中回显所有选项。这是我的密码:

<?php
echo'
    <script> //conf calendar
                        var reserviert = $.parseJSON(\''.$reserved.'\'); //here in this var I get all appointments from sql as a json and parse it afterwards
                        window.onerror = function(errorMsg) {$("#console").html($("#console").html()+"<br>"+errorMsg)}
                        $.datetimepicker.setLocale("de");
                        var logik = function( currentDateTime ){  //logic for specific weekdays
                            switch(currentDateTime.getDay()){
                                case 1:
                                    this.setOptions({
                                      minTime: '.$confIn['min1'].',
                                      maxTime: '.$confIn['max1'].',
                                      allowTimes: ['.$confIn['allow1'].'] 
                                    });
                                break;
                                case 2:
                                    this.setOptions({
                                      minTime: '.$confIn['min2'].',
                                      maxTime: '.$confIn['max2'].',
                                      allowTimes: ['.$confIn['allow2'].']
                                    });
                                break;
                                case 3:
                                    this.setOptions({
                                      minTime: '.$confIn['min3'].',
                                      maxTime: '.$confIn['max3'].',
                                      allowTimes: ['.$confIn['allow3'].']
                                    });
                                break;
                                case 4:
                                    this.setOptions({
                                      minTime: '.$confIn['min4'].',
                                      maxTime: '.$confIn['max4'].',
                                      allowTimes: ['.$confIn['allow4'].']
                                    });
                                break;
                                case 5:
                                    this.setOptions({
                                      minTime: '.$confIn['min5'].',
                                      maxTime: '.$confIn['max5'].',
                                      allowTimes: ['.$confIn['allow5'].']
                                    });
                                break;
                                case 6:
                                    this.setOptions({
                                      minTime: '.$confIn['min6'].',
                                      maxTime: '.$confIn['max6'].',
                                      allowTimes: ['.$confIn['allow6'].']
                                    });
                                break;
                                case 7:
                                    this.setOptions({
                                      minTime: '.$confIn['min7'].',
                                      maxTime: '.$confIn['max7'].',
                                      allowTimes: ['.$confIn['allow7'].']
                                    });
                                break;
                                default:
                                    this.setOptions({
                                         minTime: false,
                                         maxTime: false,
                                         allowTimes: []
                                    });
                            }
                        };

                        $("#datetimepicker3").datetimepicker({
                            '.$blocked.' //blocking weekened
                            inline:true,
                            value: new Date(),
                            allowTimes:['.$weekdatetimeconf['onlyT'].$timeFlex.'], //allowing times, general + flex conf, i should do it in one variable, still need to change it though
                            allowDates: ['.$weekdatetimeconf['onlyD'].$dateFlex.'], // lockes everything except specific date
                            disabledDates: ['.$weekdatetimeconf['banD'].'], // lock specific date
                            disabledWeekDays:['.$weekdatetimeconf['banweekdays'].'], //lock specific weekdays
                            step: '.$allg[0]['terminspanne'].', // min
                            todayButton: true,
                            yearStart: "'.date("Y").'",
                            yearEnd: "'.date('Y', strtotime('+1 year')).'",
                            dayOfWeekStart: 1,
                            onChangeDateTime: logik,
                            onShow: logik,
                            onSelectTime(dp,$input){ //still under construction
                                if($.inArray($input.val(), reserviert)){
                                    alert("reserved!");
                                }
                            },
                            minDate: "0",
                            maxDate: "'.date("Y/m/d", maxDate($freigabe)).'",
                            minTime: "'.date("H:i", strtotime($allg[0]['minOeffnungszeit'])).'",
                            maxTime: "'.date("H:i", strtotime($allg[0]['maxOeffnungszeit'])).'",


    });</script>';</php>

不是最灵活的解决方案,但在JQuery中锁定特定日期的时间仍然是解决问题的好方法

<script>
var specificDates = []; 
var hoursToTakeAway = [];
var i=0; var old=0; var from; var collect=[]; var changed = false; var bag=[];
                    $.each( reserviert, function(key, value){
                        specificDates.push(moment(key).format("DD/MM/YYYY")); 
                        $.each( value, function( keyn, valuen ){
                            if(i !== old){
                                old=i;
                                changed = true;
                            }
                            if(i == old){
                                if(keyn.indexOf("from") >= 0){
                                    from = valuen;
                                } else{
                                    bag = addBetween(parseInt(from), parseInt(valuen));
                                    if(changed == false){
                                        collect = bag.concat(collect);  
                                    } else collect = bag;
                                }
                            }
                        });
                        hoursToTakeAway.push(collect);
                        i++;        
                    });
                    function addBetween(p1, p2){
                        var hoursToAdd=[];
                        for(var i=p1; i<=p2; i++){
                            hoursToAdd.push(i);
                        }
                        return hoursToAdd;
                    }
</script>

var specificDates=[];
var hoursToTakeAway=[];
var i=0;var-old=0;var来自;var collect=[];var=false;var bag=[];
$。每个(保留项、函数(键、值){
具体日期。推送(时间(键)。格式(“DD/MM/YYYY”);
$.each(值,函数(键,值){
如果(i!==旧){
old=i;
更改=正确;
}
如果(i==old){
如果(键号indexOf(“from”)>=0){
from=valuen;
}否则{
bag=addBetween(parseInt(from),parseInt(valuen));
如果(更改==false){
collect=袋子。concat(collect);
}否则收集=袋子;
}
}
});
数小时后停止。推(收集);
i++;
});
函数addBetween(p1、p2){
var hoursToAdd=[];
对于(var i=p1;i
<?php 
    echo '$("#datetimepicker3").datetimepicker({
                                        onGenerate:function(ct,$i){
                                            var ind = specificDates.indexOf(moment(ct).format("DD/MM/YYYY"));
                                            $(".xdsoft_time_variant .xdsoft_time").show();
                                            if(ind !== -1){
                                                $(".xdsoft_time_variant .xdsoft_time").each(function(index){
                                                    if(hoursToTakeAway[ind].indexOf($(this).text()) !== -1) {
                                                        $(this).hide();
                                                    }
                                                });
                                            }
                                            '.$blocked.'
                                        },
                                        inline:true,
                                        value: new Date(), //(alloweDateRe)(regexdates)
                                        allowTimes:['.$weekdatetimeconf['onlyT'].$timeFlex.'], 
                                        allowDates: ['.$weekdatetimeconf['onlyD'].$dateFlex.'], 
                                        disabledDates: ['.$weekdatetimeconf['banD'].'], 
                                        disabledWeekDays:['.$weekdatetimeconf['banweekdays'].'], 
                                        step: '.$allg[0]['terminspanne'].', // min
                                        todayButton: true,
                                        yearStart: "'.date("Y").'",
                                        yearEnd: "'.date('Y', strtotime('+1 year')).'",
                                        dayOfWeekStart: 1,
                                        onChangeDateTime: logik,
                                        onShow: logik,
                                        minDate: "0",
                                        maxDate: "'.date("Y/m/d", maxDate($freigabe)).'",
                                        minTime: "'.date("H:i", strtotime($allg[0]['minOeffnungszeit'])).'",
                                        maxTime: "'.date("H:i", strtotime($allg[0]['maxOeffnungszeit'])).'"
                                    });'; 
?>