Revision: 2685
          https://sourceforge.net/p/mrbs/code/2685/
Author:   tbleher
Date:     2013-02-08 06:37:46 +0000 (Fri, 08 Feb 2013)
Log Message:
-----------
Create an overview page for areas in month.php
    
If a booking spans several rooms in one area, only one entry is shown
together with the list of rooms.

Modified Paths:
--------------
    mrbs/branches/linked_bookings/web/Themes/default/header.inc
    mrbs/branches/linked_bookings/web/functions.inc
    mrbs/branches/linked_bookings/web/index.php
    mrbs/branches/linked_bookings/web/lang/lang.de
    mrbs/branches/linked_bookings/web/lang/lang.en
    mrbs/branches/linked_bookings/web/month.php
    mrbs/branches/linked_bookings/web/standard_vars.inc.php
    mrbs/branches/linked_bookings/web/trailer.inc
    mrbs/branches/linked_bookings/web/week.php

Modified: mrbs/branches/linked_bookings/web/Themes/default/header.inc
===================================================================
--- mrbs/branches/linked_bookings/web/Themes/default/header.inc 2013-02-05 
16:40:50 UTC (rev 2684)
+++ mrbs/branches/linked_bookings/web/Themes/default/header.inc 2013-02-08 
06:37:46 UTC (rev 2685)
@@ -16,7 +16,7 @@
   global $select_options;
   global $ajax_refresh_rate;
   global $main_table_cell_border_width, $main_cell_height;
-  global $timetohighlight;
+  global $timetohighlight, $room_selected;
   
   $page = basename($PHP_SELF, ".php");
   $user = getUserName();
@@ -135,7 +135,7 @@
             {
               echo "<input type=\"hidden\" name=\"area\" value=\"$area\">\n";
             }
-            if (!empty($room))
+            if (!empty($room) && $room_selected)
             {
               echo "<input type=\"hidden\" name=\"room\" value=\"$room\">\n";
             }
@@ -193,7 +193,7 @@
       {
         $query_str .= "&amp;area=$area";
       }
-      if (!empty($room))
+      if (!empty($room) && $room_selected)
       {
         $query_str .= "&amp;room=$room";
       }

Modified: mrbs/branches/linked_bookings/web/functions.inc
===================================================================
--- mrbs/branches/linked_bookings/web/functions.inc     2013-02-05 16:40:50 UTC 
(rev 2684)
+++ mrbs/branches/linked_bookings/web/functions.inc     2013-02-08 06:37:46 UTC 
(rev 2685)
@@ -2245,10 +2245,10 @@
 } // end make_area_select_html
 
 
