". 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"); $time = mktime(0, 0, 0, $month, $day, $year); // date("w", $time) : jour de la semaine en partant de dimancche // date("w", $time) - $weekstarts : jour de la semaine en partant du jour défini dans GRR // Si $day ne correspond pas au premier jour de la semaine tel que défini dans GRR, on recule la date jusqu'au précédent début de semaine // Evidemment, problème possible avec les changement été-hiver et hiver-été if (($weekday = (date("w", $time) - $weekstarts + 7) % 7) > 0) { $time -= $weekday * 86400; } // $day_week, $month_week, $year_week sont jours, semaines et années correspondant au premier jour de la semaine $day_week = date("d", $time); $month_week = date("m", $time); $year_week = date("Y", $time); //$date_start : date de début des réservation à extraire $date_start = mktime($morningstarts,0,0,$month_week,$day_week,$year_week); // Nombre de jours dans le mois $days_in_month = date("t", $date_start); if ($debug_flag) echo "$month_week $day_week "; // $date_end : date de fin des réservation à extraire $date_end = mktime($eveningends, $eveningends_minutes, 0, $month_week, $day_week+6, $year_week); // Si format imprimable ($_GET['pview'] = 1), on n'affiche pas cette partie if ($_GET['pview'] != 1) { # Table with areas, rooms, minicals. echo "\n\n"; #Draw the three month calendars minicals($year, $month, $day, $area, $room, 'week_all'); echo "
\n"; $this_area_name = ""; $this_room_name = ""; 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('week_all.php', $area, $year, $month, $day, $session_login); # from functions.inc.php # echo make_room_select_html('month.php', $area, $room, $year, $month, $day); } else { echo "\n
\n"; echo make_area_list_html('week_all.php', $area, $year, $month, $day, $session_login); # from functions.inc.php echo "
\n"; } echo "
\n"; } $this_area_name = sql_query1("select area_name from grr_area where id=$area"); $this_room_name = sql_query1("select room_name from grr_room where id=$room"); $this_room_name_des = sql_query1("select description from grr_room where id=$room"); # Don't continue if this area has no rooms: if ($room <= 0) { echo "

".$vocab['no_rooms_for_area']."

\n"; include "trailer.inc.php"; exit; } # Show Month, Year, Area, Room header: if (($this_room_name_des) and ($this_room_name_des!="-1")) { $this_room_name_des = " (".$this_room_name_des.")"; } else { $this_room_name_des = ""; } switch ($dateformat) { case "en": $dformat = "%A, %b %d"; break; case "fr": $dformat = "%A %d %b"; break; } echo "

".$vocab["week"]." : " . strftime($dformat, $date_start)." - ". strftime($dformat, $date_end) . "
$this_area_name - ".$vocab["all_rooms"]."

\n"; #y? are year, month and day of the previous week. #t? are year, month and day of the next week. $i= mktime(0,0,0,$month_week,$day_week-7,$year_week); $yy = date("Y",$i); $ym = date("m",$i); $yd = date("d",$i); $i= mktime(0,0,0,$month_week,$day_week+7,$year_week); $ty = date("Y",$i); $tm = date("m",$i); $td = date("d",$i); // Si format imprimable ($_GET['pview'] = 1), on n'affiche pas cette partie if ($_GET['pview'] != 1) { #Show Go to week before and after links echo "\n
<< ".$vocab["weekbefore"]."   ". $vocab['weekafter']." >>
"; } # 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,type FROM grr_entry inner join grr_room on grr_entry.room_id=grr_room.id WHERE start_time <= $date_end AND end_time > $date_start ORDER by start_time, end_time, grr_entry.id"; # 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); # 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], $date_start); $end_t = min((int)$row[1], $date_end); $day_num = date("j", $t); $month_num = date("m", $t); $year_num = date("Y", $t); //$midnight = mktime(0, 0, 0, $month_num, $day_num, $year); // bug changement heure été/hiver $midnight = mktime(0, 0, 0, $month_num, $day_num, $year_num); $midnight2 = gmmktime(0, 0, 0, $month_num, $day_num, $year_num); if ($debug_flag) echo "
DEBUG: result $i, id $row[2], starts $row[0], ends $row[1], temps en heures : ".($row[1]- $row[0])/(60*60).", midnight : $midnight \n"; 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] ; $d[$day_num]["color"][]=$row[6]; $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 "\n\n"; # Weekday name header row: echo "\n"; for ($weekcol = 0; $weekcol < 7; $weekcol++) { echo "\n"; } echo "\n"; # We need to know what all the rooms area called, so we can show them all # pull the data from the db and store it. Convienently we can print the room # headings and capacities at the same time $sql = "select room_name, capacity, id, description from grr_room where area_id=$area order by 1"; $res = sql_query($sql); # It might be that there are no rooms defined for this area. # If there are none then show an error and dont bother doing anything # else if (! $res) fatal_error(0, sql_error()); if (sql_count($res) == 0) { echo "

".$vocab[no_rooms_for_area]."

"; sql_free($res); } else { $li=0; for ($ir = 0; ($row = sql_row($res, $ir)); $ir++) { // Affichage de la première colonne (nom des ressources) echo "\n"; $li++; $t = $time; $t2 = $time; for ($k = 0; $k<=6; $k++) { $cday = date("j", $t2); $t2 += 86400; if ($li<=1) { // On inscrit le numéro du mois dans la deuxième ligne $num_day = strftime("%d", $t); $num_month = strftime("%m", $t); $num_year = strftime("%Y", $t); $t += 86400; echo "\n"; if (++$weekcol == 5) $weekcol = 0; } echo ""; } } echo "
".$vocab["rooms"]."" . day_name(($weekcol + $weekstarts)%7) . "
" . htmlspecialchars($row[0]) ." \n"; } else { echo ""; } # 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; } */ if ($d[$cday]["room"][$i]==$row[0]) { #if ($i > 0 && $i % 2 == 0) echo "
"; else echo " "; echo "\n"; tdcell($d[$cday]["color"][$i]); echo "". $d[$cday]["data"][$i] . "
" . "" . htmlspecialchars($d[$cday]["who1"][$i]) . "" . "
"; } } echo "
"; } echo " 
\n"; include "trailer.inc.php"; ?>