Revision: 2179
          http://mrbs.svn.sourceforge.net/mrbs/?rev=2179&view=rev
Author:   cimorrison
Date:     2011-11-21 03:41:22 +0000 (Mon, 21 Nov 2011)
Log Message:
-----------
Disabled dragging on multi-day bookings except for extending the start and end 
times

Modified Paths:
--------------
    mrbs/trunk/web/Themes/default/header.inc
    mrbs/trunk/web/functions_table.inc

Modified: mrbs/trunk/web/Themes/default/header.inc
===================================================================
--- mrbs/trunk/web/Themes/default/header.inc    2011-11-19 04:02:59 UTC (rev 
2178)
+++ mrbs/trunk/web/Themes/default/header.inc    2011-11-21 03:41:22 UTC (rev 
2179)
@@ -2225,8 +2225,16 @@
                 }
               }  <?php // divResizeStop ?>
             
-            
-              var handles = 'all';
+              <?php
+              // Get the set of directions in which we are allowed to drag the
+              // box.   At this stage we will do it by reference to the axes.
+              // Then later we will turn it into n/s/e/w handles (this will 
depend
+              // on $times_along_top
+              ?>  
+              var directions = {timesPlus: true,
+                                timesMinus: true,
+                                otherPlus: true,
+                                otherMinus: true};
               if ($(this).hasClass('series'))
               {
                 <?php
@@ -2235,7 +2243,8 @@
                 // series dragged across days to make it a new daily series, 
or rooms
                 // to create new bookings in other rooms.
                 ?>
-                handles = '<?php echo ($times_along_top) ? "e,w" : "n,s" ?>';
+                directions.otherPlus = false;
+                directions.otherMinus = false;
               }
               <?php
               if (!$is_admin)
@@ -2248,11 +2257,62 @@
                   // aren't allowed to select multiple rooms, then we want to 
restrict
                   // the handles we offer them so that they can't get that far.
                   ?>
-                  handles = '<?php echo ($times_along_top) ? "e,w" : "n,s" ?>';
+                  directions.otherPlus = false;
+                  directions.otherMinus = false;
                   <?php
                 }
               }
+              // Don't allow multiday bookings to be moved at the end
+              // which is joined to another day nor along the other axis
               ?>
+              if ($(this).hasClass('multiday_start'))
+              {
+                directions.timesMinus = false;
+                directions.otherPlus = false;
+                directions.otherMinus = false;
+              }
+              if ($(this).hasClass('multiday_end'))
+              {
+                directions.timesPlus = false;
+                directions.otherPlus = false;
+                directions.otherMinus = false;
+              }
+              <?php
+              // Now turn the directions in which we are allowed to move the 
+              // boxes into an array of n/s/e/w handles, depending on the
+              // setting of $times_along_top
+              ?>
+              var aHandles = [];
+              if (directions.timesPlus)
+              {
+                aHandles.push('<?php echo ($times_along_top) ? "e" : "s" ?>');
+              }
+              if (directions.timesMinus)
+              {
+                aHandles.push('<?php echo ($times_along_top) ? "w" : "n" ?>');
+              }
+              if (directions.otherPlus)
+              {
+                aHandles.push('<?php echo ($times_along_top) ? "s" : "e" ?>');
+              }
+              if (directions.otherMinus)
+              {
+                aHandles.push('<?php echo ($times_along_top) ? "n" : "w" ?>');
+              }
+              <?php
+              // Test each corner.  If we've got both the side handles then
+              // add in the corner handle
+              ?>
+              var corners = ['nw', 'ne', 'se', 'sw'];
+              for (var i=0; i<corners.length; i++)
+              {
+                if ((aHandles.indexOf(corners[i][0]) >= 0) &&
+                    (aHandles.indexOf(corners[i][1]) >= 0))
+                {
+                  aHandles.push(corners[i]);
+                }
+              }
+              var handles = aHandles.join(',');
               var divBooking = $(this).children('div');
               var divClone = divBooking.clone();
               divBooking.css('visibility', 'hidden');
@@ -2266,11 +2326,14 @@
                       .addClass('clone')
                       .width(divBooking.outerWidth())
                       .height(divBooking.outerHeight())
-                      .resizable({handles: handles,
-                                  resize: divResize,
-                                  start: divResizeStart,
-                                  stop: divResizeStop})
-                      .appendTo($(this));
+              if (handles)
+              {
+                divClone.resizable({handles: handles,
+                                    resize: divResize,
+                                    start: divResizeStart,
+                                    stop: divResizeStop});
+              }
+              divClone.appendTo($(this));
               $(this).css('background-color', 'transparent')
                      .wrapInner('<div style="position: relative"><\/div>');
             });

Modified: mrbs/trunk/web/functions_table.inc
===================================================================
--- mrbs/trunk/web/functions_table.inc  2011-11-19 04:02:59 UTC (rev 2178)
+++ mrbs/trunk/web/functions_table.inc  2011-11-21 03:41:22 UTC (rev 2179)
@@ -29,6 +29,10 @@
   // It looks like:
   //     $column[Time][n][id]
   //                     [is_repeat]
+  //                     [is_multiday_start]  a boolean indicating if the 
booking stretches
+  //                                          beyond the day start
+  //                     [is_multiday_end]    a boolean indicating if the 
booking stretches
+  //                                          beyond the day end
   //                     [color]
   //                     [data]
   //                     [long_descr]
@@ -88,6 +92,9 @@
     $row['status'] &= ~STATUS_PRIVATE;  // Clear the private bit
   }
 
