". function cmp3($a, $b) { if ($a < $b) return "< "; if ($a == $b) return "= "; return "> "; } # print the page header print_header($day, $month, $year, $area, $type_session); if (empty($area)) $area = get_default_area(); if (empty($room)) $room = sql_query1("select min(id) from grr_room where area_id=$area"); # Note $room will be -1 if there are no rooms; this is checked for below. # Month view start time. This ignores morningstarts/eveningends because it # doesn't make sense to not show all entries for the day, and it messes # things up when entries cross midnight. $month_start = mktime(0, 0, 0, $month, 1, $year); # What column the month starts in: 0 means $weekstarts weekday. $weekday_start = (date("w", $month_start) - $weekstarts + 7) % 7; $days_in_month = date("t", $month_start); $month_end = mktime(23, 59, 59, $month, $days_in_month, $year); $this_area_name = ""; $this_room_name = ""; // Si format imprimable ($_GET['pview'] = 1), on n'affiche pas cette partie if ($_GET['pview'] != 1) { #Table avec areas, rooms, minicals. echo "
"; if (isset($_SESSION['default_list_type']) or ($authentification_obli==1)) { $area_list_format = $_SESSION['default_list_type']; } else { $area_list_format = getSettingValue("area_list_format"); } # show either a select box or the normal html list if ($area_list_format != "list") { echo make_area_select_html('month_all.php', $area, $year, $month, $day, $session_login); # from functions.inc.php } else { echo make_area_list_html('month_all.php', $area, $year, $month, $day, $session_login); # from functions.inc.php } echo " | \n"; #Draw the three month calendars minicals($year, $month, $day, $area, $room, 'month_all'); echo "
<< $vocab[monthbefore] | $vocab[monthafter] >> |
DEBUG: month=$month year=$year start=$weekday_start range=$month_start:$month_end\n";
# Used below: localized "all day" text but with non-breaking spaces:
$all_day = ereg_replace(" ", " ", $vocab["all_day"]);
#Get all meetings for this month in the room that we care about
# row[0] = Start time
# row[1] = End time
# row[2] = Entry ID
# row[3] = Entry name (brief description)
# row[4] = creator of the booking
$sql = "SELECT start_time, end_time, grr_entry.id, name, create_by, room_name
FROM grr_entry inner join grr_room on grr_entry.room_id=grr_room.id
WHERE (start_time <= $month_end AND end_time > $month_start and area_id='".$area."')
ORDER by start_time, end_time, grr_room.room_name";
# Build an array of information about each day in the month.
# The information is stored as:
# d[monthday]["id"][] = ID of each entry, for linking.
# d[monthday]["data"][] = "start-stop" times of each entry.
$res = sql_query($sql);
if (! $res) echo sql_error();
else for ($i = 0; ($row = sql_row($res, $i)); $i++)
{
$sql_creator = "SELECT prenom, nom FROM grr_utilisateurs WHERE login = '$row[4]'";
$res_creator = sql_query($sql_creator);
if ($res_creator) $row_user = sql_row($res_creator, 0);
if ($debug_flag)
echo "
DEBUG: result $i, id $row[2], starts $row[0], ends $row[1]\n";
# Fill in data for each day during the month that this meeting covers.
# Note: int casts on database rows for min and max is needed for PHP3.
$t = max((int)$row[0], $month_start);
$end_t = min((int)$row[1], $month_end);
$day_num = date("j", $t);
$midnight = mktime(0, 0, 0, $month, $day_num, $year);
while ($t < $end_t)
{
if ($debug_flag) echo "
DEBUG: Entry $row[2] day $day_num\n";
$d[$day_num]["id"][] = $row[2];
$d[$day_num]["who"][] = $row[3]." - ".$vocab["created_by"].$row_user[0]." ".$row_user[1];
$d[$day_num]["who1"][] = $row[3];
$d[$day_num]["room"][]=$row[5] ;
$midnight_tonight = $midnight + 86400;
# Describe the start and end time, accounting for "all day"
# and for entries starting before/ending after today.
# There are 9 cases, for start time < = or > midnight this morning,
# and end time < = or > midnight tonight.
# Use ~ (not -) to separate the start and stop times, because MSIE
# will incorrectly line break after a -.
switch (cmp3($row[0], $midnight) . cmp3($row[1], $midnight_tonight))
{
case "> < ": # Starts after midnight, ends before midnight
case "= < ": # Starts at midnight, ends before midnight
$d[$day_num]["data"][] = date(hour_min_format(), $row[0]) . "~" . date(hour_min_format(), $row[1]);
break;
case "> = ": # Starts after midnight, ends at midnight
$d[$day_num]["data"][] = date(hour_min_format(), $row[0]) . "~24:00";
break;
case "> > ": # Starts after midnight, continues tomorrow
$d[$day_num]["data"][] = date(hour_min_format(), $row[0]) . "~====>";
break;
case "= = ": # Starts at midnight, ends at midnight
$d[$day_num]["data"][] = $all_day;
break;
case "= > ": # Starts at midnight, continues tomorrow
$d[$day_num]["data"][] = $all_day . "====>";
break;
case "< < ": # Starts before today, ends before midnight
$d[$day_num]["data"][] = "<====~" . date(hour_min_format(), $row[1]);
break;
case "< = ": # Starts before today, ends at midnight
$d[$day_num]["data"][] = "<====" . $all_day;
break;
case "< > ": # Starts before today, continues tomorrow
$d[$day_num]["data"][] = "<====" . $all_day . "====>";
break;
}
# Only if end time > midnight does the loop continue for the next day.
if ($row[1] <= $midnight_tonight) break;
$day_num++;
$t = $midnight = $midnight_tonight;
}
}
if ($debug_flag)
{
echo "
DEBUG: Array of month day data:
\n"; for ($i = 1; $i <= $days_in_month; $i++) { if (isset($d[$i]["id"])) { $n = count($d[$i]["id"]); echo "Day $i has $n entries:\n"; for ($j = 0; $j < $n; $j++) echo " ID: " . $d[$i]["id"][$j] . " Data: " . $d[$i]["data"][$j] . "\n"; } } echo "\n"; } echo "
" . day_name(($weekcol + $weekstarts)%7) . " | "; } echo "|
---|---|
\n"; } # Draw the days of the month: for ($cday = 1; $cday <= $days_in_month; $cday++) { if ($weekcol == 0) echo " | |
\n";
# Anything to display for this day?
if (isset($d[$cday]["id"][0]))
{
echo "";
$n = count($d[$cday]["id"]);
# Show the start/stop times, 2 per line, linked to view_entry.
# If there are 12 or fewer, show them, else show 11 and "...".
for ($i = 0; $i < $n; $i++)
{
if ($i == 11 && $n > 12)
{
echo " ...\n";
break;
}
echo "";
echo "". $d[$cday]["data"][$i]
. " " . htmlspecialchars($d[$cday]["room"][$i]) . " " . "" . htmlspecialchars($d[$cday]["who1"][$i]) . " "; } echo ""; } echo " | \n";
if (++$weekcol == 7) $weekcol = 0;
}
# Skip from end of month to end of week:
if ($weekcol > 0) for (; $weekcol < 7; $weekcol++)
{
echo "\n"; } echo " |