Revision: 1083
http://mrbs.svn.sourceforge.net/mrbs/?rev=1083&view=rev
Author: cimorrison
Date: 2009-04-02 22:28:41 +0000 (Thu, 02 Apr 2009)
Log Message:
-----------
Added support for transposed tables in the day and week views. Transposed
tables are controlled by a config variable called $times_along_top.
($times_right_side has been renamed $row_labels_both_sides, as it's now
possible to have rooms down the right hand side when the table is transposed.)
Modified Paths:
--------------
mrbs/trunk/web/config.inc.php
mrbs/trunk/web/day.php
mrbs/trunk/web/functions.inc
mrbs/trunk/web/mrbs.css.php
mrbs/trunk/web/week.php
Modified: mrbs/trunk/web/config.inc.php
===================================================================
--- mrbs/trunk/web/config.inc.php 2009-04-01 13:55:22 UTC (rev 1082)
+++ mrbs/trunk/web/config.inc.php 2009-04-02 22:28:41 UTC (rev 1083)
@@ -148,7 +148,8 @@
// This is the maximum number of rows (timeslots or periods) that one can
expect to see in the day
// and week views. It is used by mrbs.css.php for creating classes. It
does not matter if it
-// is too large, except for the fact that more CSS than necessary will be
generated.
+// is too large, except for the fact that more CSS than necessary will be
generated. (The variable
+// is ignored if $times_along_top is set to TRUE).
$max_slots = 60;
@@ -259,9 +260,17 @@
// 'first day of the week' (13 Oct), set this to TRUE
$view_week_number = FALSE;
-// To display times on right side in day and week view, set to TRUE;
-$times_right_side = FALSE;
+// To display times on the x-axis (along the top) and rooms or days on the
y-axis (down the side)
+// set to TRUE; the default/traditional version of MRBS has rooms (or days)
along the top and
+// times along the side. Transposing the table can be useful if you have a
large number of
+// rooms and not many time slots.
+$times_along_top = FALSE;
+// To display the row labels (times, rooms or days) on the right hand side as
well as the
+// left hand side in the day and week views, set to TRUE;
+// (was called $times_right_side in earlier versions of MRBS)
+$row_labels_both_sides = FALSE;
+
// Define default starting view (month, week or day)
// Default is day
$default_view = "day";
Modified: mrbs/trunk/web/day.php
===================================================================
--- mrbs/trunk/web/day.php 2009-04-01 13:55:22 UTC (rev 1082)
+++ mrbs/trunk/web/day.php 2009-04-02 22:28:41 UTC (rev 1083)
@@ -293,7 +293,7 @@
echo "InitActiveCell("
. ($show_plus_link ? "true" : "false") . ", "
. "true, "
- . ((FALSE != $times_right_side) ? "true" : "false") . ", "
+ . ((FALSE != $row_labels_both_sides) ? "true" : "false") . ", "
. "\"$highlight_method\", "
. "\"" . get_vocab("click_to_reserve") . "\""
. ");\n";
@@ -301,35 +301,80 @@
echo "</script>\n";
}
- // This is where we start displaying stuff
+ // START DISPLAYING THE MAIN TABLE
echo "<table class=\"dwm_main\" id=\"day_main\">\n";
+ ( $dst_change != -1 ) ? $j = 1 : $j = 0;
- // Table header giving room names
+ // TABLE HEADER
echo "<thead>\n";
echo "<tr>\n";
- echo "<th class=\"first_last\">".($enable_periods ? get_vocab("period") :
get_vocab("time")).":</th>";
-
- $room_column_width = (int)(95 / sql_count($res));
- for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
+
+
+ // We can display the table in two ways
+ if ($times_along_top)
{
- echo "<th style=\"width: $room_column_width%\">
- <a
href=\"week.php?year=$year&month=$month&day=$day&area=$area&room=".$row['id']."\"
- title=\"" . get_vocab("viewweek") . "
".$row['description']."\">"
- . htmlspecialchars($row['room_name']) . ($row['capacity'] > 0 ?
"(".$row['capacity'].")" : "") . "</a></th>";
- $rooms[] = $row['id'];
- }
-
- // next line to display times on right side
- if ( FALSE != $times_right_side )
+ // with times along the top and rooms down the side
+ $start_first_slot = ($morningstarts*60) + $morningstarts_minutes; //
minutes
+ $start_last_slot = ($eveningends*60) + $eveningends_minutes; //
minutes
+ $start_difference = ($start_last_slot - $start_first_slot) * 60; //
seconds
+ $n_slots = ($start_difference/$resolution) + 1;
+ $column_width = (int)(95 / $n_slots);
+ echo "<th class=\"first_last\">" . get_vocab("room") . ":</th>";
+ for (
+ $t = mktime($morningstarts, $morningstarts_minutes, 0, $month,
$day+$j, $year);
+ $t <= mktime($eveningends, $eveningends_minutes, 0, $month, $day+$j,
$year);
+ $t += $resolution
+ )
+ {
+ echo "<th style=\"width: $column_width%\">";
+ if ( $enable_periods )
+ {
+ // convert timestamps to HHMM format without leading zeros
+ $time_t = date($format, $t);
+ // and get a stripped version of the time for use with periods
+ $time_t_stripped = preg_replace( "/^0/", "", $time_t );
+ echo $periods[$time_t_stripped];
+ }
+ else
+ {
+ echo utf8_strftime(hour_min_format(),$t);
+ }
+ echo "</th>\n";
+ }
+ // next: line to display times on right side
+ if ( FALSE != $row_labels_both_sides )
+ {
+ echo "<th class=\"first_last\">" . get_vocab("room") . ":</th>";
+ }
+ } // end "times_along_top" view (for the header)
+
+ else
{
- echo "<th class=\"first_last\">". ( $enable_periods ? get_vocab("period")
: get_vocab("time") )
- .":</th>";
- }
+ // the standard view, with rooms along the top and times down the side
+ echo "<th class=\"first_last\">" . ($enable_periods ? get_vocab("period")
: get_vocab("time")) . ":</th>";
+
+ $column_width = (int)(95 / sql_count($res));
+ for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
+ {
+ echo "<th style=\"width: $column_width%\">
+ <a
href=\"week.php?year=$year&month=$month&day=$day&area=$area&room=".$row['id']."\"
+ title=\"" . get_vocab("viewweek") . "
".$row['description']."\">"
+ . htmlspecialchars($row['room_name']) . ($row['capacity'] > 0 ?
"(".$row['capacity'].")" : "") . "</a></th>";
+ $rooms[] = $row['id'];
+ }
+
+ // next line to display times on right side
+ if ( FALSE != $row_labels_both_sides )
+ {
+ echo "<th class=\"first_last\">" . ( $enable_periods ?
get_vocab("period") : get_vocab("time") ) . ":</th>";
+ }
+ } // end standard view (for the header)
+
echo "</tr>\n";
echo "</thead>\n";
- // Table body listing bookings
+ // TABLE BODY LISTING BOOKINGS
echo "<tbody>\n";
// This is the main bit of the display
@@ -343,89 +388,113 @@
// the timetohighlight parameter duplicated each time you click.
$hilite_url="day.php?year=$year&month=$month&day=$day&area=$area$room_param&timetohighlight";
- ( $dst_change != -1 ) ? $j = 1 : $j = 0;
+
$row_class = "even_row";
- for (
- $t = mktime($morningstarts, $morningstarts_minutes, 0, $month, $day+$j,
$year);
- $t <= mktime($eveningends, $eveningends_minutes, 0, $month, $day+$j,
$year);
- $t += $resolution, $row_class = ($row_class ==
"even_row")?"odd_row":"even_row"
- )
+
+ // We can display the table in two ways
+ if ($times_along_top)
{
- // convert timestamps to HHMM format without leading zeros
- $time_t = date($format, $t);
- // and get a stripped version for use with periods
- $time_t_stripped = preg_replace( "/^0/", "", $time_t );
-
- // calculate hour and minute (needed for links)
- $hour = date("H",$t);
- $minute = date("i",$t);
-
- // Show the time linked to the URL for highlighting that time
- echo "<tr>";
- tdcell("times", 1);
- echo "<div class=\"celldiv1\">\n";
- if( $enable_periods )
- {
- echo "<a href=\"$hilite_url=$time_t\" title=\""
- . get_vocab("highlight_line") . "\">"
- . $periods[$time_t_stripped] . "</a>\n";
- }
- else
+ // with times along the top and rooms down the side
+ for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++, $row_class =
($row_class == "even_row")?"odd_row":"even_row")
{
- echo "<a href=\"$hilite_url=$time_t\" title=\""
- . get_vocab("highlight_line") . "\">"
- . utf8_strftime(hour_min_format(),$t) . "</a>\n";
- }
- echo "</div></td>\n";
-
- // Loop through the list of rooms we have for this area
- while (list($key, $room_id) = each($rooms))
- {
- // set up the query strings to be used for the link in the cell
- $query_strings = array();
- $query_strings['new_periods'] =
"area=$area&room=$room_id&period=$time_t_stripped&year=$year&month=$month&day=$day";
- $query_strings['new_times'] =
"area=$area&room=$room_id&hour=$hour&minute=$minute&year=$year&month=$month&day=$day";
- $query_strings['booking'] =
"area=$area&day=$day&month=$month&year=$year";
- // and then draw the cell
- if (!isset($today[$room_id][$day][$time_t]))
+ echo "<tr>\n";
+ $room_id = $row['id'];
+ $room_cell_link =
"week.php?year=$year&month=$month&day=$day&area=$area&room=$room_id";
+ draw_room_cell($row, $room_cell_link);
+ for (
+ $t = mktime($morningstarts, $morningstarts_minutes, 0, $month,
$day+$j, $year);
+ $t <= mktime($eveningends, $eveningends_minutes, 0, $month,
$day+$j, $year);
+ $t += $resolution
+ )
{
- $today[$room_id][$day][$time_t] = array(); // to avoid an undefined
index NOTICE error
- }
- if (isset($timetohighlight) && ($time_t == $timetohighlight))
+ // convert timestamps to HHMM format without leading zeros
+ $time_t = date($format, $t);
+ // and get a stripped version of the time for use with periods
+ $time_t_stripped = preg_replace( "/^0/", "", $time_t );
+
+ // calculate hour and minute (needed for links)
+ $hour = date("H",$t);
+ $minute = date("i",$t);
+
+ // set up the query strings to be used for the link in the cell
+ $query_strings = array();
+ $query_strings['new_periods'] =
"area=$area&room=$room_id&period=$time_t_stripped&year=$year&month=$month&day=$day";
+ $query_strings['new_times'] =
"area=$area&room=$room_id&hour=$hour&minute=$minute&year=$year&month=$month&day=$day";
+ $query_strings['booking'] =
"area=$area&day=$day&month=$month&year=$year";
+ // and then draw the cell
+ if (!isset($today[$room_id][$day][$time_t]))
+ {
+ $today[$room_id][$day][$time_t] = array(); // to avoid an undefined
index NOTICE error
+ }
+ $cell_class = $row_class;
+ draw_cell($today[$room_id][$day][$time_t], $query_strings,
$cell_class);
+ } // end for (looping through the times)
+ if ( FALSE != $row_labels_both_sides )
{
- $cell_class = "row_highlight";
+ draw_room_cell($row, $room_cell_link);
}
- else
- {
- $cell_class = $row_class;
- }
- draw_cell($today[$room_id][$day][$time_t], $query_strings, $cell_class);
- }
-
- // next lines to display times on right side
- if ( FALSE != $times_right_side )
+ echo "</tr>\n";
+ } // end for (looping through the rooms)
+ } // end "times_along_top" view (for the body)
+
+ else
+ {
+ // the standard view, with rooms along the top and times down the side
+ for (
+ $t = mktime($morningstarts, $morningstarts_minutes, 0, $month,
$day+$j, $year);
+ $t <= mktime($eveningends, $eveningends_minutes, 0, $month, $day+$j,
$year);
+ $t += $resolution
+ )
{
- tdcell("times", 1);
- echo "<div class=\"celldiv1\">\n";
- if ( $enable_periods )
+ // convert timestamps to HHMM format without leading zeros
+ $time_t = date($format, $t);
+ // and get a stripped version of the time for use with periods
+ $time_t_stripped = preg_replace( "/^0/", "", $time_t );
+
+ // calculate hour and minute (needed for links)
+ $hour = date("H",$t);
+ $minute = date("i",$t);
+
+ // Show the time linked to the URL for highlighting that time
+ echo "<tr>";
+ draw_time_cell($t, $time_t, $time_t_stripped, $hilite_url);
+
+ // Loop through the list of rooms we have for this area
+ while (list($key, $room_id) = each($rooms))
{
- echo "<a href=\"$hilite_url=$time_t\" title=\""
- . get_vocab("highlight_line") . "\">"
- . $periods[$time_t_stripped] . "</a>\n";
+ // set up the query strings to be used for the link in the cell
+ $query_strings = array();
+ $query_strings['new_periods'] =
"area=$area&room=$room_id&period=$time_t_stripped&year=$year&month=$month&day=$day";
+ $query_strings['new_times'] =
"area=$area&room=$room_id&hour=$hour&minute=$minute&year=$year&month=$month&day=$day";
+ $query_strings['booking'] =
"area=$area&day=$day&month=$month&year=$year";
+ // and then draw the cell
+ if (!isset($today[$room_id][$day][$time_t]))
+ {
+ $today[$room_id][$day][$time_t] = array(); // to avoid an undefined
index NOTICE error
+ }
+ if (isset($timetohighlight) && ($time_t == $timetohighlight))
+ {
+ $cell_class = "row_highlight";
+ }
+ else
+ {
+ $cell_class = $row_class;
+ }
+ draw_cell($today[$room_id][$day][$time_t], $query_strings,
$cell_class);
}
- else
+
+ // next lines to display times on right side
+ if ( FALSE != $row_labels_both_sides )
{
- echo "<a href=\"$hilite_url=$time_t\" title=\""
- . get_vocab("highlight_line") . "\">"
- . utf8_strftime(hour_min_format(),$t) . "</a>\n";
+ draw_time_cell($t, $time_t, $time_t_stripped, $hilite_url);
}
- echo "</div></td>\n";
+
+ echo "</tr>\n";
+ reset($rooms);
}
-
- echo "</tr>\n";
- reset($rooms);
- }
+ } // end standard view (for the body)
+
echo "</tbody>\n";
echo "</table>\n";
Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc 2009-04-01 13:55:22 UTC (rev 1082)
+++ mrbs/trunk/web/functions.inc 2009-04-02 22:28:41 UTC (rev 1083)
@@ -686,11 +686,12 @@
// $slots is the number of time slots high that the cell should be
function tdcell($colclass, $slots)
{
+ global $times_along_top;
echo "<td class=\"$colclass\"";
if ($slots > 1)
// No need to output more HTML than necessary
{
- echo " rowspan=\"$slots\"";
+ echo " " . (($times_along_top) ? "colspan" : "rowspan") . "=\"$slots\"";
}
echo ">\n";
}
@@ -1139,7 +1140,7 @@
global $main_cell_height, $main_table_cell_border_width;
global $area, $year, $month, $timetohighlight;
- global $javascript_cursor, $enable_periods;
+ global $javascript_cursor, $enable_periods, $times_along_top;
// if the time slot has got multiple bookings, then draw a mini-table
if(isset($cell[1]["id"]))
@@ -1313,7 +1314,14 @@
}
else // if it is booked then show the booking
{
- echo "<div class=\"celldiv" . $slots . "\">\n"; // we want
clipping of overflow
+ if ($times_along_top)
+ {
+ echo "<div class=\"celldiv1\">\n";
+ }
+ else
+ {
+ echo "<div class=\"celldiv" . $slots . "\">\n"; // we want
clipping of overflow
+ }
echo " <a href=\"view_entry.php?id=$id&".
$query_strings['booking'] . "\" title=\"$long_descr\">$descr</a>\n";
echo "</div>\n";
}
@@ -1322,4 +1330,56 @@
}
} // end function draw_cell
+
+// Draw a time cell to be used in the first and last columns of the day and
week views
+// $t the timestamp for the start of the slot
+// $time_t the time converted to HHMM format without leading
zeros
+// $time_t_stripped a stripped version of the time for use with periods
+// $hilite_url the url to form the basis of the link in the time cell
+function draw_time_cell($t, $time_t, $time_t_stripped, $hilite_url)
+{
+ global $enable_periods, $periods;
+
+ tdcell("times", 1);
+ echo "<div class=\"celldiv1\">\n";
+ if ( $enable_periods )
+ {
+
+ echo "<a href=\"$hilite_url=$time_t\" title=\""
+ . get_vocab("highlight_line") . "\">"
+ . $periods[$time_t_stripped] . "</a>\n";
+ }
+ else
+ {
+ echo "<a href=\"$hilite_url=$time_t\" title=\""
+ . get_vocab("highlight_line") . "\">"
+ . utf8_strftime(hour_min_format(),$t) . "</a>\n";
+ }
+ echo "</div></td>\n";
+}
+
+// Draw a room cell to be used in the first and last columns of the day view
+// $row contains the room details; comes from an SQL query
+// $link the href to be used for the link
+function draw_room_cell($row, $link)
+{
+ tdcell("times", 1);
+ echo "<div class=\"celldiv1\">\n";
+ echo "<a href=\"$link\" title=\"" . get_vocab("viewweek") . " " .
$row['description'] . "\">";
+ echo htmlspecialchars($row['room_name']) . ($row['capacity'] > 0 ?
"(".$row['capacity'].")" : "");
+ echo "</a>\n";
+ echo "</div></td>\n";
+}
+
+// Draw a day cell to be used in the first and last columns of the week view
+// $text contains the date, formatted as a string
+// $link the href to be used for the link
+function draw_day_cell($text, $link)
+{
+ tdcell("times", 1);
+ echo "<div class=\"celldiv1\">\n";
+ echo "<a href=\"$link\" title=\"" . get_vocab("viewday") . "\">$text</a>\n";
+ echo "</div></td>\n";
+}
+
?>
Modified: mrbs/trunk/web/mrbs.css.php
===================================================================
--- mrbs/trunk/web/mrbs.css.php 2009-04-01 13:55:22 UTC (rev 1082)
+++ mrbs/trunk/web/mrbs.css.php 2009-04-02 22:28:41 UTC (rev 1083)
@@ -118,7 +118,7 @@
// normal columns (ie columns that are not hidden)
$n_hidden_days = count($hidden_days);
$column_week = 100 - $column_times_width; // subtract the width
of the left hand column
-if ($times_right_side)
+if ($row_labels_both_sides)
{
$column_week -= $column_times_width; // and the right hand
column if present
}
@@ -251,7 +251,7 @@
td.row_highlight {background-color: <?php echo $row_highlight_color ?>} /*
used for highlighting a row */
td.even_row {background-color: <?php echo $row_even_color ?>} /*
even rows in the day view */
td.odd_row {background-color: <?php echo $row_odd_color ?>} /*
odd rows in the day view */
-td.times {background-color: <?php echo $main_table_times_back_color
?>} /* used for the column with times/periods */
+td.times {background-color: <?php echo $main_table_times_back_color
?>; white-space: nowrap} /* used for the column with times/periods */
.times a:link {color: <?php echo $anchor_link_color_header ?>;
text-decoration: none; font-weight: normal}
.times a:visited {color: <?php echo $anchor_visited_color_header ?>;
text-decoration: none; font-weight: normal}
.times a:hover {color: <?php echo $anchor_hover_color_header ?>;
text-decoration:underline; font-weight: normal}
@@ -346,7 +346,12 @@
if ($clipped)
{
- for ($i=1; $i<=$max_slots; $i++)
+ // work out how many classes we'll need. If we're transposing the table
then we'll only need one, since all
+ // cells are the same height (it's the width that varies, controlled by the
colspan attribute). For a normal
+ // table we'll need at least as many as we've got slots, since a booking
could span as many as all the slots
+ // (in this case controlled by a rowspan).
+ $classes_required = ($times_along_top) ? 1 : $max_slots;
+ for ($i=1; $i<=$classes_required; $i++)
{
$div_height = $main_cell_height * $i;
$div_height = $div_height + (($i-1)*$main_table_cell_border_width);
@@ -361,7 +366,6 @@
}
-
// Multiple bookings. These rules control the styling of the cells and
controls when there is more than
// one booking in a time slot.
?>
Modified: mrbs/trunk/web/week.php
===================================================================
--- mrbs/trunk/web/week.php 2009-04-01 13:55:22 UTC (rev 1082)
+++ mrbs/trunk/web/week.php 2009-04-02 22:28:41 UTC (rev 1083)
@@ -310,7 +310,7 @@
echo "InitActiveCell("
. ($show_plus_link ? "true" : "false") . ", "
. "true, "
- . ((FALSE != $times_right_side) ? "true" : "false") . ", "
+ . ((FALSE != $row_labels_both_sides) ? "true" : "false") . ", "
. "\"$highlight_method\", "
. "\"" . get_vocab("click_to_reserve") . "\""
. ");\n";
@@ -318,13 +318,17 @@
echo "</script>\n";
}
-//This is where we start displaying stuff
+ // START DISPLAYING THE MAIN TABLE
echo "<table class=\"dwm_main\" id=\"week_main\">";
+// if the first day of the week to be displayed contains as DST change then
+// move to the next day to get the hours in the day.
+( $dst_change[0] != -1 ) ? $j = 1 : $j = 0;
-// The header row contains the weekday names and short dates.
+ // TABLE HEADER
echo "<thead>\n";
-echo "<tr><th class=\"first_last\">".($enable_periods ? get_vocab("period") :
get_vocab("time")).":</th>";
+echo "<tr>\n";
+
if (empty($dateformat))
{
$dformat = "%a<br>%b %d";
@@ -333,145 +337,240 @@
{
$dformat = "%a<br>%d %b";
}
-for ($j = 0; $j<=($num_of_days-1) ; $j++)
+
+// If we've got a table with times along the top then put everything on the
same line
+// (ie replace the <br> with a space). It looks slightly better
+if ($times_along_top)
{
- $t = mktime( 12, 0, 0, $month, $day_start_week+$j, $year);
-
- if (is_hidden_day(($j + $weekstarts) % 7))
+ $dformat = ereg_replace("<br>", " ", $dformat);
+}
+
+
+// We can display the table in two ways
+if ($times_along_top)
+{
+ // with times along the top and days of the week down the side
+ $start_first_slot = ($morningstarts*60) + $morningstarts_minutes; //
minutes
+ $start_last_slot = ($eveningends*60) + $eveningends_minutes; //
minutes
+ $start_difference = ($start_last_slot - $start_first_slot) * 60; //
seconds
+ $n_slots = ($start_difference/$resolution) + 1;
+ $column_width = (int)(95 / $n_slots);
+ echo "<th class=\"first_last\">" . get_vocab("date") . ":</th>";
+ for (
+ $t = mktime($morningstarts, $morningstarts_minutes, 0, $month,
$day_start_week+$j, $year);
+ $t <= mktime($eveningends, $eveningends_minutes, 0, $month,
$day_start_week+$j, $year);
+ $t += $resolution
+ )
{
- // These days are to be hidden in the display (as they are hidden, just
give the
- // day of the week in the header row
- echo "<th class=\"hidden_day\">" . utf8_strftime('%a', $t) . "</th>\n";
+ echo "<th style=\"width: $column_width%\">";
+ if ( $enable_periods )
+ {
+ // convert timestamps to HHMM format without leading zeros
+ $time_t = date($format, $t);
+ // and get a stripped version of the time for use with periods
+ $time_t_stripped = preg_replace( "/^0/", "", $time_t );
+ echo $periods[$time_t_stripped];
+ }
+ else
+ {
+ echo utf8_strftime(hour_min_format(),$t);
+ }
+ echo "</th>\n";
}
+ // next: line to display times on right side
+ if ( FALSE != $row_labels_both_sides )
+ {
+ echo "<th class=\"first_last\">" . get_vocab("date") . ":</th>";
+ }
+} // end "times_along_top" view (for the header)
- else
- {
- echo "<th><a href=\"day.php?year=" . strftime("%Y", $t) .
- "&month=" . strftime("%m", $t) . "&day=" . strftime("%d", $t) .
- "&area=$area\" title=\"" . get_vocab("viewday") . "\">"
- . utf8_strftime($dformat, $t) . "</a></th>\n";
+else
+{
+ // the standard view, with days along the top and times down the side
+ echo "<th class=\"first_last\">".($enable_periods ? get_vocab("period") :
get_vocab("time")).":</th>";
+ for ($j = 0; $j<=($num_of_days-1) ; $j++)
+ {
+ $t = mktime( 12, 0, 0, $month, $day_start_week+$j, $year);
+
+ if (is_hidden_day(($j + $weekstarts) % 7))
+ {
+ // These days are to be hidden in the display (as they are hidden, just
give the
+ // day of the week in the header row
+ echo "<th class=\"hidden_day\">" . utf8_strftime('%a', $t) . "</th>\n";
+ }
+
+ else
+ {
+ echo "<th><a href=\"day.php?year=" . strftime("%Y", $t) .
+ "&month=" . strftime("%m", $t) . "&day=" . strftime("%d", $t)
.
+ "&area=$area\" title=\"" . get_vocab("viewday") . "\">"
+ . utf8_strftime($dformat, $t) . "</a></th>\n";
+ }
}
-}
-// next line to display times on right side
-if ( FALSE != $times_right_side )
-{
- echo "<th class=\"first_last\">"
- . ( $enable_periods ? get_vocab("period") : get_vocab("time") )
- . ":</th>";
-}
+ // next line to display times on right side
+ if ( FALSE != $row_labels_both_sides )
+ {
+ echo "<th class=\"first_last\">"
+ . ( $enable_periods ? get_vocab("period") : get_vocab("time") )
+ . ":</th>";
+ }
+} // end standard view (for the header)
echo "</tr>\n";
echo "</thead>\n";
-// This is the main bit of the display. Outer loop is for the time slots,
-// inner loop is for days of the week.
+
+// TABLE BODY LISTING BOOKINGS
echo "<tbody>\n";
// URL for highlighting a time. Don't use REQUEST_URI or you will get
// the timetohighlight parameter duplicated each time you click.
$hilite_url="week.php?year=$year&month=$month&day=$day&area=$area&room=$room&timetohighlight";
+$row_class = "even_row";
-// if the first day of the week to be displayed contains as DST change then
-// move to the next day to get the hours in the day.
-( $dst_change[0] != -1 ) ? $j = 1 : $j = 0;
-
-$row_class = "even_row";
-for (
- $t = mktime($morningstarts, $morningstarts_minutes, 0, $month,
$day_start_week+$j, $year);
- $t <= mktime($eveningends, $eveningends_minutes, 0, $month,
$day_start_week+$j, $year);
- $t += $resolution, $row_class = ($row_class ==
"even_row")?"odd_row":"even_row"
-)
+// We can display the table in two ways
+if ($times_along_top)
{
- // use hour:minute format
- $time_t = date($format, $t);
- // and get a stripped version for use with periods
- $time_t_stripped = preg_replace( "/^0/", "", $time_t );
-
- // calculate hour and minute (needed for links)
- $hour = date("H",$t);
- $minute = date("i",$t);
-
- // Show the time linked to the URL for highlighting that time:
- echo "<tr>";
- tdcell("times", 1);
- echo "<div class=\"celldiv1\">\n";
- if ( $enable_periods )
- {
- echo "<a href=\"$hilite_url=$time_t\" title=\""
- . get_vocab("highlight_line") . "\">"
- . $periods[$time_t_stripped] . "</a>";
- }
- else
- {
- echo "<a href=\"$hilite_url=$time_t\" title=\""
- . get_vocab("highlight_line") . "\">"
- . utf8_strftime(hour_min_format(),$t) . "</a>";
- }
- echo "</div></td>\n";
-
-
+ // with times along the top and days of the week down the side
// See note above: weekday==0 is day $weekstarts, not necessarily Sunday.
- for ($thisday = 0; $thisday<=($num_of_days-1) ; $thisday++)
+ for ($thisday = 0; $thisday<=($num_of_days-1) ; $thisday++, $row_class =
($row_class == "even_row")?"odd_row":"even_row")
{
if (is_hidden_day(($thisday + $weekstarts) % 7))
{
- // These days are to be hidden in the display
- echo "<td class=\"hidden_day\"> </td>\n";
+ // These days are to be hidden in the display: don't display a row
+ // Toggle the row class back to keep it in sequence
+ $row_class = ($row_class == "even_row")?"odd_row":"even_row";
+ continue;
}
+
else
{
- // set up the query strings to be used for the link in the cell
+ echo "<tr>\n";
+
$wt = mktime( 12, 0, 0, $month, $day_start_week+$thisday, $year );
$wday = date("d", $wt);
$wmonth = date("m", $wt);
$wyear = date("Y", $wt);
- $query_strings = array();
- $query_strings['new_periods'] =
"room=$room&area=$area&period=$time_t_stripped&year=$wyear&month=$wmonth&day=$wday";
- $query_strings['new_times'] =
"room=$room&area=$area&hour=$hour&minute=$minute&year=$wyear&month=$wmonth&day=$wday";
- $query_strings['booking'] =
"area=$area&day=$wday&month=$wmonth&year=$wyear";
-
- // and then draw the cell
- if (!isset($week_map[$room][$thisday][$time_t]))
+ $day_cell_text = utf8_strftime($dformat, $wt);
+ $day_cell_link = "day.php?year=" . strftime("%Y", $wt) .
+ "&month=" . strftime("%m", $wt) .
+ "&day=" . strftime("%d", $wt) .
+ "&area=$area";
+
+ draw_day_cell($day_cell_text, $day_cell_link);
+ for (
+ $t = mktime($morningstarts, $morningstarts_minutes, 0, $month,
$day_start_week+$j, $year);
+ $t <= mktime($eveningends, $eveningends_minutes, 0, $month,
$day_start_week+$j, $year);
+ $t += $resolution
+ )
{
- $week_map[$room][$thisday][$time_t] = array(); // to avoid an
undefined index NOTICE error
- }
- if (isset($timetohighlight) && ($time_t == $timetohighlight))
+ // use hour:minute format
+ $time_t = date($format, $t);
+ // and get a stripped version for use with periods
+ $time_t_stripped = preg_replace( "/^0/", "", $time_t );
+
+ // calculate hour and minute (needed for links)
+ $hour = date("H",$t);
+ $minute = date("i",$t);
+
+ // set up the query strings to be used for the link in the cell
+ $query_strings = array();
+ $query_strings['new_periods'] =
"room=$room&area=$area&period=$time_t_stripped&year=$wyear&month=$wmonth&day=$wday";
+ $query_strings['new_times'] =
"room=$room&area=$area&hour=$hour&minute=$minute&year=$wyear&month=$wmonth&day=$wday";
+ $query_strings['booking'] =
"area=$area&day=$wday&month=$wmonth&year=$wyear";
+
+ // and then draw the cell
+ if (!isset($week_map[$room][$thisday][$time_t]))
+ {
+ $week_map[$room][$thisday][$time_t] = array(); // to avoid an
undefined index NOTICE error
+ }
+ $cell_class = $row_class;
+ draw_cell($week_map[$room][$thisday][$time_t], $query_strings,
$cell_class);
+ } // end looping through the time slots
+ if ( FALSE != $row_labels_both_sides )
{
- $cell_class = "row_highlight";
+ draw_day_cell($day_cell_text, $day_cell_link);
}
- else
- {
- $cell_class = $row_class;
- }
- draw_cell($week_map[$room][$thisday][$time_t], $query_strings,
$cell_class);
+ echo "</tr>\n";
}
+
+ } // end looping through the days of the week
+
+} // end "times along top" view (for the body)
- } // for loop
-
- // next lines to display times on right side
- if ( FALSE != $times_right_side )
+else
+{
+ // the standard view, with days of the week along the top and times down the
side
+ for (
+ $t = mktime($morningstarts, $morningstarts_minutes, 0, $month,
$day_start_week+$j, $year);
+ $t <= mktime($eveningends, $eveningends_minutes, 0, $month,
$day_start_week+$j, $year);
+ $t += $resolution, $row_class = ($row_class ==
"even_row")?"odd_row":"even_row"
+ )
+ {
+ // use hour:minute format
+ $time_t = date($format, $t);
+ // and get a stripped version for use with periods
+ $time_t_stripped = preg_replace( "/^0/", "", $time_t );
+
+ // calculate hour and minute (needed for links)
+ $hour = date("H",$t);
+ $minute = date("i",$t);
+
+ // Show the time linked to the URL for highlighting that time:
+ echo "<tr>";
+ draw_time_cell($t, $time_t, $time_t_stripped, $hilite_url);
+
+
+ // See note above: weekday==0 is day $weekstarts, not necessarily Sunday.
+ for ($thisday = 0; $thisday<=($num_of_days-1) ; $thisday++)
{
- tdcell("times", 1);
- echo "<div class=\"celldiv1\">\n";
- if ( $enable_periods )
+ if (is_hidden_day(($thisday + $weekstarts) % 7))
{
- echo "<a href=\"$hilite_url=$time_t\" title=\""
- . get_vocab("highlight_line") . "\">"
- . $periods[$time_t_stripped] . "</a>";
+ // These days are to be hidden in the display
+ echo "<td class=\"hidden_day\"> </td>\n";
}
else
{
- echo "<a href=\"$hilite_url=$time_t\" title=\""
- . get_vocab("highlight_line") . "\">"
- . utf8_strftime(hour_min_format(),$t) . "</a>";
+ // set up the query strings to be used for the link in the cell
+ $wt = mktime( 12, 0, 0, $month, $day_start_week+$thisday, $year );
+ $wday = date("d", $wt);
+ $wmonth = date("m", $wt);
+ $wyear = date("Y", $wt);
+
+ $query_strings = array();
+ $query_strings['new_periods'] =
"room=$room&area=$area&period=$time_t_stripped&year=$wyear&month=$wmonth&day=$wday";
+ $query_strings['new_times'] =
"room=$room&area=$area&hour=$hour&minute=$minute&year=$wyear&month=$wmonth&day=$wday";
+ $query_strings['booking'] =
"area=$area&day=$wday&month=$wmonth&year=$wyear";
+
+ // and then draw the cell
+ if (!isset($week_map[$room][$thisday][$time_t]))
+ {
+ $week_map[$room][$thisday][$time_t] = array(); // to avoid an
undefined index NOTICE error
+ }
+ if (isset($timetohighlight) && ($time_t == $timetohighlight))
+ {
+ $cell_class = "row_highlight";
+ }
+ else
+ {
+ $cell_class = $row_class;
+ }
+ draw_cell($week_map[$room][$thisday][$time_t], $query_strings,
$cell_class);
}
- echo "</div></td>\n";
- }
-
- echo "</tr>\n";
-}
+
+ } // for loop
+
+ // next lines to display times on right side
+ if ( FALSE != $row_labels_both_sides )
+ {
+ draw_time_cell($t, $time_t, $time_t_stripped, $hilite_url);
+ }
+
+ echo "</tr>\n";
+ }
+} // end standard view (for the body)
echo "</tbody>\n";
echo "</table>\n";
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits