Revision: 1451
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1451&view=rev
Author:   cimorrison
Date:     2010-09-15 09:02:05 +0000 (Wed, 15 Sep 2010)

Log Message:
-----------
Simplified code.  No functionality change.

Modified Paths:
--------------
    mrbs/branches/provisional_bookings_new_style/web/edit_entry_handler.php

Modified: 
mrbs/branches/provisional_bookings_new_style/web/edit_entry_handler.php
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/edit_entry_handler.php     
2010-09-14 16:04:51 UTC (rev 1450)
+++ mrbs/branches/provisional_bookings_new_style/web/edit_entry_handler.php     
2010-09-15 09:02:05 UTC (rev 1451)
@@ -503,8 +503,7 @@
     {
       $status |= STATUS_TENTATIVE;
     }
-
-    
+        
     if ($edit_type == "series")
     {
       $booking = mrbsCreateRepeatingEntrys($starttime,
@@ -521,51 +520,12 @@
                                            $status,
                                            $custom_fields);
       $new_id = $booking['id'];
-
-      // Send a mail to the Administrator
-      if ($need_to_send_mail)
-      {
-        require_once "functions_mail.inc";
-        // Send a mail only if this a new entry, or if this is an
-        // edited entry but we have to send mail on every change,
-        // and if mrbsCreateRepeatingEntrys is successful
-        if ( ( (isset($id) && $mail_settings['admin_all']) or !isset($id) ) &&
-             (0 != $new_id) )
-        {
-          // Get room name and area name. Would be better to avoid
-          // a database access just for that. Ran only if we need
-          // details
-          if ($mail_settings['details'])
-          {
-            $sql = "SELECT r.id AS room_id, r.room_name, r.area_id, 
a.area_name ";
-            $sql .= "FROM $tbl_room r, $tbl_area a ";
-            $sql .= "WHERE r.id=$room_id AND r.area_id = a.id";
-            $res = sql_query($sql);
-            $row = sql_row_keyed($res, 0);
-            $room_name = $row['room_name'];
-            $area_name = $row['area_name'];
-          }
-          // If this is a modified entry then call
-          // getPreviousEntryData to prepare entry comparison.
-          if (isset($id))
-          {
-            $mail_previous = getPreviousEntryData($repeat_id, TRUE);
-          }
-          $result = notifyAdminOnBooking(!isset($id), $new_id, 
$booking['series']);
-        }
-      }
+      $is_repeat_table = $booking['series'];
     }
     else
     {
       // Mark changed entry in a series with entry_type 2:
-      if ($repeat_id > 0)
-      {
-        $entry_type = 2;
-      }
-      else
-      {
-        $entry_type = 0;
-      }
+      $entry_type = ($repeat_id > 0) ? 2 : 0;
 
       // Create the entry:
       $new_id = mrbsCreateSingleEntry($starttime,
@@ -579,39 +539,49 @@
                                       $description,
                                       $status,
                                       $custom_fields);
-
-      // Send a mail to the Administrator
-      if ($need_to_send_mail)
+      $is_repeat_table = FALSE;
+    }
+    
+    // Send a mail to the Administrator
+    if ($need_to_send_mail)
+    {
+      // Send a mail only if this a new entry, or if this is an
+      // edited entry but we have to send mail on every change,
+      // and if the entry creation is successful
+      if ( ( (isset($id) && $mail_settings['admin_all']) or !isset($id) ) &&
+           (0 != $new_id) )
       {
         require_once "functions_mail.inc";
-        // Send a mail only if this a new entry, or if this is an
-        // edited entry but we have to send mail on every change,
-        // and if mrbsCreateRepeatingEntrys is successful
-        if ( ( (isset($id) && $mail_settings['admin_all']) or !isset($id) ) && 
(0 != $new_id) )
+        // Get room name and area name. Would be better to avoid
+        // a database access just for that. Ran only if we need
+        // details
+        if ($mail_settings['details'])
         {
-          // Get room name and are name. Would be better to avoid
-          // a database access just for that. Ran only if we need
-          // details.
-          if ($mail_settings['details'])
+          $sql = "SELECT r.id AS room_id, r.room_name, r.area_id, a.area_name 
";
+          $sql .= "FROM $tbl_room r, $tbl_area a ";
+          $sql .= "WHERE r.id=$room_id AND r.area_id = a.id";
+          $res = sql_query($sql);
+          $row = sql_row_keyed($res, 0);
+          $room_name = $row['room_name'];
+          $area_name = $row['area_name'];
+        }
+        // If this is a modified entry then call
+        // getPreviousEntryData to prepare entry comparison.
+        if (isset($id))
+        {
+          if ($edit_type == "series")
           {
-            $sql = "SELECT r.id AS room_id, r.room_name, r.area_id, 
a.area_name ";
-            $sql .= "FROM $tbl_room r, $tbl_area a ";
-            $sql .= "WHERE r.id=$room_id AND r.area_id = a.id";
-            $res = sql_query($sql);
-            $row = sql_row_keyed($res, 0);
-            $room_name = $row['room_name'];
-            $area_name = $row['area_name'];
+            $mail_previous = getPreviousEntryData($repeat_id, TRUE);
           }
-          // If this is a modified entry then call
-          // getPreviousEntryData to prepare entry comparison.
-          if (isset($id))
+          else
           {
             $mail_previous = getPreviousEntryData($id, FALSE);
           }
-          $result = notifyAdminOnBooking(!isset($id), $new_id, ($edit_type == 
"series"));
         }
+        // Send the email
+        $result = notifyAdminOnBooking(!isset($id), $new_id, $is_repeat_table);
       }
-    }
+    }   
   } // end foreach $rooms
 
   // Delete the original entry


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to