Revision: 1061
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1061&view=rev
Author:   cimorrison
Date:     2009-03-22 17:01:52 +0000 (Sun, 22 Mar 2009)

Log Message:
-----------
Improved handling of conflicts in edit_entry to allow for easy addition of more 
booking policies (at present there is only one, a limit on the number of 
bookings).

Modified Paths:
--------------
    mrbs/trunk/web/edit_entry_handler.php
    mrbs/trunk/web/lang.en

Modified: mrbs/trunk/web/edit_entry_handler.php
===================================================================
--- mrbs/trunk/web/edit_entry_handler.php       2009-03-22 15:22:19 UTC (rev 
1060)
+++ mrbs/trunk/web/edit_entry_handler.php       2009-03-22 17:01:52 UTC (rev 
1061)
@@ -362,10 +362,14 @@
 {
   fatal_error(1, get_vocab("failed_to_acquire"));
 }
-    
+
+// Validate the booking for (a) conflicting bookings and (b) conformance to 
rules
+$valid_booking = TRUE;
+$conflicts = "";          // Holds a list of all the conflicts (ideally this 
would be an array)
+$rules_broken = array();  // Holds an array of the rules that have been broken
+ 
 // Check for any schedule conflicts in each room we're going to try and
 // book in
-$err = "";
 foreach ( $rooms as $room_id )
 {
   if ($rep_type != 0 && !empty($reps))
@@ -387,26 +391,32 @@
 
         if (!empty($tmp))
         {
-          $err = $err . $tmp;
+          $valid_booking = FALSE;
+          $conflicts .= $tmp;
         }
       }
     }
     else
     {
-      $err        .= get_vocab("too_may_entrys") . "\n";
-      $hide_title  = 1;
+      $valid_booking = FALSE;
+      $rules_broken[] = get_vocab("too_may_entrys");
     }
   }
   else
   {
-    $err .= mrbsCheckFree($room_id, $starttime, $endtime-1, $ignore_id, 0);
+    $tmp .= mrbsCheckFree($room_id, $starttime, $endtime-1, $ignore_id, 0);
+    if (!empty($tmp))
+      {
+        $valid_booking = FALSE;
+        $conflicts .= $tmp;
+      }
   }
 
 } // end foreach rooms
 
 
 // If the rooms were free, go ahead an process the bookings
-if (empty($err))
+if ($valid_booking)
 {
   foreach ( $rooms as $room_id )
   {
@@ -533,23 +543,30 @@
 // The room was not free.
 sql_mutex_unlock("$tbl_entry");
 
-if (strlen($err))
+if (!$valid_booking)
 {
   print_header($day, $month, $year, $area, isset($room) ? $room : "");
     
   echo "<h2>" . get_vocab("sched_conflict") . "</h2>\n";
-  if (!isset($hide_title))
+  if (!empty($rules_broken))
   {
     echo "<p>\n";
-    echo get_vocab("conflict").":\n";
+    echo get_vocab("rules_broken") . ":\n";
     echo "</p>\n";
     echo "<ul>\n";
+    foreach ($rules_broken as $rule)
+    {
+      echo "<li>$rule</li>\n";
+    }
+    echo "</ul>\n";
   }
-
-  echo $err;
-    
-  if(!isset($hide_title))
+  if (!empty($conflicts))
   {
+    echo "<p>\n";
+    echo get_vocab("conflict").":\n";
+    echo "</p>\n";
+    echo "<ul>\n";
+    echo $conflicts;
     echo "</ul>\n";
   }
 }

Modified: mrbs/trunk/web/lang.en
===================================================================
--- mrbs/trunk/web/lang.en      2009-03-22 15:22:19 UTC (rev 1060)
+++ mrbs/trunk/web/lang.en      2009-03-22 17:01:52 UTC (rev 1061)
@@ -107,7 +107,8 @@
 // Used in edit_entry_handler.php
 $vocab["error"]              = "Error";
 $vocab["sched_conflict"]     = "Scheduling Conflict";
-$vocab["conflict"]           = "The new booking will conflict with the 
following entry(s)";
+$vocab["conflict"]           = "The new booking will conflict with the 
following entries";
+$vocab["rules_broken"]       = "The new booking will conflict with the 
following policies";
 $vocab["too_may_entrys"]     = "The selected options will create too many 
entries.<br>Please use different options!";
 $vocab["returncal"]          = "Return to calendar view";
 $vocab["failed_to_acquire"]  = "Failed to acquire exclusive database access";


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

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to