Я взял 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>
Пока что, ini, я все еще спрашиваю себя, есть ли какое-то лучшее решение для управления свободным / заблокированным временем в DateTimePicker, потому что у меня слишком много ошибок, которые нужно исправить. У кого-нибудь есть идея получше?