Revision: 1051
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1051&view=rev
Author:   cimorrison
Date:     2009-03-18 19:14:51 +0000 (Wed, 18 Mar 2009)

Log Message:
-----------
Made the timeslot settings (resolution, default_duration, morningstarts, 
morningstarts_minutes, eveningends and eveningends_minutes) per-area settings 
with the values being held in the area table of the database.   Default values 
are taken from the config file.   The area values can be edited from the 
edit_area_room.php page.   At this stage period settings have not been moved to 
a per-area basis, but could be in the future, as could other config variables 
such as timezone.

Modified Paths:
--------------
    mrbs/trunk/tables.my.sql
    mrbs/trunk/web/config.inc.php
    mrbs/trunk/web/day.php
    mrbs/trunk/web/dbsys.inc
    mrbs/trunk/web/edit_area_room.php
    mrbs/trunk/web/edit_entry.php
    mrbs/trunk/web/edit_entry_handler.php
    mrbs/trunk/web/functions.inc
    mrbs/trunk/web/lang.en
    mrbs/trunk/web/month.php
    mrbs/trunk/web/mrbs-ielte6.css
    mrbs/trunk/web/mrbs.css.php
    mrbs/trunk/web/week.php

Added Paths:
-----------
    mrbs/trunk/web/upgrade/2/
    mrbs/trunk/web/upgrade/2/mysql.sql
    mrbs/trunk/web/upgrade/2/pgsql.sql
    mrbs/trunk/web/upgrade/2/post.inc

Modified: mrbs/trunk/tables.my.sql
===================================================================
--- mrbs/trunk/tables.my.sql    2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/tables.my.sql    2009-03-18 19:14:51 UTC (rev 1051)
@@ -11,9 +11,15 @@
 
 CREATE TABLE mrbs_area
 (
-  id               int NOT NULL auto_increment,
-  area_name        varchar(30),
-  area_admin_email text,
+  id                    int NOT NULL auto_increment,
+  area_name             varchar(30),
+  area_admin_email      text,
+  resolution            int,
+  default_duration      int,
+  morningstarts         int,
+  morningstarts_minutes int,
+  eveningends           int,
+  eveningends_minutes   int,
 
   PRIMARY KEY (id)
 );

Modified: mrbs/trunk/web/config.inc.php
===================================================================
--- mrbs/trunk/web/config.inc.php       2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/web/config.inc.php       2009-03-18 19:14:51 UTC (rev 1051)
@@ -103,12 +103,23 @@
 // $eveningends_minutes and $twentyfourhour_format are ignored.
 $enable_periods = FALSE;
 
+// This is the maximum number of rows (timeslots or periods) that one can 
expect to see in the day
+// and week views.    It is used by mrbs.css.php for creating classes.    It 
does not matter if it
+// is too large, except for the fact that more CSS than necessary will be 
generated.
+$max_slots = 60;
+
+// TIMES SETTINGS
+// --------------
+
+// NOTE:  The "Times" settings can all be configured per area.    These are the
+// default settings to be used.   The "Times" settings are ignored if 
$enable_periods
+// is TRUE.
+
 // Resolution - what blocks can be booked, in seconds.
 // Default is half an hour: 1800 seconds.
-$resolution = 1800;
+$resolution = (30 * 60);
 
 // Default duration - default length (in seconds) of a booking.
-// Ignored if $enable_periods is TRUE
 // Defaults to (60 * 60) seconds, i.e. an hour
 $default_duration = (60 * 60);
 
@@ -140,7 +151,11 @@
 // eveningends_minutes=45; and resolution=900.
 
 
+// PERIODS SETTINGS
+// ----------------
 
+// The "Periods" settings are ignored if $enable_periods is FALSE.
+
 // Define the name or description for your periods in chronological order
 // For example:
 // $periods[] = "Period 1"
@@ -164,6 +179,10 @@
 $periods[] = "Period 2";
 // NOTE:  The maximum number of periods is 60.   Do not define more than this.
 
+
+// CHECKING
+// --------
+
 // Do some checking
 if ($enable_periods)
 {
@@ -183,6 +202,13 @@
   }
 }
 
+/******************
+ * Display settings
+ ******************/
+
+// [These are all variables that control the appearance of pages and could in 
time
+//  become per-user settings]
+
 // Start of week: 0 for Sunday, 1 for Monday, etc.
 $weekstarts = 0;
 
@@ -206,16 +232,6 @@
 // in 24 hour format
 $twentyfourhour_format = 1;
 
-/************************
- * Miscellaneous settings
- ************************/
-
-// Maximum repeating entrys (max needed +1):
-$max_rep_entrys = 365 + 1;
-
-// Default report span in days:
-$default_report_days = 60;
-
 // Results per page for searching:
 $search["count"] = 20;
 
@@ -244,6 +260,27 @@
 // To display times on right side in day and week view, set to TRUE;
 $times_right_side = FALSE;
 
+// Define default starting view (month, week or day)
+// Default is day
+$default_view = "day";
+
+// Define default room to start with (used by index.php)
+// Room numbers can be determined by looking at the Edit or Delete URL for a
+// room on the admin page.
+// Default is 0
+$default_room = 0;
+
+
+/************************
+ * Miscellaneous settings
+ ************************/
+
+// Maximum repeating entrys (max needed +1):
+$max_rep_entrys = 365 + 1;
+
+// Default report span in days:
+$default_report_days = 60;
+
 // Control the active cursor in day/week/month views.   By default, 
highlighting
 // is implemented using the CSS :hover pseudo-class.    For old browers such as
 // IE6, this is not supported and MRBS will automatically switch over to use 
@@ -259,16 +296,7 @@
                               // JavaScript highlighting is used anyway.    
The rest of the time CSS
                               // highlighting is used, whether or not 
$javascript_cursor is set.
 
-// Define default starting view (month, week or day)
-// Default is day
-$default_view = "day";
 
