Changeset:
        accc8367b2cd
        
https://sourceforge.net/p/mrbs/hg-code/ci/accc8367b2cd48d13710d27f9a423b645b81ce33
Author:
        Campbell Morrison <[email protected]>
Date:
        Tue Apr 11 16:02:59 2017 +0100
Log message:

Added the ability to have different period names in each area.    See SF
Support Requests 1214.   For the moment every area has to have the same number
of periods.

diffstat:

 tables.my.sql                |   3 ++-
 tables.pg.sql                |   3 ++-
 web/dbsys.inc                |   2 +-
 web/edit_area_room.php       |  26 ++++++++++++++++++++++++++
 web/functions.inc            |   7 +++++--
 web/js/edit_area_room.js.php |   2 ++
 web/lang/lang.en             |   1 +
 7 files changed, 39 insertions(+), 5 deletions(-)

diffs (166 lines):

diff -r ebe6cb7cedc8 -r accc8367b2cd tables.my.sql
--- a/tables.my.sql     Tue Apr 11 11:17:21 2017 +0100
+++ b/tables.my.sql     Tue Apr 11 16:02:59 2017 +0100
@@ -56,6 +56,7 @@
   approval_enabled          tinyint(1),
   reminders_enabled         tinyint(1),
   enable_periods            tinyint(1),
+  periods                   text CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT NULL,
   confirmation_enabled      tinyint(1),
   confirmed_default         tinyint(1),
 
@@ -189,6 +190,6 @@
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 INSERT INTO mrbs_variables (variable_name, variable_content)
-  VALUES ( 'db_version', '49');
+  VALUES ( 'db_version', '50');
 INSERT INTO mrbs_variables (variable_name, variable_content)
   VALUES ( 'local_db_version', '1');
diff -r ebe6cb7cedc8 -r accc8367b2cd tables.pg.sql
--- a/tables.pg.sql     Tue Apr 11 11:17:21 2017 +0100
+++ b/tables.pg.sql     Tue Apr 11 16:02:59 2017 +0100
@@ -61,6 +61,7 @@
   approval_enabled          smallint,
   reminders_enabled         smallint,
   enable_periods            smallint,
+  periods                   text DEFAULT NULL,
   confirmation_enabled      smallint,
   confirmed_default         smallint,
   
@@ -181,6 +182,6 @@
 );
 
 INSERT INTO mrbs_variables (variable_name, variable_content)
-  VALUES ('db_version', '49');
+  VALUES ('db_version', '50');
 INSERT INTO mrbs_variables (variable_name, variable_content)
   VALUES ('local_db_version', '1');
diff -r ebe6cb7cedc8 -r accc8367b2cd web/dbsys.inc
--- a/web/dbsys.inc     Tue Apr 11 11:17:21 2017 +0100
+++ b/web/dbsys.inc     Tue Apr 11 16:02:59 2017 +0100
@@ -22,7 +22,7 @@
 }
 
 
-$db_schema_version = 49;
+$db_schema_version = 50;
 $local_db_schema_version = 1;
 
 // Convenience wrapper function to provide access to a DB object for
diff -r ebe6cb7cedc8 -r accc8367b2cd web/edit_area_room.php
--- a/web/edit_area_room.php    Tue Apr 11 11:17:21 2017 +0100
+++ b/web/edit_area_room.php    Tue Apr 11 16:02:59 2017 +0100
@@ -460,6 +460,20 @@
 }
 
 
+function create_fields_period_settings()
+{
+  global $periods;
+  
+  foreach ($periods as $period)
+  {
+    echo "<div>\n";
+    echo "<label class=\"no_suffix\"></label>";
+    echo "<input name=\"area_periods[]\" value=\"" . htmlspecialchars($period) 
. "\">\n";
+    echo "</div>\n";
+  }
+}
+
+
 function create_fieldset_time_period_settings()
 {
   global $enable_periods;
@@ -475,6 +489,15 @@
   
   create_fields_time_settings();
 
+  echo "</fieldset>\n";
+  
+  // and vice versa for the period settings
+  echo "<fieldset id=\"period_settings\"" .
+       (($enable_periods) ? '' : ' class="js_none"') .
+       ">\n";
+  echo "<legend>" . get_vocab("period_settings") . "</legend>\n";
+  
+  create_fields_period_settings();
 
   echo "</fieldset>\n";
 }
