我想要的只是根据我的营业时间计算时间段列表,并阻止或禁用那些预约的时间段。
我已经用我的问题完成了这些事情,坚持最后一项任务,如下所述。
My Service Duration = 60min.
My Today Busines Hours:
start time - 10:00 AM
end time - 3:00 PM
我根据我今天的营业时间生成了 15 分钟的时隙列表:
$start = strtotime('10:00 AM');
$end = strtotime('3:00 PM');
for( $i = $start; $i <= $end; $i += (60*15))
{
$slotlist[] = date('g:iA', $i);
}
//output
10:00AM
10:15AM
10:30AM
10:45AM
11:00AM
11:15AM
11:30AM
11:45AM
12:00PM
12:15PM
12:30PM
12:45PM
1:00PM
1:15PM
1:30PM
1:45PM
2:00PM
2:15PM
2:30PM
2:45PM
3:00PM
现在我已经预约了 3 个约会
约会 | 开始时间到结束时间
预约 1 : 10:00AM 到 11:00AM (根据我的服务时间 60 分钟)
预约 2 : 11:15AM 到 12:15PM
预约 3 : 1:00PM 到 2:00PM
//array of all appointment start_time
$appointment_start_time = array('10:00AM','11:15AM','1:00PM');
现在禁用那些已经在约会中预订的时间段
foreach($slotlist as $single)
{
if(in_array($single, $appointment_start_time))
{
echo "<input name=start_time type='radio' disabled value='$single' />".$single; echo "<br>";
$time = $single;
$event_length = 60-15; // 60 is time duration
$timestamp = strtotime("$time");
$endtime = strtotime("+$event_length minutes", $timestamp);
$next_time = date('g:i A', $endtime);
//calculate between slots (start-end time)
$start = strtotime($single);
$end = strtotime($next_time);
for( $i = $start; $i <= $end; $i += (60*15))
{
$list2[] = date('g:iA', $i);
}
}
else
{
if(in_array($single, $list2))
{
echo "<input name=start_time type='radio' disabled value='$single' />".$single; echo "<br>";
}
else
{
echo "<input name=start_time type='radio' value='$single' />".$single; echo "<br>";
}
}
}
//output
10:00AM -disabled
10:15AM -disabled
10:30AM -disabled
10:45AM -disabled
11:00AM
11:15AM -disabled
11:30AM -disabled
11:45AM -disabled
12:00PM -disabled
12:15PM
12:30PM
12:45PM
1:00PM -disabled
1:15PM -disabled
1:30PM -disabled
1:45PM -disabled
2:00PM
2:15PM
2:30PM
2:45PM
3:00PM
现在要做的最后一个任务,如何删除那些不符合服务持续时间的时间段,例如:
11:00AM (single slot b/w 2 appointment, cover only 15min)
12:15PM -
12:30PM -(3 slot b/w 2 appointment, cover only 45min)
12:45PM -