+  $is_multiday_start = ($row['start_time'] < $am7);
+  $is_multiday_end = ($row['end_time'] > ($pm7 + $resolution));
+              
   $start_t = max(round_t_down($row['start_time'], $resolution, $am7), $am7);
   $end_t = min(round_t_up($row['end_time'], $resolution, $am7) - $resolution, 
$pm7);
   // calculate the times used for indexing
@@ -109,6 +116,8 @@
     // fill in the id, type and start time
     $column[$time_t][$n]["id"] = $row['entry_id'];
     $column[$time_t][$n]["is_repeat"] = !empty($row['repeat_id']);
+    $column[$time_t][$n]["is_multiday_start"] = $is_multiday_start;
+    $column[$time_t][$n]["is_multiday_end"] = $is_multiday_end;
     $column[$time_t][$n]["status"] = $row['status'];
     $column[$time_t][$n]["color"] = $row['type'];
     $column[$time_t][$n]["start_time"] = utf8_strftime(hour_min_format(), 
$row['start_time']);
@@ -249,6 +258,8 @@
   // 
   // $cell[n][id]
   //         [is_repeat]
+  //         [is_multiday_start]
+  //         [is_multiday_end]
   //         [color]
   //         [data]
   //         [long_descr]
@@ -308,12 +319,14 @@
                                             // and (b) each stripe is at least 
1 unit high
     for ($n=0; $n<$n_bookings; $n++)
     {
-      $id         = $cell[$n]["id"];
-      $is_repeat  = $cell[$n]["is_repeat"];
-      $status     = $cell[$n]["status"];
-      $color      = $cell[$n]["color"];
-      $descr      = htmlspecialchars($cell[$n]["data"]);
-      $long_descr = htmlspecialchars($cell[$n]["long_descr"]);
+      $id          = $cell[$n]["id"];
+      $is_repeat   = $cell[$n]["is_repeat"];
+      $is_multiday_start = $cell[$n]["is_multiday_start"];
+      $is_multiday_end   = $cell[$n]["is_multiday_end"];
+      $status      = $cell[$n]["status"];
+      $color       = $cell[$n]["color"];
+      $descr       = htmlspecialchars($cell[$n]["data"]);
+      $long_descr  = htmlspecialchars($cell[$n]["long_descr"]);
       $class = $color;
       if ($status & STATUS_PRIVATE)
       {
@@ -327,6 +340,15 @@
       {
         $class .= " tentative";
       }
+      if ($is_multiday_start)
+      {
+        $class .= " multiday_start";
+      }
+      if ($is_multiday_end)
+      {
+        $class .= " multiday_end";
+      }
+
       $html .= "<tr>\n";
       $html .= "<td class=\"$class\"" .
                (($n==0) ? " style=\"border-top-width: 0\"" : "") .   // no 
border for first row
@@ -357,12 +379,14 @@
     $html .= "<tbody>\n";
     for ($n=0; $n<$n_bookings; $n++)
     {
-      $id         = $cell[$n]["id"];
-      $is_repeat  = $cell[$n]["is_repeat"];
-      $status     = $cell[$n]["status"];
-      $color      = $cell[$n]["color"];
-      $descr      = htmlspecialchars($cell[$n]["start_time"] . " " . 
$cell[$n]["data"]);
-      $long_descr = htmlspecialchars($cell[$n]["long_descr"]);
+      $id          = $cell[$n]["id"];
+      $is_repeat   = $cell[$n]["is_repeat"];
+      $is_multiday_start = $cell[$n]["is_multiday_start"];
+      $is_multiday_end   = $cell[$n]["is_multiday_end"];
+      $status      = $cell[$n]["status"];
+      $color       = $cell[$n]["color"];
+      $descr       = htmlspecialchars($cell[$n]["start_time"] . " " . 
$cell[$n]["data"]);
+      $long_descr  = htmlspecialchars($cell[$n]["long_descr"]);
       $class = $color;
       if ($status & STATUS_PRIVATE)
       {
@@ -375,7 +399,15 @@
       if ($confirmation_enabled && ($status & STATUS_TENTATIVE))
       {
         $class .= " tentative";
-      }    
+      }
+      if ($is_multiday_start)
+      {
+        $class .= " multiday_start";
+      }
+      if ($is_multiday_end)
+      {
+        $class .= " multiday_end";
+      }
       $html .= "<tr>\n";
       $html .= "<td class=\"$class\"" .
                (($n==0) ? " style=\"border-top-width: 0\"" : "") .   // no 
border for first row
@@ -403,6 +435,8 @@
     {       
       $id         = $cell[0]["id"];
       $is_repeat  = $cell[0]["is_repeat"];
+      $is_multiday_start = $cell[0]["is_multiday_start"];
+      $is_multiday_end   = $cell[0]["is_multiday_end"];
       $status     = $cell[0]["status"];
       $color      = $cell[0]["color"];
       $descr      = htmlspecialchars($cell[0]["data"]);
@@ -434,6 +468,14 @@
       {
         $c .= " tentative";
       }
+      if ($is_multiday_start)
+      {
+        $c .= " multiday_start";
+      }
+      if ($is_multiday_end)
+      {
+        $c .= " multiday_end";
+      }
       // Add a class to bookings that this user is allowed to edit so that the
       // JavaScript can turn them into resizable bookings
       if (getWritable($cell[0]['create_by'], $user, $cell[0]['room_id']))

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


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to