Revision: 2620
          https://sourceforge.net/p/mrbs/code/2620/
Author:   cimorrison
Date:     2012-12-29 20:05:32 +0000 (Sat, 29 Dec 2012)
Log Message:
-----------
Made edit_entry_handler.php and email notifications work with new tables

Modified Paths:
--------------
    mrbs/branches/linked_bookings/web/edit_entry_handler.php
    mrbs/branches/linked_bookings/web/functions_mail.inc

Modified: mrbs/branches/linked_bookings/web/edit_entry_handler.php
===================================================================
--- mrbs/branches/linked_bookings/web/edit_entry_handler.php    2012-12-29 
20:03:15 UTC (rev 2619)
+++ mrbs/branches/linked_bookings/web/edit_entry_handler.php    2012-12-29 
20:05:32 UTC (rev 2620)
@@ -357,7 +357,10 @@
 {
   // Editing an existing booking: get the room_id from the database (you can't
   // get it from $rooms because they are the new rooms)
-  $target_room = sql_query1("SELECT room_id FROM $tbl_entry WHERE id=$id LIMIT 
1");
+  $target_room = sql_query1("SELECT room_id
+                               FROM $tbl_room_entry
+                              WHERE entry_id=$id
+                              LIMIT 1");
   if ($target_room < 0)
   {
     trigger_error(sql_error(), E_USER_WARNING);

Modified: mrbs/branches/linked_bookings/web/functions_mail.inc
===================================================================
--- mrbs/branches/linked_bookings/web/functions_mail.inc        2012-12-29 
20:03:15 UTC (rev 2619)
+++ mrbs/branches/linked_bookings/web/functions_mail.inc        2012-12-29 
20:05:32 UTC (rev 2620)
@@ -245,25 +245,21 @@
 // Returns an empty string in the case of an error
 function get_area_admin_email($id, $series=FALSE)
 {
-  global $tbl_room, $tbl_area, $tbl_entry, $tbl_repeat;
+  global $tbl_room, $tbl_area, $tbl_room_entry, $tbl_room_repeat;
   
-  $id_table = ($series) ? "rep" : "e";
+  $sql  = "SELECT A.area_admin_email
+             FROM $tbl_room R, $tbl_area A, " .
+                  (($series) ? "$tbl_room_repeat" : "$tbl_room_entry") . " J
+            WHERE " . (($series) ? "J.repeat_id" : "J.entry_id") . "=$id
+              AND R.id=J.room_id
+              AND A.id=R.area_id
+            LIMIT 1";
+            
+  $email = sql_query1($sql);
   
-  $sql = "SELECT a.area_admin_email ";
-  $sql .= "FROM $tbl_room r, $tbl_area a, $tbl_entry e ";
-  // If this is a repeating entry...
-  if ($id_table == 'rep')
-  {
-    // ...use the repeat table
-    $sql .= ", $tbl_repeat rep ";
-  }
-  $sql .= "WHERE ${id_table}.id=$id 
-             AND r.id=${id_table}.room_id
-             AND a.id=r.area_id
-           LIMIT 1";
-  $email = sql_query1($sql);
   if ($email == -1)
   {
+    trigger_error(sql_error(), E_USER_NOTICE);
     $email = "";
   }
   return $email;
@@ -275,24 +271,20 @@
 // Returns an empty string in the case of an error
 function get_room_admin_email($id, $series=FALSE)
 {
-  global $tbl_room, $tbl_entry, $tbl_repeat;
+  global $tbl_room, $tbl_room_entry, $tbl_room_repeat;
   
-  $id_table = ($series) ? "rep" : "e";
+  $sql  = "SELECT R.room_admin_email
+             FROM $tbl_room R, " .
+                  (($series) ? "$tbl_room_repeat" : "$tbl_room_entry") . " J
+            WHERE " . (($series) ? "J.repeat_id" : "J.entry_id") . "=$id
+              AND R.id=J.room_id
+            LIMIT 1";
+            
+  $email = sql_query1($sql);
   
-  $sql = "SELECT r.room_admin_email ";
-  $sql .= "FROM $tbl_room r, $tbl_entry e ";
-  // If this is a repeating entry...
-  if ($id_table == 'rep')
-  {
-    // ...use the repeat table
-    $sql .= ", $tbl_repeat rep ";
-  }
-  $sql .= "WHERE ${id_table}.id=$id 
-             AND r.id=${id_table}.room_id
-           LIMIT 1";
-  $email = sql_query1($sql);
   if ($email == -1)
   {
+    trigger_error(sql_error(), E_USER_NOTICE);
     $email = "";
   }
   return $email;
------------------------------------------------------------------------------
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. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122912
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to