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); # print the page header print_header($day, $month, $year, $area, $type_session); ?> "; if (isset($_GET['display_message'])) { if ($_GET['display_message'] == 'yes') { echo " alert(\"".$vocab["message_records"]."\")"; $display_message = 'no'; } } echo ""; // Si c'est un admin qui est connecté, on affiche le nombre de personnes actuellement connectées. if(authGetUserLevel(getUserName(),-1) >= 5) { $sql = "select LOGIN from grr_log where END > now()"; $res = sql_query($sql); $nb_connect = sql_count($res); if ($nb_connect == 1) { echo "".$nb_connect.$vocab["one_connected"].""; } else { echo "".$nb_connect.$vocab["several_connected"].""; } $version_old = getSettingValue("version"); if (($version_old =='') or ($version_grr > $version_old)) { echo ""; } } // fin de la condition "Si format imprimable" } # Define the start of day and end of day (default is 7-7) $am7=mktime($morningstarts,00,0,$month_week,$day_week,$year_week); $pm7=mktime($eveningends,$eveningends_minutes,0,$month,$day_week,$year_week); # Start and end of week: $week_midnight = mktime(0, 0, 0, $month_week, $day_week, $year_week); $week_start = $am7; $week_end = mktime($eveningends, $eveningends_minutes, 0, $month_week, $day_week+6, $year_week); $this_area_name = ""; $this_room_name = ""; // Si format imprimable ($_GET['pview'] = 1), on n'affiche pas cette partie if ($_GET['pview'] != 1) { # Table with areas, rooms, minicals. echo "\n"; #Draw the three month calendars minicals($year, $month, $day, $area, $room, 'week'); 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('week.php', $area, $year, $month, $day, $session_login); # from functions.inc.php echo make_room_select_html('week.php', $area, $room, $year, $month, $day); } else { echo "
"; echo make_area_list_html('week.php', $area, $year, $month, $day, $session_login); # from functions.inc.php # Show all rooms in the current area echo ""; make_room_list_html('week.php', $area, $room, $year, $month, $day); echo "
"; } 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"); $this_statut_room = sql_query1("select statut_room from grr_room where id=$room"); $this_show_fic_room = sql_query1("select show_fic_room from grr_room where id=$room"); # Don't continue if this area has no rooms: if ($room <= 0) { echo "

$vocab[no_rooms_for_area]

"; include "trailer.inc.php"; exit; } # Show area and room: if (($this_room_name_des) and ($this_room_name_des!="-1")) { $this_room_name_des = " (".$this_room_name_des.")"; } else { $this_room_name_des = ""; } echo "

".ucfirst($this_area_name)." - $this_room_name $this_room_name_des\n"; if ($this_show_fic_room == 'y') echo " \"détails\""; if (authGetUserLevel(getUserName(),$room) > 2) echo "\"configuration\""; if ($this_statut_room == "0") echo "

".$vocab["ressource_temporairement_indisponible"]."

"; echo ""; #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 "
<< $vocab[weekbefore]   $vocab[weekafter] >>
"; } #Get all appointments for this week in the room that we care about # row[0] = Start time # row[1] = End time # row[2] = Entry type # row[3] = Entry name (brief description) # row[4] = Entry ID # row[5] = creator of the booking # row[6] = status of the booking # The range predicate (starts <= week_end && ends > week_start) is # equivalent but more efficient than the original 3-BETWEEN clauses. $sql = "SELECT start_time, end_time, type, name, id, create_by, statut_entry FROM grr_entry WHERE room_id=$room AND start_time <= $week_end AND end_time > $week_start"; # Each row returned from the query is a meeting. Build an array of the # form: d[weekday][slot][x], where x = id, color, data. # [slot] is based at 0 for midnight, but only slots within the hours of # interest (morningstarts : eveningends) are filled in. # [id] and [data] are only filled in when the meeting should be labeled, # which is once for each meeting on each weekday. # Note: weekday here is relative to the $weekstarts configuration variable. # If 0, then weekday=0 means Sunday. If 1, weekday=0 means Monday. $first_slot = $morningstarts * 3600 / $resolution; $last_slot = ($eveningends * 3600 + $eveningends_minutes * 60) / $resolution; if ($debug_flag) echo "
DEBUG: query=$sql
slots=$first_slot:$last_slot\n"; $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[5]'"; $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[4], starts $row[0], ends $row[1]\n"; # Fill in slots for the meeting. Start at the meeting start time or # week start (which ever is later), and end one slot before the meeting # end time or week end (which ever is earlier). # Note: int casts on database rows for min and max is needed for PHP3. $t = max(round_t_down($row[0], $resolution, $am7), $week_start); $end_t = min((int)round_t_up((int)$row[1], (int)$resolution, $am7), (int)$week_end+1); $weekday = (date("w", $t) + 7 - $weekstarts) % 7; $prev_weekday = -1; # Invalid value to force initial label. $slot = ($t - $week_midnight) % 86400 / $resolution; do { if ($debug_flag) echo "
DEBUG: t=$t, weekday=$weekday, slot=$slot\n"; if ($slot < $first_slot) { # This is before the start of the displayed day; skip to first slot. $slot = $first_slot; $t = $weekday * 86400 + $am7; continue; } if ($slot <= $last_slot) { # This is within the working day; color it. $d[$weekday][$slot]["color"] = $row[2]; # Only label it if it is the first time on this day: if ($prev_weekday != $weekday) { $prev_weekday = $weekday; $d[$weekday][$slot]["data"] = $row[3]; $d[$weekday][$slot]["id"] = $row[4]; $d[$weekday][$slot]["who"] = $vocab["created_by"].$row_user[0]." ".$row_user[1]; $d[$weekday][$slot]["statut"] = $row[6]; } } # Step to next time period and slot: $t += $resolution; $slot++; if ($slot > $last_slot) { # Skip to first slot of next day: $weekday++; $slot = $first_slot; $t = $weekday * 86400 + $am7; } } while ($t < $end_t); } if ($debug_flag) { echo "

