* @package Schoorbs * @license http://www.gnu.org/licenses/gpl.html GNU General Public License */ ## Includes ## /** The Configuration file */ require_once 'config.inc.php'; /** The general 'things' when viewing Schoorbs on the web */ require_once 'schoorbs-includes/global.web.php'; /** The general functions */ require_once 'schoorbs-includes/global.functions.php'; /** The database wrapper */ require_once "schoorbs-includes/database/$dbsys.php"; /** The 3 minicalendars */ require_once 'schoorbs-includes/minicals.php'; ## Var Init ## /** day, month, year */ list($day, $month, $year) = input_DayMonthYear(); /** area */ $area = input_Area(); $dst_change = is_dst($month,$day,$year); $am7 = am7($day, $month, $year); $pm7 = pm7($day, $month, $year); // y? are year, month and day of yesterday list($yd, $ym, $yy) = getYesterday($day, $month, $year); // t? are year, month and day of tomorrow list($td, $tm, $ty) = getTomorrow($day, $month, $year); ## Main ## // print the page header print_header(); if ($pview != 1) { # need to show either a select box or a normal html list, # depending on the settings in config.inc.php if ($area_list_format == 'select') { $smarty->assign('area_select_list', make_area_select_html('day.php', $area, $year, $month, $day)); } else { $smarty->assign('areas', getAreas()); // show the standard html list } $smarty->assign(array( 'area' => $area, 'dwm' => 'day.php', 'day' => $day, 'year' => $year, 'month' => $month, 'area_list_format' => $area_list_format )); $smarty->display('area_list.tpl'); # Draw the three month calendars minicals($year, $month, $day, $area, '', 'day'); puts(''); } # We want to build an array containing all the data we want to show # and then spit it out. # Get all appointments for today in the area that we care about # Note: The predicate clause 'start_time <= ...' is an equivalent but simpler # form of the original which had 3 BETWEEN parts. It selects all entries which # occur on or cross the current day. $sQuery = "SELECT $tbl_room.id, start_time, end_time, name, $tbl_entry.id, type, $tbl_entry.description, $tbl_entry.create_by FROM $tbl_entry, $tbl_room WHERE $tbl_entry.room_id = $tbl_room.id AND area_id = ".sql_escape_arg($area) ." AND start_time <= $pm7 AND end_time > $am7"; $res = sql_query($sQuery); if (!$res) fatal_error(0, sql_error()); for ($i = 0; ($row = sql_row($res, $i)); $i++) { # Each row weve got here is an appointment. #Row[0] = Room ID #row[1] = start time #row[2] = end time #row[3] = short description #row[4] = id of this booking #row[5] = type (internal/external) #row[6] = description #row[7] = creator # $today is a map of the screen that will be displayed # It looks like: # $today[Room ID][Time][id] # [color] # [data] # [long_descr] # Fill in the map for this meeting. Start at the meeting start time, # or the day start time, whichever is later. End one slot before the # meeting end time (since the next slot is for meetings which start then), # or at the last slot in the day, whichever is earlier. # Time is of the format HHMM without leading zeros. # # Note: int casts on database rows for max may be needed for PHP3. # Adjust the starting and ending times so that bookings which don't # start or end at a recognized time still appear. $start_t = max(round_t_down($row[1], $resolution, $am7), $am7); $end_t = min(round_t_up($row[2], $resolution, $am7) - $resolution, $pm7); for ($t = $start_t; $t <= $end_t; $t += $resolution) { $today[$row[0]][date($format,$t)]["id"] = $row[4]; $today[$row[0]][date($format,$t)]["color"] = $row[5]; $today[$row[0]][date($format,$t)]["data"] = ""; $today[$row[0]][date($format,$t)]["long_descr"] = ""; $today[$row[0]][date($format,$t)]['create_by'] = $row[7]; } # Show the name of the booker in the first segment that the booking # happens in, or at the start of the day if it started before today. if ($row[1] < $am7) { $today[$row[0]][date($format,$am7)]["data"] = $row[3]; $today[$row[0]][date($format,$am7)]["long_descr"] = $row[6]; } else { $today[$row[0]][date($format,$start_t)]["data"] = $row[3]; $today[$row[0]][date($format,$start_t)]["long_descr"] = $row[6]; } } # 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 $sQuery = "SELECT room_name, capacity, id, description FROM $tbl_room WHERE area_id = " .sql_escape_arg($area)." ORDER BY 1"; $res = sql_query($sQuery); # 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 "