-function make_room_select_html ($link, $area, $current, $year, $month, $day)
+function make_room_select_html ($link, $area, $current, $year, $month, $day, 
$all_rooms_select)
 {
   global $tbl_room, $tbl_area, $area_list_format;
-  
+
   $out_html = '';
   $sql = "SELECT R.id, R.room_name, R.description
             FROM $tbl_room R, $tbl_area A
@@ -2269,7 +2269,13 @@
       $out_html .= "<form id=\"roomChangeForm\" method=\"get\" 
action=\"$link\">\n" .
                    "<div>\n" .
                    "<select class=\"room_area_select\" name=\"room\" 
onchange=\"this.form.submit()\">\n";
-  
+
+      if( $all_rooms_select )
+      {
+       $selected = empty($current) ? "selected=\"selected\"" : "";
+       $out_html .= "<option $selected 
value=\"\">".get_vocab("all_rooms")."</option>\n";
+      }
+
       for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
       {
         $selected = ($row['id'] == $current) ? "selected=\"selected\"" : "";
@@ -2288,6 +2294,12 @@
     else  // list format
     {
       $out_html .= "<ul>\n";
+      if( $all_rooms_select )
+      {
+        $out_html .= "<li><a 
href=\"$link?year=$year&amp;month=$month&amp;day=$day&amp;area=$area\">";
+        $out_html .= "<span" . (empty($current) ? ' class="current"' : '') . 
">";
+        $out_html .= get_vocab("all_rooms") . "</span></a></li>\n";
+      }
       for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
       {
         $out_html .= "<li><a 
href=\"$link?year=$year&amp;month=$month&amp;day=$day&amp;area=$area&amp;room=".$row['id']."\"
 title=\"". htmlspecialchars($row['description'])."\">";

Modified: mrbs/branches/linked_bookings/web/index.php
===================================================================
--- mrbs/branches/linked_bookings/web/index.php 2013-02-05 16:40:50 UTC (rev 
2684)
+++ mrbs/branches/linked_bookings/web/index.php 2013-02-08 06:37:46 UTC (rev 
2685)
@@ -22,8 +22,10 @@
     $redirect_str = "day.php";
 }
 
-$redirect_str .= "?year=$year&month=$month&day=$day&area=$area&room=$room";
+$redirect_str .= "?year=$year&month=$month&day=$day&area=$area";
+if( $room_selected )
+  $redirect_str .= "&room=$room";
 
 header("Location: $redirect_str");
 
-?>
\ No newline at end of file
+?>

Modified: mrbs/branches/linked_bookings/web/lang/lang.de
===================================================================
--- mrbs/branches/linked_bookings/web/lang/lang.de      2013-02-05 16:40:50 UTC 
(rev 2684)
+++ mrbs/branches/linked_bookings/web/lang/lang.de      2013-02-08 06:37:46 UTC 
(rev 2685)
@@ -21,6 +21,7 @@
 $vocab["search"]             = "Suche";
 $vocab["not_php3"]           = "WARNUNG: Funktioniert warscheinlich nicht mit 
PHP3";
 $vocab["outstanding"]        = "ausstehende Einträge";
+$vocab["all_rooms"]          = "Alle Räume";
 
 // Used in day.php
 $vocab["bookingsfor"]        = "Einträge für";
@@ -137,6 +138,8 @@
 $vocab["more_info"]          = "Weitere Informationen";
 $vocab["remind_admin"]       = "Administrator erinnern";
 $vocab["series"]             = "Serie";
+$vocab["linked_entry"]       = "Verknüpfter Eintrag";
+$vocab["linked_with"]        = "Verknüpft mit:";
 $vocab["request_more_info"]  = "Bitte listen Sie die benötigten Informationen 
auf";
 $vocab["reject_reason"]      = "Bitte geben Sie den Grund für das Ablehnen der 
Reservierungsanfrage an";
 $vocab["send"]               = "Abschicken";

Modified: mrbs/branches/linked_bookings/web/lang/lang.en
===================================================================
--- mrbs/branches/linked_bookings/web/lang/lang.en      2013-02-05 16:40:50 UTC 
(rev 2684)
+++ mrbs/branches/linked_bookings/web/lang/lang.en      2013-02-08 06:37:46 UTC 
(rev 2685)
@@ -20,6 +20,7 @@
 $vocab["search"]             = "Search";
 $vocab["not_php3"]           = "WARNING: This probably doesn't work with PHP3";
 $vocab["outstanding"]        = "pending bookings";
+$vocab["all_rooms"]          = "All rooms";
 
 // Used in day.php
 $vocab["bookingsfor"]        = "Bookings for";

Modified: mrbs/branches/linked_bookings/web/month.php
===================================================================
--- mrbs/branches/linked_bookings/web/month.php 2013-02-05 16:40:50 UTC (rev 
2684)
+++ mrbs/branches/linked_bookings/web/month.php 2013-02-08 06:37:46 UTC (rev 
2685)
@@ -85,12 +85,12 @@
 // Show all available areas
 echo make_area_select_html('month.php', $area, $year, $month, $day);  
 // Show all available rooms in the current area:
-echo make_room_select_html('month.php', $area, $room, $year, $month, $day);
+echo make_room_select_html('month.php', $area, $room_selected ? $room : "", 
$year, $month, $day, true);
     
 // Draw the three month calendars
 if (!$display_calendar_bottom)
 {
-  minicals($year, $month, $day, $area, $room, 'month');
+  minicals($year, $month, $day, $area, $room_selected ? $room : "", 'month');
 }
 
 echo "</div>\n";
@@ -106,9 +106,10 @@
 }
 
 // Show Month, Year, Area, Room header:
+$this_page_title = $room_selected ? $this_area_name . $area_room_separator . 
$this_room_name : $this_area_name;
 echo "<div id=\"dwm\">\n";
 echo "<h2>" . utf8_strftime($strftime_format['monthyear'], $month_start)
-  . " - " . htmlspecialchars($this_area_name . $area_room_separator . 
$this_room_name) . "</h2>\n";
+  . " - " . htmlspecialchars($this_page_title) . "</h2>\n";
 echo "</div>\n";
 
 // Show Go to month before and after links
@@ -143,20 +144,21 @@
 }
 
 
+$room_link = $room_selected ? "&amp;room=$room" : "";
 $before_after_links_html = "<div class=\"screenonly\">
   <div class=\"date_nav\">
     <div class=\"date_before\">
-      <a 
href=\"month.php?year=$yy&amp;month=$ym&amp;day=$yd&amp;area=$area&amp;room=$room\">
+      <a 
href=\"month.php?year=$yy&amp;month=$ym&amp;day=$yd&amp;area=$area$room_link\">
           &lt;&lt;&nbsp;".get_vocab("monthbefore")."
         </a>
     </div>
     <div class=\"date_now\">
-      <a 
href=\"month.php?year=$cy&amp;month=$cm&amp;day=$cd&amp;area=$area&amp;room=$room\">
+      <a 
href=\"month.php?year=$cy&amp;month=$cm&amp;day=$cd&amp;area=$area$room_link\">
           ".get_vocab("gotothismonth")."
         </a>
     </div>
     <div class=\"date_after\">
-       <a 
href=\"month.php?year=$ty&amp;month=$tm&amp;day=$td&amp;area=$area&amp;room=$room\">
+       <a 
href=\"month.php?year=$ty&amp;month=$tm&amp;day=$td&amp;area=$area$room_link\">
           ".get_vocab("monthafter")."&nbsp;&gt;&gt;
         </a>
     </div>
@@ -184,13 +186,23 @@
 
 for ($day_num = 1; $day_num<=$days_in_month; $day_num++)
 {
-  $sql = "SELECT start_time, end_time, E.id, name, type,
-                 repeat_id, status, create_by
-            FROM $tbl_entry E, $tbl_room_entry RE
-           WHERE E.id = RE.entry_id
-             AND RE.room_id=$room
-             AND start_time <= $pm7[$day_num] AND end_time > $am7[$day_num]
-        ORDER BY start_time";
+  if( $room_selected ) {
+    $sql = "SELECT start_time, end_time, E.id, name, type,
+                   repeat_id, status, create_by, \"dummy\" AS room_name, 
room_id
+              FROM $tbl_entry E, $tbl_room_entry RE
+             WHERE E.id = RE.entry_id
+               AND RE.room_id=$room
+               AND start_time <= $pm7[$day_num] AND end_time > $am7[$day_num]
+               ORDER BY start_time";
+  } else {
+    $sql = "SELECT start_time, end_time, E.id, name, type,
+                   repeat_id, status, create_by, room_name, room_id
+              FROM $tbl_entry E, $tbl_room_entry RE, $tbl_room R
+             WHERE E.id = RE.entry_id
+               AND R.area_id=$area AND RE.room_id=R.id
+               AND start_time <= $pm7[$day_num] AND end_time > $am7[$day_num]
+          ORDER BY start_time, end_time, type, status, name, E.id, R.sort_key";
+  }
 
   // Build an array of information about each day in the month.
   // The information is stored as:
@@ -210,10 +222,6 @@
       if ($debug_flag)
       {
         echo "<br>DEBUG: result $i, id ".$row['id'].", starts 
".$row['start_time'].", ends ".$row['end_time']."\n";
-      }
-
-      if ($debug_flag)
-      {
         echo "<br>DEBUG: Entry ".$row['id']." day $day_num\n";
       }
       $d[$day_num]['id'][] = $row['id'];
@@ -248,6 +256,9 @@
         $d[$day_num]['status'][] = $row['status'] & ~STATUS_PRIVATE;  // Clear 
the private bit
         $d[$day_num]['shortdescrip'][] = htmlspecialchars($row['name']);
       }
+
+      $d[$day_num]["room"][] = htmlspecialchars($row['room_name']);
+      $d[$day_num]["room_id"][] = $row['room_id'];
       
 
       // Describe the start and end time, accounting for "all day"
@@ -413,7 +424,7 @@
     // If it's a Monday (the start of the ISO week), show the week number
     if ($view_week_number && (($weekcol + $weekstarts)%7 == 1))
     {
-      echo "<a class=\"week_number\" 
href=\"week.php?year=$year&amp;month=$month&amp;day=$cday&amp;area=$area&amp;room=$room\">";
+      echo "<a class=\"week_number\" 
href=\"week.php?year=$year&amp;month=$month&amp;day=$cday&amp;area=$area$room_link\">";
       echo date("W", gmmktime(12, 0, 0, $month, $cday, $year));
       echo "</a>\n";
     }
@@ -423,7 +434,7 @@
     echo "</div>\n";
     
     // then the link to make a new booking
-    $query_string = 
"room=$room&amp;area=$area&amp;year=$year&amp;month=$month&amp;day=$cday";
+    $query_string = 
"area=$area$room_link&amp;year=$year&amp;month=$month&amp;day=$cday";
     if ($enable_periods)
     {
       $query_string .= "&amp;period=0";
@@ -444,10 +455,36 @@
     if (isset($d[$cday]["id"][0]))
     {
       echo "<div class=\"booking_list\">\n";
+      $accumulate=false;
       $n = count($d[$cday]["id"]);
       // Show the start/stop times, 1 or 2 per line, linked to view_entry.
       for ($i = 0; $i < $n; $i++)
       {
+        if( !$accumulate ) {
+          // new booking
+          $rooms="";
+          $rooms_for_entry=array();
+        }
+        $rooms_for_entry[] = $d[$cday]["room_id"][$i];
+
+        if( !$room_selected ) {
+          // if no room was selected by the user, show an area overview.
+          if( $rooms != "" )
+            $rooms .= ", ";
+          $rooms .= $d[$cday]["room"][$i];
+
+          if(    $i < $n-1
+              && $d[$cday]["id"][$i] === $d[$cday]["id"][$i+1] ) {
+            // next booking has same id as the current booking, so it is 
+            // actually the same booking, just for another room. Simply 
+            // accumulate the parameters.
+            $accumulate=true;
+            continue;
+          } else {
+            $accumulate=false;
+          }
+        }
+
         // give the enclosing div the appropriate width: full width if both,
         // otherwise half-width (but use 49.9% to avoid rounding problems in 
some browsers)
         $class = $d[$cday]["color"][$i]; 
@@ -491,12 +528,21 @@
             echo "error: unknown parameter";
           }
         }
+        if( !$room_selected ) {
+          $display_text .= " (" . $rooms . ")";
+          $full_text .= " (" . $rooms . ")";
+        }
         echo "<a href=\"$booking_link\" title=\"$full_text\">";
         echo ($d[$cday]['is_repeat'][$i]) ? "<img class=\"repeat_symbol\" 
src=\"images/repeat.png\" alt=\"" . get_vocab("series") . "\" title=\"" . 
get_vocab("series") . "\" width=\"10\" height=\"10\">" : '';
         if (count($d[$cday]['linked'][$i]) > 1)
         {
-        echo "<img class=\"link_symbol\" src=\"images/link.png\" alt=\"" . 
get_vocab("linked_entry") . "\" title=\"" .
-             get_vocab("linked_with") . "\n" . implode("\n", 
get_full_room_names(array_diff($d[$cday]['linked'][$i], array($room)))) . "\" 
width=\"16\" height=\"16\">";
+          $rooms_not_shown = array_diff($d[$cday]['linked'][$i], 
$rooms_for_entry);
+          if( !empty($rooms_not_shown) )
+          {
+            // if the entry is linked to rooms not currently shown, display 
the link icon
+            echo "<img class=\"link_symbol\" src=\"images/link.png\" alt=\"" . 
get_vocab("linked_entry") . "\" title=\"" .
+               get_vocab("linked_with") . "\n" . implode("\n", 
get_full_room_names($rooms_not_shown)) . "\" width=\"16\" height=\"16\">";
+          }
         }
         echo "$display_text</a>\n";
         echo "</div>\n";
@@ -539,7 +585,7 @@
 // Draw the three month calendars
 if ($display_calendar_bottom)
 {
-  minicals($year, $month, $day, $area, $room, 'month');
+  minicals($year, $month, $day, $area, $room_selected ? $room : "", 'month');
 }
 
 output_trailer();

Modified: mrbs/branches/linked_bookings/web/standard_vars.inc.php
===================================================================
--- mrbs/branches/linked_bookings/web/standard_vars.inc.php     2013-02-05 
16:40:50 UTC (rev 2684)
+++ mrbs/branches/linked_bookings/web/standard_vars.inc.php     2013-02-08 
06:37:46 UTC (rev 2685)
@@ -17,9 +17,11 @@
   $area = get_default_area();
 }
 