DEBUG:

\n";
    if (gettype($d) == "array")
    while (list($w_k, $w_v) = each($d))
        while (list($t_k, $t_v) = each($w_v))
            while (list($k_k, $k_v) = each($t_v))
                echo "d[$w_k][$t_k][$k_k] = '$k_v'\n";
    else echo "d is not an array!\n";
    echo "

\n"; } #This is where we start displaying stuff echo ""; # The header row contains the weekday names and short dates. echo ""; switch ($dateformat) { case "en": $dformat = "%A
%b %d"; break; case "fr": $dformat = "%A
%d %b"; break; } $k=$day_week; for ($t = $week_start; $t < $week_end; $t += 86400) { echo "\n"; $k++; } echo "\n"; echo ""; tdcell("cell_hours"); echo "$vocab[time]"; for ($t = $week_start; $t < $week_end; $t += 86400) { tdcell("cell_hours"); $num_day = strftime("%d", $t); echo "".$vocab["allday"].""; } tdcell("cell_hours"); echo "$vocab[time]\n"; # This is the main bit of the display. Outer loop is for the time slots, # inner loop is for days of the week. # $t is the date/time for the first day of the week (Sunday, if $weekstarts=0). # $wt is for the weekday in the inner loop. $t = $am7; for ($slot = $first_slot; $slot <= $last_slot; $slot++) { # Show the time linked to the URL for highlighting that time: echo ""; tdcell("cell_hours"); echo date(hour_min_format(),$t) . ""; $wt = $t; $empty_color = "empty_cell"; # See note above: weekday==0 is day $weekstarts, not necessarily Sunday. for ($weekday = 0; $weekday < 7; $weekday++) { # Three cases: # color: id: Slot is: Color: Link to: # ----- ----- -------- --------- ----------------------- # unset - empty white,red add new entry # set unset used by type none (unlabelled slot) # set set used by type view entry $wday = date("d", $wt); $wmonth = date("m", $wt); $wyear = date("Y", $wt); if(!isset($d[$weekday][$slot]["color"])) { if ($this_statut_room == "0") tdcell("avertissement"); else tdcell($empty_color); $hour = date("H",$wt); $minute = date("i",$wt); $date_booking = mktime($hour, $minute, 0, $wmonth, $wday, $wyear); if ((authGetUserLevel(getUserName(),-1) > 1) and (UserRoomMaxBooking(getUserName(), $room, 1) != 0) and verif_booking_date(getUserName(), -1, $date_booking, $date_now) and (($this_statut_room == "1") or (($this_statut_room == "0") and (authGetUserLevel(getUserName(),$room) > 2) ))) { echo "
"; echo ""; echo "
"; } else { echo " "; } } else { tdcell($d[$weekday][$slot]["color"]); // si la ressource est "occupée, on l'affiche if ((isset($d[$weekday][$slot]["statut"])) and ($d[$weekday][$slot]["statut"]=='y')) echo " \"".$vocab["reservation_en_cours"]."\" \n"; if (!isset($d[$weekday][$slot]["id"])) { echo " \" "; } else { if (($this_statut_room == "1") or (($this_statut_room == "0") and (authGetUserLevel(getUserName(),$room) > 2) )) { echo " " . htmlspecialchars($d[$weekday][$slot]["data"]) . ""; } else { echo htmlspecialchars($d[$weekday][$slot]["data"]); } } } echo "\n"; $wt += 86400; } // répétition de la première colonne tdcell("cell_hours"); echo date(hour_min_format(),$t) . ""; echo "\n"; $t += $resolution; } // répétition de la première ligne echo ""; for ($t = $week_start; $t < $week_end; $t += 86400) { echo "\n"; $k++; } echo "\n"; echo "
 " . strftime($dformat, $t) . " 
 " . strftime($dformat, $t) ." 
"; show_colour_key(); include "trailer.inc.php"; ?>