Revision: 2645
          https://sourceforge.net/p/mrbs/code/2645/
Author:   cimorrison
Date:     2013-01-17 12:41:29 +0000 (Thu, 17 Jan 2013)
Log Message:
-----------
Made the week view work with linked bookings

Modified Paths:
--------------
    mrbs/branches/linked_bookings/web/functions_table.inc

Modified: mrbs/branches/linked_bookings/web/functions_table.inc
===================================================================
--- mrbs/branches/linked_bookings/web/functions_table.inc       2013-01-17 
12:04:47 UTC (rev 2644)
+++ mrbs/branches/linked_bookings/web/functions_table.inc       2013-01-17 
12:41:29 UTC (rev 2645)
@@ -1099,6 +1099,40 @@
   }
   unset($j);  // Just so that we pick up any accidental attempt to use it later
 
+  // First of all get an array showing which entries are linked, ie span
+  // more than one room.   We can confine the query to the start and end
+  // times, because any linked booking will have the same start and end times.
+  // However we will get entries for all areas because in the future we hope
+  // to be able to have bookings linked across areas.  (But we don't include
+  // linked entries in disabled rooms or areas.  If we did it would be 
confusing
+  // to the user to see a linked booking covering two rooms, one of which is
+  // disabled.   The booking would show as linked in the calendar view, but
+  // when they look at view_entry they'd only see one room.   So we exclude the
+  // disabled rooms and areas - and if they edit the booking a new booking will
+  // be made leaving the rest of the linked booking in the disabled room as a
+  // separate booking).
+  $sql = "SELECT entry_id, COUNT(*) AS n_linked
+            FROM $tbl_room_entry RE, $tbl_entry E, $tbl_room R, $tbl_area A
+           WHERE E.id = RE.entry_id
+             AND RE.room_id = R.id
+             AND R.area_id = A.id
+             AND R.disabled = 0
+             AND A.disabled = 0
+             AND start_time <= ${pm7[$num_of_days - 1]} AND end_time > $am7[0]
+        GROUP BY entry_id";
+  
+  $res = sql_query($sql);
+  if ($res === FALSE)
+  {
+    trigger_error(sql_error(), E_USER_WARNING);
+    fatal_error(FALSE, get_vocab("fatal_db_error"));
+  }
+  $linked_entries = array();
+  for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
+  {
+    $linked_entries[$row['entry_id']] = $row['n_linked'];
+  }
+  
   // Get all appointments for this week in the room that we care about.
   //
   // row['room_id'] = Room ID
@@ -1144,6 +1178,8 @@
     {
       for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
       {
+        // Add in the number of entries that are linked
+        $row['n_linked'] = $linked_entries[$row['entry_id']];
         map_add_booking($row, $week_map[$room][$j], $am7[$j], $pm7[$j]);
       }
     }
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to