Revision: 2617
          https://sourceforge.net/p/mrbs/code/2617/
Author:   cimorrison
Date:     2012-12-27 15:38:31 +0000 (Thu, 27 Dec 2012)
Log Message:
-----------
Made viewentry work with the new tables

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

Modified: mrbs/branches/linked_bookings/web/mrbs_sql.inc
===================================================================
--- mrbs/branches/linked_bookings/web/mrbs_sql.inc      2012-12-27 11:46:42 UTC 
(rev 2616)
+++ mrbs/branches/linked_bookings/web/mrbs_sql.inc      2012-12-27 15:38:31 UTC 
(rev 2617)
@@ -1099,6 +1099,7 @@
 function mrbsGetBookingInfo($id, $series, $silent=FALSE)
 {
   global $tbl_entry, $tbl_repeat, $tbl_room, $tbl_area;
+  global $tbl_room_repeat, $tbl_room_entry;
 
   // Check that we've got an id
   if (!isset($id))
@@ -1114,7 +1115,10 @@
     }
   }
 
-  $table = ($series) ? $tbl_repeat : $tbl_entry;
+  $table          = ($series) ? $tbl_repeat      : $tbl_entry;
+  $junction_table = ($series) ? $tbl_room_repeat : $tbl_room_entry;
+  $junction_id    = ($series) ? 'repeat_id'      : 'entry_id';
+  
   $table_fields = sql_field_info($table);
 
   // Build an array of the field names in the repeat table so that
@@ -1126,7 +1130,8 @@
     $rep_fields[$field['name']] = 1;
   }
 
-  $terms = array("M.room_name",
+  $terms = array("J.room_id",
+                 "M.room_name",
                  "M.room_admin_email",
                  "M.area_id",
                  "A.area_name",
@@ -1140,6 +1145,12 @@
   {
     switch ($field['name'])
     {
+      // This is just a temporary measure while we're still developing the
+      // code to use the new junction tables.   It can be removed as soon as
+      // we have removed the room_id columns from the entry and repeat tables
+      case 'room_id':
+        break;
+        
       // these fields only exist in the entry table
       case 'entry_type':
       case 'repeat_id':
@@ -1181,8 +1192,9 @@
   }
   
   $sql = "SELECT " . implode(", ",$terms)."
-            FROM $table T, $tbl_room M, $tbl_area A
-           WHERE T.room_id = M.id
+            FROM $table T, $tbl_room M, $tbl_area A, $junction_table J
+           WHERE T.id=J.$junction_id
+             AND J.room_id = M.id
              AND M.area_id = A.id
              AND T.id=$id";
 
------------------------------------------------------------------------------
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