@@ -528,6 +551,7 @@
 $area_approval_enabled = get_form_var('area_approval_enabled', 'string');
 $area_reminders_enabled = get_form_var('area_reminders_enabled', 'string');
 $area_enable_periods = get_form_var('area_enable_periods', 'string');
+$area_periods = get_form_var('area_periods', 'array');
 $area_confirmation_enabled = get_form_var('area_confirmation_enabled', 
'string');
 $area_confirmed_default = get_form_var('area_confirmed_default', 'string');
 $custom_html = get_form_var('custom_html', 'string');  // Used for both area 
and room, but you only ever have one or the other
@@ -990,6 +1014,8 @@
       $sql_params[] = $area_reminders_enabled;
       $assign_array[] = "enable_periods=?";
       $sql_params[] = $area_enable_periods;
+      $assign_array[] = "periods=?";
+      $sql_params[] = json_encode($area_periods);
       $assign_array[] = "confirmation_enabled=?";
       $sql_params[] = $area_confirmation_enabled;
       $assign_array[] = "confirmed_default=?";
diff -r ebe6cb7cedc8 -r accc8367b2cd web/functions.inc
--- a/web/functions.inc Tue Apr 11 11:17:21 2017 +0100
+++ b/web/functions.inc Tue Apr 11 16:02:59 2017 +0100
@@ -1950,7 +1950,7 @@
   global $min_create_ahead_enabled, $max_create_ahead_enabled, 
$min_create_ahead_secs, $max_create_ahead_secs;
   global $min_delete_ahead_enabled, $max_delete_ahead_enabled, 
$min_delete_ahead_secs, $max_delete_ahead_secs;
   global $max_duration_enabled, $max_duration_secs, $max_duration_periods;
-  global $approval_enabled, $reminders_enabled, $enable_periods;
+  global $approval_enabled, $reminders_enabled, $enable_periods, $periods;
   global $confirmation_enabled, $confirmed_default, $timezone;
   global $max_per_interval_area_enabled, $max_per_interval_area;
   global $interval_types;
@@ -1978,7 +1978,7 @@
                    'max_per_month_enabled', 'max_per_month',
                    'max_per_year_enabled', 'max_per_year',
                    'max_per_future_enabled', 'max_per_future',
-                   'approval_enabled', 'reminders_enabled', 'enable_periods',
+                   'approval_enabled', 'reminders_enabled', 'enable_periods', 
'periods',
                    'confirmation_enabled', 'confirmed_default');
                    
   $sql = "SELECT *
@@ -2025,6 +2025,9 @@
     }
   }
   
+  // Periods are stored as a JSON encoded string in the database
+  $periods = json_decode($periods);
+  
   // If we're using periods then set the resolution to 60 seconds
   if ($enable_periods)
   {
diff -r ebe6cb7cedc8 -r accc8367b2cd web/js/edit_area_room.js.php
--- a/web/js/edit_area_room.js.php      Tue Apr 11 11:17:21 2017 +0100
+++ b/web/js/edit_area_room.js.php      Tue Apr 11 16:02:59 2017 +0100
@@ -24,11 +24,13 @@
   {
     $('#book_ahead_periods_note').hide(speed);
     $('#time_settings').show(speed);
+    $('#period_settings').hide(speed);
   }
   else
   {
     $('#book_ahead_periods_note').show(speed);
     $('#time_settings').hide(speed);
+    $('#period_settings').show(speed);
   }
 }
 
diff -r ebe6cb7cedc8 -r accc8367b2cd web/lang/lang.en
--- a/web/lang/lang.en  Tue Apr 11 11:17:21 2017 +0100
+++ b/web/lang/lang.en  Tue Apr 11 16:02:59 2017 +0100
@@ -380,6 +380,7 @@
 $vocab["too_many_slots"]          = 'You need to increase the value of 
$max_slots in the config file!';
 $vocab["general_settings"]        = "General";
 $vocab["time_settings"]           = "Slot times";
+$vocab["period_settings"]         = "Period names";
 $vocab["confirmation_settings"]   = "Confirmation settings";
 $vocab["allow_confirmation"]      = "Allow tentative bookings";
 $vocab["default_settings_conf"]   = "Default setting";

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to