-// Define default room to start with (used by index.php)
-// Room numbers can be determined by looking at the Edit or Delete URL for a
-// room on the admin page.
-// Default is 0
-$default_room = 0;
-
 /***********************************************
  * Authentication settings - read AUTHENTICATION
  ***********************************************/

Modified: mrbs/trunk/web/day.php
===================================================================
--- mrbs/trunk/web/day.php      2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/web/day.php      2009-03-18 19:14:51 UTC (rev 1051)
@@ -23,6 +23,15 @@
   $debug_flag = 0;
 }
 
+if (empty($area))
+{
+  $area = get_default_area();
+}
+
+// Get the timeslot settings (resolution, etc.) for this area
+get_area_settings($area);
+
+
 // If we don't know the right date then use today:
 if (!isset($day) or !isset($month) or !isset($year))
 {
@@ -46,11 +55,6 @@
   }
 }
 
-if (empty($area))
-{
-  $area = get_default_area();
-}
-
 // form the room parameter for use in query strings.    We want to preserve 
room information
 // if possible when switching between views
 if (empty($room))

Modified: mrbs/trunk/web/dbsys.inc
===================================================================
--- mrbs/trunk/web/dbsys.inc    2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/web/dbsys.inc    2009-03-18 19:14:51 UTC (rev 1051)
@@ -15,7 +15,7 @@
 $tbl_variables = $db_tbl_prefix . "variables";
 
 
-$db_schema_version = 1;
+$db_schema_version = 2;
 
 
 // Include the abstraction configured to be used for the default MRBS

Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php   2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/web/edit_area_room.php   2009-03-18 19:14:51 UTC (rev 1051)
@@ -19,6 +19,15 @@
 $capacity = get_form_var('capacity', 'int');
 $room_admin_email = get_form_var('room_admin_email', 'string');
 $area_admin_email = get_form_var('area_admin_email', 'string');
+$area_morningstarts = get_form_var('area_morningstarts', 'int');
+$area_morningstarts_minutes = get_form_var('area_morningstarts_minutes', 
'int');
+$area_morning_ampm = get_form_var('area_morning_ampm', 'string');
+$area_res_mins = get_form_var('area_res_mins', 'int');
+$area_def_duration_mins = get_form_var('area_def_duration_mins', 'int');
+$area_eveningends = get_form_var('area_eveningends', 'int');
+$area_eveningends_minutes = get_form_var('area_eveningends_minutes', 'int');
+$area_evening_ampm = get_form_var('area_evening_ampm', 'string');
+$area_eveningends_t = get_form_var('area_eveningends_t', 'int');
 $change_done = get_form_var('change_done', 'string');
 $change_room = get_form_var('change_room', 'string');
 $change_area = get_form_var('change_area', 'string');
@@ -31,6 +40,38 @@
   $year  = date("Y");
 }
 
