Revision: 2614
          https://sourceforge.net/p/mrbs/code/2614/
Author:   cimorrison
Date:     2012-12-27 10:05:00 +0000 (Thu, 27 Dec 2012)
Log Message:
-----------
Made new bookings work with the new tables (linked bookings not yet implemented)

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 09:19:15 UTC 
(rev 2613)
+++ mrbs/branches/linked_bookings/web/mrbs_sql.inc      2012-12-27 10:05:00 UTC 
(rev 2614)
@@ -469,6 +469,7 @@
 function mrbsCreateEntry($table, $data)
 {
   global $standard_fields, $db_tbl_prefix;
+  global $tbl_entry, $tbl_room_entry, $tbl_room_repeat;
   
   $sql_col = array();
   $sql_val = array();
@@ -483,6 +484,10 @@
     {
       switch ($key)
       {
+        // fields to ignore
+        case 'room_id':  // We'll do something else later
+          break;
+          
         // integers
         case 'start_time':
         case 'end_time':
@@ -491,7 +496,6 @@
         case 'rep_type':
         case 'month_absolute':
         case 'end_date':
-        case 'room_id':
         case 'status':
         case 'ical_sequence':
           $sql_col[] = $key;
@@ -569,6 +573,7 @@
     } // if
   } // foreach
   
+  sql_begin();
   // Note that we don't have to escape or quote the fieldname
   // thanks to the restriction on custom field names
   $sql = "INSERT INTO $table (" . implode(', ',$sql_col) . ") VALUES (" . 
implode(', ',$sql_val) . ")";
@@ -580,7 +585,25 @@
     fatal_error(TRUE, get_vocab("fatal_db_error"));
   }
 
-  return sql_insert_id($table, "id");
+  $id = sql_insert_id($table, "id");
+  
+  if ($table == $tbl_entry)
+  {
+    $sql = "INSERT INTO $tbl_room_entry (room_id, entry_id) 
VALUES(${data['room_id']}, $id)";
+  }
+  else
+  {
+    $sql = "INSERT INTO $tbl_room_repeat (room_id, repeat_id) 
VALUES(${data['room_id']}, $id)";
+  }
+  if (sql_command($sql) < 0)
+  {
+    trigger_error(sql_error(), E_USER_WARNING);
+    fatal_error(TRUE, get_vocab("fatal_db_error"));
+  }
+  
+  sql_commit();
+  
+  return $id;
 }
 
 /** mrbsCreateSingleEntry()
------------------------------------------------------------------------------
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