diff -Naurw /home/mike/moodle-clean/moodle/blocks/mrbs/web/day.php /home/mike/moodle-dev/mrbs/web/day.php --- /home/mike/moodle-clean/moodle/blocks/mrbs/web/day.php 2009-04-21 16:33:45.000000000 +0100 +++ /home/mike/moodle-dev/mrbs/web/day.php 2009-04-21 15:49:37.000000000 +0100 @@ -186,23 +186,33 @@ $end_t = min(round_t_up($row[2], $resolution, $am7) - $resolution, $pm7); for ($t = $start_t; $t <= $end_t; $t += $resolution) { + //checks for double bookings + if(empty($today[$row[0]][date($format,$t)])){ + $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)]["data"] .= ""; + $today[$row[0]][date($format,$t)]["long_descr"] .= ""; + $today[$row[0]][date($format,$t)]["double_booked"] = false; + }else{ + $today[$row[0]][date($format,$t)]["id"] .= ','.$row[4]; + $today[$row[0]][date($format,$t)]["data"] .= "\n"; + $today[$row[0]][date($format,$t)]["long_descr"] .= ","; + $today[$row[0]][date($format,$t)]["double_booked"] = true; + } } # 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]; + $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]; + $today[$row[0]][date($format,$start_t)]["data"] .= $row[3]; + $today[$row[0]][date($format,$start_t)]["long_descr"] .= $row[6]; } } @@ -331,6 +341,8 @@ $color = $today[$room][$time_t]["color"]; $descr = htmlspecialchars($today[$room][$time_t]["data"]); $long_descr = htmlspecialchars($today[$room][$time_t]["long_descr"]); + $double_booked = $today[$room][$time_t]["double_booked"]; + if($double_booked) $color='DoubleBooked'; } else unset($id); @@ -375,13 +387,27 @@ } } else echo ' '; } - elseif ($descr != "") + elseif ($double_booked){ + $descrs=split("\n",$descr); + $long_descrs=split(",",$long_descr); + $ids=split(",",$id); + }else{ + $descrs[]=$descr; + $long_descrs[]=$long_descr; + $ids[]=$id; + } + for($i=0;$i$descr"; + echo " $descrs[$i]
"; } else - echo " \" "; + echo " \" 
"; + } + unset($descrs); + unset($long_descrs); + unset($ids); echo "\n"; } diff -Naurw /home/mike/moodle-clean/moodle/blocks/mrbs/web/day.php.orig /home/mike/moodle-dev/mrbs/web/day.php.orig --- /home/mike/moodle-clean/moodle/blocks/mrbs/web/day.php.orig 2009-04-21 16:30:11.000000000 +0100 +++ /home/mike/moodle-dev/mrbs/web/day.php.orig 1970-01-01 01:00:00.000000000 +0100 @@ -1,444 +0,0 @@ -forcelogin) { - require_login(); - } -/* -$id = required_param('id', PARAM_INT); // course -if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); - } -require_course_login($course); -add_to_log($course->id, "mrbs", "view all", "day.php?id=$course->id", ""); -*/ - - -if (empty($debug_flag)) $debug_flag = 0; - -#If we dont know the right date then make it up -if (($day==0) or ($month==0) or ($year==0)) -{ - $day = date("d"); - $month = date("m"); - $year = date("Y"); -} else { -# Make the date valid if day is more then number of days in month - while (!checkdate(intval($month), intval($day), intval($year))) - $day--; -} -// if (($area>0)) -// $area = get_default_area(); - -# print the page header -print_header_mrbs($day, $month, $year, $area); - -$format = "Gi"; -if( $enable_periods ) { - $format = "i"; - $resolution = 60; - $morningstarts = 12; - $morningstarts_minutes = 0; - $eveningends = 12; - $eveningends_minutes = count($periods)-1; - -} - -# ensure that $morningstarts_minutes defaults to zero if not set -# not needed if initialized with optoinal_param - ab. - -# Define the start and end of each day in a way which is not affected by -# daylight saving... -# dst_change: -# -1 => no change -# 0 => entering DST -# 1 => leaving DST -$dst_change = is_dst($month,$day,$year); -$am7=mktime($morningstarts,$morningstarts_minutes,0,$month,$day,$year,is_dst($month,$day,$year,$morningstarts)); -$pm7=mktime($eveningends,$eveningends_minutes,0,$month,$day,$year,is_dst($month,$day,$year,$eveningends)); - -if ( $pview != 1 ) { - echo "\n"; - - //insert the goto room form - echo""; - - #Draw the three month calendars - minicals($year, $month, $day, $area, '', 'day'); - echo "
"; - - #Show all avaliable areas - echo "".get_string('areas','block_mrbs')."
"; - - # 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") { - echo make_area_select_html('day.php', $area, $year, $month, $day); # from functions.php - } else { - # show the standard html list - $sql = "select id, area_name from $tbl_area order by area_name"; - $res = sql_query($sql); - - if ($res) for ($i = 0; ($row = sql_row($res, $i)); $i++) - { - echo ""; - if ($row[0] == $area) - echo "" . htmlspecialchars($row[1]) . "
\n"; - else echo htmlspecialchars($row[1]) . "
\n"; - } - } - echo "

Find a room

-
- Go to: - - - - -
"; -} - -#y? are year, month and day of yesterday -#t? are year, month and day of tomorrow - -$i= mktime(12,0,0,$month,$day-1,$year); -$yy = date("Y",$i); -$ym = date("m",$i); -$yd = date("d",$i); - -$i= mktime(12,0,0,$month,$day+1,$year); -$ty = date("Y",$i); -$tm = date("m",$i); -$td = date("d",$i); - -#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. -// Don't continue if there are no areas: - -if ($area <= 0) { - echo "

".get_string('noareas','block_mrbs')."

"; - echo "\n"; - (isset($output)) ? print $output : ''; - show_colour_key(); - include "trailer.php"; - exit; -} - - -if (!empty($area)) { - $sql = "SELECT $tbl_room.id, start_time, end_time, name, $tbl_entry.id, type, - $tbl_entry.description - FROM $tbl_entry, $tbl_room - WHERE $tbl_entry.room_id = $tbl_room.id - AND area_id = $area - AND start_time <= $pm7 AND end_time > $am7"; - - $res = sql_query($sql); - if (!$res) fatal_error(0, sql_error()); - for ($i = 0; ($row = sql_row($res, $i)); $i++) { //Each row we have 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 - - # $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) - { - //checks for double bookings - if(empty($today[$row[0]][date($format,$t)])){ - - $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)]["double_booked"] = false; - }else{ - $today[$row[0]][date($format,$t)]["id"] .= ','.$row[4]; - $today[$row[0]][date($format,$t)]["data"] .= "\n"; - $today[$row[0]][date($format,$t)]["long_descr"] .= ","; - $today[$row[0]][date($format,$t)]["double_booked"] = true; - } - } - - # 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]; - } - } - - - if ($debug_flag) - { - echo "

DEBUG:

\n";
-	   echo "\$dst_change = $dst_change\n";
-	   echo "\$am7 = $am7 or " . date($format,$am7) . "\n";
-	   echo "\$pm7 = $pm7 or " . date($format,$pm7) . "\n";
-	   if (gettype($today) == "array")
-	   while (list($w_k, $w_v) = each($today))
-		  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 "today is not an array!\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 $tbl_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 "

".get_string('no_rooms_for_area','block_mrbs')."

"; - sql_free($res); - } - else - { - #Show current date - echo "

" . userdate($am7, "%A %d %B %Y") . "

\n"; - - if ( $pview != 1 ) { - #Show Go to day before and after links - $output = " - -
<<".get_string('daybefore','block_mrbs')."".get_string('gototoday','block_mrbs')."".get_string('dayafter','block_mrbs').">>
\n"; - print $output; - } - - // Include the active cell content management routines. - // Must be included before the beginnning of the main table. - if ($javascript_cursor) { // If authorized in config.inc.php, include the javascript cursor management. - echo "\n"; - echo "\n"; - } - - #This is where we start displaying stuff - echo ""; - echo ""; - - $room_column_width = (int)(95 / sql_count($res)); - for ($i = 0; ($row = sql_row($res, $i)); $i++) { - echo ""; - $rooms[] = $row[2]; - } - - # next line to display times on right side - if ( FALSE != $times_right_side ) - { - echo ""; - } - echo "\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="day.php?year=$year&month=$month&day=$day&area=$area&timetohighlight"; - - # This is the main bit of the display - # We loop through time and then the rooms we just got - - # if the today is a day which includes a DST change then use - # the day after to generate timesteps through the day as this - # will ensure a constant time step - ( $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" - ) - { - # convert timestamps to HHMM format without leading zeros - $time_t = date($format, $t); - - # Show the time linked to the URL for highlighting that time - echo ""; - tdcell("red"); - if( $enable_periods ){ - $time_t_stripped = preg_replace( "/^0/", "", $time_t ); - echo "" - . $periods[$time_t_stripped] . "\n"; - } else { - echo "" - . userdate($t,hour_min_format()) . "\n"; - } - - # Loop through the list of rooms we have for this area - while (list($key, $room) = each($rooms)) - { - if(isset($today[$room][$time_t]["id"])) - { - $id = $today[$room][$time_t]["id"]; - $color = $today[$room][$time_t]["color"]; - $descr = htmlspecialchars($today[$room][$time_t]["data"]); - $long_descr = htmlspecialchars($today[$room][$time_t]["long_descr"]); - $double_booked = $today[$room][$time_t]["double_booked"]; - if($double_booked) $color='DoubleBooked'; - } - else - unset($id); - - # $c is the colour of the cell that the browser sees. White normally, - # red if were hightlighting that line and a nice attractive green if the room is booked. - # We tell if its booked by $id having something in it - if (isset($id)) - $c = $color; - elseif (($timetohighlight>0) && ($time_t == $timetohighlight)) - $c = "red"; - else - $c = $row_class; # Use the default color class for the row. - - tdcell($c); - - # If the room isnt booked then allow it to be booked - if(!isset($id)) - { - $hour = date("H",$t); - $minute = date("i",$t); - - if ( $pview != 1 ) { - if ($javascript_cursor) - { - echo ""; - } - echo "
"; - if( $enable_periods ) { - echo ""; - } else { - echo ""; - } - echo "
"; - if ($javascript_cursor) - { - echo ""; - } - } else echo ' '; - } - elseif ($double_booked){ - $descrs=split("\n",$descr); - $long_descrs=split(",",$long_descr); - $ids=split(",",$id); - }else{ - $descrs[]=$descr; - $long_descrs[]=$long_descr; - $ids[]=$id; - } - for($i=0;$i$descrs[$i]
"; - } - else - echo " \" 
"; - } - unset($descrs); - unset($long_descrs); - unset($ids); - - echo "\n"; - } - # next lines to display times on right side - if ( FALSE != $times_right_side ) - { - if( $enable_periods ) - { - tdcell("red"); - $time_t_stripped = preg_replace( "/^0/", "", $time_t ); - echo "" - . $periods[$time_t_stripped] . "\n"; - } - else - { - tdcell("red"); - echo "" - . userdate($t,hour_min_format()) . "\n"; - - } - } - - echo "
\n"; - reset($rooms); - } -} -echo "
".($enable_periods ? get_string('period','block_mrbs') : get_string('time'))." - " - . htmlspecialchars($row[0]) . ($row[1] > 0 ? "($row[1])" : "") . "". ( $enable_periods ? get_string('period','block_mrbs') : get_string('time') ) - ."
\n"; -(isset($output)) ? print $output : ''; -show_colour_key(); -} -include "trailer.php"; -?> diff -Naurw /home/mike/moodle-clean/moodle/blocks/mrbs/web/mrbs.css /home/mike/moodle-dev/mrbs/web/mrbs.css --- /home/mike/moodle-clean/moodle/blocks/mrbs/web/mrbs.css 2009-04-21 16:33:46.000000000 +0100 +++ /home/mike/moodle-dev/mrbs/web/mrbs.css 2009-04-21 12:12:28.000000000 +0100 @@ -52,6 +52,7 @@ TD.I {background-color:#DDFFDD} TD.J {background-color:#CCCCCC} TD.white {background-color:#FFFFFF} +TD.DoubleBooked {background-color:#FF0000} TD.calendar { border:0px; font-size: 8pt} TD.calendarHeader {border:0px; font-size: 10pt} diff -Naurw /home/mike/moodle-clean/moodle/blocks/mrbs/web/mrbs.css.orig /home/mike/moodle-dev/mrbs/web/mrbs.css.orig --- /home/mike/moodle-clean/moodle/blocks/mrbs/web/mrbs.css.orig 2009-04-21 15:46:40.000000000 +0100 +++ /home/mike/moodle-dev/mrbs/web/mrbs.css.orig 1970-01-01 01:00:00.000000000 +0100 @@ -1,78 +0,0 @@ -BODY {color:black; font-size: 10pt; font-family:arial,sans-serif; -background-color:#ffffed} - -A:link {color:#5B69A6; font-weight: bold; text-decoration: none} -A:visited {color:#5B69A6; font-weight: bold; text-decoration: none} -A:hover {color:red; text-decoration:underline} -H1 {color:black; font-family:verdana,sans-serif; font-size:16pt} -H2 {color:black; font-family:verdana,sans-serif; font-size:14pt} -H3 {font-family:verdana,sans-serif} - -TD {font-size:10pt; font-family:arial,sans-serif; border-width:1; -vertical-align:top} -TD.header {color:black; font-family:verdana,sans-serif; border-width:0; -background-color:#ffffdd; font-size:26pt} -TD.CR { vertical-align: middle; text-align: right} -TD.CL { vertical-align: middle; text-align: left} -TD.BR { vertical-align: baseline; text-align: right} -TD.BL { vertical-align: baseline; text-align: left} -TD.TR { vertical-align: top; text-align: right} -TD.TL { vertical-align: top; text-align: left} - -td form { margin:0; } /* Prevent IE from displaying margins around forms in tables. */ - -TD.unallocated {color:gray} -TD.allocated {color:black} -A:link.unallocated {color:#9BA9E6} -A:link.allocated {color:#5B69A6} - -A:hover.unallocated {color:red} -A:hover.allocated {color:red} - -A.blue {color:blue} -A:visited.blue {color:blue} -A:hover.blue {color:red} - -TH {color:#eeeeee; font-size:10pt; font-family:verdana,sans-serif; -background-color:#999999; -border-width:1; border-color:#999999; vertical-align:top} -TD.banner {vertical-align:middle; background-color:#C0E0FF} - -TD.blue {background-color:#F0F0FF} -TD.red {background-color:#FFF0F0} -TD.green {background-color:#DDFFDD} -TD.A {background-color:#FFCCFF} -TD.B {background-color:#99CCCC} -TD.C {background-color:#FF9999} -TD.D {background-color:#FFFF99} -TD.E {background-color:#C0E0FF} -TD.F {background-color:#FFCC99} -TD.G {background-color:#FF6666} -TD.H {background-color:#66FFFF} -TD.I {background-color:#DDFFDD} -TD.J {background-color:#CCCCCC} -TD.white {background-color:#FFFFFF} -TD.DoubleBooked {background-color:#FF0000} - -TD.calendar { border:0px; font-size: 8pt} -TD.calendarHeader {border:0px; font-size: 10pt} -FONT.calendarHighlight {color: red} - -TD.even_row {background-color:#FFFFFF} /* Even rows in the day view */ -TD.odd_row {background-color:#EEEEEE} /* Odd rows in the day view */ - -TD.highlight {background-color:#AABBFF; border-style:solid; border-width:1; border-color:#0000AA;} /* The highlighted cell under the cursor */ -.naked { margin: 0; padding: 0; border-width:0} /* Invisible tables used for internal needs */ - -.sitename -{font-size: 18px; -font-style: normal; -font-weight: bold; -text-transform: none; -color:#ffffff; -position: absolute; -left:30; -top:12} - -TD.month {font-size: 8pt; background-color:#FFFFFF} -.monthday {font-size: 12pt; vertical-align: top; text-align: left}