Changeset:
        3c54790d1ca3
        
https://sourceforge.net/p/mrbs/hg-code/ci/3c54790d1ca3c1c55fa8d279a4cf59169c309496
Author:
        Campbell Morrison <cimorri...@hg.code.sf.net>
Date:
        Mon Apr 03 18:47:38 2017 +0100
Log message:

Added a basic time grid - no labels yet.

diffstat:

 web/css/mrbs.css.php |  26 ++++++++++++++++++++++----
 web/index.php        |  44 +++++++++++++++++++++++++++++++++++---------
 2 files changed, 57 insertions(+), 13 deletions(-)

diffs (142 lines):

diff -r ea8fb568b958 -r 3c54790d1ca3 web/css/mrbs.css.php
--- a/web/css/mrbs.css.php      Mon Apr 03 17:17:38 2017 +0100
+++ b/web/css/mrbs.css.php      Mon Apr 03 18:47:38 2017 +0100
@@ -1437,7 +1437,7 @@
   padding: 0;
 }
 
-.main_view_data {
+.main_view_data, .grid {
   width: 100%;
   table-layout: fixed;
 }
@@ -1461,6 +1461,7 @@
 .main_view a, .main_view .grid span {
   display: block;
   width: 100%;
+  box-sizing: border-box;
   white-space: nowrap;
   padding: 0.1em 0.2em;
 }
@@ -1472,7 +1473,6 @@
 ?>
 .main_view_data a {
   border-right: 1px solid <?php echo $body_background_color ?>;
-  box-sizing: border-box;
 }
 
 .main_view_data td:last-child a,
@@ -1492,10 +1492,28 @@
   position: absolute;
   top: 0;
   left: 0;
-  width: 100%;
-  border: 1px solid red;
 }
 
 .main_view .grid td {
   border-top-color: transparent;
 }
+
+.grid span {
+  border-left: 1px dotted #788d9c;
+}
+
+.week .grid span,
+.month .grid span {
+  border-left-width: 0;
+}
+
+.grid .first_slot_of_day span {
+  border-left: 1px dotted #788d9c;
+}
+
+.grid td:first-child span {
+  border-left-width: 0;
+}
+
+
+
diff -r ea8fb568b958 -r 3c54790d1ca3 web/index.php
--- a/web/index.php     Mon Apr 03 17:17:38 2017 +0100
+++ b/web/index.php     Mon Apr 03 18:47:38 2017 +0100
@@ -297,21 +297,47 @@
 }
 
 
-function get_grid($map)
+function get_grid($area, $interval)
 {
   $html = '';
   
   $html .= "<table class=\"grid\">\n";
   
-  $slots = array_keys(current($map));
-  $n_rooms = count($map);
+  // First get all the slots in this interval
+  $date = new DateTime();
+  $date->setTimestamp($interval['start']);
+  
+  $days = array();
+  
+  do {
+    $j = $date->format('j');  // day, no leading zero
+    $n = $date->format('n');  // month, no leading zero
+    $Y = $date->format('Y');  // year, four digits
+    
+    $days[] = get_slot_starts($n, $j, $Y);
+    $date->modify('+1 day');
+  } while (get_end_last_slot($n, $j, $Y) < $interval['end']);
 
+  // Get the number of rooms
+  $rooms = get_rooms($area);
+  $n_rooms = count($rooms);
+  
   for ($i=0; $i<$n_rooms; $i++)
   {
     $html .= "<tr>\n";
-    foreach ($slots as $slot)
+    foreach ($days as $day)
     {
-      $html .= "<td><span>&nbsp;</span></td>\n";
+      $first_slot = true;
+      foreach ($day as $slot)
+      {
+        $html .= "<td";
+        if ($first_slot)
+        {
+          $html .= " class=\"first_slot_of_day\"";
+          $first_slot = false;
+        }
+        $html .= "><span>&nbsp;</span></td>\n";
+      }
     }
     $html .= "</tr>\n";
   }
@@ -322,16 +348,16 @@
 }
 
 
-function get_table($map)
+function get_table($map, $area, $interval, $view)
 {
   $html = '';
   
   // We use nested tables so that we can get set the column width exactly for
   // the main data.
-  $html .= "<table class=\"main_view\">\n";
+  $html .= "<table class=\"main_view $view\">\n";
   $html .= "<tr>\n";
   $html .= "<td>" . get_row_labels_table($map) . "</td>\n";
-  $html .= "<td class=\"data\">" . get_row_data_table($map) . get_grid($map) . 
" </td>\n";
+  $html .= "<td class=\"data\">" . get_row_data_table($map) . get_grid($area, 
$interval) . " </td>\n";
   $html .= "</tr>\n";
   $html .= "</table>\n";
   
@@ -364,5 +390,5 @@
 }
 
 echo "</div>\n";
-echo get_table($map);
+echo get_table($map, $area, $interval, $view);
 output_trailer();

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
Mrbs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to