+if (isset($area_eveningends_t))
+{
+  // if we've been given a time in minutes rather than hours and minutes, 
convert it
+  // (this will happen if JavaScript is enabled)
+  $area_eveningends_minutes = $area_eveningends_t % 60;
+  $area_eveningends = ($area_eveningends_t - $area_eveningends_minutes)/60;
+}
+
+if (!empty($area_morning_ampm))
+{
+  if (($area_morning_ampm == "pm") && ($area_morningstarts < 12))
+  {
+    $area_morningstarts += 12;
+  }
+  if (($area_morning_ampm == "am") && ($area_morningstarts > 11))
+  {
+    $area_morningstarts -= 12;
+  }
+}
+
+if (!empty($area_evening_ampm))
+{
+  if (($area_evening_ampm == "pm") && ($area_eveningends < 12))
+  {
+    $area_eveningends += 12;
+  }
+  if (($area_evening_ampm == "am") && ($area_eveningends > 11))
+  {
+    $area_eveningends -= 12;
+  }
+}
+
 if (!getAuthorised(2))
 {
   showAccessDenied($day, $month, $year, $area, "");
@@ -98,7 +139,7 @@
   sql_free($res);
 ?>
 
-<form class="form_edit_area_room" action="edit_area_room.php" method="post">
+<form class="form_general" action="edit_area_room.php" method="post">
   <fieldset class="admin">
   <legend><?php echo get_vocab("editroom") ?></legend>
   
@@ -133,8 +174,12 @@
     
     <fieldset class="submit_buttons">
     <legend></legend>
-      <input type="submit" name="change_room" value="<?php echo 
get_vocab("change") ?>">
-      <input type="submit" name="change_done" value="<?php echo 
get_vocab("backadmin") ?>">
+      <div id="edit_area_room_submit_back">
+        <input class="submit" type="submit" name="change_done" value="<?php 
echo get_vocab("backadmin") ?>">
+      </div>
+      <div id="edit_area_room_submit_save">
+        <input class="submit" type="submit" name="change_room" value="<?php 
echo get_vocab("change") ?>">
+      </div>
     </fieldset>
     
   </fieldset>
@@ -147,51 +192,85 @@
 <?php
 if (!empty($area))
 {
-  require_once 'Mail/RFC822.php';
-  (!isset($area_admin_email)) ? $area_admin_email = '': '';
-  $emails = explode(',', $area_admin_email);
   $valid_email = TRUE;
-  $email_validator = new Mail_RFC822();
-  foreach ($emails as $email)
+  $valid_resolution = TRUE;
+  
+  if (isset($change_area))  // we're on the second pass through
   {
-    // if no email address is entered, this is OK, even if isValidInetAddress
-    // does not return TRUE
-    if ( !$email_validator->isValidInetAddress($email, $strict = FALSE)
-         && ('' != $area_admin_email) )
+    // validate email addresses
+    require_once 'Mail/RFC822.php';
+    (!isset($area_admin_email)) ? $area_admin_email = '': '';
+    $emails = explode(',', $area_admin_email);
+    $email_validator = new Mail_RFC822();
+    foreach ($emails as $email)
     {
-      $valid_email = FALSE;
+      // if no email address is entered, this is OK, even if isValidInetAddress
+      // does not return TRUE
+      if ( !$email_validator->isValidInetAddress($email, $strict = FALSE)
+           && ('' != $area_admin_email) )
+      {
+        $valid_email = FALSE;
+      }
     }
-  }
-  //
-  if ( isset($change_area) && (FALSE != $valid_email) )
-  {
-    $sql = "UPDATE $tbl_area SET area_name='" . addslashes($area_name)
-      . "', area_admin_email='" . addslashes($area_admin_email)
-      . "' WHERE id=$area";
-    if (sql_command($sql) < 0)
+    //
+    
+    // Check morningstarts, eveningends, and resolution for consistency
+    $start_first_slot = ($area_morningstarts*60) + 
$area_morningstarts_minutes;   // minutes
+    $start_last_slot  = ($area_eveningends*60) + $area_eveningends_minutes;    
   // minutes
+    $start_difference = ($start_last_slot - $start_first_slot);         // 
minutes
+    if (($start_difference < 0) or ($start_difference%$area_res_mins != 0))
     {
-      fatal_error(0, get_vocab("update_area_failed") . sql_error());
+      $valid_resolution = FALSE;
     }
-  }
+    
+    // If everything is OK, update the database
+    if ((FALSE != $valid_email) && (FALSE != $valid_resolution))
+    {
+      $sql = "UPDATE $tbl_area SET area_name='" . addslashes($area_name)
+        . "', area_admin_email='" . addslashes($area_admin_email)
+        . "', resolution=" . $area_res_mins * 60
+        . ", default_duration=" . $area_def_duration_mins * 60
+        . ", morningstarts=" . $area_morningstarts
+        . ", morningstarts_minutes=" . $area_morningstarts_minutes
+        . ", eveningends=" . $area_eveningends
+        . ", eveningends_minutes=" . $area_eveningends_minutes
+        . " WHERE id=$area";
+      if (sql_command($sql) < 0)
+      {
+        fatal_error(0, get_vocab("update_area_failed") . sql_error());
+      }
+    }
+  }  // if isset($change_area)
 
-  $res = sql_query("SELECT * FROM $tbl_area WHERE id=$area");
+  $res = sql_query("SELECT * FROM $tbl_area WHERE id=$area LIMIT 1");
   if (! $res)
   {
     fatal_error(0, get_vocab("error_area") . $area . get_vocab("not_found"));
   }
   $row = sql_row_keyed($res, 0);
   sql_free($res);
+  // Get the settings for this area, from the database if they are there, 
otherwise from
+  // the config file.    A little bit inefficient repeating the SQL query
+  // we've just done, but it makes the code simpler and this page is not used 
very often.
+  get_area_settings($area);
 ?>
 
-<form class="form_edit_area_room" action="edit_area_room.php" method="post">
+<form class="form_general" action="edit_area_room.php" method="post">
   <fieldset class="admin">
   <legend><?php echo get_vocab("editarea") ?></legend>
   
     <fieldset>
     <legend></legend>
-      <span class="error">
-         <?php echo ((FALSE == $valid_email) ? get_vocab('invalid_email') : 
"&nbsp;"); ?>
-      </span>
+      <?php
+      if (FALSE == $valid_email)
+      {
+        echo "<p class=\"error\">" .get_vocab('invalid_email') . "</p>\n";
+      }
+      if (FALSE == $valid_resolution)
+      {
+        echo "<p class=\"error\">" .get_vocab('invalid_resolution') . "</p>\n";
+      }
+      ?>
     </fieldset>
   
     <input type="hidden" name="area" value="<?php echo $row["id"]?>">
@@ -206,10 +285,221 @@
     <input type="text" id="area_admin_email" name="area_admin_email" 
maxlength="75" value="<?php echo htmlspecialchars($row["area_admin_email"]); 
?>">
     </div>
     
+    <?php
+    if (!$enable_periods)
+    {
+    ?>
+      <script type="text/javascript">
+      //<![CDATA[
+      
+        function getTimeString(time, twentyfourhour_format)
+        {
+           // Converts a time (in minutes since midnight) into a string
+           // of the form hh:mm if twentyfourhour_format is true,
+           // otherwise of the form hh:mm am/pm.
+           
+           // This function doesn't do a great job of replicating the PHP
+           // internationalised format, but is probably sufficient for a 
+           // rarely used admin page.
+           
+           var minutes = time % 60;
+           time -= minutes;
+           var hour = time/60;
+           if (!twentyfourhour_format)
+           {
+             var ap = "AM";
+             if (hour > 11) {ap = "PM";}
+             if (hour > 12) {hour = hour - 12;}
+             if (hour == 0) {hour = 12;}
+           }
+           if (hour < 10) {hour   = "0" + hour;}
+           if (minutes < 10) {minutes = "0" + minutes;}
+           var timeString = hour + ':' + minutes;
+           if (!twentyfourhour_format)
+           {
+             timeString += ap;
+           }
+           return timeString;
+        } // function getTimeString()
+
+        
+        function writeSelect(morningstarts, morningstarts_minutes, 
eveningends, eveningends_minutes, res_mins)
+        {
+          // generates the HTML for the drop-down for the last slot time and
+          // puts it in the element with id 'last_slot'
+          var first_slot = (morningstarts * 60) + morningstarts_minutes;
+          var last_slot = (eveningends * 60) + eveningends_minutes;
+          var last_possible = (24 * 60) - res_mins;
+          var html = '<label for="area_eveningends_t"><?php echo 
get_vocab("area_last_slot_start")?>:<\/label>\n';
+          html += '<select id="area_eveningends_t" 
name="area_eveningends_t">\n';
+          for (var t=first_slot; t <= last_possible; t += res_mins)
+          {
+            html += '<option value="' + t + '"';
+            if (t == last_slot)
+            {
+              html += ' selected="selected"';
+            }
+            html += ">" + getTimeString(t, <?php echo ($twentyfourhour_format 
? "true" : "false") ?>) + "<\/option>\n";
+          }
+          html += "<\/select>\n";
+          document.getElementById('last_slot').innerHTML = html;
+        }  // function writeSelect
+        
+      
+        function changeSelect(formObj)
+        {
+          // re-generates the dropdown given changed form values
+          var res_mins = +formObj.area_res_mins.value;
+          var morningstarts = +formObj.area_morningstarts.value;
+          var morningstarts_minutes = 
+formObj.area_morningstarts_minutes.value;
+          var eveningends_t = +formObj.area_eveningends_t.value;
+          var morningstarts_t = (morningstarts * 60) + morningstarts_minutes;
+          var ampm = "am";
+          if (formObj.area_morning_ampm && 
formObj.area_morning_ampm[1].checked)
+          {
+            ampm = "pm";
+          }        
+          if (<?php echo (!$twentyfourhour_format ? "true" : "false") ?>)
+          {
+            if ((ampm == "pm") && (morningstarts < 12))
+            {
+              morningstarts += 12;
+            }
+            if ((ampm == "am") && (morningstarts>11))
+            {
+              morningstarts -= 12;
+            }
+          }
+          // Find valid values for eveningends
+          var remainder = (eveningends_t - morningstarts_t) % res_mins;
+          // round up to the nearest slot boundary
+          if (remainder != 0)
+          {
+            eveningends_t += res_mins - remainder;
+          }
+          // and then step back to make sure that the end of the slot isn't 
past midnight (and the beginning isn't before the morning start)
+          while ((eveningends_t + res_mins > 1440) && (eveningends_t > 
morningstarts_t + res_mins))  // 1440 minutes in a day
+          {
+            eveningends_t -= res_mins;
+          }
+          // convert into hours and minutes
+          var eveningends_minutes = eveningends_t % 60;
+          var eveningends = (eveningends_t - eveningends_minutes) / 60;
+          writeSelect (morningstarts, morningstarts_minutes, eveningends, 
eveningends_minutes, res_mins);
+        } // function changeSelect
+        
+      //]]>
+      </script>
+      
+      <div class="div_time">
+        <label><?php echo get_vocab("area_first_slot_start")?>:</label>
+        <?php
+        echo "<input class=\"time_hour\" type=\"text\" 
id=\"area_morningstarts\" name=\"area_morningstarts\" value=\"";
+        if ($twentyfourhour_format)
+        {
+          printf("%02d", $morningstarts);
+        }
+        elseif ($morningstarts > 12)
+        {
+          echo ($morningstarts - 12);
+        } 
+        elseif ($morningstarts == 0)
+        {
+          echo "12";
+        }
+        else
+        {
+          echo $morningstarts;
+        } 
+        echo "\" maxlength=\"2\" onChange=\"changeSelect(this.form)\">\n";
+        ?>
+        <span>:</span>
+        <input class="time_minute" type="text" id="area_morningstarts_minutes" 
name="area_morningstarts_minutes" value="<?php printf("%02d", 
$morningstarts_minutes) ?>" maxlength="2" onChange="changeSelect(this.form)">
+        <?php
+        if (!$twentyfourhour_format)
+        {
+          echo "<div class=\"group ampm\">\n";
+          $checked = ($morningstarts < 12) ? "checked=\"checked\"" : "";
+          echo "      <label><input name=\"area_morning_ampm\" type=\"radio\" 
value=\"am\" onChange=\"changeSelect(this.form)\" $checked>" . 
utf8_strftime("%p",mktime(1,0,0,1,1,2000)) . "</label>\n";
+          $checked = ($morningstarts >= 12) ? "checked=\"checked\"" : "";
+          echo "      <label><input name=\"area_morning_ampm\" type=\"radio\" 
value=\"pm\" onChange=\"changeSelect(this.form)\" $checked>". 
utf8_strftime("%p",mktime(13,0,0,1,1,2000)) . "</label>\n";
+          echo "</div>\n";
+        }
+        ?>
+      </div>
+      
+      <div class="div_dur_mins">
+      <label for="area_res_mins"><?php echo get_vocab("area_res_mins") 
?>:</label>
+      <input type="text" id="area_res_mins" name="area_res_mins" value="<?php 
echo $resolution/60 ?>" onChange="changeSelect(this.form)">
+      </div>
+      
+      <div class="div_dur_mins">
+      <label for="area_def_duration_mins"><?php echo 
get_vocab("area_def_duration_mins") ?>:</label>
+      <input type="text" id="area_def_duration_mins" 
name="area_def_duration_mins" value="<?php echo $default_duration/60 ?>">
+      </div>
+      <?php
+      echo "<div id=\"last_slot\">\n";
+      // The contents of this div will be overwritten by JavaScript if 
enabled.    The JavaScript version is a drop-down
+      // select input with options limited to those times for the last slot 
start that are valid.   The options are
+      // dynamically regenerated if the start of the first slot or the 
resolution change.    The code below is
+      // therefore an alternative for non-JavaScript browsers.
+      echo "<div class=\"div_time\">\n";
+        echo "<label>" . get_vocab("area_last_slot_start") . ":</label>\n";
+        echo "<input class=\"time_hour\" type=\"text\" id=\"area_eveningends\" 
name=\"area_eveningends\" value=\"";
+        if ($twentyfourhour_format)
+        {
+          printf("%02d", $eveningends);
+        }
+        elseif ($eveningends > 12)
+        {
+          echo ($eveningends - 12);
+        } 
+        elseif ($eveningends == 0)
+        {
+          echo "12";
+        }
+        else
+        {
+          echo $eveningends;
+        } 
+        echo "\" maxlength=\"2\" onChange=\"changeSelect(this.form)\">\n";
+
+        echo "<span>:</span>\n";
+        echo "<input class=\"time_minute\" type=\"text\" 
id=\"area_eveningends_minutes\" name=\"area_eveningends_minutes\" value=\""; 
+        printf("%02d", $eveningends_minutes);
+        echo "\" maxlength=\"2\" onChange=\"changeSelect(this.form)\">\n";
+        if (!$twentyfourhour_format)
+        {
+          echo "<div class=\"group ampm\">\n";
+          $checked = ($eveningends < 12) ? "checked=\"checked\"" : "";
+          echo "      <label><input name=\"area_evening_ampm\" type=\"radio\" 
value=\"am\" onChange=\"changeSelect(this.form)\" $checked>" . 
utf8_strftime("%p",mktime(1,0,0,1,1,2000)) . "</label>\n";
+          $checked = ($eveningends >= 12) ? "checked=\"checked\"" : "";
+          echo "      <label><input name=\"area_evening_ampm\" type=\"radio\" 
value=\"pm\" onChange=\"changeSelect(this.form)\" $checked>". 
utf8_strftime("%p",mktime(13,0,0,1,1,2000)) . "</label>\n";
+          echo "</div>\n";
+        }
+      echo "</div>\n";  
+      echo "</div>\n";  // last_slot
+      ?>
+      
+      <script type="text/javascript">
+      //<![CDATA[
+        writeSelect(<?php echo "$morningstarts, $morningstarts_minutes, 
$eveningends, $eveningends_minutes, $resolution/60" ?>);
+      //]]>
+      </script>
+      
+      <?php
+    }
+    
+    ?>
+    
     <fieldset class="submit_buttons">
     <legend></legend>
-      <input type="submit" name="change_area" value="<?php echo 
get_vocab("change") ?>">
-      <input type="submit" name="change_done" value="<?php echo 
get_vocab("backadmin") ?>">
+      <div id="edit_area_room_submit_back">
+        <input class="submit" type="submit" name="change_done" value="<?php 
echo get_vocab("backadmin") ?>">
+      </div>
+      <div id="edit_area_room_submit_save">
+        <input class="submit" type="submit" name="change_area" value="<?php 
echo get_vocab("change") ?>">
+      </div>
     </fieldset>
     
   </fieldset>

Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php       2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/web/edit_entry.php       2009-03-18 19:14:51 UTC (rev 1051)
@@ -23,6 +23,14 @@
 $edit_type = get_form_var('edit_type', 'string');
 $returl = get_form_var('returl', 'string');
 
+if (empty($area))
+{
+  $area = get_default_area();
+}
+
+// Get the timeslot settings (resolution, etc.) for this area
+get_area_settings($area);
+
 // If we dont know the right date then make it up
 if (!isset($day) or !isset($month) or !isset($year))
 {
@@ -30,10 +38,7 @@
   $month = date("m");
   $year  = date("Y");
 }
-if (empty($area))
-{
-  $area = get_default_area();
-}
+
 if (!isset($edit_type))
 {
   $edit_type = "";
@@ -450,15 +455,15 @@
     if(! $enable_periods ) 
     { 
     ?>
-      <div id="div_time">
+      <div class="div_time">
         <label><?php echo get_vocab("time")?>:</label>
-        <input id="time_hour" name="hour" value="<?php if 
(!$twentyfourhour_format && ($start_hour > 12)){ echo ($start_hour - 12);} else 
{ echo $start_hour;} ?>" maxlength="2">
+        <input class="time_hour" name="hour" value="<?php if 
(!$twentyfourhour_format && ($start_hour > 12)){ echo ($start_hour - 12);} else 
{ echo $start_hour;} ?>" maxlength="2">
         <span>:</span>
-        <input id="time_minute" name="minute" value="<?php echo $start_min;?>" 
maxlength="2">
+        <input class="time_minute" name="minute" value="<?php echo 
$start_min;?>" maxlength="2">
         <?php
         if (!$twentyfourhour_format)
         {
-          echo "<div class=\"group\" id=\"ampm\">\n";
+          echo "<div class=\"group ampm\">\n";
           $checked = ($start_hour < 12) ? "checked=\"checked\"" : "";
           echo "      <label><input name=\"ampm\" type=\"radio\" value=\"am\" 
$checked>" . utf8_strftime("%p",mktime(1,0,0,1,1,2000)) . "</label>\n";
           $checked = ($start_hour >= 12) ? "checked=\"checked\"" : "";

Modified: mrbs/trunk/web/edit_entry_handler.php
===================================================================
--- mrbs/trunk/web/edit_entry_handler.php       2009-03-16 16:10:55 UTC (rev 
1050)
+++ mrbs/trunk/web/edit_entry_handler.php       2009-03-18 19:14:51 UTC (rev 
1051)
@@ -38,6 +38,15 @@
 $rep_day = get_form_var('rep_day', 'array'); // array of bools
 $rep_num_weeks = get_form_var('rep_num_weeks', 'int');
 
+if (empty($area))
+{
+  $area = get_default_area();
+}
+
+// Get the timeslot settings (resolution, etc.) for this area
+get_area_settings($area);
+
+
 // When $all_day is set, the hour and minute (or $period) fields are set to 
disabled, which means 
 // that they are not passed through by the form.   We need to set them because 
they are needed below  
 // in various places. (We could change the JavaScript in edit_entry.php to set 
the fields to readonly
@@ -66,11 +75,6 @@
   $year  = date("Y");
 }
 
-if (empty($area))
-{
-  $area = get_default_area();
-}
-
 // Set up the return URL.    As the user has tried to book a particular room 
and a particular
 // day, we must consider these to be the new "sticky room" and "sticky day", 
so modify the 
 // return URL accordingly.

Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc        2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/web/functions.inc        2009-03-18 19:14:51 UTC (rev 1051)
@@ -527,6 +527,32 @@
   return ($room < 0 ? 0 : $room);
 }
 
+// Update the default timeslot settings with the ones specific to this area
+function get_area_settings($area)
+{
+  global $tbl_area;
+  global $resolution, $default_duration, $morningstarts, 
$morningstarts_minutes, $eveningends, $eveningends_minutes;
+  $sql = "SELECT *
+          FROM $tbl_area 
+          WHERE id=$area 
+          LIMIT 1";
+  $res = sql_query($sql);
+  if (!$res || (sql_count($res) == 0))
+  {
+    return;
+  }
+  else
+  {
+    $row = sql_row_keyed($res, 0);
+    $resolution = (isset($row['resolution']) ? $row['resolution'] : 
$resolution);
+    $default_duration = (isset($row['default_duration']) ? 
$row['default_duration'] : $default_duration);
+    $morningstarts = (isset($row['morningstarts']) ? $row['morningstarts'] : 
$morningstarts);
+    $morningstarts_minutes = (isset($row['morningstarts_minutes']) ? 
$row['morningstarts_minutes'] : $morningstarts_minutes);
+    $eveningends = (isset($row['eveningends']) ? $row['eveningends'] : 
$eveningends);
+    $eveningends_minutes = (isset($row['eveningends_minutes']) ? 
$row['eveningends_minutes'] : $eveningends_minutes);
+  }
+}
+
 // Get the local day name based on language. Note 2000-01-02 is a Sunday.
 function day_name($daynumber)
 {

Modified: mrbs/trunk/web/lang.en
===================================================================
--- mrbs/trunk/web/lang.en      2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/web/lang.en      2009-03-18 19:14:51 UTC (rev 1051)
@@ -234,19 +234,24 @@
 $vocab["administration"]     = "Administration";
 
 // Used in edit_area_room.php
-$vocab["editarea"]           = "Edit Area";
-$vocab["change"]             = "Change";
-$vocab["backadmin"]          = "Back to Admin";
-$vocab["editroomarea"]       = "Edit Area or Room Description";
-$vocab["editroom"]           = "Edit Room";
-$vocab["update_room_failed"] = "Update room failed: ";
-$vocab["error_room"]         = "Error: room ";
-$vocab["not_found"]          = " not found";
-$vocab["update_area_failed"] = "Update area failed: ";
-$vocab["error_area"]         = "Error: area ";
-$vocab["room_admin_email"]   = "Room admin email";
-$vocab["area_admin_email"]   = "Area admin email";
-$vocab["invalid_email"]      = "Invalid email!";
+$vocab["editarea"]               = "Edit Area";
+$vocab["change"]                 = "Change";
+$vocab["backadmin"]              = "Back to Admin";
+$vocab["editroomarea"]           = "Edit Area or Room Description";
+$vocab["editroom"]               = "Edit Room";
+$vocab["update_room_failed"]     = "Update room failed: ";
+$vocab["error_room"]             = "Error: room ";
+$vocab["not_found"]              = " not found";
+$vocab["update_area_failed"]     = "Update area failed: ";
+$vocab["error_area"]             = "Error: area ";
+$vocab["room_admin_email"]       = "Room admin email";
+$vocab["area_admin_email"]       = "Area admin email";
+$vocab["area_first_slot_start"]  = "Start of first slot";
+$vocab["area_last_slot_start"]   = "Start of last slot";
+$vocab["area_res_mins"]          = "Resolution (minutes)";
+$vocab["area_def_duration_mins"] = "Default duration (minutes)";
+$vocab["invalid_email"]          = "Invalid email!";
+$vocab["invalid_resolution"]     = "Invalid combination of first slot, last 
slot and resolution!";
 
 // Used in edit_users.php
 $vocab["name_empty"]         = "You must enter a name.";

Modified: mrbs/trunk/web/month.php
===================================================================
--- mrbs/trunk/web/month.php    2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/web/month.php    2009-03-18 19:14:51 UTC (rev 1051)
@@ -38,6 +38,14 @@
   $debug_flag = 0;
 }
 
+if (empty($area))
+{
+  $area = get_default_area();
+}
+
+// Get the timeslot settings (resolution, etc.) for this area
+get_area_settings($area);
+
 // If we don't know the right date then use today:
 if (!isset($day) or !isset($month) or !isset($year))
 {
@@ -65,10 +73,6 @@
 // print the page header
 print_header($day, $month, $year, $area, isset($room) ? $room : "");
 
-if (empty($area))
-{
-  $area = get_default_area();
-}
 if (empty($room))
 {
   $room = get_default_room($area);

Modified: mrbs/trunk/web/mrbs-ielte6.css
===================================================================
--- mrbs/trunk/web/mrbs-ielte6.css      2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/web/mrbs-ielte6.css      2009-03-18 19:14:51 UTC (rev 1051)
@@ -22,9 +22,6 @@
 .minimized div.mini {display: none}   /* Ignore the minimized class and always 
display the maxi table */
 .minimized div.maxi {display: block}
 
-/* ------------ EDIT_AREA_ROOM.PHP ------------------*/
-.form_edit_area_room label {height: 2.0em}   /* min-height not recognised by 
IE6 and below */
-
 /* ------------ EDIT_USERS.PHP ----------------------*/
 #form_edit_users label {height: 2.0em}       /* min-height not recognised by 
IE6 and below */
 

Modified: mrbs/trunk/web/mrbs.css.php
===================================================================
--- mrbs/trunk/web/mrbs.css.php 2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/web/mrbs.css.php 2009-03-18 19:14:51 UTC (rev 1051)
@@ -346,19 +346,8 @@
 
 if ($clipped)
 {
-  // find the max. number of slots in a day
-  if ($enable_periods)
+  for ($i=1; $i<=$max_slots; $i++) 
   {
-    $n_slots = count($periods);    // if we're using periods it's just the 
number of periods
-  }
-  else
-  {
-    $n_slots = ($eveningends*60) + $eveningends_minutes;
-    $n_slots = $n_slots - (($morningstarts*60) + $morningstarts_minutes);  // 
day duration in minutes
-    $n_slots = (($n_slots*60)/$resolution) + 1;                            // 
number of slots
-  }
-  for ($i=1; $i<=$n_slots; $i++) 
-  {
     $div_height = $main_cell_height * $i;
     $div_height = $div_height + (($i-1)*$main_table_cell_border_width);
     $div_height = (int) $div_height;    // Make absolutely sure it's an int to 
avoid generating invalid CSS
@@ -411,43 +400,11 @@
 #del_room_confirm_links span:hover {text-decoration: underline}    /* for 
Firefox */
 
 
-/* ------------ EDIT_AREA_ROOM.PHP ------------------*/
-<?php
-// Ideally the label text will fit on a single line, but as the text
-// is editable in the lang.* files and there are so many translations, we 
cannot
-// be sure how long the longest line will be.    Once you've chosen your 
preferred language and you can see what it looks like,
-// you may want to adjust the width of the label below so that the longest 
label just fits on one line.  
 
-$edit_area_room_label_width       = '11.0';    // em
-$edit_area_room_input_margin_left = '1.0';
-$edit_area_room_input_width       = $admin_form_input_width;
-$edit_area_room_width_overheads   = '1.0';     // borders around inputs etc.   
 Konqueror seems to be the most extreme
-$edit_area_room_form_width        = $edit_area_room_label_width + 
$edit_area_room_input_margin_left + $edit_area_room_input_width + 
$edit_area_room_width_overheads;
-$edit_area_room_form_width        = number_format($edit_area_room_form_width, 
1, '.', '');   // get rid of any commas
-      
-?>
-form.form_edit_area_room {
-    position: relative; width: <?php echo $edit_area_room_form_width ?>em;
-    margin-top: 2em; margin-bottom: 2em; margin-left: auto; margin-right: auto
-}
-.form_edit_area_room label {
-    display: block; float: left; clear: left; min-height: 2.0em;
-    width: <?php echo $edit_area_room_label_width ?>em; text-align: right
-}
-.form_edit_area_room input {
-    display: block; position: relative; float: right; clear: right; 
-    width: <?php echo $edit_area_room_input_width ?>em; 
-    margin-top: -0.2em; margin-left: <?php echo 
$edit_area_room_input_margin_left ?>em
-}
-.form_edit_area_room .submit_buttons input {width: auto; clear: none; 
margin-top: 1.2em; margin-left: 1.0em}
-.form_edit_area_room span.error {display: block; width: 100%; margin-bottom: 
0.5em}
-.form_edit_area_room div {float: left; clear: left; width: 100%}
-
-
 /* ------------ FORM_GENERAL ------------------------*/
 /*                                                   */
-/*   used in EDIT_ENTRY.PHP, REPORT.PHP              */
-/*   and SEARCH.PHP                                  */
+/*   used in EDIT_ENTRY.PHP, REPORT.PHP,             */
+/*   SEARCH.PHP and EDIT_AREA_ROOM.PHP               */
 
 <?php
 // Common to all forms in the class "form_general"
@@ -480,17 +437,26 @@
 $logon_input_width             = '12';      // em
 $logon_form_min_width          = $logon_left_col_max_width + 
$logon_input_width + $general_gap;
 $logon_form_min_width          = number_format($logon_form_min_width, 1, '.', 
'');   // get rid of any commas
+
+// Specific to the "edit_area_room" form
+$edit_area_room_left_col_max_width  = '14';      // em
+$edit_area_room_input_width         = '12';      // em
+$edit_area_room_form_min_width      = $edit_area_room_left_col_max_width + 
$edit_area_room_input_width + $general_gap;
+$edit_area_room_form_min_width      = 
number_format($edit_area_room_form_min_width, 1, '.', '');   // get rid of any 
commas
+
+
 ?>
 form.form_general {margin-top: 2.0em; width: 100%}
-.edit_entry form.form_general {min-width: <?php echo 
$edit_entry_form_min_width ?>em}
-.report     form.form_general {min-width: <?php echo $report_form_min_width 
?>em}
-.search     form.form_general {min-width: <?php echo $search_form_min_width 
?>em}
+.edit_entry     form.form_general {min-width: <?php echo 
$edit_entry_form_min_width ?>em}
+.report         form.form_general {min-width: <?php echo 
$report_form_min_width ?>em}
+.search         form.form_general {min-width: <?php echo 
$search_form_min_width ?>em}
+.edit_area_room form.form_general {min-width: <?php echo 
$edit_area_room_form_min_width ?>em}
 form.form_general#logon       {min-width: <?php echo $logon_form_min_width 
?>em}
 
 .form_general div {float: left; clear: left; width: 100%}
 .form_general div div {float: none; clear: none; width: auto}
 .form_general div.group {float: left; width: <?php echo 
$general_right_col_width ?>%}
-.form_general div.group#ampm {width: <?php echo $edit_entry_ampm_width ?>em}
+.form_general div.group.ampm {width: <?php echo $edit_entry_ampm_width ?>em}
 .form_general fieldset {width: auto; border: 0; padding-top: 2.0em}
 
 .form_general label {
@@ -500,9 +466,10 @@
     text-align: right; padding-bottom: 0.8em; font-weight: bold;
 }
 
-.edit_entry .form_general label {max-width: <?php echo 
$edit_entry_left_col_max_width ?>em}
-.report     .form_general label {max-width: <?php echo 
$report_left_col_max_width ?>em}
-.search     .form_general label {max-width: <?php echo 
$search_left_col_max_width ?>em}
+.edit_entry     .form_general label {max-width: <?php echo 
$edit_entry_left_col_max_width ?>em}
+.report         .form_general label {max-width: <?php echo 
$report_left_col_max_width ?>em}
+.search         .form_general label {max-width: <?php echo 
$search_left_col_max_width ?>em}
+.edit_area_room .form_general label {max-width: <?php echo 
$edit_area_room_left_col_max_width ?>em}
 #logon                    label {max-width: <?php echo 
$logon_left_col_max_width ?>em}
 
 .form_general .group      label {clear: none; width: auto; max-width: 100%; 
font-weight: normal; overflow: visible}
@@ -511,9 +478,10 @@
     display: block; float: left; margin-left: <?php echo $general_gap ?>em; 
     font-family: <?php echo $standard_font_family ?>; font-size: small
 }
-.edit_entry .form_general input {width: <?php echo $edit_entry_textarea_width 
?>em}
-.report     .form_general input {width: <?php echo $report_input_width ?>em}
-.search     .form_general input {width: <?php echo $search_input_width ?>em}
+.edit_entry     .form_general input {width: <?php echo 
$edit_entry_textarea_width ?>em}
+.report         .form_general input {width: <?php echo $report_input_width 
?>em}
+.search         .form_general input {width: <?php echo $search_input_width 
?>em}
+.edit_area_room .form_general input {width: <?php echo 
$edit_area_room_input_width ?>em}
 #logon                    input {width: <?php echo $logon_input_width ?>em}
 .form_general .group      input {clear: none; width: auto}
 
@@ -535,12 +503,16 @@
 div#logon_submit      {width: <?php echo $general_left_col_width ?>%; 
max-width: <?php echo $logon_left_col_max_width ?>em}
 #edit_entry_submit input, #report_submit input, #search_submit input, 
#logon_submit input
     {position: relative; left: 100%; width: auto}
+div#edit_area_room_submit_back {float: left; width: <?php echo 
$general_left_col_width ?>%; max-width: <?php echo 
$edit_area_room_left_col_max_width ?>em}
+div#edit_area_room_submit_save {float: left; clear: none; width: auto}
+#edit_area_room_submit_back input {float: right}
 
-.form_general #div_time input {width: 2.0em}
-.form_general #div_time input#time_hour {text-align: right}
-.form_general #div_time input#time_minute {text-align: left; margin-left: 0}
-.form_general #div_time span + input {margin-left: 0}
-.form_general #div_time span {display: block; float: left; width: 0.5em; 
text-align: center}
+.form_general .div_dur_mins input{width: 4.0em}
+.form_general .div_time input {width: 2.0em}
+.form_general .div_time input.time_hour {text-align: right}
+.form_general .div_time input.time_minute {text-align: left; margin-left: 0}
+.form_general .div_time span + input {margin-left: 0}
+.form_general .div_time span {display: block; float: left; width: 0.5em; 
text-align: center}
 .form_general input#duration {width: 2.0em; text-align: right}
 .form_general select#dur_units {margin-right: 1.0em; margin-left: 0.5em}
 .form_general div#ad {float: left}
@@ -551,7 +523,10 @@
 .form_general #rep_info input {width: 13em}
 .form_general input#rep_num_weeks {width: 2.0em}
 
+.edit_area_room span.error {display: block; width: 100%; margin-bottom: 0.5em}
 
+    
+
 /* ------------ EDIT_USERS.PHP ------------------*/
 <?php
 $edit_users_label_height     = '2.0';    // em

Added: mrbs/trunk/web/upgrade/2/mysql.sql
===================================================================
--- mrbs/trunk/web/upgrade/2/mysql.sql                          (rev 0)
+++ mrbs/trunk/web/upgrade/2/mysql.sql  2009-03-18 19:14:51 UTC (rev 1051)
@@ -0,0 +1,9 @@
+# $Id$
+
+ALTER TABLE %DB_TBL_PREFIX%area 
+ADD COLUMN resolution            int,
+ADD COLUMN default_duration      int,
+ADD COLUMN morningstarts         int,
+ADD COLUMN morningstarts_minutes int,
+ADD COLUMN eveningends           int,
+ADD COLUMN eveningends_minutes   int;


Property changes on: mrbs/trunk/web/upgrade/2/mysql.sql
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: mrbs/trunk/web/upgrade/2/pgsql.sql
===================================================================
--- mrbs/trunk/web/upgrade/2/pgsql.sql                          (rev 0)
+++ mrbs/trunk/web/upgrade/2/pgsql.sql  2009-03-18 19:14:51 UTC (rev 1051)
@@ -0,0 +1,10 @@
+-- $Id$
+
+ALTER TABLE %DB_TBL_PREFIX%area 
+ADD COLUMN resolution            int,
+ADD COLUMN default_duration      int,
+ADD COLUMN morningstarts         int,
+ADD COLUMN morningstarts_minutes int,
+ADD COLUMN eveningends           int,
+ADD COLUMN eveningends_minutes   int;
+


Property changes on: mrbs/trunk/web/upgrade/2/pgsql.sql
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: mrbs/trunk/web/upgrade/2/post.inc
===================================================================
--- mrbs/trunk/web/upgrade/2/post.inc                           (rev 0)
+++ mrbs/trunk/web/upgrade/2/post.inc   2009-03-18 19:14:51 UTC (rev 1051)
@@ -0,0 +1,27 @@
+<?php
+
+// $Id$
+
+// Populate the new columns in the area table with the default values taken
+// from the config file.
+
+global $tbl_area;
+global $resolution, $default_duration;
+global $morningstarts, $morningstarts_minutes, $eveningends, 
$eveningends_minutes;
+
+$sql = "UPDATE $tbl_area SET
+        resolution = $resolution,
+        default_duration = $default_duration,
+        morningstarts = $morningstarts,
+        morningstarts_minutes = $morningstarts_minutes,
+        eveningends = $eveningends,
+        eveningends_minutes = $eveningends_minutes";
+    
+$res = sql_command($sql);
+if ($res == -1)
+{
+  // No need to localise, should never happen
+  print "<span class=\"error\">Failed to set default values for new columns in 
area table.</span>";
+}
+
+?>
\ No newline at end of file


Property changes on: mrbs/trunk/web/upgrade/2/post.inc
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Modified: mrbs/trunk/web/week.php
===================================================================
--- mrbs/trunk/web/week.php     2009-03-16 16:10:55 UTC (rev 1050)
+++ mrbs/trunk/web/week.php     2009-03-18 19:14:51 UTC (rev 1051)
@@ -25,6 +25,14 @@
   $debug_flag = 0;
 }
 
+if (empty($area))
+{
+  $area = get_default_area();
+}
+
+// Get the timeslot settings (resolution, etc.) for this area
+get_area_settings($area);
+
 $num_of_days=7; //could also pass this in as a parameter or whatever
 
 // If we don't know the right date then use today:
@@ -59,10 +67,6 @@
 // because we want the booking display to start on the first day of the week 
(eg Sunday if $weekstarts is 0)
 // but we want to preserve the notion of the current day (or 'sticky day') 
when switching between pages
 
-
-if (empty($area))
-{
-  $area = get_default_area();}
 if (empty($room))
 {
   $room = get_default_room($area);


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