我们目前正在为我们的网络控制面板添加一个事件调度程序,以允许公司用户发布他们的工作事件并跟踪报告等。
一些背景
包含事件的数据库的结构包括以下内容:
cid, ceventpostedby, ceventstart, ceventend, ceventday, ceventmonth, ceventyear,
ceventtitle, ceventdesc, cuserdomain, ceventlocation, clastupdated
典型的条目如下所示:
1, 1, 8:30, 13:30, 30, 1, 2017, Some Event, Event Desc, example.com, Some City, 142000000
这些事件被加载到只有同一域组中的用户(和根管理员)才能看到的日历中,以使系统中不同的 Web 组将它们分开。这是由
cuserdomain
字段定义的。典型的日历如下图所示:
当用户单击某一天时,他们将进入一个页面,该页面将显示当前的每日事件(如果已设置)或显示带有上午 7 点至晚上 7 点的空白时间表(时间是根据用户的工作办公时间选择的,并且事件不应比这些时间晚或早预订)。当页面为空且未预订任何活动时,页面如下所示:
现在一些 PHP..
因此,活动页面正在检查当天是否有活动并设置“是”或“否”。如果确实有事件,它应该将它们打印到正确的时间框中。如果没有,则仅显示所设置的上午 7 点至下午 7 点(或 12 小时)之间的所有时段。我们使用以下代码
for($i = 0; $i < 12; $i++) {
if($starting_time == 12) {
// default is AM, change to pm after noon
$time_type = "PM";
}
if($starting_time > 12) {
// reset the time to 1 instead of 13 for user ease
$starting_time = "1";
}
if(mysqli_num_rows($schedule_events_query) > 0) {
while($event_result = mysqli_fetch_array($schedule_events_query)) {
$time_start = $event_result['ceventstart'];
$time_end = $event_result['ceventend'];
$time_start = explode(":", $time_start);
$time_end = explode(":", $time_end);
// CODE SHOULD GO HERE TO DISPLAY THIS EVENT
}
} else {
// Using custom template engine we call the empty blocks 12 times
// since there was no event scheduled for today.
echo $x10->template->extract("calendar_empty_schedule", $starting_time, $time_type);
}
$starting_time++;
}
最后是问题/问题
如果当天预订了一个活动甚至多个活动,我如何打印它们以便它们填写开始和结束时间的块?到目前为止,简单地打印一个块只会为每个事件打印一个块,并且不会显示其余日期的时间。我也不知道如何将每个事件的特定块显示为不同的,然后显示其余的。我确信制作起来并不困难,但我似乎无法全神贯注,因为我自己在这个面板上花了很多时间,我已经感到麻木了(笑)。欢迎任何建议并表示感谢。我努力使这篇文章包含尽可能多的数据。这是一天块的 html 片段也可供参考
<div class="schedule_item_row">
<div class="time">
<div class="time_smaller">
<div class="time_smaller_item">
<div style="padding-top: 13px;">00</div>
</div>
<div class="time_smaller_item">
<div style="padding-top: 13px;">30</div>
</div>
</div>
<div style="padding-top: 32px;">8 AM</div>
</div>
<div class="schedule_info">
<div class="schedule_block">
<div style="padding: 13px;">
</div>
</div>
<div class="schedule_block">
<div style="padding: 13px;">
</div>
</div>
</div>
<div class="clear"></div>
</div>
我在事件和日期方面做了很多工作,我可以告诉你这不是一个简单的任务。我强烈建议使用 Javascript 插件来管理你的日历,我使用 fullCalendar。
FullCalendar 是一个简单、完整的 Javascript 插件,可以做任何你想做的事情。我假设您也熟悉 Jquery。如果没有,这里有一些入门教程。它确实会提高您的应用程序的质量。
Gatting 从 fullCalendar 开始
W3C 上的 Jquery 教程