+$room_selected = true;
 if (empty($room))
 {
   $room = get_default_room($area);
+  $room_selected = false;
 }
 
 // Get the settings (resolution, etc.) for this area
@@ -48,4 +50,4 @@
   }
 }
 
-?>
\ No newline at end of file
+?>

Modified: mrbs/branches/linked_bookings/web/trailer.inc
===================================================================
--- mrbs/branches/linked_bookings/web/trailer.inc       2013-02-05 16:40:50 UTC 
(rev 2684)
+++ mrbs/branches/linked_bookings/web/trailer.inc       2013-02-08 06:37:46 UTC 
(rev 2685)
@@ -4,7 +4,7 @@
 
 function generate_trailer()
 {
-  global $year, $month, $day, $area, $room;
+  global $year, $month, $day, $area, $room, $room_selected;
   global $strftime_format, $weekstarts, $simple_trailer, $view_week_number;
 
   $output = "";
@@ -32,7 +32,7 @@
   {
     $params = "&amp;area=$area";
   }
-  if (!empty($room))
+  if (!empty($room) && $room_selected)
   {
     $params .= "&amp;room=$room";
   }

Modified: mrbs/branches/linked_bookings/web/week.php
===================================================================
--- mrbs/branches/linked_bookings/web/week.php  2013-02-05 16:40:50 UTC (rev 
2684)
+++ mrbs/branches/linked_bookings/web/week.php  2013-02-08 06:37:46 UTC (rev 
2685)
@@ -32,7 +32,7 @@
 // Show all available areas
 echo make_area_select_html('week.php', $area, $year, $month, $day);   
 // Show all available rooms in the current area:
-echo make_room_select_html('week.php', $area, $room, $year, $month, $day);
+echo make_room_select_html('week.php', $area, $room, $year, $month, $day, 
false);
 
 // Draw the three month calendars
 if (!$display_calendar_bottom)
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to